Get the Fibonacci series between 0 to 10

In this program, we will get the Fibonacci series between 0 to 10.

Steps to solve the program
  1. Create two variables num1, and num2 and assign their values equal to 0 and 1.
  2. Create a count variable and assign its values equal to 0.
  3. While the count variable is less than 10 print num1.
  4. Add num1 and num2 and store the result in a new variable n2.
  5. Change num1 to num2 and num2 to n2 and add 1 to the count variable.
  6. Print the output.
				
					count = 0
num1,num2 = 0,1
print("Sequence is: ",end=" ")

while count < 11:
    print(num1,end=" ")
    n2 = num1 + num2
    num1 = num2
    num2 = n2
    count += 1
				
			

Output :

				
					Sequence is:  0 1 1 2 3 5 8 13 21 34 55 
				
			

construct the following pattern

check the validity of password

Program to Construct the pattern using for loop

In this program, we will construct the pattern using a nested for loop.

Steps to solve the program
  1. Use for loop with range function to iterate over numbers from 1-5.
  2. Initiate another for loop inside the above for loop to print the number initiated by 1st for lopp times the given in the pattern.
  3. Print the output.
				
					for i in range(1,6):
        for j in range(i):
            print(i,end=" ")
        print()
				
			

Output :

				
					1 
2 2 
3 3 3 
4 4 4 4 
5 5 5 5 5 
				
			

construct the following pattern

get the Fibonacci series between 0 to 10

Find numbers divisible by number within a range

In this program, we will find the numbers divisible by number within the given range of numbers.

Steps to solve the program
  1. Use for loop to iterate over numbers between 0-100.
  2. If a number is divisible by 5, print the number.
				
					
for i in range(1,101):
    if i%5 == 0:
        print(i,end=" ")
				
			

Output :

				
					5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 
				
			

calculate the sum of all odd numbers between 1-100

construct the following pattern

Calculate the sum of odd numbers from 1-100

In this program, we will calculate the sum of odd numbers from 1-100.

Steps to solve the program
  1. Create a variable to calculate the sum and assign its value equal to 0.
  2. Use for loop to iterate over all numbers between 1-100.
  3. If the number is odd then add it to the variable created.
  4. Print the output.
				
					total = 0

for i in range(1,101):
    if i%2 != 0:
        total += i
        
print("Sum of odd numbers: ",total)
				
			

Output :

				
					Sum of odd numbers:  2500
				
			

Calculate the electricity bill

numbers which are divisible by 5 in 0-100

Calculate the electricity bill of a consumer.

In this program, we will calculate the electricity bill of a consumer.

Steps to solve the program
  1. Take the units consumed by a user as input.
  2. Calculate the number of units consumed in each category (i.e. given in the question) using for loop.
  3. Calculate the amount for each category according to the units consumed.
  4. Calculate the total of all categories and add an additional surcharge of 17%.
  5. Print the output.
				
					x=int(input("Total units consumed= "))
b=c=d=e=0
p=q=r=s=0

for i in range(1,x+1):
    if i<51:
        p += 1        
    b = p*0.5
    if i>50 and i<151:
        q += 1        
    c = q*0.75
    if i>150 and i<251:
        r += 1        
    d = r*1.25
    if i>250:
        s += 1
    e = s*1.50
y = b+c+d+e
z = y+y*0.17
print("Total Bill: ",z)
				
			

Output :

				
					Total units consumed= 350
Total Bill:  438.75
				
			

Calculate the bill according to the distance covered

calculate the sum of all odd numbers between 1-100

Calculate the bill by distance covered.

In this program, we will calculate the bill by distance covered.

Steps to solve the program
  1. Take Km covered as input through the user.
  2. Create three variables and assign their values equal to 0.
  3. In the first variable calculate the Km covered in the first 5 Km.
  4. In the second variable calculate the Km covered for the next 20 Km.
  5. In the third variable calculate the Km covered for further distance.
  6. Use for loop to calculate it.
  7. Finally, calculate the bill according to the Km covered.
  8. Print the output.
				
					km = int(input("Enter the KM covered: "))
bill = 0
a=b=c=0
for i in range(1,km+1):
    if i<6:
        a += 1
    elif i>5 and i<26:
        b += 1
    elif i>25:
        c += 1

bill = a*5 + b*12 + c*10
print("Total bill: ", bill)
				
			

Output :

				
					Enter the KM covered: 15
Total bill:  145
				
			

get input from the user if it is a string insert it into an empty list

Calculate the electricity bill

Check the input type from the user.

In this program, we will check the input type from the user and perform actions according to it.

Steps to solve the program
  1. Take input from the user and create an empty list.
  2. If the type of input is a string then add it to the empty list using for loop.
  3. Print the output.
				
					data = input("Enter your text: ")
List = []

if type(data) == str:
    for char in data:
        List.append(char)
        
print(List)
				
			

Output :

				
					Enter your text: sqatools007
['s', 'q', 'a', 't', 'o', 'o', 'l', 's', '0', '0', '7']
				
			

get input from the user if it is a number insert it into an empty list

Calculate the bill according to the distance covered

Program to print the pyramid structure

In this program, we will print the pyramid structure.

Steps to solve the program
				
					var1 = 3
var2 = 5

for i1 in range(5):
    for j1 in range(9):

        if j1 > var1 and j1 < var2:

            print("*", end=" ")
        else:
            print(" ", end=" ")
    print("\n")

    var1 = var1 - 1
    var2 = var2 + 1
				
			

Output :

				
					        *        

      * * *       

    * * * * *     

  * * * * * * *   

* * * * * * * * * 
				
			

print the pattern A

count total numbers of even numbers between 1-100