0% found this document useful (0 votes)
18 views

Python Programming Exam Questions

The document outlines Python programming exam questions for AKTU's semester exam, divided into four units covering Python basics, flow control, data structures, and file handling. Each unit includes short answer and programming questions designed to test knowledge and skills in Python. Additionally, it provides final exam tips for effective preparation.

Uploaded by

Vaibhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Python Programming Exam Questions

The document outlines Python programming exam questions for AKTU's semester exam, divided into four units covering Python basics, flow control, data structures, and file handling. Each unit includes short answer and programming questions designed to test knowledge and skills in Python. Additionally, it provides final exam tips for effective preparation.

Uploaded by

Vaibhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Python Programming Exam Questions (AKTU Semester Exam)

Unit 1: Python Basics

Short Answer Questions:

1. What are the key features of Python?

2. Explain the difference between compiled and interpreted languages. Where does Python fit?

3. What is the difference between Python 2 and Python 3?

4. Define variables and data types in Python with examples.

5. What are Python’s built-in data types?

6. Explain the use of indentation in Python.

7. What is dynamic typing in Python?

8. How do you take user input in Python?

9. What are Python's different operators?

10. Explain the difference between == and = in Python.

11. What is the purpose of type conversion in Python? Provide examples.

12. Explain the difference between mutable and immutable objects in Python.

Programming Questions:

1. Write a Python program to swap two variables without using a temporary variable.

2. Write a program to check whether a given number is even or odd.

3. Write a Python program to convert temperature from Celsius to Fahrenheit.

4. Write a program to check if a number is positive, negative, or zero.

5. Write a Python program to find the greatest of three numbers entered by the user.

Unit 2: Flow Control (Loops & Conditional Statements)

Short Answer Questions:

1. What are conditional statements in Python?

2. Explain if-elif-else with syntax and an example.

3. What is the difference between for loop and while loop?

4. How does the break statement work in Python?

5. What is the difference between continue and pass?

6. What is a nested loop? Provide an example.


7. What will be the output of the following code?

for i in range(1, 10, 2):

if i % 3 == 0:

continue

print(i, end=" ")

8. Explain the role of else with loops in Python.

9. What is recursion? Provide an example of a recursive function.

Programming Questions:

1. Write a Python program to find the factorial of a number using a loop.

2. Write a program to print the Fibonacci series up to n terms.

3. Write a Python program to reverse a number.

4. Write a Python program to check if a number is prime.

5. Write a program to print all numbers divisible by 3 and 5 between 1 and 100.

6. Write a recursive function to calculate the sum of the first n natural numbers.

Unit 3: Strings, Lists, Tuples & Dictionaries

Short Answer Questions:

1. What are immutable and mutable data types in Python?

2. Explain string slicing in Python with an example.

3. What is the difference between lists and tuples?

4. How do you access elements of a dictionary in Python?

5. Explain list comprehension with an example.

6. What is a tuple? Can it be modified?

7. How do you remove duplicate elements from a list?

8. Explain dictionary methods like keys(), values(), and items().

9. What will be the output of the following code?

d = {"name": "John", "age": 25}

print(d.keys(), d.values(), d.items())

10. How do you merge two lists into a dictionary?


Programming Questions:

1. Write a Python program to reverse a string without using loops.

2. Write a program to count the frequency of words in a given string.

3. Write a Python function to find the maximum element in a list.

4. Write a program to remove all occurrences of a given element from a list.

5. Write a Python program to merge two dictionaries.

6. Write a Python program to find the second-largest number in a list.

Unit 4: File Handling & Exception Handling

Short Answer Questions:

1. What are different file modes in Python?

2. How do you read and write to a file in Python?

3. Explain with open() and its advantages.

4. What is the difference between read(), readline(), and readlines()?

5. What is the purpose of the seek() and tell() functions?

6. How do you handle exceptions in Python?

7. What is the role of try-except-finally in exception handling?

8. Explain ZeroDivisionError with an example.

9. Write the output of the following code:

try:

x=5/0

except ZeroDivisionError:

print("Cannot divide by zero")

10. What is the difference between syntax errors and runtime errors?

Programming Questions:

1. Write a Python program to read a file and print its contents.

2. Write a Python program to count the number of words in a text file.

3. Write a program that reads a file and prints only the even-numbered lines.

4. Write a Python program to handle division by zero using exception handling.

5. Write a program to append text to an existing file.

6. Write a Python program to copy the contents of one file to another.


Bonus: Debugging & Output-Based Questions

1. Find and fix the error in the following code:

for i in range(5)

print(i)

2. What will be the output of the following code?

x = "Python"

print(x[::-1])

3. Predict the output:

def test():

return "Hello", "World"

print(test())

4. Identify the error in the following code and fix it:

numbers = [1, 2, 3, 4, 5]

print(numbers[5])

Final Exam Tips:

✅ Revise Python basics, loops, functions, file handling, and exception handling.
✅ Practice writing code instead of just reading theory.
✅ Solve previous year questions and predict output-based questions.
✅ Use online platforms like W3Schools, GeeksforGeeks, and HackerRank for extra practice.

You might also like