0% found this document useful (0 votes)
48 views76 pages

PRPCOEM-IoT Lab-II Manual - Students

IoT lab manual II

Uploaded by

arpawade
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)
48 views76 pages

PRPCOEM-IoT Lab-II Manual - Students

IoT lab manual II

Uploaded by

arpawade
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/ 76

P. R.

POTE (PATIL) EDUCATION & WELFARE TRUST’S


GROUP OF INSTITUTIONS,

COLLEGE OF ENGINEERING & MANAGEMENT,


AMRAVATI.

DEPARTMENT OF ARTIFICIAL INTELLIGENCE & DATA


SCIENCE ENGINEERING

Year: 2022-23 Semester: Fourth

SUBJECT: C-Skill Lab-II


Institute Vision Mission
Mission
 To flourish as a center of excellence for producing the skilled technocrats
and committed human beings.
Vision

 To create conducive environment for teaching &learning.

 To impart quality education through demanding academic programs.

 To enhance career opportunities by exposure to Industries & recent


technologies.

 To develop professionals with strong ethics and human values for the
betterment of society.

Department of Artificial Intelligence & Data Science.

Vision
To achieve the excellent standard of quality education by using transcending the
process of integrating intelligence to Technology Products and Processes by
architectural and algorithmic solution building procedures resulting autonomous
entities which shall surpass collective human intelligence in society.
Mission
 Engage learners to develop competency in Data centric algorithmic
approaches in resolving complexities of real time problems.
 Help pupils to develop competency in creative and architectural solution
building processes for building efficiencies in artificial intelligence.
 Scaling up the process of creating digital learning content in the realm of
AI & DS underpinning the theories of cognitive science and virtual /
Augmented reality techniques.
Program Educational Objectives (PEOs)
 Graduates will have the capabilities to apply AI&DS knowledge to
develop feasible systems.
 Graduates will be able to handle the challenges of rapidly changing
technology.
 Equip the graduates with strong technical knowledge, competency
in soft skills, lifelong learning skills that allow them to contribute
ethically to the need of society.
Department of Artificial Intelligence & Data Science Engineering

Certificate

This is to certify that

Mr./Ms…………………………………………………………...

of …...………… Semester of Bachelor of Engineering in ………………………………

Engineering of P. R. Pote (Patil) College of Engineering & Management,

Amravati, has completed the term work satisfactory in subject

……………………. for the academic year 2022- 2023 as prescribed in the

curriculum.

Place………………… PRN No……………………

Date………………… Roll No……………………

Prof. A. R. Pawade Dr. V. B. Gadicha


Subject Teacher Head of the Department
Academic Year: 2022-23 Course: AI&DS

Subject & Code: C-Skill Lab-II (4AD09) Semester: 4th

Name of Faculty: Prof. Aniket R. Pawade

Name of Student:

PRN No: Roll No:

Sign of
Title of the Date of Date of Assessment Teacher
SN.
Practical / Experiment Performance Submission Marks (15) and
Remarks
Study Raspberry Pi and its
1
component.
Study Arduino and its
2
component.
3 Learn how to install Raspberry
Pi
Learn configuration settings of
4
Raspberry Pi
Start Raspberry Pi and learn
5 the basics of editor and
Raspberry Pi infrastructure
Start Raspberry Pi and try
various Linux commands in
command terminal window ,
6 Such as: ls, cd, touch, mv, rm,
man, mkdir, rmdir, tar, gzip,
cat, more, less, ps, sudo, cron,
chown, chgrp, ping etc.
Write a program to Read your
7 name and print Hello message
with name in python.
Write a program to Read two
8 numbers and perform all
arithmetic operations in python.
Write a program to do Word
9 and character count of a given
string in python
Write a program to calculate
Area of a given shape
10
(rectangle, triangle and circle)
in python
Control Raspberry Pi via
11
Telegram Messenger.
12

Signature of Faculty
INSTRUCTIONS FOR STUDENTS
Students shall read the points given below for understanding the theoretical concepts
and practical applications.
1 Listen carefully to the lecture given by teacher about importance of subject,
curriculum philosophy, learning structure, skills to be developed,
information about equipment, instruments, procedure, method of continuous
assessment, tentative plan of work in laboratory and total amount of works to
be done in a semester.
2 Student shall undergo study visit of the laboratory for types of equipment,
and material to be used, before performing experiments.
3 Read the write up of each experiment to be performed, a day in advance.
4
Organize the work in the group and make a record of all observations.
5
Understand the purpose of experiment and its practical implications.
6
Student should not hesitate to ask any difficulty faced during conduct of
practical /exercise.
7
Write the answers of the questions allotted by the teacher during practical
hours if possible or afterwards, but immediately.
8 The student shall study all the questions given in the laboratory manual and
practice to write the answers to these questions.
9 Student should develop the habit of pear discussion / group discussion
related to experiments / exercise so that exchanges of knowledge / skills
could take place.
10 Students shall attempt to develop related hands-on-skills and gain
confidence.
11 Student shall focus on development of skills rather than theoretical or
codified knowledge.
12 Student shall insist for the completions of recommended Laboratory Work,
answers to the given question etc.
13 Student shall develop the habit of evolving more ideas, innovations, skills
etc. that included in the scope of the manual.
14 Student shall refer technical magazines, proceedings of the Seminars, refer
website related to the scope of the subjects and update their knowledge and
skills.
15 Student should develop the habit of not depend totally on teachers but to
develop self-learning techniques.
16 Student should develop the habit to interact with the teacher without
hesitation with respect to academic involved.
17 Student should develop habit to submit the practical’s exercise continuously
and progressively on the schedule dates and should get the assessment
done.
18 Student should be well prepared while submitting the write up of the
exercise. This will develop the continuity of the studies and he will not be
overloaded at the end of the term.
LABORATORY INSTRUCTIONS

 Students must present a valid ID card before entering the computer


lab.
 Playing of games on computer in the lab is strictly prohibited.
 Before leaving the lab, users must close all programs positively and
keep the desktop blank.
 Users are strictly prohibited from modifying or deleting any important
files and install any software or settings in the computer
 Based on the prime priority, users may be requested by the lab in-
charge, to leave the workstation any time and the compliance is a
must.
 Internet facility is only for educational/ study purpose.
 Silence must be maintained in the lab at all times.
 The lab must be kept clean and tidy at all times.
 If any problem arises, please bring the same to the notice of lab in-
charge.
 Lab timing will be as per the academic time table of different classes
 Every user must make an entry while entering in the Computer Lab
and also at the time of exit from the lab.
 Students are not allowed to use personal Pen Drives, CDs, DVDs etc.,
in a Computer Lab. Only prescribed official Pen Drives, CDs, DVDs
etc. will be used in the Computer Lab to avoid VIRUS in Computers.
 Users must turn-off the computer before leaving the computer lab.
 In case of theft / destruction of the computers or peripherals, double
