18.Programming Assignment 4( using loops)

Try the Following Programs using loops
1)Print the even numbers between 0 and 50 (use while)
2)Print the odd numbers between 0 and 50 in the reverse order ( use while)
3)Print the series 5,10,15,….,100 (using for loop)
4)Generate the series 1 2 4 7 11 16....n ( use while...read n)
5)Generate the Fibonacci series 0 1 1 2 3 5 8…..n ( use while..read n)
6)Find the factorial of a number ( use for statement do not use built in factorial() function)
7)Print the powers of a number upto 10th power. ( Eg: if n=2 then the program should print 2**0, 2**1, 2**2,2**3,…..,2**10 use for loop)
8)Print the multiplication table of a given number. ( use while)
9)Print the numbers from 1 to 10 and their natural logarithms as a table ( use for)
10)Find the sum of the digits of a number.( use while-university question)
11)Check whether the given 3 digit number is an Armstrong number. (use while Eg:153,370,371,407)
12)Find the factors of a number ( use for)
13)Check whether the given number is prime or not ( use for)
14) Find the GCD or HCF of two numbers ( use Euclid algorithm and while loop)
15) Reverse a number (use while)
16)Find the numbers between 10 and 1000 that are divisible by 13 but not divisible by 3( use for)
17)Find the sum of series 1-x^2/2+x^4/4-x^6/6........x^n/n ( use while)
18)Check whether the given number is a Krishnamurti number( Krishnamurthy Number: It is a number which is equal to the sum of the factorials of all its digits.Use factorial() function from math 
For example : 145 = 1! + 4! + 5! = 1 + 24 + 120 = 145)
19)Read N numbers and find the biggest and smallest. ( university question)
20)Read N numbers and find the sum of all odd and even numbers separately.(university question)
21)Count the number of digits in a number.(university question)
22)Write a Python program to input a list of n numbers. Calculate and display the sum of cubes of each value in the list.(university question)
23)Write a python program to count the number of zeros and negative terms in a given set of n numbers.
24)Write a python program to input a list of n numbers. calculate and display the average of numbers. Also display the cube of each value in the list.( university question)
25)read mark of n students and print the average mark.Also print the number of students who scored more than 80% mark (mark out of 50)
26)Write a program that computes an investment report.
The inputs to this program are the following:
 An initial amount to be invested (a floating-point number)
A period of years (an integer)
An interest rate (a percentage expressed as an integer)
Enter the investment amount: 10000.00
Enter the number of years: 5
Enter the rate as a %: 5
Year Starting balance Interest Ending balance
1         10000.00         500.00     10500.00
2         10500.00         525.00     11025.00
3         11025.00         551.25     11576.25
4         11576.25         578.81     12155.06
5         12155.06         607.75     12762.82
Ending balance: $12762.82
Total interest earned: $2762.82
Programs to try using Nested loops
Generate the following pattern
1)
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
2)
* * * * *
* * * *
* * *
* *
*
3)
1
2 3
4 5 6
7 8 9 10
4)
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
5)Print the multiplication table of numbers from 5-15.
6)Print all prime numbers in a given range.
7)Print all 3 digit Armstrong numbers in a range.
8)Print all the factors of numbers between 10 and 20.
9)Print all Armstrong numbers in the given range.
10)Print all Krishnamurti numbers in the given range.
11)Print the sum of digits of all numbers between 100 and 200.

Comments

Popular posts from this blog

Python For Machine Learning - CST 283 - KTU Minor Notes- Dr Binu V P

46.Classes and Objects in Python- Accessors and mutators

KTU Python for machine learning Sample Question Paper and Answer Key Dec 2020