Python Assignment
Python Assignment
Q1. What is Python? List at least three major uses of Python. Who created
Python, and when was it first released? What are some key differences between
Python 2.x and Python 3.x?
Q2. What is a module in Python? Provide an example of how to import and use
a module. Explain the difference between a module and a package in Python.
Q3. Write a Python expression using a logical operator to check if a number is
both greater than 10 and less than 20.
Q4. What is the difference between mutable and immutable types in Python?
Provide examples of each. Convert the string "1234" to an integer and a float.
Q5. What is the difference between a while loop and a for loop? Provide an
example of each. Write a Python program to check whether a no. is prime or
not.
Q6. What is the effect of using break, continue, pass, and else in loops?
Demonstrate each with examples.
Q7. Write a Python program to:
A)
Create a list of 5 different integers.
Append a new element to the list.
Remove the second element from the list.
Sort the list in ascending order.
Print the final list.
B) Given a list number = [10, 20, 30, 40, 50], write a Python program to
calculate the sum of all elements.
Q8. Given a tuple t = (5, 10, 15, 20, 25), write a program to find the index of the
element 15.
Q9. Given a dictionary student = {"name": "Alice", "age": 20, "marks": 85},
write a program to check if a key ("age") exists in the dictionary.
Q10. What is recursion? Write a recursive function to find the Fibonacci series
up to n terms.
Q11. Write a Python program to:
Take a string input from the user.
Convert the string to uppercase and lowercase.
Reverse the string.