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

Python Programming Tasks and Solutions

Python Programming

Uploaded by

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

Python Programming Tasks and Solutions

Python Programming

Uploaded by

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

Chapter 7: Programming Task – Programs

Task 2:
def sort():
num=int(input("enter the limit of element : "))
data=[]
for i in range(num):
[Link](int(input("enter the element : ")))
for i in range(len(data)-1):
for j in range(len(data)-1):
if data[j]<data[j+1]:
temp=data[j]
data[j]=data[j+1]
data[j+1]= temp
print("The sorted elements are:", data)
sort()
Task 3:
price=0
count=0
total=0
i=0
while i!=-1:
price=int(input("enter the item price"))
i=int(input("Enter -1 if you want to exit"))
total=total+price
count=count+1
Avg=total/count
print("The Total Amount :",total)
print("The number of Item:",count)
print("The average Prices:",Avg)
Task 4:
total1=0
total2=0
total3=0
count1=0
count2=0
count3=0
i=0
while i!=-1:
weight=float(input("Enter the weight of the parcel:"))
if weight < 1:
total1=total1+weight
count1=count1+1
elif weight >= 1 and weight < 2:
total2=total2+weight
count2=count2+1
else:
total3=total3+weight
count3=count3+1
i=int(input("Enter -1 if you want to exit"))
print("Parcel less than 1kg:", count1)
print("Parcel between 1kg and 2kg:", count2)
print("Parcel greater than 2kg:", count3)
Task 5:
l=[]
total=0
n=int(input("How many students mark do you want to enter?"))
for i in range(n):
[Link](int(input("Enter the students mark")))
for i in range(n):
total=total+l[i]
if l[i]>=80:
print("The student",i,"got Distinction")
elif l[i]>=60:
print("The student",i,"got Merit")
elif l[i]>=40:
print("The student",i,"got Pass")
else:
print("The student",i,"Fail")
print("The class maximum mark is", max(l))
print("The class maximum mark is", min(l))
print("The class average mark is", total/len(l))

You might also like