the cost of the lost will be charged from the student/user.
 Computer Lab Assistants are available to assist with BASIC computer
and software problems. They are not tutors and will not tell you how to
complete your assignments.
 Unauthorized copying and/or installing of unauthorized software is not
permitted. This may be a violation of copyright laws.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Lab Course Outcomes

After successful completion of laboratory course, the students will able


to

Outcomes
SN
1. Raspberry Pi and Arduino hardware/software
2. Raspberry Pi and Arduino hardware/software
3. Basic operations of handling data
4. Code to perform string and numeric operations on given user input
5. Describe IOT(Internet of things).

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
EXPERIMENT NO. 1

AIM: Study of Raspberry Pi and its component.


LEARNING OBJECTIVE: -

 To get familiar with raspberry pi board.

 To understand how to function every component.

LEARNING OUTCOME:

 Students will able to identify different components on pi board.

HARDWARE/SOFTWARE REQUIRED:
SN Name of Software Tool Specification
1 Raspberry Pi Board Model B (1 GB RAM)
2 Micro SD Card, Card Reader & Adapter

INTRODUCTION:

Raspberry Pi is the name of a series of single-board computers made by the


Raspberry Pi Foundation, a UK charity that aims to educate people in computing and
create easier access to computing education.
The Raspberry Pi is a very cheap computer that runs Linux, but it also
provides a set of GPIO (general purpose input/output) pins, allowing you to
control electronic components for physical computing and explore the
Internet of Things (IoT).
There have been many generations of the Raspberry Pi line: from Pi 1
to 4, and even a Pi 400. There has generally been a Model A and a Model B
of most generations. The Raspberry Pi operates in the open source
ecosystem: it runs Linux (a variety of distributions), and its main supported
operating system, Pi OS, is open source and runs a suite of open source
software. The Raspberry Pi Foundation contributes to the Linux kernel and
various other open source projects as well as releasing much of its own
software as open source.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
DIAGRAM:

Components of RASPBERRY-PI:
Micro-USB Power Supply: A 5V micro USB typically powers the Raspberry
Pi. But how much current (in milliamps or amps) the Pi requires to function
depends on your usage.
The recommended amount is between 700mA for a Raspberry Pi Model A,
and up to 2.5A for a Raspberry Pi 3 Model B.
The Raspberry Pi boards typically draw much lower amounts, between 200
and 500mA.
Usage depends on what you’re doing with the Pi. Playing video and
browsing the web draws more power than idling and booting. It also
depends on what devices you have connected; some keyboards and mice
draw more power than others.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
SD Card Slot: Secure Digital Card slot (SD Card) slot is a solid-state
removable storage device which is required to run operating systems on
Raspberry Pi as Raspberry Pi doesn’t have any onboard memory and data
storage functionality. Raspberry Pi supports both SDHC (Secure Digital High
Capacity) and SDXC (Secure Digital extended Capacity). The best suited
card for proper running of all sorts of operating systems without any hiccup
is Class 10 with speed @ 10MB/sec.

USB Ports & Ethernet Port:


USB Port: The number and type of USB ports on Raspberry Pi depends on
the model. The Raspberry Pi Model B is equipped with two USB 2.0 ports; the
B+, 2B, 3B and 3B+ have four USB 2.0 ports. The Pi 4 has two USB 2.0 ports
and two USB 3.0 ports.
In all models prior to the Pi 4, the USB ports connect to a combo
hub/Ethernet chip, which is itself a USB device connected to the single
upstream USB port on BCM2835. On the Pi 4, the USB hub chip is connected
to the SoC using a PCIe bus. On the Model A and Zero range, the single USB
2.0 port is directly wired to the SoC.

Ethernet Port: In order to enable Internet connection online and to update


the software’s or to install latest packages from online repositories,
Raspberry Pi supports Ethernet Connection. Raspberry Pi (Every Model)
comprise of RJ45 Ethernet Jack which supports CAT5/6 cables. It enables
Raspberry Pi to be connected to Wireless Router, ADSL Model or any other
Internet connectivity sharing device.
HDMI (High Definition Multimedia Interface): HDMI Port enables
Raspberry Pi to be connected to HDTV via HDMI cable. Raspberry Pi
supports maximum resolution of 1920x1200. With the help of HDMI Full HD
MPEG-4 can be streamed via HDMI.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Video Out (RCA Cable): In addition to HDMI Connectivity which facilitates
HD connection, Raspberry Pi also has provision to be connected to standard
monitor or TV using RCA video cable. RCA cable is less expensive as
compared to HDMI but along with RCA cable, the user has to buy 3.5mm
stereo cable for audio facilitation.
The Pi Model B+, Pi 2, Pi 3 and Pi 4 features a 4-pole 3.5mm audio jack which
also includes the composite video signal. This has allowed for the removal of
the composite video socket found on the original Model B.
The new jack is a 4-pole socket which carries both audio and video signals.
It’s similar to sockets found on other multimedia devices such as iPods, MP3
players and smart-phones. It now used on the A+, B+, Pi 2, Pi 3 and Pi 4.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Status Led’s: Raspberry Pi comprise of 5 main LED’s performing the
following functions:
ACT: (Color-Green): The main function of ACT LED is to show card status.
Normally flashing during any SD Card activity performed by end user.
PWR: (Color-Red): The main function of PWR led is power. This led is
continuously ON when raspberry Pi is switched on and keep on till switched
off.
FDX: (Color-Orange): The main function of FDX led is full duplex. This Led
is powered on when Ethernet connection is of Full Duplex type.
LNK: (Color- Orange): The function performed by LNK led is Link. This LED
is powered on when Ethernet connection is established and packet transfer
starts taking place.
100: (Color-Orange): The 100 Led objective is to show 100 Mbps
connection. When any connection is established at Ethernet port, this LED
only gets on when connection is of 100 Mbps speed and gets powered off
when connection is at 10 Mbps.
GPIO (General Purpose Input Output): GPIO facilitates connecting all
sorts of peripheral devices to Raspberry Pi. Raspberry Pi has onboard GPIO
with 40 pins, 26 of which are used as digital inputs or outputs. More
importantly, 9 of the 14 new GPIO pins are dedicated inputs/outputs, it also
facilitates the onboard UART, I2C, SPI Bus and still large amount of free GPIO
pins are there for add-on attachments.

CSI Camera Connector: Raspberry Pi has a Mobile Industry Processor


Interface (MIPI) Camera Serial Interface Type 2 (CSI-2). CSI-2 facilitates
connection of small camera to Broadcom BCM 2835 processor. The function
of this interface is to standardize the attachment of camera modules to the
processors for the mobile phone industry. MIPI CSI-2 version 1.01 supports
upto 4 data lanes, and each lane carries 1 Gbps bandwidth. The D- PHY
specification defines the physical hardware layer interface between camera
and processor to facilitate fast exchange of data.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
System On Chip (SoC): Raspberry Pi (System on Chip) SoC is ARM Based
by Broadcom Technologies. The ARM processor runs from 700 Mhz to 1 Ghz.
The SoC also facilitates videocore 4 GPU, and is capable for fast 3D core,
openGL and supports Blueray and H.264 video playback.

