WorksheetsPython Programming Quiz
Total questions: 95
Worksheet time: 1hrs 11mins
Who developed Python?
What is Python and what are its uses?
What are the two modes of working in Python?
Interactive mode
Script mode
How is Python interpreted?
What is the smallest element of Python coding termed as?
Tokens
Variables
Functions
Differentiate between call by value and call by reference.
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
math module
random module
pickle module
What type of objects can be used as keys in dictionaries?
Mutable objects
Immutable objects
What is pickling and unpickling?
How is memory managed in Python?
State the use of the split() function in Python.
Can keywords be used as identifiers in Python?
Yes
No
What are the built-in data types that Python provides?
What is pass in Python?
What is negative index in Python?
How can you convert a number into a string?
Which operator checks a value’s presence in a list of values?
in
not in
In file handling, what does the terms ‘r’, ‘a’ stand for?
What do you understand by module and package in Python?
What are the rules for local and global variables in Python?
How do you access and modify a global variable in Python?
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.
Explain how you can generate random numbers in Python.
Mention five benefits of using Python.
What is the use of // operator in Python?
Write any two rules of naming an identifier in Python.
What are literals in Python?
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.
What are the three types of files in Python?
In text file, each line is terminated by which special character?
Which command is used to read “n” number of characters from a file using the file object
Terminated by which special character?
Which command is used to read “n” number of characters from a file using the file object
(a)
What is the difference between actual parameter/argument and formal parameter?
Name the different file processing modes supported by Python.
What are tell() and seek() functions in Python?
What is the difference between read() and readlines() method?
Which mode in file opening statement results or generates an error if the file does not exist?
r+
w+
a+
rb
Which module is required to use the built-in function dump()?
pickle
json
sqlite3
os
What is/are the basic I/O (input-output) streams in file?
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.
What are the different types of operators in Python?
What is a Dictionary in Python?
What is the use of help() function in Python?
Which package must be imported in Python to create a database connectivity application?
mysql.connector
sqlite3
psycopg2
pymongo
Which function will return all rows from the ResultSet in the form of tuple containing records?
fetchall()
fetchone()
fetchmany()
fetchallrows()
Write a statement to import module for MySQL connectivity with Python.
In the stack, if a user tries to remove element from the empty stack, what is the situation called?
How does Python do compile-time and run-time code checking?
Explain the use of try, except, raise and finally blocks.
What is the purpose of PYTHONPATH environment variable?
What is the difference between lists and tuples?
How will you reverse a list?
What is a string in Python?
Why is the return keyword used in Python?
When should you use the ‘break’ statement in Python?
What is a tuple in Python?
Explain the following results retrieval methods with examples: (i) fetchone() (ii) fetchall() (iii) fetchmany()
Explain the use of ‘with’ statement.
Differentiate between append() and extend() methods.
To make the changes made by any SQL Queries permanently in database, which function is used after execution of the query?
How can we get current directory using Python?
can we get current directory using Python?
What is a CSV file?
Differentiate between file mode ‘w’ and ‘a’ mode with respect to Python.
What is the difference between del keyword and clear() function?
Give the syntax of seek() method while working randomly with Python Files.
Write full form of the following terms: (a) LAN (b) WAN (c) MAN (d) SMTP (e) TCP/IP (f) VoIP (g) URL (h) HTTP
LAN – Local Area Network
WAN – Wide Area Network
TCP/IP – Transmission Control Protocol
MAN – Metropolitan Area Network
SMTP – Simple Mail Transfer Protocol
Differentiate between web browser and web server.
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
SMTP (Simple Mail Transfer Protocol)
VoIP (Voice over Internet Protocol)
TCP (Transmission Control Protocol)
TELNET
FTP (File Transfer Protocol)
Differentiate between Hub and Switch.
Give examples of guided and unguided mediums of data transmission.
Identify the network topology: (a) Each node is connected to a single backbone cable. (b) Each node is connected to a central device.
Bus topology
Star topology
Define the following terms: (a) Website (b) Web page (c) Home page (d) Web server
Differentiate between IP address and MAC address.
Name the device used to connect dissimilar networks.
What is Primary key?
What is Candidate key?
What is Foreign key?
What is Alternate key?
What is MySQL?
What is RDBMS?
Differentiate between Drop and Delete command.
What do you understand by NOT NULL constraint?
What is the significance of COUNT() function in MySQL?
How can we add a record and add a column in a table?
Differentiate between DDL and DML commands.
Give the necessary command to incorporate SQL interface within Python.
To establish a connection between Python and SQL database, connect() is used. Which argument(s) may not necessarily be given while calling connect()?
Which of the functions gives the result as a string when applied while reading contents from a text file in Python?
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?
Which function is used to open a connection with MySQL database from within Python using mysql.connector package?
After establishing database connection, which database object is created so that the SQL query may be executed through it to obtain result set?
What is the output of the expression 3 * '7' in Python?
21
777
Error
Which of the following is a mutable data type in Python?
String
List
Tuple
