Does the following statement work or produce an error message when executed? If it works, what does it display? value1 = 2.0 value2 = 3 print("The sum of " + value1 + " and " + value2 + "is" + (value1 + value2))
Error message
TypeError: can only concatenate str (not "float") to str
What would be stored in the variable result after the expression is executed in Python?
result = 10**3
1000
What would be stored in the variable result after the expression is executed in Python?
result = 10//3
3
Will this statement execute or produce an error message?
dataValue = int(input("Enter the quantity of candy bars that you wish to purchase: "))
Execute
The command used in Python to display something to standard output is
print
What would be stored in the variable result after the expression is executed in Python?
result = 6 + 4 * 3 - 2
16
Suppose that we want to read in a data value from standard input. What are two things we'd need to consider in order to successfully write the Python statement to accomplish this goal?
1. What is a meaningful identifier?
2. Is the data going to be a string or a numeric type?
3. What should we say to prompt the user to enter the data?
I'm writing software for a pizza company and pizzas are 6.00. The software will ask the user to enter the number of pizzas that he/she is purchasing and store that as quantityOfPizza. Write an expression to calculate the total cost.
totalCost = quantityOfPizza * 6.00
What would be stored in the variable result after the expression is executed in Python?
result = 5 // 2 + 4 / 2
4.0
Does the following statement work or produce an error message when executed? If it works, what does it display?
value1 = 2.0
value2 = 3
print("The sum of ", value1, " and ", value2, "is", value1 + value2)
The sum of 2.0 and 3 is 5.0
The command used in Python to read in input from standard input is
input
I'm writing software for a pizza company and I want the user to enter his/her phone number. I wrote the following Python statement:
phoneNumber = input("Please enter your phone number")
Will this work well to store the phone number?
Yes, phone number will be stored as a string but we are unlikely to perform arithmetic calculations on the number so that's fine.
Your experience on this site will be improved by allowing cookies.