Python Programming
Instructions:
- The marks are indicated in the right-hand margin.
- There are NINE questions in this paper.
- Attempt FIVE questions in all.
- Question No. 1 is compulsory.
Which of the following statements about indentation in Python is correct?
a = 10
b = 3
c = 2
result = a + b * c ** 2
print(result)
The value of result is:Which statement is used to skip the remaining statements of the current iteration of a loop and proceed with the next iteration?
for i in range(1, 6):
if i == 3:
continue
print(i, end=" ")
What is the output?Which statement about a Python list is correct?
L = [10, 20, 30, 40, 50]
print(L[1:4])
The output is:Which statement about a tuple is correct?
Which file mode opens a file for reading binary data?
Which OOP concept allows a derived class to acquire properties and methods from a base class?
Which of the following is a suitable application of NumPy?
Describe the arithmetic and relational operators in Python with suitable examples. Write a Python program to demonstrate their use.
Explain type conversion in Python. Differentiate between implicit and explicit type conversions with suitable code examples
Write a Python program to find the largest of three numbers using appropriate decision control statements.
Explain the scope and lifetime of variables in Python with suitable examples.
Write a Python program using for and while loops to generate a sequence of numbers from 1 to 10. Explain the working of the loops used.
Write a Python program to demonstrate commonly used string methods such as upper(), lower(), replace(), split() and join().
Write a Python program to perform basic operations on a list such as adding, removing, updating and accessing elements. Explain the operations used.
Explain list indexing and slicing in Python with suitable examples. Write a Python program to access and extract specific elements from a list using indexing and slicing.
Consider the following dictionary:
student = {"Name": "Shyam", "Age": 18, "Branch": "CSE", "Marks": 85}
Write Python statements to perform different operations such as accessing values, adding a new key-value pair, modifying a value, deleting an item and displaying all keys and values.Explain the built-in functions and methods available for tuples in Python with suitable examples.
Write a Python program to create a text file, write data into it and read the contents of the file. Explain the file operations used.
Write a Python program to read a text file and count the number of lines, words and characters in the file. Explain the approach used.
Explain Object-Oriented Design in Python. Discuss how OOP concepts are used in designing Python programs.
What is Inheritance? Explain single inheritance in Python with a suitable example.
Operator Precedence and Associativity
zip() Function in Python
Binary Files in Python
NumPy and Its Applications
