Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming Quiz

Total questions: 95

Worksheet time: 1hrs 11mins

Name
Class
Date
1.

Who developed Python?

4 lines
2.

What is Python and what are its uses?

4 lines
3.

What are the two modes of working in Python?

a)

Interactive mode

b)

Script mode

4.

How is Python interpreted?

4 lines
5.

What is the smallest element of Python coding termed as?

a)

Tokens

b)

Variables

c)

Functions

6.

Differentiate between call by value and call by reference.

4 lines
7.

Identify and write the name of the Python module to which the following functions belong: (a) ceil() (b) floor() (c) randint() (d) dump() (e) sqrt() (f) factorial

a)

math module

b)

random module

c)

pickle module

8.

What type of objects can be used as keys in dictionaries?

a)

Mutable objects

b)

Immutable objects

9.

What is pickling and unpickling?

4 lines
10.

How is memory managed in Python?

4 lines
11.

State the use of the split() function in Python.

4 lines
12.

Can keywords be used as identifiers in Python?

a)

Yes

b)

No

13.

What are the built-in data types that Python provides?

4 lines
14.

What is pass in Python?

4 lines
15.

What is negative index in Python?

4 lines
16.

How can you convert a number into a string?

4 lines
17.

Which operator checks a value’s presence in a list of values?

a)

in

b)

not in

18.

In file handling, what does the terms ‘r’, ‘a’ stand for?

4 lines
19.

What do you understand by module and package in Python?

4 lines
20.

What are the rules for local and global variables in Python?

4 lines
21.

How do you access and modify a global variable in Python?

4 lines
22.

To delete a file in Python, you can use the os module, which provides a method called remove(). Here is a simple example:

import os

# Specify the file path
file_path = 'path/to/your/file.txt'

# Delete the file
os.remove(file_path)

Make sure to handle exceptions, as trying to delete a file that does not exist will raise a FileNotFoundError.

4 lines
23.

Explain how you can generate random numbers in Python.

4 lines
24.

Mention five benefits of using Python.

4 lines
25.

What is the use of // operator in Python?

4 lines
26.

Write any two rules of naming an identifier in Python.

4 lines
27.

What are literals in Python?

4 lines
28.

Python functions are reusable blocks of code that perform a specific task. They allow for better organization and modularity in programming. Functions can take inputs, known as parameters, and can return outputs. In Python, functions are defined using the def keyword followed by the function name and parentheses. They can be called multiple times throughout a program, making code more efficient and easier to maintain.

4 lines
29.

What are the three types of files in Python?

4 lines
30.

In text file, each line is terminated by which special character?

4 lines
31.

Which command is used to read “n” number of characters from a file using the file object ?

4 lines
32.

Terminated by which special character?

4 lines
33.

Which command is used to read “n” number of characters from a file using the file object ?

(a)  

34.

What is the difference between actual parameter/argument and formal parameter?

4 lines
35.

Name the different file processing modes supported by Python.

4 lines
36.

What are tell() and seek() functions in Python?

4 lines
37.

What is the difference between read() and readlines() method?

4 lines
38.

Which mode in file opening statement results or generates an error if the file does not exist?

a)

r+

b)

w+

c)

a+

d)

rb

39.

Which module is required to use the built-in function dump()?

a)

pickle

b)

json

c)

sqlite3

d)

os

40.

What is/are the basic I/O (input-output) streams in file?

4 lines
41.

An operator in Python is a special symbol or keyword that is used to perform operations on variables and values. Operators can be classified into several categories, including arithmetic operators (like +, -, *, /), comparison operators (like ==, !=, >, <), logical operators (like and, or, not), and assignment operators (like =, +=, -=). Each operator has a specific function and is used to manipulate data in various ways.

4 lines
42.

What are the different types of operators in Python?

4 lines
43.

What is a Dictionary in Python?

4 lines
44.

What is the use of help() function in Python?

4 lines
45.

Which package must be imported in Python to create a database connectivity application?

a)

mysql.connector

b)

sqlite3

c)

psycopg2

d)

pymongo

46.

Which function will return all rows from the ResultSet in the form of tuple containing records?

a)

fetchall()

b)

fetchone()

c)

fetchmany()

d)

