Python Practice Questions PDF
Document Details

Uploaded by ImaginativeCourage3340
Tags
Summary
This PDF document contains a series of practice questions designed to test and enhance your Python programming skills. The topics cover fundamental concepts from variables and loops to functions and more complex algorithms and code. The questions are suitable for students and anyone looking to improve their Python proficiency.
Full Transcript
1. ‘What are the key components of a python program structure? 2. XYZ storw plans to give festival discount to its customers.The store management has decided to give discount on the following criteria: Shopping Amount Discount offered >=500 and =1000 and =2...
1. ‘What are the key components of a python program structure? 2. XYZ storw plans to give festival discount to its customers.The store management has decided to give discount on the following criteria: Shopping Amount Discount offered >=500 and =1000 and =2000 15% An additional discount 5% is given to customers who are the members of the store. Create using user Defined function that accepts the shopping amount as a parameter and calculates discount and net amount payable on the basis of the following conditions: Net payable amount=total shopping amount – discount 3. Explain the difference between an interpreted language and compiled language. 4. Write Python code to perform the following calculations. Add 50 and 25. Find the square root of 64. Calculate the result. Explain how Python can be used as a calculator interactively. 5. Why is indentation important in Python? What error does Python throw if indentation is not followed correctly. 6. Write a program to display the sum of all even numbers and odd numbers within a starting limit ‘l’ and an ending limit ‘u’. 7. What are arithmetic operators in Python? List them with examples. 8. What is the ternary operator in Python? Provide its syntax. Write Python code to find the maximum of two numbers using a ternary operator. 9. What is recursion ?write a program that determines whether a given number is prime or not using recursion. 10. Does Python have increment (++) or decrement (--) operators? Why or why not? 11. Write a Python program to print the first 10 natural numbers using a while loop. 12. What is the difference between if and elif ? Write a Python program to find the largest of three numbers using if-elif-else. 13. What are string? Explain all the ways using which String can be declared in python? state two uses of string slicing. 14. What is the purpose of the exit() function in Python? How does it differ from break? 15. Write a Python program that catches a ZeroDivisionError when dividing two numbers. 16. Explain the difference between keywords and identifiers ?why are keywords reserved give five example of python keywords and their usage? 17. What are functions with respect to programming ? How are functionS defined in python? Explain with the syntax. 18. What is a list in Python? How is it different from strings? Write a Python program to access and modify elements in a list. 19. What are the difference between break and continue statement.illustrate with an example. 20. Generate the given Fibonacci sequence in python. 0 1 1 2 3 5 8………up to n terms.