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

Python If Statement Lab Exercises

This document contains a computer application lab assignment from Adamas University focused on Python programming using if statements. It includes five exercises with code examples and outputs, covering finding the largest number, checking voting eligibility, determining if a number is positive, negative, or zero, identifying even or odd numbers, and evaluating grades based on marks. Each exercise provides a clear coding task along with expected user input and output.

Uploaded by

Sumit Prasad
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)
12 views3 pages

Python If Statement Lab Exercises

This document contains a computer application lab assignment from Adamas University focused on Python programming using if statements. It includes five exercises with code examples and outputs, covering finding the largest number, checking voting eligibility, determining if a number is positive, negative, or zero, identifying even or odd numbers, and evaluating grades based on marks. Each exercise provides a clear coding task along with expected user input and output.

Uploaded by

Sumit Prasad
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

Computer Application Lab Assignment

ADAMAS UNIVERSITY
SCHOOL OF ENGINEERING & TECHNOLOGY
PYTHON PROGRAM (if statement)

1. Write a program in python to find largest number among two numbers.

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

Output:
Enter first number: 15
Enter second number: 10
Largest number is 15

2. Write a program in python to check a person is eligible to give vote or not (age>18).

Code:
age = int(input("Enter age: "))
if age > 18:
print("Person is eligible to vote")
else:
print("Person is not eligible to vote")

Output:
Enter age: 20
Person is eligible to vote

3. Write a program in python to check a given number is positive, negative or zero.

Code:
num = int(input("Enter a number: "))
if num > 0:
print("Number is Positive")
elif num < 0:
print("Number is Negative")
else:
print("Number is Zero")

Output:
Enter a number: -5
Number is Negative

4. Write a program in python to check a given number is even of odd.

Code:
num = int(input("Enter a number: "))
if num % 2 == 0:
print("Number is Even")
else:
print("Number is Odd")

Output:
Enter a number: 7
Number is Odd

5. Write a program in python to evaluate Grade based on marks.


(Hints:Marks>=90:A, >=80:B,>=70:C,>=60:D otherwise :F)

Code:
marks = int(input("Enter marks: "))
if marks >= 90:
print("Grade A")
elif marks >= 80:
print("Grade B")
elif marks >= 70:
print("Grade C")
elif marks >= 60:
print("Grade D")
else:
print("Grade F")

Output:
Enter marks: 85
Grade B

You might also like