RESULTS:

CONCLUSION:

ASSESSMENT SCHEME:
Pre-Lab In Lab Post Lab Record Total
Test performance Test (5) (15)
(2) (5) (3)

Signature of Faculty

LIST OF PRE-LAB QUESTIONS/MODEL ANSWERS:

1 What is Raspberry Pi?


2 Does Raspberry Pi need external hardware?
3 What is the NOOBS Software all about?
4 What are the advantages of raspberry pi?
5 What is the language used by Raspberry Pi?

LIST OF POST-LABQUESTIONS/MODEL ANSWERS:

1 What is the Ethernet/LAN cable used in RPi?


2 Which instruction set architecture is used in Raspberry Pi?
3 What are the distributions are supported by raspberry Pi?
4 What are the different components of a Raspberry pi board?
5 How many GPIO pins does raspberry pi model B+ have?

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
EXPERIMENT NO. 2
AIM: Study Arduino and its component.

LEARNING OBJECTIVE: -

 To get familiar with Arduino board.

 To understand how to function every component.

LEARNING OUTCOME:

 Students will able to identify different components on pi board.

HARDWARE/SOFTWARE REQUIRED:
SN Name of Software Tool Specification
1 Arduino Board Uno

2 USB Cable, Adapter

INTRODUCTION:
Arduino is a prototype platform (open-source) based on an easy-to-use
hardware and software. It consists of a circuit board, which can be
programed (referred to as a microcontroller) and a ready-made software
called Arduino IDE (Integrated Development Environment), which is used to
write and upload the computer code to the physical board.
Arduino provides a standard form factor that breaks the functions of the
micro-controller into a more accessible package.

The key features are −


 Arduino boards are able to read analog or digital input signals from
different sensors and turn it into an output such as activating a motor,
turning LED on/off, connect to the cloud and many other actions.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
 One can control your board functions by sending a set of instructions to
the microcontroller on the board via Arduino IDE (referred to as
uploading software).
 Unlike most previous programmable circuit boards, Arduino does not
need an extra piece of hardware (called a programmer) in order to load a
new code onto the board. You can simply use a USB cable.
 Additionally, the Arduino IDE uses a simplified version of C++, making it
easier to learn to program.

DIAGRAM:

COMPONENTS ON THE ARDUINO BOARD:

An Arduino development board consists of the core microcontroller with its


supplementary components and the necessary circuitry to communicate with
the PC which we will be using for both communications as well as
programming the microcontroller. For communication or programming
purposes, use of a USB to TTL converter.
Components will vary from board to board, depending on the Controller
used and features. Here we will be looking at an Arduino Uno as an example.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
USB - B Socket
The USB socket on the UNO has two functions. One is for communication, to
connect with the computer through a USB port, and also to load the firmware
into the Arduino with the help of the bootloader. The second is to power the
Arduino.
ISCP Pins
In the UNO you can find two 6 pin connectors. One is near the USB – TTL
Chip and the other one is at the end of the board. These pins are used to
program those two microcontrollers. The USB – TTL chip on this board is an
ATMgega16U.
Reset Button
As the name indicates this tactile switch is used to reset the ATMega328
microcontroller. It’s connected to the PC6/Reset pin, which is pulled up
through a 10K. When the switch is pressed the pin is pulled to the ground
and the chip will reset.
USB-TTL Interface Chip
To communicate with the computer, the Arduino relies on a USB-TTL
interface. In UNO, ATMega16U with custom firmware act as a USB – TTL
interface chip.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Crystal Oscillator/ Ceramic resonator
For a microcontroller to work it needs a clock source. The clock circuit
determines the speed with which the microcontroller operates. How many
instructions per second it will execute is dependent on the clock frequency.
The ATMega series microcontrollers can use two types of clock sources. One
is an internal RC oscillator that is already built into the microcontroller.
Power Path control
an LM358. It’s used as a comparator to control the input power path. When
the input power is provided through the barrel jack or Vin pin the power
path control circuit will cut off the USB power pin from the circuit which in
fact will protect the USB port.
Voltage Regulator
The ATMega328 and ATmega16U2 have a maximum input voltage of around
5V and most modules or accessories work on either 5V or 3.3V. The Arduino
can accept 7-12V through the Vin pin or the DC barrel jack. So, to step it
down, there are two regulators onboard. One is a 5V regulator (marked as 1)
for the microcontrollers and the other one is a 3.3V regulator which is used
to provide 3.3V through 3.3V pin.
DC Barrel Jack
The DC barrel jack is used to supply power to the UNO. We can supply 7-
12V through it and hence we can use a 12V DC adapter or 9V DC adapter on
this Jack to power the Arduino board.
Digital and Analog I/O
The Arduino UNO has 14 digital I/O pins and 6 Analog inputs. The digital I/O
pins are 5V logic level and you can also use the Analog pins as digital I/O
too. Arduino UNO supports 6 channel 10-bit ADC inputs through A0-A5,
which can be sampled and analyzed using UNO.
Status LEDs and Inbuilt LED
Uno has 4 LEDs onboard. One is used as a power indicator and two are used
to show the activity of the Rx and Tx pin. The other one is tied to the Digital
pin 13, which can be used to test the Arduino board or simply as an indicator

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
ATMega328P – The Brain
UNO uses a 28Pin DIP version of ATMega328P. Atmega328P is pre-
programmed with a bootloader that allows you to directly upload the
program to Arduino through USB without the need for an external
programmer.

RESULT:

CONCLUSION:

ASSESSMENT SCHEME:
Pre-Lab In Lab Post Lab Record Total
Test performance Test (5) (15)
(2) (5) (3)

Signature of Faculty

LIST OF PRE-LAB QUESTIONS/MODEL ANSWERS:

1 How is Raspberry Pi different from Arduino?


2 The Arduino has __________ output and input ports
3 What is Arduino?
4 What language is a typical Arduino code based on?
5 What is the microcontroller used in Arduino UNO?

LIST OF POST-LABQUESTIONS/MODEL ANSWERS:

1 Arduino IDE consists of 2 functions. What are they?


2 What is the use of the Arduino.h header file?
3 What is the use of the Vin pin present on some Arduino Boards?
4 What is the difference between an IDE and a compiler?
5 What type of signal does the digitalWrite() function output?

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
EXPERIMENT NO. 3
AIM: Learn how to install Raspberry Pi

LEARNING OBJECTIVE: -
 To understand different software required for operating system
installation.

 To understand process of operating system installation.

LEARNING OUTCOME:

 Students will able to install different operating system for raspberry pi.
