wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

python high grade

Total questions: 80

Worksheet time: 40mins

Name
Class
Date
1.
What is syntax?
a)
Syntax is the word used to describe an error
b)
Syntax is the rules of the programming language
c)
It is used to read information
d)
It is used to output information 
2.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
3.

Is variable name case sensitive?

a)

Yes

b)

No

4.

A line of text that Python won't try to run as code

a)

Integer

b)

Comment

c)

Strings

d)

Input

5.
What is the correct definition for a VARIABLE?
a)
a changeable value, such as a score in a computer game.
b)
a value that cannot be changed
6.

Which data type stores TRUE/FALSE values

a)

Integer

b)

Real

c)

Boolean

d)

Array

7.

Which data type can store numbers, letters and symbols?

a)

String

b)

Float

c)

Integer

d)

Boolean

8.

What is the output of the following statement. ?

9_ah = “akash”

Print(9_ah)

a)

akash

b)

9_ah

c)

Error

d)

none

9.

What is the output of the following code?


var1 = 1

var2 = 2

var3 = "3"


print(var + var2 + var3)

a)

6

b)

33

c)

133

d)

Error. Mixing operators between numbers and strings are not supported

10.

Which one of the following has the highest precedence in the expression?

a)

Addition

b)

Multiplication

c)

Exponential

d)

ParenthesIs

11.

What is the answer of this expression, 100 % 98 is?

a)

2

b)

1

12.

The__________ function is used to convert string data as integer data explicitly.

a)

int( )

b)

char()

c)

float()

d)

input()

13.

10//3

a)

3

b)

3.3

c)

0.3

d)

3.0

14.

xy x^{y\ }  

a)

x^^y

b)

x^y

c)

x**y

d)

x pow y

15.

Choose the correct Python code. if age is less than 20 and greater than or equal to 15 then

a)

if age <20 and age >=15:

b)

if age <20>=15 :

16.

This statement is used to evaluate only one condition

a)

IF STATEMENT

b)

IF -ELSE STATEMENT

c)

IF-ELIF-ELSE STATEMENT

17.

Which selection execution flow is given:

a)

if statement

b)

if-else statement

c)

if-elif statement

18.

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?

a)

numCredits >= 120 and majorGPA >= 3.0 or overallGPA >= 3.5

b)

numCredits > 120 and majorGPA > 3.0 and overallGPA >3.5

c)

numCredits > =119 and majorGPA >= 3.0 and overallGPA >= 3.5

19.

What is the result of the code:

team = Cowboys

if team = Cowboys:

print "Dallas is #1"

a)

team

b)

Cowboys

c)

Error

d)

Dallas is #1

20.

Which is the correct output for :

for i in range(1,10):

print(i)

a)

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

b)

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

c)

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

d)

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

21.

Consider the following loop given below :


for i in range(5):

print(i)


How many times will this loop run ?

a)

5

b)

0

c)

infinite

d)

Error

22.

Function range(3) is equivalent to "

a)

range(1,3)

b)

range(0,3)

c)

range(0,3,1)

d)

range(1,3,0)

23.

if you choose to count down from 100 to -100 using a for loop, what would your range function look like ?

a)

range(1,100,-1)

b)

range(100,-100,-1)

c)

range(100,-100,1)

d)

range(100,-1,-100)

24.

Which of the following for loops would print the following numbers?

3

5

7

9

a)

for i in range(3, 10, 2):

print(i)

b)

for i in range(3, 9, 2):

print(i)

c)

for i in range(9):

print(i)

d)

for i in range(3,9):

print(i)

25.

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.

a)

FOR Loop

b)

WHILE Loop

26.

What will happen when this program runs

a)

It will display numbers 0-10 on separate lines

b)

It will display numbers 0-9 on separate lines

c)

It will crash

d)

It will display 0s in an infinite loop

27.
a)
5
4
3
2
1
b)
5  4  3  2  1
c)
4
3
2
1
0
d)
4  3  2  1  0
28.

In a While loop a code will be repeated until the condition becomes

a)

FALSE

b)

TRUE

c)

User choice

29.

What would be the output of the following code:

for i in range(3):

print(5)

a)

0 1 2

b)

3 3 3 3 3

c)

5 5 5

d)

0 1 2 3 4

30.

for i in 100 :

print ( i )

a)

Syntax error

b)

prints numbers 0 to 100

c)

prints numbers 1 to 100

d)

prints numbers 0 to 99

e)

prints numbers 1 to 99

31.

What is the index number for 'Spain'?

['England','Brazil','Spain','France']

a)

0

b)

1

c)

2

d)

3

32.

How do i remove something from a list?

a)

variable.append()

b)

variable.delete()

c)

variable.remove()

d)

variable=(new variable)

33.

Which code would i use to add an item to a list?

a)

variable.add()

b)

variable.append()

c)

append.variable()

d)

add.variable()

34.

Which of these is the best description of a list in Python?

a)

A list is a collection of data that has an order and can be changed

b)

A list is a lot of variables

c)

A list is used for shopping

d)

A list is a collection of data that cannot hold duplicated data and cannot be changed

35.

List items have an index number. In the following list, which item has the index number of 3?

["John", "Harry", "Jesse", "John", "Harry", "Harry"]

a)

"John"

b)

"Harry"

c)

"Jesse"

36.

Consider this list, what will be the highest index the list can have:

li=[1,2,3,4,5]

a)

2

b)

3

c)

4

d)

5

37.

Consider this list, what will be the output of the following:


li=[1,2,3,4,3,2,1]

print(li[-3])

a)

4

b)

3

c)

2

d)

1

38.

Consider this list, what will be the output of the following:


li=[1,2,3,4,3,2,1]

print(li[3:4])

a)

1

b)

2

c)

