0% found this document useful (0 votes)
9 views4 pages

Python Code

The document contains a series of Python code snippets for various tasks, including calculating average grades, performing basic arithmetic operations, scoring a quiz, multiplying numbers in a loop, and counting down from 20. Each section demonstrates different programming concepts such as lists, conditionals, loops, and user input. The code also includes print statements to provide feedback and results to the user.

Uploaded by

taimoor khan
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)
9 views4 pages

Python Code

The document contains a series of Python code snippets for various tasks, including calculating average grades, performing basic arithmetic operations, scoring a quiz, multiplying numbers in a loop, and counting down from 20. Each section demonstrates different programming concepts such as lists, conditionals, loops, and user input. The code also includes print statements to provide feedback and results to the user.

Uploaded by

taimoor khan
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

grades=[85,90,78,92,88,75,89]

average= sum(grades)/len(grades)

print ("The average of the numbers is",average)

high= max(grades)

print("The highest number is",high)

low=min(grades)

print("The lowest number is",low)

grades.append (95)

print (grades)

grades.remove(85)

print (grades)

#Q2

print("+,-,/,*")

a=str(input("please select any one of the operations mentioned above:"))

b=float(input("enter a number:"))

c=float(input("enter another number:"))

if a=="+":

print (b+c)

elif a=="-":

print(b-c)

elif a=="/":

print (b/c)

elif a=="*":

print (b*c)

else:

print ("invalid operations")

#Q3

score=0
m=score

a=str(input("10+5="))

if a=="15":

print ("Correct!")

score+=2

else:

print("Wrong correct answer is 15")

b=str(input("2y*4="))

if b=="8y":

print("Correct!")

score+=2

else:

print("Wrong correct answer is 8y")

c=str(input("2x/2x="))

if c=="1":

print ("Correct!")

score+=2

else:

print("Wrong the correct answer is 1")

d=str(input("50*50="))

if d=="250":

print("Correct!")

score+=2

else:

print("Wrong the correct answer is 250")

import time

print("Now the last one is hard")

time.sleep(1)

print("Okay here it comes")

time.sleep(1)

e=str(input("5y+4x=8y-4x:"))
if e=="8x-3y":

print("Correct!")

score+=2

elif e=="-3y+8x":

print("Correct!")

score+=2

else:

print("Wrong the correct answer is 8x-3y or -3y+8x")

print("Now time for your big score")

time.sleep(2)

print("Calculating...")

time.sleep(2)

if score>5:

print("I predict you did a great job")

else:

print("I predict you did a bad job")

time.sleep(2)

print("Your Score is:",score)

if score>5:

print("I was right, well done!")

else:

print("I was right, horrible job")

#Q4

count=1

multiply=float(input("enter a number:"))

for i in range (1,11):

print(multiply,"X",i,"=",multiply*count)

count+=1

#Q5

import time
for i in range (20,0,-1):

time.sleep(1)

print (i)

You might also like