fetchallrows()

47.

Write a statement to import module for MySQL connectivity with Python.

4 lines
48.

In the stack, if a user tries to remove element from the empty stack, what is the situation called?

4 lines
49.

How does Python do compile-time and run-time code checking?

4 lines
50.

Explain the use of try, except, raise and finally blocks.

4 lines
51.

What is the purpose of PYTHONPATH environment variable?

4 lines
52.

What is the difference between lists and tuples?

4 lines
53.

How will you reverse a list?

4 lines
54.

What is a string in Python?

4 lines
55.

Why is the return keyword used in Python?

4 lines
56.

When should you use the ‘break’ statement in Python?

4 lines
57.

What is a tuple in Python?

4 lines
58.

Explain the following results retrieval methods with examples: (i) fetchone() (ii) fetchall() (iii) fetchmany()

4 lines
59.

Explain the use of ‘with’ statement.

4 lines
60.

Differentiate between append() and extend() methods.

4 lines
61.

To make the changes made by any SQL Queries permanently in database, which function is used after execution of the query?

4 lines
62.

How can we get current directory using Python?

4 lines
63.

can we get current directory using Python?

4 lines
64.

What is a CSV file?

4 lines
65.

Differentiate between file mode ‘w’ and ‘a’ mode with respect to Python.

4 lines
66.

What is the difference between del keyword and clear() function?

4 lines
67.

Give the syntax of seek() method while working randomly with Python Files.

4 lines
68.

Write full form of the following terms: (a) LAN (b) WAN (c) MAN (d) SMTP (e) TCP/IP (f) VoIP (g) URL (h) HTTP

a)

LAN – Local Area Network

b)

WAN – Wide Area Network

c)

TCP/IP – Transmission Control Protocol

d)

MAN – Metropolitan Area Network

e)

SMTP – Simple Mail Transfer Protocol

69.

Differentiate between web browser and web server.

4 lines
70.

Identify the protocols: (a) Used to send emails (b) Used to send voice, video and data over the internet (c) It breaks down the original message into packets (d) Used to login to a remote machine (e) Used to exchange files over the internet

a)

SMTP (Simple Mail Transfer Protocol)

b)

VoIP (Voice over Internet Protocol)

c)

TCP (Transmission Control Protocol)

d)

TELNET

e)

FTP (File Transfer Protocol)

71.

Differentiate between Hub and Switch.

4 lines
72.

Give examples of guided and unguided mediums of data transmission.

4 lines
73.

Identify the network topology: (a) Each node is connected to a single backbone cable. (b) Each node is connected to a central device.

a)

Bus topology

b)

Star topology

74.

Define the following terms: (a) Website (b) Web page (c) Home page (d) Web server

4 lines
75.

Differentiate between IP address and MAC address.

4 lines
76.

Name the device used to connect dissimilar networks.

4 lines
77.

What is Primary key?

4 lines
78.

What is Candidate key?

4 lines
79.

What is Foreign key?

4 lines
80.

What is Alternate key?

4 lines
81.

What is MySQL?

4 lines
82.

What is RDBMS?

4 lines
83.

Differentiate between Drop and Delete command.

4 lines
84.

What do you understand by NOT NULL constraint?

4 lines
85.

What is the significance of COUNT() function in MySQL?

4 lines
86.

How can we add a record and add a column in a table?

4 lines
87.

Differentiate between DDL and DML commands.

4 lines
88.

Give the necessary command to incorporate SQL interface within Python.

4 lines
89.

To establish a connection between Python and SQL database, connect() is used. Which argument(s) may not necessarily be given while calling connect()?

4 lines
90.

Which of the functions gives the result as a string when applied while reading contents from a text file in Python?

4 lines
91.

After executing any DML command from Python in Python-MySQL connectivity, which method/statement is necessary to execute in order to make the changes permanent in MySQL?

4 lines
92.

Which function is used to open a connection with MySQL database from within Python using mysql.connector package?

4 lines
93.

After establishing database connection, which database object is created so that the SQL query may be executed through it to obtain result set?

4 lines
94.

What is the output of the expression 3 * '7' in Python?

a)

21

b)

777

c)

Error

95.

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

a)

String

b)

List

c)

Tuple