0% found this document useful (0 votes)
44 views13 pages

Assignment 1: Topic: Python

The document contains Python code solutions for 10 programming assignments: 1) Calculate the area of a circle given radius 2) Calculate average of 5 subject marks 3) Calculate area of a triangle given base and height 4) Print multiples of a given number 5) Find largest of 3 numbers 6) Sum even numbers up to a given number 7) Calculate arithmetic operations on 2 numbers 8) Identify if character is vowel or consonant 9) Calculate area/circumference based on user choice 10) Find largest number among 3 inputted numbers Screenshots of the original Python code are provided for each assignment.

Uploaded by

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

Assignment 1: Topic: Python

The document contains Python code solutions for 10 programming assignments: 1) Calculate the area of a circle given radius 2) Calculate average of 5 subject marks 3) Calculate area of a triangle given base and height 4) Print multiples of a given number 5) Find largest of 3 numbers 6) Sum even numbers up to a given number 7) Calculate arithmetic operations on 2 numbers 8) Identify if character is vowel or consonant 9) Calculate area/circumference based on user choice 10) Find largest number among 3 inputted numbers Screenshots of the original Python code are provided for each assignment.

Uploaded by

atul ratan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

ASSIGNMENT 1

TOPIC : PYTHON
To write a Python program that accepts radius of a circle and prints its area.

CODES:-
r=int(input(‘Enter the radius: ‘)) area=3.14*r*r

print(‘The area is’,area)

RESULT-

Enter the radius: 10

The area is 314

SCREENSHOTS (of original Python code)-

Indirapuram Public School, Crossings Republik


To write a Python program that accepts marks in 5 subjects and output average
m Marks.

CODES:-
p=int(input('Enter your Portuguese marks: '))

a=int(input('Enter your Arabic marks: '))

f=int(input('Enter your French marks: '))

e=int(input('Enter your English marks: '))

s=int(input('Enter your Spanish marks: '))

avg=(p+a+f+e+s)/5

print('The average marks are', avg)

RESULT- your Portuguese marks: 100


Enter
Enter your Arabic marks: 100

Enter your French marks: 100

Enter your English marks: 100

Enter your Spanish marks: 100

The average marks are 100

SCREENSHOTS (Python code)-

Indirapuram Public School, Crossings Republik


To write a Python program to find the area of a triangle.

CODES :-

b=float(input('Enter the base of the triangle: '))

h=float(input('Enter the height of the triangle: '))

area=b*h*0.5

print("The triangle's area is",area)

RESULT- Enter the base of the triangle: 50

Enter the height of the triangle: 60

The triangle's area is 150.0

Indirapuram Public School, Crossings Republik


To write a Python program to find the input a number and print its first five multiples.

CODES :-

n=int(input("Enter the number to find it's first five multiples: "))

one=n*1

two=n*2

three=n*3

four=n*4

five=n*5

print(n,'* 1 = ',one)

print(n,'* 2 = ',two)

print(n,'* 3 = ',three)

print(n,'* 4 = ',four)

print(n,'* 5 = ',five)

RESULT- Enter the number to find it's first five multiples: 5


5 * 1 = 5

5 * 2 = 10

5 * 3 = 15

5 * 4 = 20

5 * 5 = 25

SCREENSHOTS (Python code)-

Indirapuram Public School, Crossings Republik


To write a Python program that finds the largest number among the three inputted
numbers.
CODES :-

a=int(input('Enter the first number: '))

b=int(input('Enter the second number: '))

c=int(input('Enter the third number: ')) if a>b

and a>c:

print('The largest number out of the three is',a) if b>a

and b>c:

print('The largest number out of the three is',b) if c>a and

c>b:

print('The largest number out of the three is',c)

RESULT- Enter the first number: 20

Enter the second number:35

Enter the third number: 17

The largest number out of the three is 35

SCREENSHOTS ( Python code)-

Indirapuram Public School, Crossings Republik


To write a Python program to display sum of even numbers up to number n entered
by the user.

Indirapuram Public School, Crossings Republik


To write a Python program that reads two numbers and an arithimetic operator and
d displays the result.

CODES: - a=float(input('Enter the first number: '))


b=float(input('Enter the second number: '))

c=str(input('Enter the arithimetic sign(+,-,* or /): ')) if c=='+':

add=a+b

print('The addition is',add) if

c=='-':

sub=a-b

print('The subtaction is',sub) if

c=='*':

mul=a*b

print('The multiplication is',mul) if

c=='/':

div=a/b

print('The division is',div)

RESULT- Enter the first number: 10


Enter the second number: 400

Enter the arithimetic sign(+,-,* or /): + The

multiplication is 410.0

SCREENSHOTS (Python code)-

Indirapuram Public School, Crossings Republik


To write a Python program that accept a character from the user and display wheter it is
a vowel or consonant.

CODES:-
a=str(input('Enter your alphabet: '))

if a=='a' or a=='e' or a=='i' or a=='o' or a=='u': print('It

is a vowel')

else:

print('It is a consonant')

RESULT- Enter your alphabet:


u It is a vowel

SCREENSHOTS (Python code)-

Indirapuram Public School, Crossings Republik


To write a Python program that following task according to user’s choice using menu:

a. Area of Circle
b. Area of Rectangle
c. Circumference of Circle
d. Area of Square

CODES :-

print('''Press '1' for finding Area of Circle Press '2' for

finding Area of Rectangle

Press '3' for finding Circumference of Circle & Press '4'

for finding Area of Square''') a=int(input('Enter here

(1,2,3 or 4): '))

if a==1:

r=float(input('Enter the radius'))

area=3.14*r*r

print('The area is',area) elif

a==2:

l=float(input('Enter the length'))

b=float(input('Enter the breadth'))

arear=l*b

print('The area is',arear) elif

a==3:

Q=float(input('Enter the radius'))

areac=2*3.14*r

print('The circumference is',areac)

elif a==4:

s=float(input('Enter the side'))

Indirapuram Public School, Crossings Republik


areas=s*s

print('The area is',areas)

RESULT- Press '1' for finding Area of Circle


Press '2' for finding Area of Rectangle

Press '3' for finding Circumference of Circle & Press '4'

for finding Area of Square

Enter here (1,2,3 or 4): 4

Enter the side: 10

The area is 100

SCREENSHOTS ( Python code)-

Indirapuram Public School, Crossings Republik


Indirapuram Public School, Crossings Republik
Indirapuram Public School, Crossings Republik

You might also like