SOFTWARE/HARDWARE REQUIRED:
SN Name of Software Tool Specification
1 Operating system image file Rasbian
2 Raspberry pi imager
3 SD card formatter
4 SD Card 32 GB Class-10
5 SD Card Reader

THEORY:
The Raspberry Pi is a mini computer specifically created to make tech
learning easier. It has a lot of components for computer-based projects,
like USB ports, an Ethernet port, an SD card slot, Wi-Fi antenna ports, and
more. A single-board computer, Raspberry Pi can be used to perform
various computing tasks. Just like any other computer Raspberry Pi also
requires an operating system to perform different operations/tasks. There
are multiple operating systems that can be installed on Raspberry Pi such
as Raspberry Pi OS, tiny core Linux, RISC OS, and many others.

PROCEDURE:

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
1. Put the SD card into the card reader and connect it to a laptop or PC.
2. Download the Raspberry Pi Imager from the link. Here, I have
installed the windows version, if you are using macOS or Linux, you
can download the respective version.

3. Once the downloading is finished, open the Raspberry Pi Imager


Application on the desktop.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
4. Then click on the “CHOOSE OS” option.

5. A drop-down list of operating systems will appear on the screen from


which you have to select the desired OS. If you want to install the
official Raspberry Pi OS, click the first option.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
6. If your desired OS is not in the list then, you can click on the “Use
custom” option to load the image of the desired OS.

7. But before this, make sure to download the image of your required OS
from the official website.

https://www.raspberrypi.com/software/operating-systems/

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
8. Now click on the “CHOOSE STORAGE” option.

9. If your card reader is connected correctly, it will be displayed as a


mounted device, click on it.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
10. Then finally click on the “WRITE” button to write the image of the OS
onto the SD card.

As soon as you click on the “WRITE” button, a warning will appear on


the screen to inform you that all the previous data on your SD card will
be erased.
11. Click “YES” to continue writing the image onto the SD card.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
The image writing process will start and it is going to take some time to
complete as it downloads the image and write it on the SD card.

12. After some time, a prompt will appear on the screen to inform you that
the process is completed and the USB device (card reader) can be
removed. Click on the “CONTINUE” button to safely remove the card
from the system.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Insert the SD card into the Raspberry Pi device and after some setup, the

Raspberry Pi OS is ready to be used on the device.

RESULTS:

CONCLUSION:

ASSESSMENT SCHEME:

Pre-Lab In Lab Post Lab Record Total


Test performance Test (5) (15)
(2) (5) (3)

Signature of Faculty

LIST OF PRE-LAB QUESTIONS/MODEL ANSWERS:

1 In how many volts does raspberry pi runs?


2 Which different hardware & software required for OS installation
3 Are we likely to confront any overheating problems with
Raspberry Pi?
4 What is the language used by Raspberry Pi?

LIST OF POST-LABQUESTIONS/MODEL ANSWERS:

1 Explain the installation process with flow chart


2 What are all the distributions which are supported by Raspberry
Pi?
3 Can Raspberry Pi be used as a server?
4 What are GPIO pins used in Raspberry pi boards?

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
EXPERIMENT NO. 4
AIM: Learn configuration settings of Raspberry Pi.
LEARNING OBJECTIVE: -
 To understand different raspberry pi configuration.

LEARNING OUTCOME:

 Students will able to configure raspberry pi by own.


SOFTWARE/HARDWARE REQUIRED:
SN Name of Software/Hardware Tool Specification
1 Raspberry Pi board
2 Installed operating System Micro SD Card

THE RASPBERRY PI CONFIGURATION TOOL:

THE RASPBERRY PI is designed to be as controllable as possible, through


the editing of configuration files found in the /boot and /etc directories on
the SD card but these files can seem dauntingly complex.
. The Raspberry Pi Configuration tool is designed to solve this problem.
Offering access to the majority of common configuration tasks through a
simple menu-based interface, the Raspberry Pi Configuration tool makes
it easy for newcomers to adjust system performance, change the memory
split, alter overscan settings, or simply change the keyboard layout.

RUNNING THE TOOL:


There are two ways to run the Raspberry Pi Configuration Tool: from the
desktop, or from the console.
 If you are running your Pi with the desktop enabled, the former is the
easiest: Simply click on the Menu button at the top-left of the screen,
scroll down to Preferences, and then click on Raspberry Pi
Configuration from the pop-out menu that appears.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
 If you are running your Pi without the desktop enabled, an alternative
is to run the console based version of the tool by typing the following
command:
 sudo raspi-config

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
 You navigate the text-based menu of raspi-config using the cursor
keys: The up- and down-arrow keys move the red selection band
through the available options, and the left and right-arrow keys move
between the option list and the Select and Finish buttons below it.
 Use the Enter key to activate an option when it is highlighted by the
red band. The default action is always Select; so if you’ve highlighted
an option in the menu, there’s no need to press the right-arrow key to
choose Select before pressing Enter.

THE SYSTEM TAB

The Raspberry Pi Configuration tool’s window is split into four tabs: System,
Interfaces, Performance, and Localisation. The default tab is System, which
provides a variety of utilities for configuring the Raspbian operating system
to your requirements. One can navigate the window using the mouse: click
on any button to execute that command, click on text boxes to change their
contents, or click on toggles to switch settings on and off.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Password
By default, Raspbian includes a single non-root user account named pi. This
account is used for the day-to-day operation of the Pi, and comes with the
default password raspberry.
Although this is fine for private use, if you have your Pi on a publicly
accessible network—including a Wi-Fi hotspot or other Internet connection
—it’s a good idea to change at least the password, if not also the username,
to improve security, especially given that Raspbian runs a Secure Shell (SSH)
server by default to allow remote logins from the local network.

