0% found this document useful (0 votes)
16 views2 pages

For Loop Programs in Python

The document contains a series of Python programs that utilize for loops to perform various tasks. These include displaying 'Hello' five times, printing the first ten natural numbers, listing odd and even numbers within specified ranges, and taking user input to display numbers between two inputs or print a name multiple times. Each program is clearly labeled with a corresponding question number for easy reference.

Uploaded by

Ratul
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

For Loop Programs in Python

The document contains a series of Python programs that utilize for loops to perform various tasks. These include displaying 'Hello' five times, printing the first ten natural numbers, listing odd and even numbers within specified ranges, and taking user input to display numbers between two inputs or print a name multiple times. Each program is clearly labeled with a corresponding question number for easy reference.

Uploaded by

Ratul
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

'''Q1 write a program to display the text Hello 5 times using for loop.

'''
print('Displaying the text hello 5 times')
for a in range(1,6,1):
print('Hello')
'''Q2 write a program to display the first 10 natural numbers using for loop.
'''
print('The first 10 natural numbers are-')
for a in range(1,11,1):
print(a)
'''Q3 write a program to display odd numbers between 1 to 10 using for loop.
'''
print('Odd nos between 1 and 10 are')
for a in range(1,10,2):
print(a)
'''Q4 write a program to display even numbers between 1 to 10 using for loop.
'''
print('Even nos between 1 and 10 are')
for a in range(2,11,2):
print(a)
'''Q5 write a program to display odd numbers from 10 to 1 using for loop.
'''
print('Odd nos from 10 to 1 are')
for a in range(9,0,-2):
print(a)
'''Q6 write a program to display even numbers from 20 to 10 using for loop.
'''
print('Even nos from 20 to 10 are')
for a in range(20,9,-2):
print(a)
'''Q7 write a program to input 2 numbers and display all numbers between them
using for loop.
'''
a=int(input('First number?'))
b=int(input('Second number?'))
print('Numbers between' , a, 'and' ,b, 'are:')
for x in range(a,b+1,1):
print(x)
'''Q8 write a program to input your name and the number of times you want to
print
using for loop'''
name=input('Name?')
no=int(input('How many times you want to print your name?'))
for x in range(1,no+1,1):
print(name)

You might also like