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

Python Ass.1

The document provides examples of Python basics including: 1) How to define comments in Python using # and docstrings. 2) The rules for naming variables in Python which can include letters, digits and underscores. 3) How the input() and print() functions work - input() reads user input as a string and print() prints output to the screen. 4) Examples of type casting in Python using functions like int(), float(), complex(), bool() and str() to convert between data types.

Uploaded by

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

Python Ass.1

The document provides examples of Python basics including: 1) How to define comments in Python using # and docstrings. 2) The rules for naming variables in Python which can include letters, digits and underscores. 3) How the input() and print() functions work - input() reads user input as a string and print() prints output to the screen. 4) Examples of type casting in Python using functions like int(), float(), complex(), bool() and str() to convert between data types.

Uploaded by

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

Unt-1

Assignmen -1
ython Basics -1 PAGE NO.:

Aue iShot uesions...


&iLst out feutuzes of python.
Ans.lfectuses ofpython..
Easy to lecn
Easy to geud
to mentcin
AEusy, bgoud standad
Inteaccive Mode
Potahe
- eoctendable
Oatubases
Scalabiadming
GUl Paog3mning
Suppoxts funchornl and staucued
prograrnming methods
9.2Ho) to dene comments in puthon?
Ans.Comments în python stuzt coth a #
chanuctex Howevex aexnatively at
times. commemting îs done sing
docstainqs, cohich are descaibed
uthexn this ar ticle.
9.3Lst the gules for decazuton ok
python.
Iyeriablesinpyoed
allocoe chonucteas
Ans (i0Th¹ onh
Rython aze alphoabets CA-2),Ca-z
dEats Co to g) Underscote C-).
PAGE NO.:

(2) ldentie should not stuats_coith


d'gits.
C3) ldenteas ae cuse sensiive.
A.4Erolen nutc) function fnn baief.
Ans.thon usex înput fsom the keybard
Cunhe eud using the înputco
built -în unchon.
The gnput from the user is ecad cs a
ting and cun be asiq ned toa
Vaiable

Syntar o inpu () Aunction


nput Cpromt)
Ex ernple of input co kncian
vealhue = nput (" pleqse entex sting:\n")
Q. ocplein printc) AuneRon Sn bief
AnsThe paint( function pints the spedfied
nessaee to the scxeen, ox othex
stundurd
be
cutput deice. The message
LcCan oe c sthny lny other
Lobiecd, the object coill be conve ated
SCTeen.
stiing before coitten to the
PAGE NO.:

Gue. Long Buesiors...


o1 cohet % meaing ol the TYpe eusting 2
Explain type cusfincg funcions of
python.
Ansoe ccn conyext one type vaue to angther
tupe This conuension s Called Tupecasfing
Lox Type coxsion.
The following are veious Inbut unctions
fox
For type custine.
co intC: le cun use this huncion to
Conveyt vehues fom othex types to
nt
>>nt C123.987)
R3
22 nt C1D S
ype emT:Cunt conveyt
Complex to înt
We cun convext faom any tupe to înt
ercept cumplex pe.

Cle ccn use float) funcion to Conveyt


othex type values
alues to float type
PAGE NO.:

Eq. 1) >flodCo)
l0.0
(2) s> flout Cio+s)
TypetroY Can't onuextcomplex
to floct
Weneves coe cre ty taying to convext
s t type to flucat ype compulsay
Lstr should he either
inteqer
loating_point IRBezal ond should be
lspe fsed only in buse- 10.

C8) Compler c
De çem use compler ()CO Auncion to conuext
ate cempter ey eitt other
types to camplex type
eq: cy complex (#o]==> 10+Qj
Q) complex Cio.s)=*> l0.s+ o
coe cen use ths method to convext
and Snto conplex numbex such
that s all he parl end
l be {maginany puxt
PAGE NO.:

()lboolco:

Oe cen use his hunction to_ convext


olhey tupe ualues to bool type.
ku: w boolco) =»felse
(a) boolC) ==> Tnie

cslsto):

ce Cun use this method to convext othex


lhype vayes o stx ype
eq: ) >>> st Co

6e Explain the appliecotforns of python n


detcRl.
Ans ce, developrnent
Cume Develoorment
Scientific and Hmesic ApplRcions
Axtifeial Intelligente ond lachine leuaning
Desktop GUl
Sottouge Developrment
Operating Sysem
PAGE NO.:

entexpaise - level /Gusiness Aeplcations.


Educufion procseams and tacining couses
Lanuage' Developrment
Oeb ap scxcIing Applications
Amage Paocessing and Gucyphic Oesien
Applcuons
S.3 CoRte o deteRled note on Dsex lrnput
and output în python Sn detRl.
Ans Rython usex input fxom the keuboazd
lcan be gead using the inputt
built-n huncson
The Snput from the usex is gecd as
a stinq cnd can be assiened to a
vaicble.

Syatux of Snputc Anchon


input CpxÔmpt)
Gaet fing Dsex Input Sn python
Hexe is C simple ercimple ol getins
the user înput cand printing ît on the
Console
vclue= înput C'please entex staing:ln")
print CEfou enteed lvealue}'
LOtputi pleuse enter a
Aython sing
dou entexed python
PAGE NO.;

Pthon usex input and eOFExror example


cohen coe entex sOF, inputC) uise s
eOfEaxox and tex minates the progrcm
Lets look Cata simple erampl
usingPuchenm
Value input C"plec1se entey an inteqer:ln'
pint Ceyou entexe d lvaluel'
please enter an
intesçri
Tgcae ehcak Cmost ecent cull last)E
le`/Usexs/pankej /Oocuments /
Puchamsoects /Pthonutoaia lRyo/
hello-cooxldusex_nput.pylinet,
in smadule>
Ualue inout Cpleuse entex an
integex:\n')
a ine

You might also like