Hostname
A system’s hostname is the name it uses to identify itself on the network.
When you use the console or terminal on the Pi, you see the hostname as
part of the prompt that accepts your command. Hostnames should be unique,
which can cause a problem if you have more than one Raspberry Pi on your
network. You can change a Pi’s hostname at any time using the Hostname
section of the Raspberry Pi Configuration tool.
When typing a new hostname into the text box in the Hostname section, you
need to be aware of the rules of a hostname. Because hostnames adhere to
an international standard, one of a group of standards known as a Request
for Comments or RFC, certain characters aren’t allowed—a hostname should

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
contain only letters and numbers, although it can include hyphens so long
as they aren’t at the beginning or end, and cannot include spaces.
You can opt for a descriptive hostname, such as living-room-pi, or name
the OK button, but the new hostname won’t come into effect until you reboot
the Pi.
Boot
Normally, Raspbian loads into the graphical user interface known as the
desktop. It does so to ensure that the Pi is ready to use as quickly as
possible. Many common uses of the Pi-including using it as a web server or
for recording video or still images with the Raspberry Pi Camera Module—
work fine at the text-based console, however, without the need to load
the desktop graphical user interface, speeding the time taken to load the Pi
and reducing the amount of memory wasted on software you’re not actively
using.
There are two options in the Boot section: To Desktop, and to CLI. Clicking
on the round radio button next to Desktop will have the Pi automatically boot
into the graphical user interface; clicking on the radio button next to To CLI
will have the Pi remain at the console until the desktop is manually loaded
with the startx command.
Auto Login
By default, Raspbian automatically logs you in as the user pi when the system
is powered on. This makes the Pi ready for use faster, as you don’t need to
log in; it also introduces a potential security concern if you use your Pi in a
shared environment.
Clicking in the box marked Login as user pi to remove the check mark
means that you’ll have to type the username and password in every time you
turn the Pi on or reboot it.
Network at Boot
To make the Pi ready for use as quickly as possible, Raspbian doesn’t wait
for a network connection to come up before continuing the boot process.
Normally, this is fine; if you’re using your Pi to provide certain network
services, though, it can cause issues with applications that load at startup and
expect a network connection that hasn’t yet been made ready.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
To solve this issue, simply click the box Wait for network to add a check
mark. Be aware, though, that this will delay the boot process if a network
isn’t available.
Overscan
Many TV sets feature overscan, which means the visible picture area is
slightly smaller than the transmitted picture. In broadcast TV, this is often
used to hide additional data such as time code information, but in
computing, it can result in the edges of the display becoming hidden. By
contrast, using a TV signal with a modern monitor can reveal the previously
hidden edges with their additional data.
One may need to adjust the overscan for one of two reasons: The image from
your Pi is surrounded by black bars, in which case the overscan needs to be
reduced or disabled altogether; or the image from your Pi extends beyond
the visible edges of your screen, in which case the overscan needs to be
increased.

DISPLAY TAB
The next tab in the Raspberry Pi Configuration tool, labelled Display

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Underscan
Old TV sets had a significant variation in the size of the picture they
produced; some had cabinets that overlapped the screen. TV pictures were
therefore given a black border so that none of the picture was lost; this is
called overscan. Modern TVs and monitors don’t need the border, and the
signal doesn’t allow for it. If the initial text shown on the screen disappears
off the edge, you need to enable overscan to bring the border back.
Resolution
Define the default HDMI/DVI video resolution to use when the system boots
without a TV or monitor being connected. This can have an effect on
RealVNC if the VNC option is enabled.

THE INTERFACES TAB


The next tab in the Raspberry Pi Configuration tool, labelled Interfaces,
allows to enable or disable various ancillary interfaces of the system-on-chip
processor that powers the Pi. This is typically required if you’re adding new
hardware to the Pi, particularly through the CSI or GPIO ports; usually, the
documentation that comes with your new hardware will tell you if enabling a
default-off interface is required. You can toggle any interface by clicking on
the Enabled or Disabled radio button next to its name, but the change will
not take place until you reboot the Pi.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Camera
Enable this interface only if you have a Raspberry Pi Camera Module
attached to your system. If you remove the Camera Module from your
Raspberry Pi, you can disable it again using the same section of the
Raspberry Pi Configuration tool. Although, strictly speaking, this step isn’t
required—having the Raspberry Pi configured for a camera that isn’t
connected will do no harm—it can help to keep things tidy.
SSH
The Secure Shell (SSH) provides a way to use the Pi’s terminal over a
network, creating an encrypted connection between the Pi and any other
computer capable of running an SSH client. This can even be used to control
a Pi that does not have a monitor or keyboard attached—known as a
headless system—or to transfer files to and from the Pi’s storage.
By default, the SSH server on the Raspberry Pi is enabled. If you know you
aren’t going to use SSH, can disable it here to save a small amount of
memory and reduce the chance of your system being attacked on a shared
network. If you do keep the SSH server enabled, be sure to change your
password from the System tab to keep your Pi secure.
SPI
The serial peripheral interface (SPI) is a communications standard used by
the Pi to control or otherwise communicate with external hardware over the
GPIO port. Many add-on boards for the Raspberry Pi require SPI support;
check the documentation included with your hardware to see if you need to
enable SPI support manually through the Raspberry Pi Configuration tool or
whether the vendor has an installation script that will do it for you
automatically.
I2C
The inter-integrated circuit (I2C) interface is similar to SPI, in that it is used
to control or communicate with external hardware via the GPIO port. Add-on
boards that don’t use SPI typically use I2C instead. As with SPI, check the
documentation included with your hardware to see if you need to enable I2C
support manually through the Raspberry Pi Configuration tool or whether
the vendor has an installation script that will do it for you automatically.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Serial
By default, the Raspberry Pi uses the serial connection on the GPIO header
to provide a terminal into which you can log in and control the Pi without a
monitor attached. Some add-on boards use this serial connection for other
purposes, such as driving an external display, in which case the serial
interface needs to be disabled. Before disabling it here, however, check the
documentation for your hardware; some boards need the interface disabled
completely, but others require you to make changes to its configuration
instead.
1-Wire
The 1-Wire interface is yet another alternative to I2C and SPI, offering
connectivity to and communication with sensors and other external
hardware. Typically, 1-Wire is used to connect simple sensors—such as
devices for reading the temperature or humidity of the environment—to the
Raspberry Pi, and is rarely used by add-on boards. If you’re using 1-Wire
devices with the Pi’s GPIO port, make sure to enable the feature here.
Remote GPIO - allow access your Raspberry Pi’s GPIO pins from another
computer.

PERFORMANCE
The Performance tab of the Raspberry Pi Configuration tool provides
settings to increase the computational power of the Pi by overclocking its
processor or increasing the GPU memory. This can help eke out a little more
power from your Pi, but comes with risks.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
GPU Memory
Depending on your Raspberry Pi model, you will have 256MB, 512MB, or 1
GB of memory available to the system. This memory is split between the
system-on-chip’s general-purpose processor, known as the central
processing unit (CPU), and the graphics processor, known as the graphics
processing unit (GPU). By default, 128MB of memory is reserved for the GPU
on most models or 64MB on models with 256MB of memory; the remainder is
given over to the CPU.

Localisation
The Localisation tab provides a way for users in countries other than the UK
to configure the Pi for their needs. By default, Raspbian sets itself to use UK
English language settings, UTC time zone settings, and keyboard layout.
Users in other countries will find that certain keys on their keyboards don’t
type the right characters, particularly those using non QWERTY keyboard
layouts such as AZERTY or QWERTZ.
Locale
Clicking the Set Locale button in the Locale section provides a list of all the
languages, countries, and character sets available to the Pi. The list is
extensive and includes most common languages.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Language
Each language in the drop-down box is named in a particular way. The
letters at the beginning are the language code used by the operating
system, and the name in brackets is a friendly name representing the
language. Scroll through the list with your mouse, and then click on the
language you want the Pi to use as its default.
Country
The language setting is independent to the country setting; it’s possible to
choose a language like Gaelic with a country where it is rarely spoken, such
as Botswana. Use the mouse to choose the country in which you reside, and
then click on your selection to have the operating system tailor certain
settings, such as the way currency is displayed.
Character Set
Each language on a computer has one or more character sets associated with
it. This is the list of possible letters, numbers, and symbols that can be
displayed in that language. Most languages have more than one option here,
but the majority of users will need to select only one: UTF-8, which specifies
the Unicode Transformation Format 8-bit encoding—the most common and
compatible encoding standard.
Confirm your selections in these submenus with the OK button on the Locale
window, and then apply them from the main Raspberry Pi Configuration
window by clicking on its OK button.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
RESULTS:

