Python - Lab 2
Python - Lab 2
List of Experiments
Laboratory 2
Title of the Laboratory Exercise: Variables, data types, operators and expressions
1. Introduction and Purpose of Experiment
Variables are the basic data objects that are manipulated in a program. Every value in
Python has a data-type. Operators specify what is to be done to them. Expressions combine
variables and constants to produce new values. These building blocks are the topics of this
Lab. By solving the given programming problems, the students will be able to apply the
concepts of variables, data types, operators and expressions.
2. Aim and Objectives
Aim
To develop programs using variables of basic data types and compute simple
expressions involving operators
Objectives
At the end of this lab, the student will be able to
Use variables of the basic data types m
Apply various operators in expressions
Create Python programs to solve simple numeric problems
3. Experimental Procedure
i. Analyse the problem statement
ii. Design an algorithm for the given problem statement and develop a
flowchart/pseudo-code
iii. Implement the algorithm in Python language
iv. Execute the Python program
v. Test the implemented program
vi. Document the Results
vii. Analyse and discuss the outcomes of the experiment
4. Questions
a. Write a Python program to exchange the values of two variables using a temporary
variable.
b. Write a Python program to compute quotient and remainder of two numbers.
c. Write a Python program to find the area and perimeter of a rectangle.
d. Write a Python program to convert temperature in Celsius to Fahrenheit.
Name: SALIN CHAUDHARY Registration Number: 21ETCS002173
5. Calculations/Computations/Algorithms
4)a.
Name: SALIN CHAUDHARY Registration Number: 21ETCS002173
4)b.
Name: SALIN CHAUDHARY Registration Number: 21ETCS002173
4)c.
Name: SALIN CHAUDHARY Registration Number: 21ETCS002173
4)d.
Name: SALIN CHAUDHARY Registration Number: 21ETCS002173
6. Presentation of Results
PROGRAM 4)a.
OUTPUT 4)a.
PROGRAM 4)b.
OUTPUT 4)b.
PROGRAM 4)c.
OUTPUT 4)c.
PROGRAM 4)d.
OUTPUT 4)d.
7. Conclusions
Here we learnt 4 programs in which the first program was based on swapping values
between 2 variables using an another variable named temp. In the second program we
found out the quotient and remainder . In the third program we found out the area and
perimeter of a rectangle using 2 variables named as length and breath. In the fourth we
converted Celsius to Fahrenheit using the input as Celsius as input for the program.