Total number of special characters in a string

In this program, we will find the total number of special characters in a string.

Steps to solve the program
  1. Take a string as input and create another string of special characters.
  2. Create a variable to count the total number of special characters in a string.
  3. Use for loop to iterate over each character of the input string.
  4. If that character is in the string containing special characters then add 1 to the variable that we have created.
  5. Print the output.
				
					str1 = '@sqa#tools!!'
special_char = '!@#$%^&*()_{[}]'
special = 0

for char in str1:
    if char in special_char:
        special += 1
        
print("Special character: ",special)
				
			

Output :

				
					Special character:  4
				
			

print the days in a week except Sunday using a while loop

add even numbers in an empty list from a given list

Print the days in a week except for Sunday

In this program, we will print the days in a week except for Sunday.

Steps to solve the program
  1. Take a list of days as input.
  2. Use for loop to iterate over each day in the list.
  3. If the iterated day is not Sunday then print the day.
  4. use the If statement for this purpose.
				
					days = ["Sunday","Monday","Tuesday","Wednesday","Thursday"
       ,"Friday","Saturday"]

for day in days:
    if day != "Sunday":
        print(day, end=" ")
				
			

Output :

				
					Monday Tuesday Wednesday Thursday Friday Saturday 
				
			

Print numbers from 1-10 except 5,6 using a while loop

find the total number of special characters in a string

Program to print certain numbers.

In this program, we will print certain numbers.

Steps to solve the program
  1. Use for loop to iterate over numbers from 1-10.
  2. Print all the numbers except 5 and 6.
  3. Use If statement for this purpose.
				
					
for i in range(1,11):
    if i != 6 and i != 5:
        print(i,end="\n")
				
			

Output :

				
					1
2
3
4
7
8
9
10
				
			

multiplication of the first 10 natural numbers

print the days in a week except Sunday using a while loop

Find the multiplication of natural numbers

In this program, we will find the multiplication of natural numbers using Python.

Steps to solve the program
  1. Create a count variable and assign its value equal to 1.
  2. Create a product variable and assign its value equal to 1.
  3. While the value of the count variable is less than 11 multiply the product variable by the count variable.
  4. Add 1 to the count variable after each iteration.
  5. Print the output.
				
					count = 1
product = 1

while count<11:
    product *= count
    count += 1
    
print("Total: ",product)
				
			

Output :

				
					Total:  3628800
				
			

sum of the first 10 natural numbers using the while loop 

Print numbers from 1-10 except 5,6 using a while loop

Find the sum of natural numbers using Python

In this program, we will find the sum of natural numbers using Python.

Steps to solve the program
  1. Create a count variable and assign its value equal to 1.
  2. Create a total variable and assign its value equal to 0.
  3. While the value of the count variable is less than 11 add the count variable to the total.
  4. Add 1 to the count variable after each iteration.
  5. Print the output.
				
					count = 1
total = 0

while count<11:
    total += count
    count += 1
    
print("Total: ",total)
				
			

Output :

				
					Total:  55
				
			

Print the table of a number using a while loop

multiplication of the first 10 natural numbers

Program to print a table using while loop

In this program, we will print a table using while loop in Python.

Steps to solve the program
  1. Create a count variable and assign its value equal to 1.
  2. While value of the count variable is less than 11 multiply the count variable by 2 and store the value in another variable.
  3. Add 1 to the count variable after each iteration.
  4. Print the output.
				
					count = 1

while count < 11:
    a = count*2
    print(count,"*",2,"=",a)
    count += 1
				
			

Output :

				
					1 * 2 = 2
2 * 2 = 4
3 * 2 = 6
4 * 2 = 8
5 * 2 = 10
6 * 2 = 12
7 * 2 = 14
8 * 2 = 16
9 * 2 = 18
10 * 2 = 20
				
			

print the first 20 natural numbers

Sum of the first 10 natural numbers using the while loop

Program to print the first 20 natural numbers

In this program, we will print the first 20 natural numbers using a while loop.

Steps to solve the program
  1. Create a variable and assign its value equal to 1.
  2. While the value of the variable is less than 21 print the variable.
  3. Add 1 to the count variable after printing a number.
  4. Print the output.
				
					count = 1

while count < 21:
    print(count,end=" ")
    count += 1
				
			

Output :

				
					1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 
				
			

print the keys and values of a dictionary

Print the table of a number using a while loop

Print the keys and values of a dictionary

In this program, we will print the keys and values of a dictionary.

Steps to solve the program
  1. Take a Dictionary as input.
  2. Get the keys and values of the dictionary using items().
  3. Use for loop to iterate over keys and values of the Dictionary.
  4. Print the output.
				
					dict1 = {'name':'virat','sports':'cricket'}

for key,val in dict1.items():
    print(key,val)
				
			

Output :

				
					name virat
sports cricket
				
			

print the values of the keys of a dictionary

print the first 20 natural numbers using a while loop

Print the values of the keys of a dictionary

In this program, we will print the values of the keys of a dictionary.

Steps to solve the program
  1. Take a Dictionary as input.
  2. Get the values of the keys of a dictionary using values().
  3. Use for loop to iterate over keys of the Dictionary.
  4. Print the output.
				
					dict1 = {'name':'virat','sports':'cricket'}

for value in dict1.values():
    print(value
				
			

Output :

				
					virat
cricket
				
			

print the keys of a dictionary

print the keys and values of a dictionary

Program to print the keys of a dictionary

In this program, we will print the keys of a dictionary.

Steps to solve the program
  1. Take a Dictionary as input.
  2. Get the keys of the DIctionary using keys().
  3. Use for loop to iterate over keys of the Dictionary.
  4. Print the output.
				
					dict1 = {'name':'virat','sports':'cricket'}

for keys in dict1.keys():
    print(keys)
				
			

Output :

				
					name
sports
				
			

create an empty list and add odd numbers from 1-10

print the values of the keys of a dictionary