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

Week 3 Programs

Hi bros how are you feeling better

Uploaded by

acharnandini928
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)
21 views2 pages

Week 3 Programs

Hi bros how are you feeling better

Uploaded by

acharnandini928
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/ 2

WEEK 3 PROGRAMS

OUTPUT
#Program to check a given number is positive
using simple if statement.

num=int(input("Enter a number:"))
if num>0:
print("The number is positive.")
print("Thank you")

OUTPUT
#Program to check a given number is EVEN or
ODD using if-else statement.

num=int(input("Enter a number:"))
if(num%2==0):
print("The number is EVEN")
else:
print("The number is ODD")

OUTPUT
#Program to assigning a letter grade based on a
numerical score using if-elif-else statement.

score=int(input("Enter your score:"))

if score >= 90:


grade = "A"
elif score >= 80:
grade = "B"
elif score >= 70:
grade = "C"
elif score >= 60:
grade = "D"
else:
grade = "F"

print("Your grade is:", grade)


OUTPUT
#Program to check the given number is positive,
negative or equal to 0 using nested if statement.

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

if num != 0:
if num > 0:
print("The number is Positive")

else:
print("The number is Negative")
else:
print("The number is Zero")

OUTPUT
#Program to find the largest of two numbers
using Short hand if-else statement.

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


b=int(input("Enter second number:"))
print(a,"is largest") if a>b else print(b,"is largest")

You might also like