1
2
3
4
5
6
7
8
9
10
11
12
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to Trinket.
Post a review on Amazon for the paperback or the Kindle edition.
Email me to give me a compliment, complaint, or correction. I'll respond.
0,1,2,3,4,5,6,7,8,9,10,11
0
0
0
0
What is the keyword used to get information from the user? | input | ^ *input *$ | |
The following code will break Python because there's no __________ to receive the input. (1 word) | input("Enter your first name: ") | variable | ^ *variable *$ |
Complete the code. The prompt is "Name: " | user_name = | input("Name: ") | input`(`"`Name: `"`) |
Ask for the user's name and store the answer in user_name. The prompt is "Name: ". Don't forget to add the space after Name: | user_name = input("Name: ") | user_name = input("Name: ") | |
Code an input statement. Make up the variable name and the prompt. | fave_color = input("What's your favorite color? ") | ^ *[a-zA-Z_][a-zA-Z0-9_]* = input\(•.*•\) *$ | |
Code an input statement. Make up the variable name and the prompt. Then display the user's answer. | fave_color = input("What's your favorite color? ") print(fave_color) | ^ *([a-zA-Z_][a-zA-Z0-9_]*) = input\(•.*•\)\nprint\(\1\) *$ | |
In a single line of code convert a number to a string and assign it to a variable. Make up the number and the variable name. | num_as_string = str(99) | ^ *[a-zA-Z_][a-zA-Z0-9_]* = str\([-]?(?:[.]\d+|\d+(?:[.]\d*)?)\) *$ | |
Convert a string to an integer and assign it to a variable. Make up the string and the variable name. | whole_number = int("99") | ^ *[a-zA-Z_][a-zA-Z0-9_]* = int\(•[-]?(?:[.]\d+|\d+(?:[.]\d*)?)•\) *$ | |
Convert a string to a float and assign it to a variable. Make up the string and the variable name. | decimal_number = float("-2.07") | ^ *[a-zA-Z_][a-zA-Z0-9_]* = float\(•[-]?(?:[.]\d+|\d+(?:[.]\d*)?)•\) *$ | |
On line 1 ask the user for a number. On line 2 convert it to a float. On line 3 add the float to another number and assign the sum to a variable. Make everything up. | num_entered = input("Enter a number: ") decimal_number = float(num_entered) total = decimal_number + 11 | ^ *([a-zA-Z_][a-zA-Z0-9_]*) = input\(•.*•\)\n([a-zA-Z_][a-zA-Z0-9_]*) = float\(\1\)\n[a-zA-Z_][a-zA-Z0-9_]* = ((\2 \+ [-]?(?:[.]\d+|\d+(?:[.]\d*)?))|(([-]?(?:[.]\d+|\d+(?:[.]\d*)?)) \+ \2)) *$ | |
| ef85490c55 | ||
| 4add2bb74d |