Loops Assignments
1.Try to Write your name 10 times with the help of while loop.
2.Print a simple multiplication table of number given by user input.
Enter the number : 10
10
20
30
40
50
60
70
80
90
100
3. Do you know Factorial ? It is the product of an integer and all the integers below it; e.g. factorial four ( 4! ) is equal to 24. Take a number from user and calculate factorial of a number.
Enter the number : 4
Factorial : 24
4.Take 10 values from user and find out the sum and multiplication and average of the numbers.
Find all even numbers between 1 to 2000.
6.Find all prime numbers between 1 to 2000.
7.Take a number from user and return sum of all digits of the number.
Enter The Number : 484
Sum of the digits : 16
8.Take integer inputs from user until he/she presses q ( Ask to press q to quit after every integer input ). Print average and product of all numbers.
Enter the number : 5
do you want to quit ? no
Enter the number : 10
do you want to quit ? no
Enter the number : 25
do you want to quit ? yes
Sum is 40
Product is 1250
Write a Python program that asks the user to enter a sentence and then prints the number of vowels in the sentence.
A simple iteration through a string to access all elements of it.
Write a program that prints the Fibonacci sequence up to a given number using a while loop. Example : Enter a number : 5 0 1 1 2 3 5 Enter a number : 10 0 1 1 2 3 5 8
Write a python program to check whether a number given by user is a special number or not. A special number is the number if the sum of the factorial of its digit is same as the original number. Example : 145
Write a program to print the even and odd numbers in the range from 1 to n where n is given by the user and also print the sum of all even numbers and odd numbers separately.(use while loop)
Create a simple calculator using loops (The program should be menu driven which runs till user exits itself. Means the program must ask the user every time to whether he want to continue or exit). Print Appropriate Message for this.(use while() loop)
Write a program to check whether the number is
automorphic number
or not.(A number is said to be automorphic number if the original number is present on the right of the square of that number.)
For example :
1. 5 is an automorphic number as its square is 25 and 5 is at its right side.
2. Similarly 25 - square 625 and 25 is at its right side.
Write a program to reverse a number taken by the user without using strings.
Write a program to count the number of alphabets and no of digits in a string using loops.
Write a program to check whether the number given by the user is an Armstrong number or not.(An Armstrong number is the number whose digits cubes sum is equal to the original number. Such as 153 as 1^3 + 5^3+3^3 = 1 + 125 + 27 = 153)
Write a program to check whether the given string is palindrome or not. Example : MADAM, MOM
Write a program to check whether the given number is palindrome or not. Example : 343, 121, 111, etc.
Create Rock, Paper, Scissor game using while loop (Hint- use random module and random.choice(['rock', 'paper', 'scissor']) function to get random value selected by computer) Your Program will contain one you and second the computer who will be generating the values from its side using random module. User will provide the choice of Rock, paper or scissor. Print Appropriate Messages and final score of both the computer and user.
Write a Python program that iterates the integers from 1 to 50. For multiples of three print "Fizz" instead of the number and for multiples of five print "Buzz". For numbers that are multiples of three and five, print "FizzBuzz". Sample Output : 1 2 fizz 4 buzz
Take a string input from user and count the number of vowels and consonants using while loop and for loop both.
Write a program to reverse the String using while loop.
Write a Python program to check the validity of passwords input by users. Validation :
At least 1 letter between [a-z] and 1 letter between [A-Z].
At least 1 number between [0-9].
At least 1 character from [$#@].
Minimum length 6 characters.
Maximum length 16 characters.
Last updated