Python Progrms Sample
Python Progrms Sample
Code a Python program to accept a number, find the sum of the digits of the number
and print the result.
2. Code a python program to accept two numbers m and n where m>n, find the
quotient, remainder and print the result.
3. Code a python program to accept two numbers m and n where m>n, find the
quotient, remainder and print the result.
4. Code a python program to find the factorial of a given number.
5. Code a python program to accept a string, count the number of vowels in the string
and print the result.
6. Code a python program to find the sum of the first ‘n’ even numbers and print the
result.
7. Code a python program to find the sum of the first ‘n’ prime numbers and print the
result.
8. Code a python program to find the sum of the first ‘n’ odd numbers and print the
result.
9. Code a python program to accept a string, reverse the string and print the result.
10. Code a python program to Generate Numbers Divisible By 2 Not By 3 & 5
11. Code a python program Add All The Number Entered By A User Until User
Enters 0.
12. Problem Statement
Emma wants to print a square pattern of stars using nested loops. She plans to use a pass
statement inside the loops for practice.
Input Format
The input consists of an integer n, representing the side length of the square.
Output Format
The output consists of n lines, each line containing n stars (*).
Sample Input
5
Sample Output
*****
*****
*****
*****
*****
You are working as a software developer at a math education company, and your team is
working on a program to help students understand odd and even numbers better. Your task
is to create a program that demonstrates the concept of using the continue statement to skip
even numbers while printing a list of odd numbers.
Input Format
The input consists of an integer n, representing the upper limit of the range.
Output Format
The output displays a list of odd numbers from 1 to 'n' separated by lines.
Constraints
1 ≤ n ≤ 100
Sample Input
10
Sample Output
Fazil needs a triangle classification program. Given the lengths of the sides of a triangle (side1, side2,
and side3), the program determines whether the triangle is classified as Equilateral, Isosceles, or
Scalene based on the following conditions:
Input Format
The first line of input consists of a float value A, representing the length of the first side of the
triangle.
The second line of input consists of a float value B, representing the length of the second side of the
triangle.
The third line of input consists of a float value C, representing the length of the third side of the
triangle.
Output Format
The output displays "The triangle is classified as X" where X is the string representing the
classification of the triangle as "Equilateral", "Isosceles", or "Scalene".
Constraints
In this scenario, the given test cases will fall under the following constraints:
1.0 ≤ A, B, C ≤ 360.0
Sample Input
90.0
90.0
90.0
Sample Output
Sample Input
4.5
4.5
6.8
Sample Output
Sample Input
12.3
15.7
17.8
Sample Output
Nandhini is working on a project that involves converting the full names of months into their
respective abbreviations.
To simplify her task, she wants to write a program that can perform this conversion for her. She
reached out to you for help in developing this program.
Write a program that takes a string as input and prints its corresponding abbreviation.
January - Jan
February - Feb
March - Mar
April - Apr
May - May
June - Jun
July - Jul
August - Aug
September - Sep
October - Oct
November - Nov
December - Dec
Input Format
Output Format
The output displays "The abbreviation for X is T." where X is the month name and T is the month
abbreviation.
Constraints
The input month name will be one of the following: "January", "February", "March", "April", "May",
"June", "July", "August", "September", "October", "November", or "December".
Sample Input
January
Sample Output
Gokul is practicing multiplication tables. Write a program that takes an integer 'number' as input and
prints its multiplication table up to 10 using while loop, displaying each multiplication along with the
result.
Input Format
The input consists of an integer n representing the base of the multiplication table.
Output Format
The output displays ten lines, each displaying a multiplication statement: "number x multiplier =
product".
Constraints
1 ≤ n ≤ 100
Sample Input
5
Sample Output
5x1=5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50
Mandy is experimenting with bitwise operations and is working on a project that involves
determining certain properties of numbers. She needs to write a program that takes an integer as
input and uses bitwise operations to determine if the integer is a power of two.
Help Mandy in her project to understand and visualise how bitwise operations can be used to
determine if a number is a power of two.
Input Format
Output Format
The output displays "Power of Two" if the number is a power of two, or "Not a Power of Two"
otherwise.
Constraints
1 ≤ N ≤ 107
Sample Input
Sample Output
Power of Two