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

PWP-PR-4

The document contains several Python code snippets that demonstrate basic programming concepts such as finding the largest number among three inputs, checking if a year is a leap year, determining if a number is positive, negative, or zero, and calculating grades based on average scores. Each code segment includes user input prompts and outputs the results based on the provided logic. The examples illustrate fundamental conditional statements and arithmetic operations in Python.

Uploaded by

arqamqazi549
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)
7 views3 pages

PWP-PR-4

The document contains several Python code snippets that demonstrate basic programming concepts such as finding the largest number among three inputs, checking if a year is a leap year, determining if a number is positive, negative, or zero, and calculating grades based on average scores. Each code segment includes user input prompts and outputs the results based on the provided logic. The examples illustrate fundamental conditional statements and arithmetic operations in Python.

Uploaded by

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

#Name: Qazi Arqam Arif

#Enrollment: 2205690362
#Batch: 2

Code:
#find the largest no among 3 numbers
n1 = int(input("Enter the first no: "))
n2 = int(input("Enter the first no: "))
n3 = int(input("Enter the first no: "))

if n1 >= n2 and n1 >= n3:


print(n1, " is greater among three")
elif n2 >= n1 and n2 > n3:
print(n2, " is greater among three")
else:
print(n3, " is greater among three")

Output:
Enter the first no: 5
Enter the first no: 4
Enter the first no: 3
5 is greater among three

Code:
#find the largest no among 3 numbers
n1 = int(input("Enter the first no: "))
n2 = int(input("Enter the first no: "))
n3 = int(input("Enter the first no: "))

if n1 >= n2 and n1 >= n3:


print(n1, " is greater among three")
elif n2 >= n1 and n2 > n3:
print(n2, " is greater among three")
else:
print(n3, " is greater among three")

Output:
Enter the first no: 2
Enter the first no: 3
Enter the first no: 4
4 is greater among three

Code:
# find if the input year is a leap year
year = int(input("Enter a year: "));

if year % 4 == 0:
print(year, " is a leap year")
else:
print(year, " is not a leap year")

Output:
Enter a year: 2024
2024 is a leap year

Code:

#find if the number is positive, Negative or zero

n = int(input("Enter a number: "))

if n > 0:
print(n, " is positive")
elif n < 0:
print(n, " is negative")
else:
print("No is zero")

Output:
Enter a number: 5
5 is positive

Enter a number: 0
No is zero

Code:

# displaying the grade

m1 = int(input("First: "))
m2 = int(input("Second: "))
m3 = int(input("Third: "))
m4 = int(input("Fourth: "))
m5 = int(input("Five: "))

avg = (m1 + m2 + m3 + m4 + m5) / 5

if avg > 80:


print("Excellent")
elif avg > 60:
print("Good")
elif avg > 40:
print("Satisfactory")
else:
print("Try again")
Output:
First: 90
Second: 80
Third: 70
Fourth: 90
Five: 90
Excellent

You might also like