0% found this document useful (0 votes)
15 views3 pages

1.1 Continue Statement

Best

Uploaded by

lpavi800
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)
15 views3 pages

1.1 Continue Statement

Best

Uploaded by

lpavi800
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
You are on page 1/ 3

Name:

Roll No.:
Assignment No.: 01
Title: Develop programs to understand the control structures of python

Code:

1.1 Continue statement:

# Program to find out even and odd number in between given range using for loop:

for num in range(10):


if num % 2 == 0:
print(num, "is even number")
continue
print(num, "is odd number")

Output:

# program to print odd numbers from 1 to 10 using while loop:

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:

1.2 Break Statement:

# program to find first 5 multiples of 6


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:

1.3 Pass Statement:

#Program to find out odd number in given list

num = [1, 3, 6, 33, 76, 29, 17, 60, 47, 53, 88, 10, 2, 3, 100]

print('Odd numbers are: ')


for i in num:
# check if the number is even
if i % 2 == 0:
# if even, then pass
pass
# print the odd numbers
else:
print (i)

Output:

1.4 Conditional Statement (Chained if):

#program to find out Grade of student:

marks = int(input("Enter the marks: "))


if marks>100:
print("Please enter proper marks!")
elif marks > 85 and marks <= 100:
print("Congrats ! you scored grade A ...")
elif marks > 60 and marks <= 85:
print("You scored grade B + ...")
elif marks > 40 and marks <= 60:
print("You scored grade B ...")
elif (marks > 30 and marks <= 40):
print("You scored grade C ...")
else:
print("Sorry you are fail")
Output:

1.5 Nested Loop:

#program to print Multiplication table up to given number:

n = int(input("Enter any number up to 100:"))

# Iterating over numbers in the range 1 to n


for row in range(1,n+1):
# Iterating over numbers in the range 1 to n
for col in range(1,n+1):
# Printing the product of row and col
print(row*col, end="\t")
print()

Output:

1.6 Nested Condition:

a = int(input("Enter 1st number: "))


b = int(input("Enter 2nd number: "))
c = int(input("Enter 3rd number: "))
if(a>b):
if(a>c):
print("a is greater")

if(b>a):
if(b>c):
print("b is greatest")

if(c>a):
if(c>b):
print("c is greatest")

if(a == b and b == c):


print("all are equal")

Output:

You might also like