Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

BK Birla Institute of Engineering & Technology, PILANI

Expesimard I
//1. odtaut Rasphwvy Rand dey vouisus linus command,
incommard teuminal window
s, cd, touch, mv, Hm, nman, mkdir, mdir, tar, gzip, cat,
more, less, ps, Sudo, cOn, chown, charp ping et.

"touch8 Guate a nw. fle or updak is timustamp.


Syntax tbuch [oP TioN.. [FILEJ
Example s Guale empty fles callad 'Alel'and 'fle 2'.
$. touch flel Rle2
.cat88 Concatenate Ales and pint to stdout..
syntax ?cat [oPTION.- [FILE)
Example &Geak flel with enered conternt
$cat > flel
Hello
^D

" cpi Copy fles


Sntaxi cp[oPtioNJ sowe destination.
Eamplki Gpy conkat fom flel to fle2 and conteajs
< filel setainad.
$ep flel fle 2
mv8 Move
fla
syntax& voPTIONJ Sauxca dastination
Bompei aove fles called flel and fle2.
f mv flel file2
BK Birla Institute of Engineering & Technology, PILANI

om Rmove fles and dinu ctories


SynBaxi m [opTION]. [FILE]
Example Delete Alel
$ m flet
mkdia &Hake diuctony
syntax? mt dir [o PT1O N dieetory
Exanpl1i Guate diactory called di
$ mtdir dirl

m dir &Remoue a directoy


Syntax mdiy loerioNJ diueetory
.Examp i. Ramavediuetory colld dil
$ mdir dial

cds Change disckny


syrtox.& cd [oPTIQNT dt ckony
Eramplei. Chang wosking dicekory to olirl
$ cd dizl
pwd s fit tha presnt woting dicckoy
Cxample Pint diol' ia cuunt coaking dlikacty d
dirl
$ pud
Qutpudi autput
divislan
Ouuti
E'o;3,.:1, nutiplicatio
#A #A
|5 subtacts tA #
An
Acdihian
World
+tello
'a':
2,
'!'i1,
'e'3,
''s,
'm's
ly

II2. BK
(b)Rad Rad(a) Birla
c).woxd acdditian
division#A3*5 subtractian
#A5-5 #A #An
stl&
fuquoy(st):
cha-def (5+5)/2muliplicaian -product
divison,
and
ncict tin/python
print#/usx/ namewit Run Institute
clict.kays()kys =
n two "Hello, seme
and
numbes_andprint of
chaadtr python
Engineering
woald hame

!";
pograj
and
count
print &
Technology,
téY Hele
a
gien
sum,
esage
ating PILANI
Qutputa5
aiaThe
c7

BK
() Birla
print('Te
(s*(s-a) (nput('ntes
Cfoat(
ana btc)2
S(at b=
fleat.a- veeading
shapl
inputcincle) [n]+=l
else :dict
prtnt(charg
uery'gAcaoogle.cometwundict Institute
(Enter
float((
input
mput a of
(sH*(s-) ( gien Engineering
Enkx
iangk shape(ucanye,
thizsecond fistside )
dside&
proprak
valgomus &
is o. side ) Technology.
5
o
4'aa) 0. )
triang
PILANI
and
The entryThe enty
Next Oops,

eeiprocal is2
class
'2evoDivisian
2a
0.5
Esvo
'>ocruud

BK
M3.
(b).Handle Birla
a)Pnnt
break
cxapt 8. tten 0;
byi entyrandom
for importsys nt
main)Lsiny # Jead Run
pi("Next
entry")
pril("Dops! cnn, ,ninit includo Institute
pziri( ) H/int
(entey)
primt"The coutd'"Hello.
Woro\m3
List diided namypacestd; somepytfona
in8
xadomlst-['a', (iostr fom
namentimes, of
hy eam) inpul, Engineering
ertry 0,
sys 2] Zero
s' woipgsarn
ng
excmfol)
ertry) ezuphm.
for whwLTechnology. &
[o"accurcd and nam an
f
whilk ike
and
&
PILANI
loops. n
)
ve
Qutaut
Enttrfle Datpat
i
d:h:m:STnput
Jumber
ime

of
name
catal,txt |4;6:56 in
lines?
seeonds
1 5

:
1234
565

BK
() Birla
print(nunlines)
point("Number -.widhnum-
ines 0 (ount
each
in. d). hous
frame Read pint(seCons
time60 day ime Pint Institute
seionds.i0
lines
+=|
r)asf8
num nane,
opon a "dah& iu time lot cwed
input(" fle l Il ( of
36
(293600) input Engineering
line ma 00
Ente u
S’ tim("Irput ne
lines")8 by
fox
file od o=
ne imu IO
360O &
name8 ) od: ime tswith
and = Technology.
minuss tiu
print od second; in
s yo
=(24
mindes, d fm
thuseords)
/(day, "3500) ? intrsval n
II "))
PILANI
word 60
tirna
hout, ,
BK Birla Institute of Engineering & Technology. PILAN!
xpeximnt -TV
Mt. @ight an LED hrough yhom pogramß.
In Raspbevy
A Bsceadboaud
fi sunning kaspbiarn,
An.LED
A330 ohm...esis tor
ode 8
import Rit GPIO.as
import time
GflQ.setmode(G PIO. BCM)
hPlC. sctwoinga (False)
aPlO. setup(18, GPIO. 00T)
print"LED on"
GPlo. output (18, GPIO. HlGaH)
Hima, sleepi)
print "lED
aPI0. output(i8, GPIQ.LOw)
(b)yt înput rom two swi tches and suitch an
caupondirne LEDs.

Cormponeny
Raspbey R.
Breadboad
*
LED
J*Buton.

Junper wincs
BK Birla institute of Engineering &Technology, PILANI
StepI8 Buils tie Circuit
StepllaChange iuctory and wuitethe prgr an
Python,
#uso/ bin/ env python kfpet
impost RP. GPIo as GPIo
impat time

ted Pin>|!
Btn Pin=/2

led_status =l

def sekup);
GaPlO.setmode( GPlO, BOA RD)
GPI0. setupl ledPin, GPlo. oUT)
GPlo.schypl Bin Pin, Ga Pr0. INypulupdoum- GPIO. PuD
GPIO. ouput(ledPin, GPI0. HIGH) UP)
def suled (=None8
qlobal led-status
led-status = not ledstatus
GPIO.outputl Led Pin, Ledstahus)
-iled-status. = = la
print led of
else i
pRt print.. ed on'
def loapl:
BK Birla Institute of Engineering & Technology. PILANI

GPlo. odd- event- detect (Bto Pin, GPl0. FALLING


callback = suled, bounutne =Q00)
ohile Toue &
tinu. sleep)
def destroy()8
GPIO.output(Led in, GPIo. HIG.H)
GPlo. chaup()
ifname ==!main'
sPtupl)
tbys
exupt KeyboasdIntuupt
dustroy ()
Step III 3.Run
(c) .Flash..an LED at. a given anime and c fim
cyca, whis thetwo fimes are taken from a fle.

Components rcquired i
oneled
l00 ohm usiston
Jumper ables
inport tane
impatRli GPIOao GPIO
GPIO. sehnode GPIO. BOARD)
GPIC. setup( ll, GPIO. oUT)
whileTauc6.
BK Birla Institute of Engineering &Technology, PILANI

GPlo. output (11, Tue)


timt slecp()
GPI0. output (I1, False)
tim. Sleep(1)
To Tun codde, Press Cl +F5
The led wll stat tliingmow.

You might also like