Programming for all
what is wrong with the following code snippet? num = 78A
78A is not a valid value in a Python program
What is the value of the variable num after the following code snippet? num = 5 num2 = 6 num = num2 + 3
9
What is printed by the following code snippet if itemCount contains a value of 10 and cost contains 80: if itemCount > 5: discount = 0.8 totalCost = cost * discount print("Total discounted price is:", totalCost)
Total discounted price is: 64.0
What is the output of the following code snippet if the cost contains 100: if cost > 150 : discount = 0.8 * cost else : discount = cost print("Your cost is:", discount)
Your cost is: 100
which of the following items is NOT considered hardware
a program
a variable is
a storage location with a name
What statement is used to implement a decision?
if
Which of the following is the correct syntax for an if statement?
if x < 10 : size = "small" else : size = "medium"
A computer program is a sequence of
instructions and decisions
to store a value for later use in Python, the programmer needs to create a
variable
What is wrong with the following code snippet? 2ndNum = 78
The 2ndNum variable is not a valid variable name
how is a value stored in a variable
an assignment statement
What are the two parts of an if statement?
condition and a body
what does capitalized code mean?
constant
What is a variable called that should remain unchanged throughout your program?
constant variable
computers are machines that
execute programs
what is the right way to assign the value of num + 10 to num2
num2 = num + 10
which of the following variables should be codes as a constant in Python?
pi: 3.14159
which parts of the computer store program code?
secondary storage
Which of the following refers o a collection of programs that a computer executes?
software
The following code snippet contains an error. What is the error? cost = int(input("Enter the cost: ")) if cost > 100 cost = cost - 10 print("Discounted Cost:",cost)
syntax error: missing colon after if statement
What does "#" mean?
that it is a comment that the computer doesn't read
Which of the following correctly identifies what is wrong with the code snippet below? if y > 300 : x = y else : x = 0 print("x:",x)
that statement after the if statement and the statement after the else statement must be indented
Which of the following statements is true about the if statement?
the else block is optional
What is wrong with this assignment statement? num + 10 = num2
the left hand side of an assignment statement cannot include an operator
Assuming the user provides 95 as input, what is the output of the following code snippet? y = int(input("Please enter a number: ")) if y > 300: x=y else: x = 0 print("x:",x)
x: 0
Assuming that the user provides 303 as input, what is the output of the following code snippet? y = int(input("Please enter a number: ")) if y > 300: x=y else: x = 0 print("x:",x)
x: 303