0% found this document useful (0 votes)
13 views3 pages

Practice Programs (Unit-2)

The document contains Python programs to check if numbers are even, odd, prime, palindromes, Armstrong or Fibonacci. It also includes programs to calculate factorials, sums of squares and cubes, and print patterns of stars.

Uploaded by

guptakrishns23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Practice Programs (Unit-2)

The document contains Python programs to check if numbers are even, odd, prime, palindromes, Armstrong or Fibonacci. It also includes programs to calculate factorials, sums of squares and cubes, and print patterns of stars.

Uploaded by

guptakrishns23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

UNIT-2

1. Python Program to take three numbers from the user and print the
greatest number.

2. Write a program to print whether given number is even or odd.

3. Write a program to print any person is eligible for vote or not (age

should not less then 18 for voting).

4. Write a Program to check Armstrong Number.

A positive integer of n digits is called an Armstrong number


of order n (order is number of digits) if.
abcd... = pow(a,n) + pow(b,n) + pow(c,n) + pow(d,n) + ....
\ Input: 153
Output: Yes
153 is an Armstrong number.
1*1*1 + 5*5*5 + 3*3*3 = 153

5. Write a program to check whether a number entered by user is Prime


or not.

6. Write a program to calculate factorial of a number entered by user.

7. Python Program to check whether a given number is a palindrome.

8. Write a program to print all Prime numbers between given range.

9. Write a program to print n-th Fibonacci number.


10. Write a program to check if a given number is Fibonacci number?

11. Write a program for Sum of squares of first n natural numbers.

Ex: if Input: N = 4
Then Output: 30
12 + 22 + 32 + 42 = 1 + 4 + 9 + 16 = 30

12. Write a program for cube sum of first n natural numbers.

13. WAP to print given pattern

14. WAP to print given pattern


15. Write a program to take an integer N as an input and display the
pattern.

Input
5
Output
*
**
***
****
*****
****
***
**
*

You might also like