NEW
Font size
WorksheetsPython Final-Exam
Total questions: 21
Worksheet time: 17mins
What will be the output?
name = "Dave"
print (name)
Dave
'Dave'
name
(name)
print(3*4+5)
A condition is
a statement that is either True or False
a string
an integer
a list
days = 5
if days > 6:
print(“Month”)
else:
print(“Week”)
Which of the following input commands would allow the user to receive and store a character from the keyboard?
character = input("Please enter a character:")
character = int(input("Please enter a character:"))
character = float(input("Please enter a character:"))
character = bool(input("Please enter a character:"))
The punctuation requirements for printing a string in Python are:
( ) , ! and " "
( ) and !
( ) and " "
" " and !
name=input("What is your name? ")
print("Your name is " + name)
What will be displayed if the user types in "Bob"?
Your name is name
name
Bob
Your name is Bob
What will print to the screen when the following program is run?
number = 5
greater_than_zero = number > 0
print(type(number))
5
True
<type ‘int’>
<type ‘bool’>
What will the following program print when run?
number_one = 5
number_two = 10
if number_one == 5:
print(1)
if number_one > 5:
print(2)
if number_two < 5:
print(3)
if number_one < number_two:
print(4)
if number_one != number_two:
print(5)
1
1
3
5
1
4
1
4
5
What will the following program print when run?
number_one = 5
number_two = 10
if number_one == 5:
print(1)
elif number_one > 5:
print(2)
elif number_two < 5:
print(3)
elif number_one < number_two:
print(4)
elif number_one != number_two:
print(5)
else:
print(6)
1
1
3
5
1
4
1
4
5
What does this program print?
height = 65
gender = "female"
if height < 62:
print "You are below average height"
elif height > 69:
print "You are above average height"
else:
print "You are average height"
You are below average height
You are above average height
You are average height
You are below average height
You are above average height
What is output when the code runs?
Hi!
Have A Nice Day
Hi!
Good Afternoon
Good Afternoon
Have a Nice Day
What does the following Python code snippet print?
x = 20
if not x > 20:
print("x is not greater than 20")
else:
print("x is greater than 20")
x is not greater than 20
x is greater than 20
How do you insert COMMENTS in Python code?
/*this is a comment
//this is a comment
#this is a comment
