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

Lab Manual 1

The document provides a guide for setting up a Python environment and Jupyter Notebook for an introductory computing and data science course. It includes detailed instructions for downloading and installing Python, verifying the installation, and setting up Jupyter Notebook, along with alternative installation methods. Additionally, it outlines class learning outcomes and provides exercises for students to practice Python programming concepts.

Uploaded by

pajeg11558
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lab Manual 1

The document provides a guide for setting up a Python environment and Jupyter Notebook for an introductory computing and data science course. It includes detailed instructions for downloading and installing Python, verifying the installation, and setting up Jupyter Notebook, along with alternative installation methods. Additionally, it outlines class learning outcomes and provides exercises for students to practice Python programming concepts.

Uploaded by

pajeg11558
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Artificial Intelligence

Department of Computer Science


University of Engineering and Technology, Lahore

Class Learning Outcomes:


● Python Installation
● Getting familiar with Jupyter Notebook

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.

Setting up Python Environment


1. Download Python Executable File
To initiate Python installation on your system, you first have to download and run the
Python.exe file. For this, navigate to the Python official website and download the latest version
of Python.
a) Open your web browser (Chrome, Firefox, etc.)
b) Go to the website: https://www.python.org/
c) Go to the downloads for windows section
d) Click on Python 3 and download ‘Windows installer (64-bit)’.
2. Running Python Executable File
a) Now, go to the directory where you have downloaded the file and open it.

(OR)

Press ‘ctrl + j’ on your browser, it will show your downloads, double click on the installer.

b) Click on ‘Install Now’ with the shown settings.

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

4. Setting Up Jupyter Notebook


Jupyter Notebook is an IDE used mostly by Data Scientists. It also supports many file formats
like JSON, CSV, jpeg, etc which is very useful when working with different forms of data.
Follow the following instructions
• Open your command prompt.
• Type ‘pip install jupyter notebook
• After the installation is complete, just type ‘jupyter notebook’ on your command
prompt and it will run the jupyter notebook on your system.
Alternative Installation and Environment Setup
• Install Python Software
• Download Anaconda from https://www.anaconda.com/download
• Install the Anaconda executable file (.exe)
• Type “jupyter notebook” in Anaconda Powershell Prompt
• Jupyter Notebook is launched on your system
Online Compiler
The students can also practice their Python Programming Skills for free on the online Compilers.

• 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

Class Learning Outcomes:


Students shall be able to

• Variables and variable types


• Use arithmetic operators
• Use logical operators
• Use comparison operators
• Use the print function
• Get the input from the user
• Use strings
• Algorithms & Flowcharts

Run the following commands in the Jupyter Notebook. Mention the


output and explain what the instruction does. 25 marks

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!”)

username = input("Enter username:")


print("Username in lower case: " + username.lower()))
print("Username in upper case: " + username.upper()))

Output:
Explanation:

var = 1
print(var)

x = 43 + 60 + 16 + 41
print (x)

y = (3 + 2) * 2
print (y)

z = x+y
print (z)

print( "Hello" + " John" + " !")

a = "Hello, World!"
print(len(a))

import sys
print(sys.version)

print("This will be printed")


frint("This will cause an error")
print("This will NOT be printed")

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)

name = "Michael Jackson"


print(name.find('el'))

name = "Michael Jackson"


print(name[2])

my_string="This is a mountain!"
new_string = my_string.replace("This", "It")
print(my_string)
print(new_string)

Output:

Explanation:

Write the following algorithms, also draw the Flowcharts 6 marks


1. Algorithm to add two numbers.
2. Algorithm to find the velocity of a moving object (Hint: 𝑣 = 𝑑𝑡).
3. Algorithm to check positive or negative numbers.
4. Algorithm to find the volume of a cylinder (Hint: 𝑉 = 𝜋𝑟 2ℎ).
5. Algorithm to calculate sales tax on an item sold (Hint: 𝑆𝑎𝑙𝑒𝑠 𝑇𝑎𝑥 = 𝑐𝑜𝑠𝑡 𝑜𝑓 𝑖𝑡𝑒𝑚 × 𝑠𝑎𝑙𝑒𝑠 𝑡𝑎𝑥 𝑟𝑎𝑡𝑒 ).
6. Algorithm to calculate the grade of each student.

You might also like