CONCLUSION:

ASSESSMENT SCHEME:

Pre-Lab In Lab
Post Lab Test Record Total
Test performance
(3) (5) (15)
(2) (5)

Signature of Faculty

LIST OF PRE-LAB QUESTIONS/MODEL ANSWERS:

1 How to run the Raspberry Pi Configuration Tool?


2 What is 1- wire?
3 What is GPU?
4 What is Overscan?

LIST OF POST-LABQUESTIONS/MODEL ANSWERS:

1 What is SSH?
2 What is PERFORMANCE Configuration?
3 List down the components of INTERFACES TAB
4 What is underscan?

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
EXPERIMENT NO. 5
AIM: Start Raspberry Pi and learn the basics of editor and Raspberry Pi
infrastructure

LEARNING OBJECTIVE: -

 To understand different types of editor.

LEARNING OUTCOME:

 Students will able to use different types of editor.


SOFTWARE/HARDWARE REQUIRED:
SN Name of Software Tool Specification Qty. Required
1 Functional Raspberry pi Model B 01

TEXT EDITOR:

A text editor is a software that edits text. They are often used in making
system configuration files and program sketches. There are two kinds of text
editors you can use on a Raspberry Pi – desktop graphical editors and
command-line editors.
DESKTOP GRAPHICAL EDITORS

Desktop graphical editors are text editors that have a GUI (Graphical User
Interface). They are the ones you see on the start menu, but they can be
accessed via terminal as well. More importantly, the main difference
between graphical editors and the following kind is that they require both
mouse and keyboard to operate properly.

Some of the desktop graphical editors that you can use on a Raspberry Pi
are:
 Text Editor
 Thonny
 Geany

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
 Mu
 GVim

COMMAND-LINE EDITORS

Command-line editors, can only be accessed via the command line. These
make them more convenient for embedded applications. Because unlike
desktop graphical editors, command-line editors can be used with only a
keyboard. As an alternative to the point-and-click interface of graphical
editors, command-line editors use keyboard shortcuts.

Some of the command-line editors you can use on a Raspberry Pi are:


 Nano
 Vim
 Vi
 Emacs
MU
Mu is a text editor, and an IDE (Integrated Development Environment)
especially made for Python programming. It is known for being easy-to-use
as its target users are beginner users, just like the Raspberry Pi.
INSTALLING MU
Before you install Mu, make sure your Raspberry Pi OS is up to date by
entering sudo apt-get update and sudo apt-get dis-upgrade in the command
line. There are two ways you can install Mu in your system. The first one is
by accessing the Menu on the top left side of your desktop.
Under the Menu, go to Preferences, then choose Recommended Software.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
A list will pop up that displays all recommended software for the Raspberry
Pi. If you don’t see Mu, just enter Mu on the search bar on the bottom right of
the window.

Click install
After installation, you can start Mu by going to Menu > Programming > Mu.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
can also get Mu by using the CLI (Command Line Interface). On your
desktop, start the terminal by clicking the blackboard icon in the quick
launch toolbar. Alternatively, you can open it by pressing CTRL + ALT + T
In the terminal, enter sudo pip3 install mu-editor to install mu.
You can start Mu by simply entering mu-editor.

MU MODES

The current version of Mu offers four modes. You can change them
depending on what you intend to use Mu for. For now, we are going to use it
for Python programming.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Select the Python 3 mode and click OK.
WRITING CODE IN MU
Let us now write our first program. Copy the line below and save your file.
No need to add .py on the file name as Mu already assumes the file type
when you set the mode to Python 3.
print ("Hello World")

Press Run to execute the program. The output will be visible on an


integrated Python shell below the text editor.

GNU NANO
GNU Nano is the native text editor of most Linux distros. It’s easy to use and
offers a myriad of keyboard shortcuts, which are useful when writing in a
computer’s CLI (Command Line Interface).
Nano comes with the Raspberry Pi OS as default, and you can start it by
simply entering nano.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
The best thing about Nano is that it is very convenient. You type text directly,
and the keyboard shortcuts are always visible. The carets on the shortcuts
stand for the CTRL button. So, for example, if you need help, just press CTRL
+ G. Same goes with the other shortcuts. If you want to cut a selected text,
simply type CTRL + K.
One thing to note about, though, is that cutting and pasting using Nano
shortcuts won’t let you get the text out of Nano to another software and vice
versa. To do that, you must press the Shift and Right Click button. This will
bring out the usual copy-cut-paste options you see on standard word editors.
Using these, you can get the text in and out of Nano.
wrote a sample text for demonstration and saved it using the shortcut
CTRL+O.
To quit nano you can use CTRL+X.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
RESULT:

CONCLUSION:

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
ASSESSMENT SCHEME:

Pre-Lab In Lab Post Lab Record Total


Test performance Test (5) (15)
(2) (5) (3)

Signature of Faculty

LIST OF PRE-LAB QUESTIONS/MODEL ANSWERS:

1 What is editor?
2 List the Desktop based editor?
3 List the Command line based editor?
4 How IDLE differ from editor

LIST OF POST-LABQUESTIONS/MODEL ANSWERS:

1 List down at least 15 shortcut keys used in editor with


description.
2 What is pip?
3 Command to install mu editor
4 How to copy paste in nano editor

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
EXPERIMENT NO. 6
AIM: Start Raspberry Pi and try various Linux commands in command
terminal window, Such as: ls, cd, touch, mv, rm, man, mkdir,
rmdir, tar, gzip, cat, more, less, ps, sudo, cron, chown, chgrp,
ping.
LEARNING OBJECTIVE: -
 To understand the usages of different Linux command.
LEARNING OUTCOME:

 Students will able to execute different Linux command.

 Students will able to understand purpose of every Linux command.


SOFTWARE REQUIRED:
SN Name of Software Tool Specification Qty. Required
1 Functional Raspberry pi Model B 01

Linux Command:
1. pwd: It prints current working directory

2. pwd -P It prints the parent working directory

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
3. mkdir <directory>: It creates an empty directory

4. mkdir -p <directory>: It make parent directories also if it does


not exist.

5. cd .. : It is used to change to the parent directory

6. cd -: It changes to previous directory

