Jawaharlal Nehru Technological University Hyderabad
Jawaharlal Nehru Technological University Hyderabad B.Tech II PYTHON PROGRAMMING Previous Question Paper (September - 2021 - R18)
Answer any five questions. All questions carry equal marks.
Main
Define a Variable and mention rules for choosing names of Variable.
Answer
A variable is a reserved memory location used to store values within a program. In Python, variables are created when a value is assigned to them using the assignment operator (=).
Rules for naming variables:
- Variable names must start with a letter or an underscore (_).
- They cannot start with a number.
- They can only contain alpha-numeric characters and underscores (A-z, 0-9, and _).
- Variable names are case-sensitive (e.g., age, Age, and AGE are different variables).
- They cannot be any of the Python keywords (e.g., if, while, def).
Discuss a various operations that can be performed on a tuple and lists with an example program.
Answer
Lists and tuples are sequence data types in Python. A list is mutable (can be modified), whereas a tuple is immutable (cannot be changed after creation).
Common operations for both include indexing, slicing, concatenation, and repetition. Lists additionally support methods like append(), remove(), and pop().
# Example program
my_list = [1, 2, 3]
my_tuple = (4, 5, 6)
# Accessing elements
print(my_list[0]) # Output: 1
# Slicing
print(my_tuple[1:]) # Output: (5, 6)
# List modification (Mutable)
my_list.append(4)
print(my_list) # Output: [1, 2, 3, 4]
# Concatenation
combined = my_list + [5]
print(combined) # Output: [1, 2, 3, 4, 5]What is an Exception? Explain types of exceptions and give an example.
Answer
Sign in to view the complete answer paper.
Define Module. How many ways to import module in python? Explain with an example.
Answer
Sign in to view the complete answer paper.
What do you mean by Regular Expression? How to find whether an email id entered by the user is valid or not using Python ‘re’ module.
Answer
Sign in to view the complete answer paper.
What is the motivation behind parallelism and state how python achieves parallelism?
Answer
Sign in to view the complete answer paper.
Write a python program to develop a checkbox widget using Tkinter.
Answer
Sign in to view the complete answer paper.
Explain about building web applications using python’s CGI Module.
Answer
Sign in to view the complete answer paper.
List and explain various cursor classes in MySQLdb.cursors.
Answer
Sign in to view the complete answer paper.
Define ORM. Why ORMs are useful? Explain.
Answer
Sign in to view the complete answer paper.
Develop a python program to find the largest number among three numbers.
Answer
Sign in to view the complete answer paper.
Explain the need for 'continue' and 'break' statements. Write a program to check whether a number is prime or not. Prompt the user for input.
Answer
Sign in to view the complete answer paper.
Write a python program to print the sum of the following series: 1 + 1/2 + 1/3 + ... + 1/n.
Answer
Sign in to view the complete answer paper.
Explain user defined exceptions in python.
Answer
Sign in to view the complete answer paper.
What are the features of python?
Answer
Sign in to view the complete answer paper.
Write a small code to illustrate packages in Python.
Answer
Sign in to view the complete answer paper.
How do we achieve code reusability in python? Write a python code to Explain code reusability.
Answer
Sign in to view the complete answer paper.