Docsity

Python Programming Problem & Practice Questions, Exercises of Computer Programming

Toggle sidebar
bg1
Python Programming
Problem Sheet โ€“ I
Instructions
1. Write Python programs for all the following questions.
2. Use meaningful variable names and appropriate data types.
3. Follow proper indentation and coding standards.
4. Display the output in a clear and user-friendly format.
5. Include suitable comments wherever necessary.
6. Obtain all required input values from the user unless otherwise specified.
1. Personal Information
Write a program to display your Name, Register Number, Department, University, and Email
ID on separate lines using appropriate output statements.
2. Basic Arithmetic Calculator
Write a program that accepts two integer values from the user and displays their Sum,
Difference, Product, Quotient, Floor Division, and Remainder.
Sample Input
Enter first number : 25
Enter second number : 8
3. Simple Interest Calculator
Write a program to calculate the Simple Interest and Total Amount by accepting the Principal
Amount, Rate of Interest, and Time Period from the user.
Sample Input
Principal : 10000
Rate : 8
Time : 2
4. Circle Measurements
Write a program to calculate the Area and Circumference of a circle by accepting its radius.
Assume ฯ€ = 3.14.
Sample Input
Radius : 7
5. Temperature Converter
Write a program to convert a temperature given in Celsius into Fahrenheit and Kelvin.
Sample Input
37
pf3
pf4
pf5

Partial preview of the text

Download Python Programming Problem & Practice Questions and more Exercises Computer Programming in PDF only on Docsity!

Python Programming

Problem Sheet โ€“ I

Instructions

  1. Write Python programs for all the following questions.
  2. Use meaningful variable names and appropriate data types.
  3. Follow proper indentation and coding standards.
  4. Display the output in a clear and user-friendly format.
  5. Include suitable comments wherever necessary.
  6. Obtain all required input values from the user unless otherwise specified. 1. Personal Information Write a program to display your Name, Register Number, Department, University, and Email ID on separate lines using appropriate output statements. 2. Basic Arithmetic Calculator Write a program that accepts two integer values from the user and displays their Sum, Difference, Product, Quotient, Floor Division, and Remainder. Sample Input Enter first number : 25 Enter second number : 8 3. Simple Interest Calculator Write a program to calculate the Simple Interest and Total Amount by accepting the Principal Amount, Rate of Interest, and Time Period from the user. Sample Input Principal : 10000 Rate : 8 Time : 2 4. Circle Measurements Write a program to calculate the Area and Circumference of a circle by accepting its radius. Assume ฯ€ = 3.14. Sample Input Radius : 7 5. Temperature Converter Write a program to convert a temperature given in Celsius into Fahrenheit and Kelvin. Sample Input 37

6. Swapping Two Numbers Write a program to interchange the values of two numbers: โ— Using a temporary variable. โ— Without using a temporary variable. Display the values before and after swapping. Sample Input 45 60 7. Compare Two Numbers Write a program to accept two numbers and determine whether the first number is greater , second number is greater , or both numbers are equal. Sample Input 78 56 8. Number Classification Write a program to determine whether a given integer is Positive , Negative , or Zero. Sample Input

9. Even or Odd Write a program to determine whether a given integer is Even or Odd. If the number is even, also determine whether it is divisible by 4. Sample Input 48 10. Divisibility Checker Write a program to determine whether a given number is: โ— Divisible by both 3 and 5 โ— Divisible only by 3 โ— Divisible only by 5 โ— Not divisible by either Sample Input 60 11. Mathematical Operations Write a program to accept a number and display its: โ— Square โ— Cube โ— Square Root

18. Even Numbers Between 1 and 50 Write a program to display all even numbers between 1 and 50 and count the total number of even values. 19. Odd Numbers Between 1 and 50 Write a program to display all odd numbers between 1 and 50 and calculate their sum. 20. Sum of Natural Numbers Write a program to accept a positive integer N and calculate the sum of the first N natural numbers. Sample Input 10 21. Countdown Using While Loop Write a program to display the numbers from 20 down to 1 using a while loop. 22. Number Pattern Write a program to display the following pattern. 1 12 123 1234 12345 23. Demonstration of break Statement Write a program to display numbers from 1 to 10 and terminate the loop when the value becomes 6 using the break statement. 24. Demonstration of continue Statement Write a program to display numbers from 1 to 10 while skipping the number 5 using the continue statement. 25. Membership Operator Create a list containing the following values: [12, 25, 18, 45, 60] Write a program to determine whether 25 , 60 , and 100 are present in the list using membership operators. 26. Identity Operator Write a program to create two variables with the same value and compare them using the is and is not operators. Display the results.

27. List Operations Write a program to create a list containing five numbers and display: โ— Original List โ— Largest Number โ— Smallest Number โ— Sum of Elements โ— Average โ— Sorted List 28. Tuple Operations

Write a program to create a tuple containing five city names and display: โ— Complete Tuple โ— First Element โ— Last Element โ— Number of Elements โ— Whether a specified city is present in the tuple

29. Dictionary Operations Write a program to create a dictionary containing the following employee details: โ— Employee ID โ— Name โ— Department โ— Salary โ— Experience

Display all the details and retrieve the salary using its key.

30. Set Operations Write a program to create a set containing five numbers and perform the following operations: โ— Display the original set. โ— Add a new element. โ— Remove an existing element. โ— Create another set containing {20, 30, 40}. โ— Display the union of both sets. โ— Display the updated set.