7. ls: It lists the content & ls -l: It lists the content in long listing
format

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
8. ls -al: It lists all sub content in long listing format

9. man <cmd> - It shows the manual of command. Eg: man cat

10.touch test.txt - It will create a zero-byte file, if it doesn't exist

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
11.cat - It concatenates the files

● cat <filename> - It dumps the contents of 'key.txt' to STDOUT

mv - It is used to moves files and renames files

12.rm - It removes files/directories

● rm <filename> : It will remove the file.

13.zip: It is used to compress the file


● zip filename.zip *.txt: It compresses the file

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
14.zip -p password filename.zip *.txt : It password protect the file
zip -e filename.zip *.txt

15.unzip : It is used to unzip the zip file

unzip filename.zip *.txt : It unzips the file

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
16.gzip : It compresses the file
gzip : It compresses the file

17.ps : It displays your currently actively processes

18.wget file link : It is used to download file

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
19. ping 192.168.2.200

Chgrp

chgrp command in Linux is used to change the group ownership of a file or


directory. All files in Linux belong to an owner and a group. You can set the
owner by using “chown” command, and the group by the “chgrp”
command.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Chown

Linux chown command is used to change a file's ownership, directory, or


symbolic link for a user or group. The chown stands for change owner.
Linux chmod example

rwx rwx rwx chmod 777 filename


rwx rwx r-x chmod 775 filename
rwx r-x r-x chmod 755 filename
rw- rw- r-- chmod 664 filename

LEGEND
U = User
G = Group
W = World
r = Read
w = write
x = execute

RESULTS:

CONCLUSION:

ASSESSMENT SCHEME:

Pre-Lab In Lab Post Lab Record Total


Test performance Test (5) (15)
(2) (5) (3)

Signature of Faculty

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
LIST OF PRE-LAB QUESTIONS/MODEL ANSWERS:

1 Which command is used to display the operating system name


2 Which command is used to print a file
3 Which of the following command is used to count the total
number of lines, words, and characters contained in a file?

LIST OF POST-LABQUESTIONS/MODEL ANSWERS:

1 The command which is used to remove files.


2 What is the core of the Linux operating system?
3 In which of the following directory does the configuration files
are present?

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
EXPERIMENT NO. 7
AIM: Write a program to Read your name and print Hello message with
name in python.
LEARNING OBJECTIVE: -
 Understand how to implement python program.
LEARNING OUTCOME:
 Students will able to learn python programming concept.
 Students will able to execute python program in raspberry pi IDLE.

SOFTWARE/HARDWARE REQUIRED:
SN Name of Software /Hardware Tool Specification
1 Functional Raspberry pi Model B

Python is a very useful programming language that has an easy to read


syntax, and allows programmers to use fewer lines of code than would be
possible in languages such as assembly, C, or Java.
The Python programming language actually started as a scripting language
for Linux. Python programs are similar to shell scripts in that the files contain
a series of commands that the computer executes from top to bottom.
If you are using the desktop versions of Raspberry Pi OS,
Python will come pre-installed on your system, so skip to the next section. If
you use your Raspberry Pi as a headless device, you can complete the
following steps over SSH.
1. Before we install Python, we should ensure that both our package list
and existing packages are up to date.

sudo apt update


sudo apt upgrade

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
2. next step is to install the Python package to our Raspberry Pi. For this
guide, we will be focusing on Python 3 as it is the currently supported
version.
Run the following command to install Python to your system

sudo apt install python3 –y

or

sudo apt-get install python3

sudo apt-get install idle3

3. Opening The Python Repl

To access the Python REPL (where you can enter Python commands
just like the command line) enter python or python3 depending on
which version you want to use:
python
or
python3

Enter Ctrl-D to exit the REPL.

4. Writing A Python Program


To demonstrate creating and executing a Python program, we’ll make
a simple “hello world” program. To begin, open the Nano text editor
and create a new file named hello-world.py by entering this at the
command prompt:

sudo nano hello-world.py

Enter this code into Nano, then press Ctrl-X and Y to exit
and save the file:

PROGRAMME:

#!/usr/bin/python

person = input ('Enter your name: ')


print ('Hello', person)

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
All Python program files will need to be saved with a “.py” extension. You
can write the program in any text editor such as Notepad or Notepad++, just
be sure to save the file with a “.py” extension.

5. Running A Python Program


To run the program without making it executable, navigate to the
location where you saved your file, and enter this at the command
prompt:
python hello-world.py
6. Make A Python File Executable
Making a Python program executable allows you to run the program
without entering python before the file name. You can make a file
executable by entering this at the command prompt:

chmod +x file-name.py

7. Now to run the program, all you need to enter is:

./file-name.py

Development Environments
The simplest way to create Python programs is to write your code in a text
editor, save it, and then run it from the terminal with the command python
<FILE>.py. You are welcome to continue working through this guide using a
text editor and command line.
Some users prefer to use an integrated development environment
(IDE) when developing code. IDEs offer a number of benefits including
syntax highlighting, code completion, one-click running, debugging hints,
etc. However, most IDEs require a graphical interface to use, which means
you will need to be on the full desktop version of Raspbian.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
IDLE
IDLE is the default Python editor that has been available on Raspbian for
many generations.
Open IDLE by selecting the Raspberry Pi logo in the top-left, and click
Programming > Python 3 (IDLE). You should be presented with the Python
interactive interpreter.

To write a program, go to File > New File. Enter in your code.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Click File > Save As... to save your code to a Python file (don't forget the
.py suffix!). Click Run > Run Module to run your program

Geany
Geany is a great, beginner-friendly IDE that works with many different
languages. However, it does not start up with a Python interactive
interpreter. You can open Geany up by click on the Raspberry Pi logo in the
top-left, and selecting Programming > Geany. Write your code in the file
editor pane.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Save your code, making sure the filename ends with .py.
By default, Geany will attempt to open a new window to show the output of
your code, which may or may not work on the Raspberry Pi. We can change
it to run in the Terminal pane. Click Edit > Preferences. Select the Terminal
tab and click to enable Execute programs in the VTE. Press enter to save and
close the Preferences window

Click Build > Execute (or click the paper airplane icon) to run your code.
You should see the output of your program appear in the Terminal pane of
Geany

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
Thonny
Finally, Thonny is another great, easy-to-use IDE that comes pre-loaded on
Raspbian. It focuses on Python and has an interactive environment when you
load the program. Start Thonny by clicking on the Raspberry Pi icon
followed by Programming > Thonny Python IDE.

Write your program in the top pane, click File > Save as... to save it, and
click Run > Run current script to execute the program. Output will appear in
the bottom interpreter pane.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
RESULT:

CONCLUSION:

ASSESSMENT SCHEME:

Pre-Lab In Lab Post Lab Record Total


Test performance Test (5) (15)
(2) (5) (3)

