Looping Statement Test 6

 

Looping Statement Test 6

Q1. Write a program to print the following pattern

5 5 5 5 5

4 4 4 4

3 3 3

2 2

1

Q2. Find errors in the following code:

a = int(“Enter any number”)

for i in Range[2,6]

    if a=i

      print(“A”)

    else

      print(“B”)

Q3. Write a program to accept decimal number

    and display its binary number.

Q4. Accept a number and check whether it is

    palindrome or not.

Q5. Write a program to accept a number and check whether it is a perfect number or not.

(Perfect number is a positive integer which is equal to the sum of its divisors like divisors of 6 are 1,2,3, and sum of divisors is also 6, so 6 is the perfect number)

Q6. Write a program to find the sum of the following series(accept values of x and n from user)

1 + x/1! + x2/2! + ……….xn/n!

Q7. Write a program to print the following pattern

A

B C

D E F

G H I J

K L M N O

Q8. Write a program to find the sum of following (Accept values of a, r, n from user)

a + ar + ar2 + ar3 + ………..arn

Q9. for x in range(10,20):

      if (x%2==0):

           continue

       print(x)

Q10. Write a function to display prime numbers below 25.

No comments:

Post a Comment

Most Recently Published

File Handling Test 6

 File Handling Test 6 Q1 . Do we need to use the close() function when we use 'with' statement to open a file? Q2. Which mode you wi...

CS - IP Assignment/Worksheet