Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

EvaluativeQuiz

Total questions: 15

Worksheet time: 15mins

Name
Class
Date
1.

How do you open a file for reading in Python?

a)

open('filename.txt', 'r')

b)

open('filename.txt', 'w')

c)

open('filename.txt', 'a')

2.

How do you read the contents of a file in Python?

a)

file.read()

b)

file.write()

c)

file.append()

3.

How do you open a file for writing in Python?

a)

open('filename.txt', 'r')

b)

open('filename.txt', 'w')

c)

open('filename.txt', 'a')

4.

How do you write to a file in Python?

a)

file.read()

b)

file.write()

c)

file.writeline()

5.

How do you close a file in Python?

a)

file.close()

b)

file.open()

c)

file.exit()

6.

What is the command used to show a message on the console in Python?

a)

print()

b)

input()

c)

read()

d)

write()

7.

Which of the following is NOT a data type in Python?

a)

Integer

b)

String

c)

Boolean

d)

Double

8.

How do you create a function in Python?

a)

function my_function():

b)

def my_function():

c)

create my_function():

d)

new_function my_function():

9.

How do you call a function in Python named my_function()?

a)

function my_function()

b)

call my_function()

c)

my_function()

d)

execute my_function()

10.

How do you check the length of a string in Python named ch?

a)

string_length(ch)

b)

len(ch)

c)

ch.length()

d)

ch.size()

11.

Give me a similar syntax:

f = open(filename)

f.read()

f.close()

(a)  

12.

What is the method used to read a single line from a file in Python?

a)

file.read()

b)

file.readline()

c)

file.getline()

13.

When we use the split() function ?

a)

Add a line in the text file

b)

Divide a string

c)

Concatenate a string

14.

When we want to work with third party library(e.g. turtule, pygame ...), we use the following syntax (Note: the library is named PyQt5)

a)

import PyQt5

b)

import PyQt5 from *

c)

from PyQt5 import *

15.

فوفة شنوة إسمها ؟

a)

ففاني

b)

فايقة

c)

فايزة