Signature of Faculty

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
EXPERIMENT NO. 8
AIM: Write a program to Read two numbers and perform all arithmetic
operations in python.
LEARNING OBJECTIVE: -
 Understand how to implement python program.
LEARNING OUTCOME:
 Students will able to learn python programming concept of arithmetic
operations.
 Students will able to execute python program in raspberry pi IDLE
SOFTWARE/HARDWARE REQUIRED:
SN Name of Software/ Hardware Tool Specification
1 Functional Raspberry pi Model B

Python is a very useful programming language that has an easy to read


syntax, and allows programmers to use fewer lines of code than would be
possible in languages such as assembly, C, or Java.
The Python programming language actually started as a scripting language
for Linux. Python programs are similar to shell scripts in that the files contain
a series of commands that the computer executes from top to bottom.
If you are using the desktop versions of Raspberry Pi OS, Python will
come pre-installed on your system, so skip to the next section. If you use
your Raspberry Pi as a headless device, you can complete the following
steps over SSH.
1. Before we install Python, we should ensure that both our package list
and existing packages are up to date.

sudo apt update


sudo apt upgrade
2. Opening The Python Repl
To access the Python REPL (where you can enter Python commands
just like the command line) enter python or python3 depending on

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
which version you want to use:
python
or
python3
Enter Ctrl-D to exit the REPL.
3. Writing A Python Program
sudo nano arithematic.py

PROGRAMME:

# Store input numbers:

num1 = input('Enter first number: ')

num2 = input('Enter second number: ')

# Add two numbers

sum = float(num1) + float(num2)

# Subtract two numbers

min = float(num1) - float(num2)

# Multiply two numbers

mul = float(num1) * float(num2)

#Divide two numbers

div = float(num1) / float(num2)

# Display the sum

print('The sum of {0} and {1} is {2}'.format(num1, num2,


sum))

# Display the subtraction

print('The subtraction of {0} and {1} is {2}'.format(num1,


num2, min))

# Display the multiplication

print('The multiplication of {0} and {1} is


{2}'.format(num1, num2, mul))
# Display the division
print('The division of {0} and {1} is {2}'.format(num1,
num2, div))

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
4. Running A Python Program
To run the program without making it executable, navigate to the
location where you saved your file, and enter this at the command
prompt:
python arithematic.py

RESULTS:
.

CONCLUSION:

ASSESSMENT SCHEME:

Pre-Lab In Lab Post Lab Record Total


Test performance Test (5) (15)
(2) (5) (3)

Signature of Faculty

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
EXPERIMENT NO. 9
AIM: Write a program to Read two numbers and perform all arithmetic
operations in python.
LEARNING OBJECTIVE: -
 Understand how to implement python program.
LEARNING OUTCOME:
 Students will able to learn python programming concept of count &
length.
 Students will able to execute python program in raspberry pi IDLE

SOFTWARE/HARDWARE REQUIRED:
SN Name of Software/ Hardware Tool Specification
1 Functional Raspberry pi Model B

Python is a very useful programming language that has an easy to read


syntax, and allows programmers to use fewer lines of code than would be
possible in languages such as assembly, C, or Java.
The Python programming language actually started as a scripting language
for Linux. Python programs are similar to shell scripts in that the files contain
a series of commands that the computer executes from top to bottom.
If you are using the desktop versions of Raspberry Pi OS, Python will
come pre-installed on your system, so skip to the next section. If you use
your Raspberry Pi as a headless device, you can complete the following
steps over SSH.
1. Before we install Python, we should ensure that both our package list
and existing packages are up to date.

sudo apt update


sudo apt upgrade
2. Opening The Python Repl
To access the Python REPL (where you can enter Python commands
just like the command line) enter python or python3 depending on

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
which version you want to use:
python
or
python3
Enter Ctrl-D to exit the REPL.
3. Writing A Python Program
sudo nano count.py

PROGRAMME:

# initializing string
test_string = "My Branch is AIDS"
# printing original string
print ("The original string is: " + test_string)
# to count words in string
res = test_string.count(" ")+1
# printing result
print("The number of words in string are : " + str(res))
print("The number of Character in string are : ",
len(test_string))

4. Running A Python Program


To run the program without making it executable, navigate to the
location where you saved your file, and enter this at the command
prompt:
python count.py

RESULTS:
.

CONCLUSION:

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
ASSESSMENT SCHEME:

Pre-Lab In Lab Post Lab Record Total


Test performance Test (5) (15)
(2) (5) (3)

Signature of Faculty

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
EXPERIMENT NO. 10
AIM: Write a program to calculate Area of a given shape (rectangle,
triangle and circle) in python.
LEARNING OBJECTIVE: -
 Understand how to implement python program.
LEARNING OUTCOME:
 Students will able to learn python programming concept.
 Students will able to execute python program in raspberry pi IDLE

SOFTWARE/HARDWARE REQUIRED:
SN Name of Software/ Hardware Tool Specification
1 Functional Raspberry pi Model B

Python is a very useful programming language that has an easy to read


syntax, and allows programmers to use fewer lines of code than would be
possible in languages such as assembly, C, or Java.
The Python programming language actually started as a scripting language
for Linux. Python programs are similar to shell scripts in that the files contain
a series of commands that the computer executes from top to bottom.
If you are using the desktop versions of Raspberry Pi OS, Python will
come pre-installed on your system, so skip to the next section. If you use
your Raspberry Pi as a headless device, you can complete the following
steps over SSH.
5. Before we install Python, we should ensure that both our package list
and existing packages are up to date.

sudo apt update


sudo apt upgrade
6. Opening The Python Repl
To access the Python REPL (where you can enter Python commands
just like the command line) enter python or python3 depending on
which version you want to use:
python

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
or
python3
Enter Ctrl-D to exit the REPL.
7. Writing A Python Program
sudo nano area.py

PROGRAMME:

Area of Rectangle=l*b
Perimeter of Rectangle=2*(l+b)
Area of Circule=PI*r*r(PI=3.14)
Circum of a Circule=2*PI*r
'''
len=int(input("Enter the Lenth of rectangle:"))
bre=int(input("Enter the Breadth of rectangle:"))
r=int(input("Enter the Redius of Circle:"))
area1=len*bre
perimeter=2*(len+bre)
area2=3.14*r*r
circum=2*3.14*r
print("Area of Rectangle =",area1)
print("Perimeter of Rectangle =",perimeter)
print("Area of Circle =",area2)
print("Circum of Circle =",circum)

8. Running A Python Program


To run the program without making it executable, navigate to the
location where you saved your file, and enter this at the command
prompt:
python area.py

RESULTS:
.

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23
CONCLUSION:

ASSESSMENT SCHEME:

Pre-Lab In Lab Post Lab Record Total


Test performance Test (5) (15)
(2) (5) (3)

Signature of Faculty

Department of Artificial Intelligence & Data Science PRPCEM, C-Skill Lab-II (4AD09)-2022-23

You might also like