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

Python programming Practice

The document outlines a series of Python programming exercises focused on various mathematical and logical problems. Tasks include calculating electricity bills, determining grades based on marks, identifying triangle types, and checking properties of numbers such as prime, palindrome, and perfect numbers. Each exercise is designed to enhance programming skills through practical applications.

Uploaded by

Ajay Agarwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python programming Practice

The document outlines a series of Python programming exercises focused on various mathematical and logical problems. Tasks include calculating electricity bills, determining grades based on marks, identifying triangle types, and checking properties of numbers such as prime, palindrome, and perfect numbers. Each exercise is designed to enhance programming skills through practical applications.

Uploaded by

Ajay Agarwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Python Programming Practice

1. Write a Python program to input electricity unit charges and calculate

and print total electricity bill according to the given condition:

Up to 50 units Rs. 1.50/unit

Up to 100 units Rs. 2.75/unit

Up to 200 units Rs. 4.20/unit

above 200 units Rs. 5.50/unit

An additional surcharge of 20% is added to the bill

2. Write a Python program to input marks of five subjects Physics,

Chemistry, Biology, Mathematics and Computer. Calculate percentage

and display grade according to following criteria:

Percentage >= 90% : Grade A

Percentage >= 80% : Grade B

Percentage >= 70% : Grade C

Percentage >= 60% : Grade D

Percentage >= 40% : Grade E

Percentage < 40% : Grade F

3. Write a Python program to input week number(1-7) and print the

corresponding day of week name using if elif.

[1- Sunday, 2- Monday.........]

4. Write a Python program to input any alphabet and check whether it is a

vowel or a consonant.

5. Write a Python program to input month number and print number of

days in that month for the year 2025.


1. Write a program to program to accept three angles of triangle and display whether it is valid or invalid triangle
2. Write a program to accept year and display whether it is leap year or not
3. Write a program to program to accept three sides of triangle and display it's type based on the sides
[all sides are equal= equilateral
two sides are equa and three sides are different]
4. Write a program to accept colour of traffic signal and display appropriate message [green=> Go, Red=> Stop,
Yellow=> Get Ready any other colour=> invalid colour]

5. Write a program to accept a two digit number check whether sum of digits of a number is even or odd.

6. Write a program to accept a two digit number check whether it is a Special two digit number or not.

A special two-digit number is a number such that when the sum of the digits of the number is added to the
product of its digits, the result is equal to the original two-digit number.

Examples :

input : 59.
output : 59 is a Special Two-Digit Number
Explanation:
Sum of digits = 5 + 9 = 14
Product of its digits = 5 x 9 = 45
Sum of the sum of digits
and product of digits = 14 + 45 = 59
1. Write a program to input a number. find and display its factorial
Factorial is the product of all positive integers less than or equal to n.
Examples: 4! = 4 × 3 × 2 × 1 = 24

2. Write a program to input a number. Check and display whether it is a Niven number or not. (A number is said
to be Niven which is divisible by the sum of its digits).

Example: Sample Input 126


Sum of its digits = 1 + 2 + 6 = 9 and 126 is divisible by 9.

3. Write a program to accept a number and check whether it is a 'Spy Number' or not. (A number is spy if the sum
of its digits equals the product of its digits.)

Example: Sample Input: 1124


Sum of the digits = 1 + 1 + 2 + 4 = 8
Product of the digits = 1*1*2*4 = 8

4. Write a program to accept a number from the user and check whether it is a Palindrome number or not. A
number is a Palindrome which when reads in reverse order is same as in the right order.

Sample Input: 242


Sample Output: A Palindrome number

Sample Input: 467


Sample Output: Not a Palindrome number

5. Write a program in PYTHON to accept a number. Check and print whether it is a prime number or not.

A prime number is a number which is divisible by 1 and itself only. For example 2, 3, 5, 7, 11, 13 are all prime
numbers.

6. Write a program in PYTHON to accept a number. Check and print whether it is a neon number or not.

A neon number is a number where the sum of digits of square of the number is equal to the number. For
example if the input number is 9, its square is 9*9 = 81 and sum of the digits is 9. i.e. 9 is a neon number.

7. Write a program in Python to accept a number. Check and print whether it is a perfect number or not.
A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself.
For instance, 6 has divisors 1, 2 and 3, and 1 + 2 + 3 = 6, so 6 is a perfect number.

8. Write a program to determine whether a given number is a Harshad number

Explanation

A number is said to be the Harshad number if it is divisible by the sum of its digit.

For example, if number is 156, then sum of its digit will be 1 + 5 + 6 = 12. Since 156 is divisible by 12. So, 156 is a
Harshad number.

. Write a program to input a number and check and print whether it is a Pronic number or not. [Pronic number is
the number which is the product of two consecutive integers.]
Examples:
12 = 3 * 4
20 = 4 * 5
42 = 6 * 7

10. Write a program to input a number and check and print whether it is an automorphic numbe number or not.

An automorphic number is a number whose square ends in the same digits as the number itself. For example, 25
is an automorphic number because (25^2 = 625), and the last two digits of 625 are 25. Similarly, 76 is an
automorphic number because (76^2 = 5776), and the last two digits of 5776 are 76

11. Write a program to input a number and check and print whether it is an abundant number numbe number or
not

An abundant number, also known as an excessive number, is a positive integer for which the sum of its proper
divisors (excluding the number itself) is greater than the number itself.

Examples:

The number 12 is abundant because its proper divisors excluding itself(1, 2, 3, 4, and 6) add up to 16, which is
greater than 12.

The number 8, on the other hand, is not abundant, because its proper divisors (1, 2, and 4) add up to 7, which is
less than 8.

You might also like