Font size
WorksheetsKENNETH'S Quiz 😁
Total questions: 93
Worksheet time: 50mins
How many variables are there in this program?
2
3
4
5
What would be the output of this program if the user input was 10?
22.04
220.4
2204
Error wrong data type
What operator is being used in this program?
less than
greater than
less than or equal to
greater than or equal to
What type of list is being used in this example?
Dictionary
List
Tuple
2d Array
Which of the following statements apply to tuples?
They are created using square brackets
They are created using curved brackets
They can be amended when the program is running
They can not be amended when the program is running
What would be the output of this program if the user entered "yes" then "what"?
Enjoy your day
it is too windy for an umbrella
Take an umbrella
Error
What would be the output of this program if the user entered "Alien"
Alienway
wayAlien
lienAay
ayAlien
What data type represents a whole number?
Float
Int
Boolean
String
What data type represents a decimal number?
Float
Int
Boolean
String
What data type represents characters?
Float
Int
Boolean
String
What data type represents only two possible outcomes?
Float
Int
Boolean
String
What you the output of this program be if the user guessed "h"?
Error
It was heads
It was tails
Bad luck
What shape would this code produce?
5 pointed star
Pentagon
Sqaure
Nothing it would give an error
Is the following subprogram a function or procedure?
Function
Procedure
What type of loop is being used in this program?
Count controlled
Condition Controlled
How many errors are there in this code?
1
2
3
4
How many errors are there in this piece of code?
0
1
2
3
Which of the following is an advantage of using local variables?
They allow the variable to be used throughout the whole program
They allow variable identifiers to be reused each time
They are easier to program than global variables
A wider range of data types can be used
What term is used to describe data passed into/out of a program?
Variable
Loop
Constant
Parameter
Leo wants to create a subroutine that will roll a dice. Which syntax is correct?
def dice roll ():
def diceroll ()
def diceroll ():
def diceroll []:
What would the output be from the program shown here? (assuming that the user enters "John" and "Smith"
John
Smith
John Smith
Error
What would the output be from this program?
Error
Hello
Hello, World
World
What is the difference between a subroutine and a function?
They are the same thing
A subroutine passes values back out to the program, a function does not
A function passes values back out to the program, a subroutine does not
A function can run without being called
What will the output of this program be when it is run?
Nothing
Hello, world
It will generate an error
What will be the output of this program if the user enters "Han" and then "Solo"?
An error
Nothing
first surname
Han Solo
Which of the following statements is not true?
Functions/subroutines are examples of reusable code
Functions and subroutines are always appropriate in programs
Using functions/subroutines make it easier to "deconstruct" a problem into smaller pieces
They can make programs easier to read and understand
What would the output be for the following program if the user enters 4 and 6?
10
14
16
error
What will be the output?
name = "Dave"
print (name)
Dave
name
"Dave"
(name)
What is a input?
To plug in something
A function that allows us to ask the user to enter some data
Data displayed on a screen
A routine
A variable must have been assigned (given) a value before that value is referenced (used).
True
False
The correct way to convert user input is:
birth_year = number(input())
birth_year = int(input())
birth_year = (input(int))
birth_year = int(input)
To display the following on screen Hello World! the following command should be used:
print(Hello World!)
print("Hello World" + !)
print("Hello World!")
print"(Hello World!)"
You assign a value to a variable with which symbol
@
==
=
*
The code you use to receive and input from the keyboard
enter()
add()
receive()
input()
Program statements are executed in sequence, one after the other...
True
False
if you receive a NameError when you run your program it means....
A variable has been assigned before it has been referred to
An incorrect name has been chosen
A variable has been referred to before it has been assigned
A language key word has been used
If the coding steps are in the incorrect order, the computer can still execute the program.
True
False
What is the output of the following piece of code when executed in Python shell?
>>> a=("Check")*3
>>> a
(‘Check’,’Check’,’Check’)
* Operator not valid for tuples
(‘CheckCheckCheck’)
Syntax error
Which are arithmetic operators?
+
-
>
<
Which of the following cannot be a variable?
_init_
in
it
on
Which one of these is floor division?
//
/
%
None of the above
Python is a general purpose programming language created by
Dennis M. Ritchie
Guido Van Rossum
James Gosling
Bjarne Stroustrup
Expand IDLE
Internal Development Learning Environment
Integrated Development Learning Enforcement
Interactive Development Learning Environment
Integrated Development Learning Environment
Example of valid identifiers
12Name
name$
total-mark
total_marks
A Relational operator is also called as ___________
Arithmetic operator
Logical operator
Assignment operator
Comparative operator
"and, or and not" are ___________________
Arithmetic operator
Logical operators
Assignment operator
Comparative operator
__________are special words that are used by Python interpreter to recognize the
structure of program.
Tokens
Identifiers
Keywords
Operators
Choose the INVALID identifiers from the following
NUmbEr1
1NUMBer
A_B
A&B
________ are data items that have a fixed value
Tokens
Literals
Keyword
Operators
Examples of String Literals
"ABC1273"
nfjdlsj@@$
12638
'7e920938'
Choose the keyword from the following
IF
Else
iF
else
‘If’ is a decision making statement
TRUE
FALSE
1. What is the output of the following code?
var1 = 1
var2 = 2
var3 = "3"
print(var + var2 + var3)
6
33
123
ERROR
2. What is the output of the following code?
p, q, r = 10, 20 ,30
print(p, q, r)
10 20
10 20 30
Error: invalid syntax
3. What is the Output of the following code?
for x in range(0.5, 5.5, 0.5):
print(x)
[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5]
[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5]
The Program executed with errors
4. What is the output of the following code?
salary = 8000
def printSalary():
salary = 12000
print("Salary:", salary)
printSalary()
print("Salary:", salary)
Salary: 12000 Salary: 8000
Salary: 8000 Salary: 12000
The program failed with errors
5. What is the output of the following code?
def calculate (num1, num2=4):
res = num1 * num2
print(res)
calculate(5, 6)
20
The program executed with errors
30
6. Can we use the “else” clause for loops?
for example:
for i in range(1, 5):
print(i)
else:
print("this is else block statement" )
YES
NO
7. A string is immutable in Python?
Every time when we modify the string, Python Always creates a new String and assigns a new string to that variable.
TRUE
FALSE
8. What is the output of the following code?
sampleList = ["Jon", "Kelly", "Jessa"]
sampleList.append(2, "Scott")
print(sampleList)
The program executed with errors
[‘Jon’, ‘Scott’, ‘Kelly’, ‘Jessa’]
[‘Jon’, ‘Kelly’, ‘Scott’, ‘Jessa’]
9. What is the output of the following?
x = 36 / 4 * (3 + 2) * 4 + 2
print(x)
182.0
37
117
ERROR
10. Which operator has higher precedence in the following list?
% Modulus
& BitWise AND
**, Exponent
> Comparison
11. What is the output of the following code?
for i in range(10, 15, 1):
print( i, end=', ')
10, 11, 12, 13, 14,
10, 11, 12, 13, 14, 15,
12. What is the output of the following code?
listOne = [20, 40, 60, 80]
listTwo = [20, 40, 60, 80]
print(listOne == listTwo)
print(listOne is listTwo)
TRUE
TRUE
TRUE
FALSE
FALSE
TRUE
13. The ‘in’ operator is used to check if a value exists within an iterable object container such as a list. Evaluates to true if it finds a variable in the specified sequence and false otherwise.
TRUE
FALSE
14. What is the output of the following code?
str = "pynative"
print (str[1:3])
py
yn
pyn
yna
15. What is the output of the following code?
valueOne = 5 ** 2
valueTwo = 5 ** 3
print(valueOne)
print(valueTwo)
10
15
25
125
ERROR
Which command will display the text 'Hello world!' on the screen?
print(Hello world!)
print "Hello world!"
print("Hello world!")
print = "Hello world!"
Which command will correctly ask the user for their age?
age = input("How old are you?")
age = input(How old are you?)
input("How old are you?") = age
How old are you = input()
Which decision statement will be triggered if the variable x is less than 20?
if x > 20:
if x <> 20:
if x == 20:
if x < 20:
Which of these tests whether the variable x is the same as 'Hello'?
x = "Hello"
x != "Hello"
x == "Hello"
x <> "Hello"
What is the output of the following program?
Yes
No
Error
No output
What is the output of the following program?
Yes
No
Error
No output
What is the output of the following program?
1 to 10 numbers
1 to 5 numbers
1
5
What would the output of this code be if the user entered the value 70?
Pass
Fail
Merit
Distinction
What would the outcome of this program be?
22
50
Nothing, it won't run due to errors in the code
38
What would the outcome of this program be?
prints 1 to 10 numbers
prints 10 to 1 numbers
prints 1 to 15 numbers
prints 1 to 14 numbers
What would the outcome of this program be?
prints 5 to 50 numbers
prints 5 to 49 numbers
prints 5 to 55 numbers
prints multiples of 5 upto 50
What is the output of the following program?
for i in range(0, 5):
print(i)
i=i+1
1 to 5 numbers
1 to 4 numbers
0 to 4 numbers
0 to 5 numbers
guess=input()
guess=input()
guess=input()
guess=input()
Which word completes this sentence: "Iteration makes code more ___________"
Complex
Efficient
Simple
Straightforward
A FOR loop is....
A COUNT controlled loop
A CONDITION controlled loop
A WHILE loop is....
A COUNT controlled loop
A CONDITION controlled loop
What will the output be for the code shown here?
3,2,1,0
0,1,2,3
3,2,1
1,2,3
What would the output be for the code shown here?
0,1,2,3,4,5,6,7,8,9
1,2,3,4,5,6,7,8,9,10
0,2,4,6,8,10
0,2,4,6,8
Anil is writing a "rock, scissors, paper" program. He wants the game to repeat until the user doesn't want to play anymore. What loop should he use?
a FOR loop
a WHILE loop
Clara is writing a program that will print out the first ten numbers of a times table (chosen by the user). Should she use....
a FOR loop
a WHILE loop
Tara has written a "Hide and Seek Simulator" - what will happen when she runs it?
It will print "1,2,3,4,5,6,7,8,9,10 Coming ready or not!"
The program will not run
It will print "1,2,3,4,5,6,7,8,9,11 Coming ready or not!"
It will print ("10 Coming ready or not!")
