Neha Py 1
Neha Py 1
Neha Py 1
Roll No.: 14
Assignment No.: 01
Title: Develop programs to understand the control structures of python
Code:
# Program to find out even and odd number in between given range using for loop:
Output:
0 is even number
2 is even number
4 is even number
6 is even number
8 is even number
num = 0
n = int(input("Enter a number in between 1 to 10: "))
if n > 10:
print("please enter a number in between 1 to 10")
else:
while num < n:
num += 1
if (num % 2) == 0:
continue
print(num)
Output:
Enter a number in between 1 to 10:3
1
3
i=1
n = int(input("Enter a number in between 1 to 10: "))
if n > 10:
print("please enter a number in between 1 to 10")
else:
while i <= 10:
print('6 * ', (i), '=',6 * i)
if i >= n:
break
i=i+1
Output:
Enter a number in between 1 to 10:5
6 * 1 = 6
6 * 2 = 12
6 * 3 = 18
6 * 4 = 24
6 * 5 = 30
num = [1, 3, 6, 33, 76, 29, 17, 60, 47, 53, 88, 10, 2, 3, 75,55]
Output:
Odd numbers are:
1
3
33
29
17
47
53
3
75
55
Output:
Enter the marks: 100
Congrats ! you scored grade A ...
Output:
Enter any number up to 100:5
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
if(b>a):
if(b>c):
print("b is greatest")
if(c>a):
if(c>b):
print("c is greatest")
Output:
Enter 1st number: 50
Enter 2nd number: 90
Enter 3rd number: 70
b is greatest