Computer Studies‎ > ‎Python‎ > ‎Python Tutorial‎ > ‎

Variables III

Remember that variables can be used to represent text (called “strings” in programming context) as well as numbers. 

The following example assigns the string value "Mary" to a variable called “name”:

name = "Mary"

Note the use of quotation marks around the string.

Assignment

Write a program that includes two variables called "FName" and "LName". Assign your first name and last name to these variables, then print your name to the screen.

Save as "021.py".

Assignment

Write a program that prompts for and prints your name, your address, your city, and your phone number. Use appropriate variable names for all variables.

Save as "021a.py".

Assignment

Write a program that prompts for a total of 10 variables, using a combination of integer, real number, and string types. Output the variables in sentence format using no more than five sentences, similarly to "Your favourite colour is red and favourite number is 7.", where "red" and "7" are the values that were entered. 

Save as "021b.py."

Assignment

Write a program that prompts for and calculates the product of three integers. The output should look similar to "The product of __, __, and __ is __. "

Save as "022.py".

Assignment

Complete the programming challenge "Transistor Current Gain".

Save as "022a.py".
Comments