Docsity

Python Programming Problem Sheet – II | Conditional Statements, Loops & Data Structures, Exercises of Computer Programming

Toggle sidebar
bg1
Python Programming
Problem Sheet – II
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. Electricity Bill Calculator
An electricity board charges consumers according to the following tariff.
Units Consumed
Charge per Unit
First 100 units
₹2
Next 100 units
₹3
Above 200 units
₹5
Write a program to accept the number of units consumed and calculate the total electricity bill.
Sample Input
250
2. Student Grade Calculator
Write a program to accept the marks obtained by a student and display the corresponding grade
based on the following criteria.
Marks
Grade
90–100
A
80–89
B
70–79
C
60–69
D
Below 60
F
Sample Input
86
pf3
pf4
pf5

Partial preview of the text

Download Python Programming Problem Sheet – II | Conditional Statements, Loops & Data Structures and more Exercises Computer Programming in PDF only on Docsity!

Python Programming

Problem Sheet – II

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. Electricity Bill Calculator An electricity board charges consumers according to the following tariff.

Units Consumed Charge per Unit

First 100 units ₹

Next 100 units ₹

Above 200 units ₹

Write a program to accept the number of units consumed and calculate the total electricity bill. Sample Input 250

2. Student Grade Calculator Write a program to accept the marks obtained by a student and display the corresponding grade based on the following criteria.

Marks Grade

90–100 A

80–89 B

70–79 C

60–69 D

Below 60 F

Sample Input 86

3. ATM Withdrawal System An account has an available balance of ₹20,. Write a program to accept the withdrawal amount from the user and perform the following tasks: ● If sufficient balance is available, display the withdrawal amount and the remaining balance. ● Otherwise, display "Insufficient Balance." Sample Input 3500 4. Museum Ticket Counter The ticket price depends on the visitor's age.

Age Ticket Price

Below 5 years Free

5–17 years ₹

18–59 years ₹

60 years and above ₹

Write a program to determine the ticket price for a visitor. Sample Input 65

5. Login Authentication The valid login credentials are: ● Username: admin ● Password: python Write a program to accept the username and password from the user and validate the login credentials. Display an appropriate message for successful and unsuccessful login attempts. 6. Shopping Discount Calculator A shopping mall offers a 10% discount for purchases above ₹. Write a program to calculate the discount amount and the final bill payable by the customer. Sample Input 6500 7. Second Largest Number Write a program to accept three distinct integers and determine the second largest number among them.

13. Multiplication Table Write a program to accept a number and display its multiplication table up to 15. 14. Sum of Natural Numbers Write a program to accept a positive integer N and calculate the sum of the first N natural numbers. 15. Even Numbers Within a Range Write a program to accept two integers and display all the even numbers between them. Sample Input 10 30 16. Odd Numbers Within a Range Write a program to display all the odd numbers between 50 and 100. 17. Factorial of a Number Write a program to accept a positive integer and calculate its factorial. Sample Input 6 18. Prime Number Checker Write a program to determine whether a given integer is a prime number. Sample Input 29 19. Palindrome Number Write a program to determine whether a given integer is a palindrome. Sample Input 1221 20. Armstrong Number Write a program to determine whether a given three-digit integer is an Armstrong number. Sample Input 153 21. Number Guessing Game The computer stores the number 25. Write a program that repeatedly accepts the user's guess until the correct number is entered. Display the total number of attempts taken to guess the correct number.

22. Demonstration of break Statement Write a program to display numbers from 1 to 20 and terminate the loop immediately when the value becomes 12 using the break statement. 23. Demonstration of continue Statement Write a program to display numbers from 1 to 20 while skipping all multiples of 4 using the continue statement. 24. List Statistics Write a program to create a list containing 10 integer values and display the following: ● Original List ● Largest Value ● Smallest Value ● Sum of Elements ● Average of the Elements 25. Student Marks Analysis Write a program to create a list containing the marks of five students and display: ● Highest Mark ● Lowest Mark ● Average Mark ● Number of students who scored **75 marks or above

  1. Dictionary Operations** Write a program to create a dictionary containing the following employee details: ● Employee ID ● Employee Name ● Department ● Salary Display all the details in a neatly formatted manner. 27. Dictionary Search Create a dictionary containing the names of five students and their corresponding marks. Write a program to accept a student's name from the user and display the corresponding mark. If the student's name is not found, display an appropriate message. 28. Tuple Operations Write a program to create a tuple containing five city names and display the following: ● Complete Tuple ● First City ● Last City