Python For loop exercises
#Ex: write a program to display the first 10 numbers
#Ex: write a program to display the numbers from 5 to 20 using the start parameter 5 in range():
#Ex: write a program to display the numbers from 5 to 20 using the start parameter 1, increment the sequence with 5:
#Ex: write a program to display numbers from 10 to 1 reverse order.
#Ex: write a program to display the first 10 numbers, add the $ end of line
# Print all numbers from 0 to 5, and print a message when the loop has ended:
#Ex: write a program to display Even numbers from 0-20
#Ex: write a program to display odd numbers from 0-20
#Ex: write a program to display both even and odd numbers from 0-20
#write a program to find the leap years between 2000 and 2100 years using the range()
#Ex: write a program to display the numbers divisible by 3, 5 and both 3 and 5 using if condition in loop
#Ex: write a program to read the number from user and display the first 'N' numbers
#Ex: write a program to read the number from user and list the factors of the number#Ex: write a program to read the number from user and list the perfect square or not#Ex: write a program to display number pyramid like
#Ex: Python program to add 50 for each number in the list
#Ex: Python program to print a multiplication table of a given number
# Write the flow chart using counter loop
# Multiplication Table generally have 10 entries so taking range 11
# write a program to write the 2 multiplication table using the range()
# write a program to write the 5 multiplication table using the range()
# write a program to write the 2, 3 and 4 multiplication tables at a time range() and nested for loops
#Ex: write a program to sum of all numbers from 1 to a given number
# iterate through the given string and append each element of the given string to the reverse_string variable
# if given_string matches the reverse_srting exactly the given string is a palindrome else the given string is not a palindrome
# print the reverse_string variable
# initialize a sum variable with 0 value to store the sum of the product of each digit
# iterate through the given string
# if the sum matches the given string its an Armstrong number
# if the below list is given
# given list of numbers
# iterate through the list elements
# using for loop
# if divided by 2, all even number leave a remainder of 0
# if remainder is not zero then it's an odd number
# Prime numbers
# import the math library
# function to print all
# non-primes in a range
# flag to track
# if no. is prime or not
# initially assume all numbers are
# non prime
# iterate in the given range
# using for loop starting from 2
# as 0 & 1 are neither prime
# nor composite
# condition to check if a
# number is prime or not
# lower bound of the range
# upper bound of the range
# given upper bound
# initial values in the series
# iterate in the given range
# of numbers
# if no. is less than 1
# move to next number
# if number is within range
# execute the below code block
# print each element that
# satisfies all the above conditions
# given number
# since 1 is a factor
# of all number
# set the factorial to 1
# iterate till the given number
# take string input from user
# declare 2 variable to store
# letters and digits
# iterate through the input string
# check if the character
# is a digit using
# the isdigit() method
# if true, increment the value
# of digits variable by 1
# check if the character
# is an alphabet using
# the isalpha() method
# if true, increment the value
# of letters variable by 1
# given range
# iterate using a for loop till the
# given range
# if no. is multiple of 4 and 5
# print fizzbuzz
# continue with the loop
# if no. is divisible by 4
# print fizz and no by 5
# continue with the loop
# if no. is divisible by 5
# print buzz and not by 4
# else just print the no.
# input password from user
# set up flags for each criteria
# of a valid password
# first verify if the length of password is
# higher or equal to 8 and lower or equal to 16
# iterate through each characters of the password
# check if there are lowercase alphabets
# check if there are uppercase alphabets
# check if the password has digits
# check if the password has special characters
if(i=="@" or i=="$" or i=="_"or i=="#" or i=="^" or i=="&" or i=="*"):
# given list of month name
# iterate through each mont in the list
Comments
Post a Comment