WorksheetsPython Quiz
Total questions: 148
Worksheet time: 1hrs 26mins
What is a programming language?
Written English
An artificial language used to program a computer
A language used in pseudocode
Machine code
What is a program?
A series of a step-by-step instructions that tell a computer how to solve a task
A video that is watched on a computer
A flowchart written on a computer
The make and model of a computer
What does the print command do?
Outputs a hard copy of a program to a printer
Outputs a message on screen
Print a hard copy of a flow chart to a printer
Prints out the the commands line by line on the screen
How do we get user input from the keyboard?
input = (What is your name?)
input = What is your name?
output = ("What is your name?")
input("What is your name? ")
Which data type is the most suited to store a telephone number in a variable?
string
integer
float
boolean
Which data type would you use for the quantity of stock in a shop?
integer
float
string
boolean
If you want to change the data type to an integer which line of code would you use?
int ("How much pocket money do you have?")
input("How much pocket money do you have?")
int(input("How much pocket money do you have?"))
int = ("How much pocket money do you have?")
What is an instruction?
A box in a flowchart
A calculation performed in a programming language
One or more statements grouped together to instruct the computer to perform a task
A separate file that has information on how to install the program
What is a statement?
A calculation performed in a programming language
A box in a flow chart
A keyword in a programming language
A printout of the program
How many statements are in this line of code?
print("If I do well in computing, I will find most subjects easy")
2 - print and if
0 - there are no statements
1 - print
Why was Python (TM) developed?
To go back to the old way of programming
To create a programming language for students in grade school
To make it easier to learn Java
Python was developed by accident
Python (TM) is owned and managed by
Microsoft (c)
Sun Microsystems (c)
Python (TM) is open source and free to use
Google (c)
Python is ___________ level programming language and is ___________.
High, compiled
High, interpreted
Low, compiled
Low, interpreted
Generally speaking, a low level programming language is easier to read, write and maintain over a high level programming language
True
False
The syntax in Python (TM) is one of the main advantages over other high level programming languages.
True
False
A statement in programming
Expresses an action to be carried out
Always returns results like expressions
Rules controlling how components in a program are combined
An instruction to perform a task, usually one word
A string
carries out an action
the elements of a command
a collection of characters
how elements in a commad are arranged
A block is
a statement including elements of a command
the structure and form of the code
source code that is grouped together
meaning assigned to symbols, characters and words
What symbol comes before a comment?
$
>>
#
!
An exception is
the structure of form of the code
the meaning of the characters and words in the code
the statement that is missing from the instructions
an event occurring during execution of a program which disrupts the flow of the program's instructions
Debugging is
how characters are arranged in a statement
detecting or removing errors from a program
removing viruses from a computer
the meaning of each of the characters and symbols in the program
A disadvantage of Python is it is harder to debug than other higher level programming languages.
True
False
In programming, a (n) _______________ is a value that can change, depending on conditions or on information passed to the program
string
block
instruction
variable
Generally speaking Python (TM) would run _____________ than C++ and take ____________ time to create
faster, less
faster, more
slower, less
slower, more
Since Python (TM) is open source,
Support for using Python (TM) is easy to find
It is free
There is a large catalog of supporting documents
it is a less powerful programming languange
What is the word (command) used to display output within Python?
input
output
display
What is a variable?
A box(memory location) where you store values
A box(memory location) where you store multiple values
Data type
A static memory value
name = 'Dave'
print (name)
Which of these would work as a piece of code in Python?
IF answer == "Yes":
if answer == "Yes"
if answer == "Yes":
if answer = "yes":
What function is used to output a message in python?
print ("")
print = ("")
Print ("")
What syntax would you use to create a name variable in Python?
name=input()
input=name
name=input{}
name=INPUT
If you want multiple options for your code, what should you use (after if)?
elif
else
if
Returns the remainder from division.
DIV
MOD
A data type consisting of numbers with decimals.
integer
float / real
string
boolean
A data type consisting of whole numbers.
integer
float / real
string
boolean
A data type consisting of a single character.
integer
character
string
boolean
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
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
Python is a high level language
Yes
No
Onlinegdp is used as a :
compiler
text editor
interpreter
debugger
In Python , variable name must start with a letter or the underscore character
Yes
No
Commands written in Python are very complex
yes
no
Following is an example of a built-in function in Python:
sum()
sub()
float()
the data type string can only store
text
text and numbers
numbers
print (18 % 6) gives the following value:
3
2
0
1
A function in Python always return a value:
Yes
No
6
4
python file has the following extension:
python
pycharm
py
py1
# is used to :
enter text to a program
enter a number to a program
enter comments to a program
What is the name of the programming language we are learning?
python
scratch
scribble
pie thin
What symbol do you use to make a comment in Python?
@
:
?
#
What does the term 'debug' mean?
Identify errors and fix them
Making a calculation
A set of instructions
Looking at code
Python is an example of a....
language written in java script
Visual-based programming language
Object orientated programming language
Text-based programming language
What extension must you add to the end of a file when saving?
.xlsx
.py
.docx
.pptx
What does the print function do in python?
It loops the code.
It's a variable.
It can input data.
It displays something like a string or integer
A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly.
True
False
What is the correct definition for a VARIABLE?
a changeable value, such as a score in a computer game.
a value that cannot be changed
What are the different data types in Python?
The different data types in Python are: int, float, complex, str, list, tuple, set, dict, bool, and NoneType.
integer, decimal, character, list, boolean
number, text, array, dictionary, boolean
int, float, string, array, boolean
What is the syntax for an if statement in Python?
The syntax for an if statement in Python is: if {condition}
The syntax for an if statement in Python is: if condition: # code block
The syntax for an if statement in Python is: if condition then
The syntax for an if statement in Python is: if (condition)
How do you write a for loop in Python?
for i in range(1, 10, 2):
for x in range(5, 10):
for item in iterable_object:
for i in range(10):
What is the purpose of a function in Python?
The purpose of a function in Python is to encapsulate a set of instructions that can be reused and called multiple times within a program.
The purpose of a function in Python is to print a specific value to the console
The purpose of a function in Python is to stop the execution of the program
The purpose of a function in Python is to create a new variable
What is a list in Python?
A list in Python is a type of loop
A list in Python is a type of function
A list in Python is a collection of items that are ordered and changeable. It allows duplicate elements and can contain different data types.
A list in Python is a type of snake
What is a tuple in Python?
A tuple in Python is a collection of unordered and mutable elements, represented by square brackets.
A tuple in Python is a data type used for storing multiple values like a list, represented by curly braces.
A tuple in Python is a collection of ordered and immutable elements, represented by parentheses.
A tuple in Python is a single value that cannot be changed, represented by angle brackets.
Explain the concept of a dictionary in Python.
A dictionary in Python is a collection of key-value pairs. It is unordered, changeable, and does not allow duplicate keys. Each key is unique and is used to access its corresponding value.
A dictionary in Python is a collection of key-value pairs, but the keys can be duplicated.
A dictionary in Python is a collection of values without keys.
A dictionary in Python is a collection of ordered pairs.
What is the difference between a while loop and a for loop in Python?
While loop is for beginners, for loop is for advanced programmers
The main difference is in their usage and the way they control the flow of the program.
While loop is used for odd numbers, for loop is used for even numbers
The difference is in the color of the text they use
What is the purpose of using 'elif' in Python?
The 'elif' statement is used to check for multiple conditions after the 'if' statement and before the 'else' statement.
The 'elif' statement is used to end the program if the 'if' condition is not met.
The 'elif' statement is used to create a new variable in Python.
The 'elif' statement is used to print a specific value to the console.
What is the purpose of using 'break' in a loop in Python?
The 'break' statement is used to terminate the loop and transfer the execution to the statement immediately following the loop.
The 'break' statement is used to skip the current iteration and continue with the next iteration of the loop.
The 'break' statement is used to print a specific value to the console.
The 'break' statement is used to create a new variable in Python.
What is the purpose of using 'pass' in Python?
The 'pass' statement is used to terminate the loop and transfer the execution to the statement immediately following the loop.
The 'pass' statement is used to skip the current iteration and continue with the next iteration of the loop.
The 'pass' statement is used to create a new variable in Python.
The 'pass' statement is used to do nothing and acts as a placeholder.
name = 'Dave'
print (name)
Which is the Python logo?
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
What function is used to output a message in python?
print("")
input=name
name=input
x = 5
y = 6
print(x*y)
The code above displays the following:
11
x*y
Syntax Error
30
Operators used in python:
divide, multiply, add, subtract
/, *, +, -
div, mul, +, -
\, x, +, -
~, *, +, -
name = 'Dave'
print (name)
Which is the Python logo?
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
What function is used to output a message in python?
print("")
input=name
name=input
x = 5
y = 6
print(x*y)
The code above displays the following:
11
x*y
Syntax Error
30
Operators used in python:
divide, multiply, add, subtract
/, *, +, -
div, mul, +, -
\, x, +, -
~, *, +, -
Write the output of the following code:
x=2
x=5
x=x+x
print(x)
7
10
4
Error
Write the output of the following code :
x=2
y=3
x+y+5
print(x+y)
8
6
10
5
What is a keyword?
Reserved Word
Predefined Word
Keywords are part of the syntax and they cannot be used as an identifier.
All of them
Which statement will display square of number (n)
print(n * n)
print(math.pow(n,2)) # math module is already imported
All of the above
Only First
Select the reserved keyword in python-
else
raise
import
All of them
What will be the output of this string operation s[2:5] , if s="hello world" -
lo
llo
llow
ell
Which of the following character is used to give single-line comments in Python?
//
#
!
/*
What will be the output?
name = 'Python'
print (type(name))
char
'Python'
str
Error
What will be the output?
d = 10 < 11
print (d)
10
11
True
False
Identify the arithmetic operator which is used to calculate exponential.
*
%
!
**
What will be the output?
str1 = "Deep Learning"
print (len(str1))
11
12
13
Out of Range Error
What will be the output?
a = 25
b = 4
print (a%b)
1
6
6.2
1.5
What will be the output ?
print (type(5 // 2))
int
float
2
2.5
A string
carries out an action
the elements of a command
a collection of characters
how elements in a commad are arranged
1. He is a Dutch Programmer known as the creator of Python?
a. Rasmus Lerdorf
b. James Gosling
c. Guido van Rossum
d. Niklaus Wirth
2. What does IDE mean?
a. Internet Detection Entertainment
b. Integrated Development Environment
c. Instantaneous Differentiation Equipment
d. Intermediate Development Element
3. Which of the following is not an IDE for Python?
a. XML
b. Pycharm
c. Visual Studio Code
d. Thonny
5. It is the process of joining two or more strings.
a. Addition
b. Concatenation
c. Integration
d. Differentiation
6. What does % math operator do?
a. To get the remainder of the two numbers.
b. To get the square root of two numbers.
c. To get the percentage from those two numbers.
d. To get the quotient of the two numbers.
7. What does == mean?
a. Assignment operator
b. Answer operator
c. Equality operator
d. Mathematical operator
8. What symbol is used to denote "not equal"?
a. *=
b. @=
c. ?=
d. !=
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
