wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python - Tổng hợp

Total questions: 80

Worksheet time: 49mins

Name
Class
Date
1.
What function would I use to display text?
a)
sum
b)
import
c)
print
d)
display
2.
What is the correct name for a *?
a)
hashtag
b)
star
c)
loop
d)
asterisk
3.
What does a hashtag represent when using Python?
a)
red text
b)
float
c)
comment
d)
integer
4.
What is missing from this program – print(hello)?
a)
‘‘  ’’
b)
:: 
c)
??
d)
***  ***
5.
To get the users input what function do we use?
a)
Input
b)
input<> 
c)
input() 
d)
INPUT()
6.
What does int() represent?
a)

internet

b)

input

c)

iheanacho

d)

integer

7.
What is a float?
a)
decimal number
b)
whole number
c)
half a number
d)
a fraction
8.
Why do we use variables in programming?
a)
edit data
b)
store data
c)
integer
d)
to look good
9.
What are these () called in programming?
a)
brackets
b)
quotation marks
c)
half circles
d)
parenthesis
10.
What three things make up an if statement?
a)

if, edit, else

b)

if, elif, else

c)

if, elif, edit

d)

if, excited, scream

11.

What is wrong with this code?

print"Do you enjoy eating Banh Mi?"

a)

no quotation marks

b)

no parentheses

c)

no commas

d)

no capital letters

12.

What is wrong with this code?

if answer == (“Leicester City”)

a)

no quotation marks

b)

no parentheses

c)

Poor choice in team

d)

No colon

13.
What does the equal sign mean in this code?

team = input(“Enter a team”)
a)
variable
b)
equal to
c)
greater than
d)
interger
14.
What does “==” represent in Python programming?
a)
less than
b)
equal to
c)
greater than
d)
not equal to
15.
What does “input()” represent in this code?

colour = input(“Enter a colour”)
a)
prompts the user to enter an input
b)
it gives the user a colour
c)
it turns the text that colour
16.
What is “team” in this line of code?
team = input()
a)
constant
b)
string
c)
variable
d)
constant
17.

What will be the output?

name = 'Jamie Vardy'

print (name)

a)

Jamie Vardy

b)

'Jamie Vardy'

c)

name

d)

(name)

18.

What will be the output?

name = 'Mr Brown'

greeting = "Good morning " + name

print (greeting)

a)

Good morning

'Mr Brown'

b)

Good morning

Mr Brown

c)

Good morning name

d)

Good morning + Mr Brown

19.
When you have an error in your code what is the term to summarise finding and fixing that error?
a)
Error checking
b)
Debugging
c)
Syntax finder
d)
Error finder
20.
Which of these would work as a piece of code?
a)
IF answer == "Yes":
b)
if answer == "Yes"
c)
if answer == "Yes":
d)
if answer = "yes":
21.
In the following expression which element is a comparison operator?
if a > b:
           print(a)
a)
a
b)
>
c)
b
d)
if
22.
What is the meaning of the following comparison operator?
a >= b
a)
Equal to
b)
Not equal to
c)
Greater than or equal to
d)
Less than or equal to
23.
What is the meaning of the following comparison operator?
a != b
a)
Equal to
b)
Greater than
c)
Not equal to
d)
Less than or equal to
24.
IF and ELSE are used when a program needs to make a what?
a)
Repeat
b)
Decision
c)
Change
d)
Output
25.
a)
You can buy some chocloate
b)
You are rich!
c)
Get a job!
d)
You almost have enough
Get a job!
26.
a)
3, 1, 6, 7, 2, 4, 5
b)
6, 3, 1, 2, 4, 5, 7
c)
3, 6, 1, 2, 4, 5, 7
d)
3, 6, 2, 5, 1, 4, 7
27.
What is syntax?
a)
Syntax is the word used to describe a variable
b)
Syntax is the rules of the programming language
c)
This is used to read information
d)
It is used to output information 
28.

What will the following code do: print("What is your name?")

a)

Allow you to type in your name

b)

Display the words 'What is your name?' on the screen

c)

Allow you to enter information

d)

Print your name to the screen

29.
A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly
a)
True
b)
False
30.

Python correct naming convention for variables is?

a)

new_user25

b)

NewUser25

c)

25_new_user

d)

25NewUser

e)

NEWUSER25

31.

What output will the console show, if 15 and 30 are entered by the user?

a)

Syntax error

b)

The sum of the two numbers - 45

c)

The concatenation of the two numbers - 1530

d)

Complier error

32.

Which one will display when this code is run?

