You are on page 1of 8

Lab Manual

Introduction to python
Lab-Sheet-05

Student Name Ikhlaq Hussain

Reg. No Ck-20-110024

Department Computing & Technology

Batch/ Semester BSCS 4th Semester

Program BSCS

Instructor
Mujtaba Awan
mujtaba@iqrauni.edu.pk
Week 4
Lab-sheet 4
Introduction to pythonLab 4

Lab Objectives:

Tasks

1) Write a program to check whether a person is eligible for voting or not. (accept age from
user)

Program coding:

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


if age >= 18:
print("You are eligible for vote.")
else:
print("You are not eligible for vote.")
Output:
2) Check whether a number entered by user is even or odd.

Program coding:

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


if num % 2 == 0:
print("Number Is Even.")
else:
print("Number Is Odd.")
Output:

3) Write a program to check whether a number is divisible by 7 or not.

Program coding:

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


if num % 7 == 0:
print("\nNumber is divisible by 7.")
else:
print("\nNumber is not divisible by 7.")
Output:
4) Write a program to display "Hello" if a number entered by user is a multiple of five,
otherwise print "Bye"

Program coding:

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


if num % 5 == 0:
print("\nHello")
else:
print("\nBye")
Output:

5) Write a program to check whether the last digit of a number(entered by user) is


divisible by 3 or not.

Program coding:

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


num = num % 10
if num % 3 == 0:
print("\nLast digit is divisible by: ", num)
else:
print("\nLast digit is not divisible by: ", num)
Output:

6) Write a program to accept percentage from the user and display the grade according to
the following criteria: using IF else statement.

Marks Grade
> 90 A
> 80 and <= 90 B
>= 60 and <= 80 C
below 60 D
Program coding:

per = int(input("Enter the percentage of student: "))


if per > 90:
print("\nGrade A")
elif per > 80 and per <= 90:
print("\nGrade B")
elif per >= 60 and per <= 80:
print("\nGrade C")
elif per < 60:
print("\nGrade D")

Output:
7) Write a program to find the lowest number out of two numbers excepted from user.

Program coding:

num1 = int(input("Enter First Number: "))


num2 = int(input("Enter Second Number: "))
if num1 > num2:
print("\nThe lowest number is: ", num2)
else:
print("\nThe lowest number is: ", num1)

Output:

8) Write a program to check whether a number (accepted from user) is positive or negative.

Program coding:

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


if num >= 0:
print("\nNumber is positive")
else:
print("\nNumber is negative")
Output:
9) Accept the temperature in degree Celsius of water and check whether it is boiling or not
(boiling point of water in 100 oC

Program coding:

temp = int(input("Enter the Temperature of


water: "))
if temp >= 100:
print("\nBoiling point")
else:
print("\nBoiling point")
Output:

10)Accept the age of 4 people and display the youngest one?

Program coding:

per1 = int(input("Enter the first person age: "))


per2 = int(input("Enter the second person age:
"))
per3 = int(input("Enter the third person age: "))
per4 = int(input("Enter the fourth person age:
"))

if per1 < per4 and per1 < per2 and per1 < per3:
print("\nYoungest is person 1 age is: ",
per1, " Year's")
elif per2 < per1 and per2 < per3 and per2 < per4:
print("\nYoungest is person 2 age is: ",
per2, " Year's")
elif per3 < per4 and per3 < per2 and per3 and
per1:
print("\nYoungest is person 3 age is: ",
per3, " Year's")
elif per4 < per3 and per4 < per2 and per4 < per1:
print("\nYoungest is person 4 age is: ",
per4, " Year's")
Output:

…The End…

You might also like