0% found this document useful (0 votes)
41 views

Programming Lab Report 6 (Conditional Statements) .... Syed Fasih - Institute of Space & Technology

This document is a lab report for an Introduction to Information Technology course. It discusses conditional statements using Python code. The objectives are to teach students how to use 'if' statements and their various formats. The lab contains 3 tasks - the first compares two values and displays which is greater, the second takes a student mark and outputs the grade, and the third takes a temperature and outputs a description based on thresholds.

Uploaded by

Fasih Abbas
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)
41 views

Programming Lab Report 6 (Conditional Statements) .... Syed Fasih - Institute of Space & Technology

This document is a lab report for an Introduction to Information Technology course. It discusses conditional statements using Python code. The objectives are to teach students how to use 'if' statements and their various formats. The lab contains 3 tasks - the first compares two values and displays which is greater, the second takes a student mark and outputs the grade, and the third takes a temperature and outputs a description based on thresholds.

Uploaded by

Fasih Abbas
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
You are on page 1/ 6

DEPARTMENT OF AVIONICS ENGINEERING

SUBJECT : Introduction to Information Technology


Lab
SUBJECT CODE : 108444
LAB NO : 06

TITLE : Conditional Statements

SUBMITTED TO : Sir Laal Said


SEMESTER : 1st
SECTION : B

Marks Obtained
NAME Syed Fasih Abbas
REGISTRATION # 220701054
LAB REPORT 6
PERFORMANCE
TOTAL MARKS

DEADLINE: 28th November 2022


DATE OF SUBMISSION:

Introduction to IT Lab Page 1 Experiment # 6


Page 2 of 6

Objectives:
 The objective of this lab is to teach the student how to use ‘if’ statements & its various
formats.
 After this lab the students will be able to understand the importance and use of ‘if’ statements
 To evaluate various conditions and execute statements or a group of statements depending on
whether the condition was True or False.

Introduction:
‘if’ statement is used to perform logical operation. In order to perform decision making,
we need to check certain condition before processing. Python supports if statement for
doing so. There are various formats of if statement including if-else and if-elif.
The basic and shortest form of if statement is as below:
if condition:
statement1
statement2

 If the condition is true then the specified block will
be executed. It is important to note

that the block is specified using indentation.


 We can also write the else block associated with the if
statement as below.

if condition:
statement1
statement2

else:
statement3
statement4

 If we are required to test a number of conditions and
want to execute one of the many

blocks of statements, then we can use if-elif-else


statement as below.
if condition1:
statement1
statement2

elif condition2:
Statement3
Statement4

elif condition3:

Introduction to IT Lab Page 2 Experiment # 6


Page 3 of 6

Statement5
Statement6
else:
Statement7
Statement8

Lab Tasks

 Task 1
Write a program that accepts two values from the user and compares both
values. The program displays “Both are equal” if the values are equal, or
“The first value is greater than second” or “The second value is greater
than the first” if user has entered so.

 y is greater than x

Introduction to IT Lab Page 3 Experiment # 6


Page 4 of 6

 Task 2
Write a Python code to accept marks of a student from 1-100 and display
the grade according to the following formula.

Grade F if marks are less than 50, Grade E if marks are between 50 to 60,
Grade D if marks are between 61 to 70, Grade C if marks are between 71 to
80, Grade B if marks are between 81 to 90, and Grade A if marks are

between 91 to 100.

Input Output

73 Grade C

59 Grade E
Introduction to IT Lab Page 4 Experiment # 6
Page 5 of 6

 Task 3

Write a Python code to accept temperature value from user (in centigrade)
and display an appropriate message as below.

FREEZING if temperature is less than 0, COLD if temperature is between 0


to 15, WARM if temperature is between 16 to 30, HOT if temperature is
between 31 to 40, VERY HOT if temperature is greater than 40.

Introduction to IT Lab Page 5 Experiment # 6


Page 6 of 6

Input (Temp in C) Output (Result)


27C WARM
55C VERY HOT
-4C FREEZING
33C HOT

Introduction to IT Lab Page 6 Experiment # 6

You might also like