a)
b)
c)
d)
33.
Surrounds multi-line comments
a)
"""
b)
**
c)
#
d)
%
34.
Symbol used for modulus
a)
%
b)
&
c)
#
d)
**
35.
To solve a problem that requires the user to enter 10 numbers would use what type of iteration?
a)
While loop
b)
For loop
c)
Variable
d)
Selection
36.
A data type consisting of numbers, letters and symbols.
a)
String
b)
Integer
c)
Float
d)
Boolean
37.
Code executed based on a condition being true
a)
Sequence
b)
Selection
c)
Iteration
d)
Variable
38.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
39.

Which of the following evaluates to the variable z rounded to two decimal places?

a)

round(x, 2)

b)

round(2, z)

c)

round(z), 2

d)

round(z, 2)

40.

#Find the error in this program

goals=int(input("Enter the number of goals you scored last season: "))

if goals>= 20:

print("You are good enough to sign for Leicester City")

else

print("Not good enough for Leicester, better sign for a rubbish team like Man united instead!")

a)

Missing Colon somewhere

b)

Missing Parenthesis somewhere

c)

Missplet variable name

d)

Leicester are not better than Man United

41.
Which python operator means 'less than or equal to'?
a)
>
b)
<
c)
>=
d)
<=
42.
What is another word for 'iteration'?
a)
Selection
b)
Variable Assignment
c)
Repetition
d)
Sequencing
43.
How many times will this loop run?
a)
10
b)
9
c)
4
d)
5
44.
I want to allow the program to repeatedly ask the user to enter their guess if it does not equal the answer...Which option do I use?
a)
while guess == answer:
    guess=input()
b)
while answer != guess:
guess=input()
c)
while answer =! guess:
guess=input()
d)
while guess != answer:
guess=input()
45.

Which word completes this sentence: "Iteration makes code more ___________"

a)

Complex

b)

Efficient

c)

Simple

d)

Straightforward

46.

A FOR loop is....

a)

A COUNT controlled loop

b)

A CONDITION controlled loop

47.

A WHILE loop is....

a)

A COUNT controlled loop

b)

A CONDITION controlled loop

48.

What will the output be for the code shown here?

a)

3,2,1,0

b)

0,1,2,3

c)

3,2,1

d)

1,2,3

49.

What would the output be for the code shown here?

a)

0,1,2,3,4,5,6,7,8,9

b)

1,2,3,4,5,6,7,8,9,10

c)

0,2,4,6,8,10

d)

0,2,4,6,8

50.

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)

a FOR loop

b)

a WHILE loop

51.

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)

a FOR loop

b)

a WHILE loop

52.

Tara has written a "Hide and Seek Simulator" - what will happen when she runs it?

a)

It will print "1,2,3,4,5,6,7,8,9,10 Coming ready or not!"

b)

The program will not run

c)

It will print "1,2,3,4,5,6,7,8,9,11 Coming ready or not!"

d)

It will print ("10 Coming ready or not!")

53.

A type of error that occurs when a rule of the programming language code is broken?

a)

Syntax error

b)

Logic error

c)

Run-time error

d)

Program error

54.

Which data type would be used in Python to store the value of pi to 2 decimal places?

a)

Integer

b)

Float

c)

Boolean

d)

String

55.

What is this a description of?


A named piece of storage used by a computer program that can change its value

a)

Variable

b)

Constant

c)

Function

d)

Parameter

56.

In what way is a constant different from a variable?

a)

It can not change its value during program execution

b)

It can store more than one value

c)

It can only be used in the global scope

d)

Its name must be written in UPPER CASE

57.

Use the correct order of operations to evaluate this expression ...


6 * 8 / 2 + (15 - 6) + 3 ^ 2

a)

42

b)

32

c)

52

d)

72

58.

The process of giving a value to a variable?

a)

Assignment

b)

Initialisation

c)

Coercion

d)

Declaration

59.

Choose all the recognised control structures in a computer program ...

a)

Sequence

b)

Selection

c)

Iteration

d)

Duplication

60.

Example of ... ?

a)

Selection

b)

Repetition

c)

Sequence

d)

Iteration

61.

Example of ...?

a)

Conditional loop

b)

Unconditional loop

c)

Selection

d)

Sequence

62.

Odd one out ...?

a)
b)
c)
d)
63.

Example of ...?

a)

Sequence

b)

Selection

c)

Repetition

d)

Recursion

64.

Example of ...?

a)

Nested loop

b)

Nested selection

c)

Recursion

d)

Sequence

65.

Example of ...?

a)

Nested selection

b)

Nested loop

c)

Repetition

d)

Iteration

66.

Type of loop to use when the number of repetitions is known before the loop starts?

a)

FOR ... loop

b)

WHILE ... loop

c)

FOR ... EACH ... loop

d)

REPEAT ... UNTIL ...

67.

A special type of loop that never ends?

a)

Infinite loop

b)

Recursive loop

c)

Nested loop

d)

Unconditional loop

68.

Symbols used for entering comments in Python ...?

a)

# This is a Python comment

b)

''' This is a Python comment '''

c)

// This is a Python comment

d)

/* This is a Python comment */

69.

An error in the way a program works where program can run but does not do what it is expected to do is called a ...

a)

Logic error

b)

Syntax error

c)

Runtime error

d)

Catastrophe

70.

What data type represents a whole number?

a)

Float

b)

Int

c)

Boolean

d)

String

71.

What data type represents characters?

a)

Float

b)

Int

c)

Boolean

d)

String

72.

What data type represents only two possible outcomes?

a)

Float

b)

Int

c)

Boolean

d)

String

73.

How many errors are there in this code?

a)

1

b)

2

c)

3

d)

4

74.

15. What is the output of the following code?


valueOne = 5 ** 2

valueTwo = 5 ** 3


print(valueOne)

print(valueTwo)

a)

10

15

b)

25

125

c)

ERROR

75.

2. What is the output of the following code?


p, q, r = 10, 20 ,30

print(p, q, r)

a)

10 20

b)

10 20 30

c)

Error: invalid syntax

76.

3. What is the Output of the following code?


for x in range(0.5, 5.5, 0.5):

print(x)

a)

[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5]

b)

[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5]

c)

The Program executed with errors

77.

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" )

a)

YES

b)

NO

78.

What would the output of this code be if the user entered the value 70?

a)

Pass

b)

Fail

c)

Merit

d)

Distinction

79.

What would the outcome of this program be?

a)

prints 1 to 10 numbers

b)

prints 10 to 1 numbers

c)

prints 1 to 15 numbers

d)

prints 1 to 14 numbers

80.

What is the output of the following program?

for i in range(0, 5):

print(i)

i=i+1

a)

1 to 5 numbers

b)

1 to 4 numbers

c)

0 to 4 numbers

d)

0 to 5 numbers