Font size
Worksheetspython high grade
Total questions: 80
Worksheet time: 40mins
print(Hello world!)
Is variable name case sensitive?
Yes
No
A line of text that Python won't try to run as code
Integer
Comment
Strings
Input
Which data type stores TRUE/FALSE values
Integer
Real
Boolean
Array
Which data type can store numbers, letters and symbols?
String
Float
Integer
Boolean
What is the output of the following statement. ?
9_ah = “akash”
Print(9_ah)
akash
9_ah
Error
none
What is the output of the following code?
var1 = 1
var2 = 2
var3 = "3"
print(var + var2 + var3)
6
33
133
Error. Mixing operators between numbers and strings are not supported
Which one of the following has the highest precedence in the expression?
Addition
Multiplication
Exponential
ParenthesIs
What is the answer of this expression, 100 % 98 is?
2
1
The__________ function is used to convert string data as integer data explicitly.
int( )
char()
float()
input()
10//3
3
3.3
0.3
3.0
xy
x^^y
x^y
x**y
x pow y
Choose the correct Python code. if age is less than 20 and greater than or equal to 15 then
if age <20 and age >=15:
if age <20>=15 :
This statement is used to evaluate only one condition
IF STATEMENT
IF -ELSE STATEMENT
IF-ELIF-ELSE STATEMENT
Which selection execution flow is given:
if statement
if-else statement
if-elif statement
Suppose you want to determine if a student is ready to graduate. The 3 criteria for graduation are that the student has earned at least 120 credits, their major GPA is at least 3.0 or their general GPA is also at least 3.5
Which Boolean expression would be the correct test for Python code?
numCredits >= 120 and majorGPA >= 3.0 or overallGPA >= 3.5
numCredits > 120 and majorGPA > 3.0 and overallGPA >3.5
numCredits > =119 and majorGPA >= 3.0 and overallGPA >= 3.5
What is the result of the code:
team = Cowboys
if team = Cowboys:
print "Dallas is #1"
team
Cowboys
Error
Dallas is #1
Which is the correct output for :
for i in range(1,10):
print(i)
1,2,3,4,5,6,7,8,9
1,2,3,4,5,6,7,8,9,10
0,1,2,3,4,5,6,7,8,9,10
1,2,3,4,5,6,7,8
Consider the following loop given below :
for i in range(5):
print(i)
How many times will this loop run ?
5
0
infinite
Error
Function range(3) is equivalent to "
range(1,3)
range(0,3)
range(0,3,1)
range(1,3,0)
if you choose to count down from 100 to -100 using a for loop, what would your range function look like ?
range(1,100,-1)
range(100,-100,-1)
range(100,-100,1)
range(100,-1,-100)
Which of the following for loops would print the following numbers?
3
5
7
9
for i in range(3, 10, 2):
print(i)
for i in range(3, 9, 2):
print(i)
for i in range(9):
print(i)
for i in range(3,9):
print(i)
Which kind of loop would be used?
I need a program that will keep letting me add money to a piggy bank until I get to £100.
FOR Loop
WHILE Loop
What will happen when this program runs
It will display numbers 0-10 on separate lines
It will display numbers 0-9 on separate lines
It will crash
It will display 0s in an infinite loop
4
3
2
1
3
2
1
0
In a While loop a code will be repeated until the condition becomes
FALSE
TRUE
User choice
What would be the output of the following code:
for i in range(3):
print(5)
0 1 2
3 3 3 3 3
5 5 5
0 1 2 3 4
for i in 100 :
print ( i )
Syntax error
prints numbers 0 to 100
prints numbers 1 to 100
prints numbers 0 to 99
prints numbers 1 to 99
What is the index number for 'Spain'?
['England','Brazil','Spain','France']
0
1
2
3
How do i remove something from a list?
variable.append()
variable.delete()
variable.remove()
variable=(new variable)
Which code would i use to add an item to a list?
variable.add()
variable.append()
append.variable()
add.variable()
Which of these is the best description of a list in Python?
A list is a collection of data that has an order and can be changed
A list is a lot of variables
A list is used for shopping
A list is a collection of data that cannot hold duplicated data and cannot be changed
List items have an index number. In the following list, which item has the index number of 3?
["John", "Harry", "Jesse", "John", "Harry", "Harry"]
"John"
"Harry"
"Jesse"
Consider this list, what will be the highest index the list can have:
li=[1,2,3,4,5]
2
3
4
5
Consider this list, what will be the output of the following:
li=[1,2,3,4,3,2,1]
print(li[-3])
4
3
2
1
Consider this list, what will be the output of the following:
li=[1,2,3,4,3,2,1]
print(li[3:4])
1
2
3
4
Consider this list, what will be the output of the following:
li=[1,2,3]
print(li[3])
1
2
3
error
To insert an the string "strawberries" in the first position of a list we use
fruit.append("strawberries, 1")
fruit.insert("strawberries",0)
fruit.insert(1, "strawberries")
fruit.insert(0, "strawberries")
What will be the value of the following Python expression?
4 + 3 % 5
a) 7
b) 2
c) 4
d) 1
Which of the following is the correct extension of the Python file?
a) .python
b) .pl
c) .py
d) .p
Which of the following character is used to give single-line comments in Python?
a) //
b) #
c) !
d) /*
Which of the following is used to define a block of code in Python language?
a) Indentation
b) Key
c) Brackets
d) All of the mentioned
What is the order of precedence in python?
a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
c) Parentheses, Exponential, Multiplication, Division, Subtraction, Addition
d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
Which of the following functions is a built-in function in python?
a) factorial()
b) print()
c) seed()
d) sqrt()
What will be the output of the “hello” +1+2+3?
a) hello123
b) hello
c) Error
d) hello6
An algorithm is a set of precise instructions designed to solve a problem.
True
False
A store your program must use as an identifier to keep track of a value is called a
Algorithm
Variable
Program
Assignment
Which symbol assigns a value to a variable?
(a)
Who developed Python Programming Language?
a) Wick van Rossum
b) Rasmus Lerdorf
c) Guido van Rossum
d) Niene Stom
Which of the following would be an example of a string variable:
ValidInput = False
GuessCount = 100
Name = "Bilbo"
Pi = 3.14159265359
Which of the following would be an example of a float variable:
ValidInput = False
GuessCount = 100
Name = "Bilbo"
Pi = 3.14159265359
The rules for how programming languages statements can be assembled is known as
Variable
Algorithm
Syntax
Debugging
Which of the following would be an example of an integer variable:
ValidInput = False
GuessCount = 100
Name = "Bilbo"
Pi = 3.14159265359
What is the greater than symbol:
(a)
What would be the result of 3 ** 3
(a)
What would be the result of 9 // 7
(a)
What would be the reult of 9 % 7
(a)
What will be the output?
name = 'Dave'
print (name)
name
Dave
error
What would print (10 + 16) produce?
10
16
24
26
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, if anything, is wrong with the following?
x=input("Type your password: ")
print("You typed", x)
The variable should be switched with the input command
You can't use commas in print statements
You can't print x
Nothing is wrong
Which two statements are used to implement iteration/Repetition)?
4
3
2
1
3
2
1
0
4
3
2
1
3
2
1
0
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
......(repeated continuously)
False
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
What does the '#' allow you to do?
Repeat code
Comment on code
Print code
End code
What will this code do?
Print Numbers 1-11
Print Numbers 1-10
Print Numbers 2-10
Print Error
holds whole numbers
holds a decimal point in a number
