WorksheetsPython In Real Life Review
Total questions: 20
Worksheet time: 11mins
name = 'Dave'
print (name)
What is a input?
A function that allows us to ask the user to enter some data.
To plug in something.
Data displayed on a screen.
A function
x = 5
y = 6
print(x*y)
The code above displays the following:
11
x*y
Syntax Error
30
numbers = [5, 14 ,9, 17]
for number in numbers:
if number >= 9:
print (number)
The output will be?
17
9
14
9
17
14
17
for number in range(6):
print(number)
Which of these is the correct code for creating a list of names?
nameList = John, Harry, Jesse, John, Harry, Harry
nameList = ("John", "Harry", "Jesse", "John", "Harry", "Harry")
nameList = ["John", "Harry", "Jesse", "John", "Harry", "Harry"]
nameList = [John, Harry, Jesse, John, Harry, Harry]
numbers = [2, 4, 6, 8]
for number in numbers:
print("hello!")
2 hello! 4 hello! 6 hello! 8 hello!
hello!
2 4 6 8
hello! hello! hello! hello!
What is the output of this code?
It would print 'So good to see you' infinite number of times
There would be no output
It would print an error message.
It would print 'Enter correct code'.
What is the final value of the variable 'number'?
(a)
What is the output of Following code?
List = ['spam', 2.0, 5, [10, 20]]
print(List[2])
(a)
What is the output of the following code?
list = []
list.append(1)
list.append(2.0)
list.append("vk")
print(list)
[1, 2.0, 'vk']
Error
['vk', 1, 2.0]
No putput
name = “Alison”
number = len(name)
print(number)
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
A = random.______([1,2,3,4,5])
Value of A can be 1 to 5(including both)
shuffle
choice
uniform
none of these
What is the minimum and maximum value of 'A' in the following statement..
import random
A=random.randint(2,30)
print(A)
3 and 30
2and 30
2 and 29
