1.6 Code Practice Question 1
Question: 1.6 Lesson Practice
Which of the following is a correct variable name?
Answer: low_Temperature
Question: 1.6 Lesson Practice
What is output by the following lines of code if we input the name “Sally”?
n = input(“What is your name?”)print(“Hello there “ + n)
Answer: Hello there Sally
Question: 1.6 Lesson Practice
This code accepts a word as input, and then prints that word to the screen.
w = input(“Enter a word: “) print(w)
Answer: The number is printed.
Question: 1.6 Code Practice: Question 1
Enter a word: Good
Enter a word: morning
Good morning
Answer: w = input(“Enter a word: Good “)
v = input(“Enter a word: Morning “)
print(w + “ “ + v)
Question: 1.6 Code Practice: Question 2
Please input your first name:
Please input your last name:
Answer: first=input(“Please input your first name: “) last=input(“Please input your last name: “)
print(last+”, “+first)
Question: 1.7 Lesson Practice
Which of the following is NOT true about variables?
Answer: The value stored by a variable cannot be changed after it is assigned.
Question: 1.7 Lesson Practice
Assume the user types in 7 and 10. What is output by the following?
num1 = input (“Enter a number: “)
num2 = input (“Enter a number: “)
print (num1 + num2)
Answer: 710
Question: 1.7 Lesson Practice
Which command converts a number to a string?
Answer: str
Question: 1.7 Lesson Practice
Which of the following is true about strings?
Answer: An input (unless otherwise specified) will be stored as a string
Question: 1.7 Lesson Practice
What is wrong with the following code?
num1 = int (input(“Enter a number: “))
num2 = int (input(“Enter a number: “))
num3 = int (input(“Enter a number: “))
print (“The average is: “ + (num1 + num2 + num3)/3)
Answer: It needs a str() command