3

d)

4

39.

Consider this list, what will be the output of the following:


li=[1,2,3]

print(li[3])

a)

1

b)

2

c)

3

d)

error

40.

To insert an the string "strawberries" in the first position of a list we use

a)

fruit.append("strawberries, 1")

b)

fruit.insert("strawberries",0)

c)

fruit.insert(1, "strawberries")

d)

fruit.insert(0, "strawberries")

41.

What will be the value of the following Python expression?

4 + 3 % 5

a)

a) 7

b)

b) 2

c)

c) 4

d)

d) 1

42.

Which of the following is the correct extension of the Python file?

a)

a) .python

b)

b) .pl

c)

c) .py

d)

d) .p

43.

Which of the following character is used to give single-line comments in Python?

a)

a) //

b)

b) #

c)

c) !

d)

d) /*

44.

Which of the following is used to define a block of code in Python language?

a)

a) Indentation

b)

b) Key

c)

c) Brackets

d)

d) All of the mentioned

45.

What is the order of precedence in python?

a)

a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction

b)

b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction

c)

c) Parentheses, Exponential, Multiplication, Division, Subtraction, Addition

d)

d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction

46.

Which of the following functions is a built-in function in python?

a)

a) factorial()

b)

b) print()

c)

c) seed()

d)

d) sqrt()

47.

What will be the output of the “hello” +1+2+3?

a)

a) hello123

b)

b) hello

c)

c) Error

d)

d) hello6

48.

An  algorithm  is a set of precise instructions designed to solve a problem.

a)

True

b)

False

49.

A store your program must use as an identifier to keep track of a value is called a

a)

Algorithm

b)

Variable

c)

Program

d)

Assignment

50.

Which symbol assigns a value to a variable?

(a)  

51.

Who developed Python Programming Language?

a)

a) Wick van Rossum

b)

b) Rasmus Lerdorf

c)

c) Guido van Rossum

d)

d) Niene Stom

52.

Which of the following would be an example of a string variable:

a)

ValidInput = False

b)

GuessCount = 100

c)

Name = "Bilbo"

d)

Pi = 3.14159265359

53.

Which of the following would be an example of a float variable:

a)

ValidInput = False

b)

GuessCount = 100

c)

Name = "Bilbo"

d)

Pi = 3.14159265359

54.

The rules for how programming languages statements can be assembled is known as

a)

Variable

b)

Algorithm

c)

Syntax

d)

Debugging

55.

Which of the following would be an example of an integer variable:

a)

ValidInput = False

b)

GuessCount = 100

c)

Name = "Bilbo"

d)

Pi = 3.14159265359

56.

What is the greater than symbol:

(a)  

57.

What would be the result of 3 ** 3

(a)  

58.

What would be the result of 9 // 7

(a)  

59.

What would be the reult of 9 % 7

(a)  

60.

What will be the output?

name = 'Dave'

print (name)

a)

name

b)

print

c)

Dave

d)

error

61.

What would print (10 + 16) produce?

a)

10

b)

16

c)

24

d)

26

62.

name=input("What is your name? ")

print("Your name is " + name)

What will be displayed if the user types in "Bob"?

a)

Your name is name

b)

name

c)

Bob

d)

Your name is Bob

63.

What, if anything, is wrong with the following?

x=input("Type your password: ")

print("You typed", x)

a)

The variable should be switched with the input command

b)

You can't use commas in print statements

c)

You can't print x

d)

Nothing is wrong

64.
In programming, what is iteration?
a)
The repetition of steps within a program
b)
The order in which instructions are carried out
c)
A decision point in a program
d)
Testing a program to make sure it works
65.

Which two statements are used to implement iteration/Repetition)?

a)
IF and WHILE
b)
ELSE and WHILE
c)
FOR and WHILE
d)
IF and ELSE
66.
Which type of loop iterates until instructed otherwise?
a)
FOR loop
b)
A count-controlled loop
c)
Repeat-once loop
d)
WHILE loop
67.
Which of the following symbols is used in Python to mean "Equal to"?
a)
=
b)
!=
c)
==
d)
>=
68.
Which of the following symbols is used in Python to mean "Not equal to"?
a)
==
b)
!=
c)
<>
d)
><
69.
Which of the following symbols is used in Python to mean "Greater than or equal to"?
a)
<=
b)
>>
c)
>=
d)
=>
70.
Which of the following symbols is used in Python to mean "Less than or equal to"?
a)
<<
b)
=<
c)
<=
d)
!=
71.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
72.
a)
5
4
3
2
1
b)
4
3
2
1
0
c)
5  4  3  2  1
d)
4  3  2  1  0
73.
a)
Hello world!
b)
Hello world
c)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
......(repeated continuously)
d)
Error
74.
a)
Welcome
b)
Try again!
c)
Error
d)
Enter your password
75.
a)
Hello world!
b)
Error
c)
Hello world!
False
d)
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
Hello world!
(repeated continuously)
76.

What does the '#' allow you to do?

a)

Repeat code

b)

Comment on code

c)

Print code

d)

End code

77.

What will this code do?

a)

Print Numbers 1-11

b)

Print Numbers 1-10

c)

Print Numbers 2-10

d)

Print Error

78.
In python the ' FLOAT data type' can be defined as...?
a)
holds alphanumerical data
b)

holds whole numbers

c)

holds a decimal point in a number

d)
hold either true or false
79.
In python the ' BOOLEAN data type' can be defined as...?
a)
holds alphanumerical data
b)
holds whole numbers
c)
holds a number with a decimal point
d)
holds either true or false
80.
In python the ' STRING data type' can be defined as...?
a)
holds alphanumeric text
b)
hold whole numbers
c)
holds numbers with a decimal point
d)
holds either a true or false value