NEW
Font size
S
M
L
XL
WorksheetsPython Lesson 1 - Homework
Total questions: 10
Worksheet time: 5mins
Name
Class
Date
1.
What is the correct command for outputting the text string Hello World?
a)
print("Hello World")
b)
print = "Hello World"
c)
print = (Hello World)
d)
PRINT(Hello World)
2.
How do you get a user to tell you their name?
a)
input("What is your name?")
b)
input = (what is your name?)
c)
input = ("What is your name?")
d)
= input (What is your name?)
3.
How do you ask the user their favorite food and store this information in a variable?
a)
favoriteFood = print("what is your favorite food?")
input()
input()
b)
favoriteFood = input("What is your favorite food?")
c)
input = favoriteFood
favoriteFood = print("What is your favorite food?")
favoriteFood = print("What is your favorite food?")
d)
input = print("What is your favorite food?")
favoriteFood = input
favoriteFood = input
4.
How do you output a message "Hello" followed by the data stored in the variables FirstName and SecondName?
a)
print("Hello",FirstName,SecondName)
b)
print("Hello","FirstName","SecondName")
c)
print = ("Hello",FirstName,SecondName)
d)
print("Hello, FirstName,SecondName")
5.
If you had both the user's first name and surname stored in variables, how would you output just their initials?
a)
print(firstname[0],surname[0])
b)
print(firstname[1],surname[1])
c)
print(firstname = 0,surname = 0)
d)
print(firstname = 1, surname = 1)
6.
How do you output a message that contains a space between their first name and their surname?
a)
print(firstname+" "+surname)
b)
print(firstname" "surname)
c)
print = ("firstname"+" "+"surname")
d)
print("firstname surname")
7.
How do you make a new variable called fullname from the two variables firstname and surname?
a)
fullname = print(firstname," ",surname)
b)
fullname = firstname+surname
c)
fullname = firstname+" "+surname
d)
fullname = "firstname + surname"
8.
How do you output the text string "hello" as a string of capital letters instead of a string of lower case letters?
a)
print("hello".upper())
b)
print("hello".capital())
c)
print("hello".upper)
d)
print(upper("hello"))
9.
How would you output the length of the user's first name?
a)
print(len(firstname))
b)
print(firstname.length())
c)
print(firstname.len())
d)
print(length(firstname))
10.
How would you ask the user their name and then output the message "hello" followed by their name.
a)
name = input("What is your name?")
print("hello",name)
print("hello",name)
b)
input("What is your name?")
print = ("hello",name)
print = ("hello",name)
c)
name = input("What is your name?")
print("hello name")
print("hello name")
d)
input = ("What is your name?")
print = ("hello",name)
print = ("hello",name)
Reset
