0% found this document useful (0 votes)
8 views2 pages

Conditional Statements in Python Code

The document contains examples of conditional statements in Python programming. It demonstrates how to compare values, calculate averages, and compute pay based on hours worked. Each example includes user input and the corresponding output based on the conditions set in the code.

Uploaded by

zubi.zeenat0
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)
8 views2 pages

Conditional Statements in Python Code

The document contains examples of conditional statements in Python programming. It demonstrates how to compare values, calculate averages, and compute pay based on hours worked. Each example includes user input and the corresponding output based on the conditions set in the code.

Uploaded by

zubi.zeenat0
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

Conditional Statements (Dated: Feb 03,2025)

In [1]: a=1000
b=200
if a>b:
print("a is greater than b")
print("a= {} ,b= {}".format(a,b))
print("This line is outside if")
print("This is rest of the program")

a is greater than b
a= 1000 ,b= 200
This line is outside if
This is rest of the program

In [2]: test1=int(input("Enter the first test score"))


test2=int(input("Enter the second test score"))
test3=int(input("Enter the third test score"))
avg=round((test1+test2+test3)/3,2)
print("Average= {}".format(avg))
if avg>=95:
print("Congrtaulation: You got an A Grade")

Enter the first test score98


Enter the second test score98
Enter the third test score97
Average= 97.67
Congrtaulation: You got an A Grade
In [3]: hours=float(input("Enter the number of hours: "))
rate=float(input("Enter the pay rate:"))
if hours>40:
pay=40*rate+(hours-40)*rate*1.5
else:
pay=hours*rate
print("Pay= ${}".format(pay))

Enter the number of hours: 50


Enter the pay rate:10
Pay= $550.0

You might also like