Lab Manual 1
Lab Manual 1
Introduction:
In this first lab of Introduction to Computing and Data Science, we shall learn about the installation of our
python environment that shall be used throughout the semester to perform various tasks for problem-
solving.
The first thing you need to do, to learn Python for Data Science, is to install Python and a suitable
Integrated Development Environment (IDE) for coding in Python. At the end of this manual, you will be
able to start coding in Python.
(OR)
Press ‘ctrl + j’ on your browser, it will show your downloads, double click on the installer.
c) After installation, click on the ‘Close’ button. Your Python installation is successful
3. Verify Installation
a. To verify your installation, go to the command prompt (type ‘cmd’ in the Search box).
b. Now type, “Python –V” to check the version of Python installed
• https://www.programiz.com/python-programming/online-compiler/
• https://www.online-python.com/
• https://www.w3schools.com/python/python_compiler.asp
Artificial Intelligence
Department of Computer Science
University of Engineering and Technology, Lahore
Output Explanation
10 + 5
10 – 5
10 * 5
10**5
10 / 5
10 % 5
25 / 5
25 // 5
26 // 5
2 * 60 + 30
2 * (60 + 30)
43 + 60 + 16 + 41
type(0)
type(-5)
type(3.1415)
type(“Hello World!”)
type(6/2)
float(2)
int(3.1415)
int(‘1’)
int(‘A’)
str(‘1’)
str(‘4.5’)
type(True)
bool(1)
print(“Hello World!”)
Output:
Explanation:
var = 1
print(var)
x = 43 + 60 + 16 + 41
print (x)
y = (3 + 2) * 2
print (y)
z = x+y
print (z)
a = "Hello, World!"
print(len(a))
import sys
print(sys.version)
Output:
Explanation:
total_min = 43 + 42 + 57 # Total length of albums in minutes
total_hours = total_min / 60 # Total length of albums in hours
print(total_min)
print(total_hours)
Output:
Explanation:
x = 10
y=5
print(x < y)
x=5
y=3
print(x > y)
x = 20
y = 20
print(x == y)
x = 15
y = 35
print(x != y)
x=5
y=3
print(x >= y)
x = 10
y=5
print(x <= y)
x=5
print(x > 3 and x < 10)
x=5
print(x > 3 or x < 4)
x=5
print(not(x > 3 and x < 10))
my_string="Hello"
substring = my_string[0:2]
print(substring)
my_string="This is a mountain!"
new_string = my_string.replace("This", "It")
print(my_string)
print(new_string)
Output:
Explanation: