Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Python

T4TEQ Software Solutions offers a variety of programming, application, and aptitude courses, including Python, Java, and Data Science. The document outlines the syllabus for Python programming and advanced Python topics, covering essential concepts such as control statements, functions, and object-oriented programming. Additionally, it includes practical exercises and interview questions related to Python.

Uploaded by

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

Python

T4TEQ Software Solutions offers a variety of programming, application, and aptitude courses, including Python, Java, and Data Science. The document outlines the syllabus for Python programming and advanced Python topics, covering essential concepts such as control statements, functions, and object-oriented programming. Additionally, it includes practical exercises and interview questions related to Python.

Uploaded by

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

python

~
T4TEQ SOFTWARE SOLUTIONS

T4TEQ SOFTWARE SOLUTIONS


S. /\II Sainh ( ompl cx, P11th111 I l igh Rond Puthur I 1
( tll () J1 I - p I c,,,,o
M.iii '. i11t'u ll I ~l ~lJ .l:Olll \\ t:b \

,4
PYTH'" •, '3 Fi!i. 2 - 32
TUE.Q YITT\".A.Rr SOlllTlO' S

COURSES OFFERED

Programming Courses: Application Courses:


C Programming Office Automation
C-'-+ Programming Advance Excel
Data Structure C#.NET
Core Java .NET l=rarrework
Advance Java Oracle
Python r11s SQL
Advance Python Photos hop
1
l achine Learning 111 ustrator
Data Science Core Id raw
Data Analytics
RProgramming Web Develop Courses:
HTML
Aptitude Courses: css
Corporate Aptitude Javascnpt
8a'1,1:ng - Clerk ASP.NET
Bani<ing - PO Php

Rtprint \fa~ 2022

1 H[Q SOffii,AR[ SOLL TIO'\S,

#5, 1• f Joor, All Szinh Com pin:,

f'uthur High Road, Puthur, Trirh~ _ 17

f1 tttps w v..faccbool: com 14tcq,

\li.in,t;igr.im.wm t4tCijsof1\\i1re1
rATCQ SOFlWARE SOLUTIONS r 11 ti I I I I I 11

INl>I X

2 I h~tLlt°)

Trick~ and Tips <,

Operators 7

5 Operator Exercise

6 Predefined Functions 9

7 Exercise Programs 12

8 Exercise Programs - Report 19

9 Interview Exercises 20

10 Frequently Asked Interview Question 22

11 ASCII Chart 32
r
T4HQ SOffiVARE <;QLLITIONS

SYLLABUS

PROGRAl\ll\11NG IN PYTHONS\ LLABUS

• lntrtiduction to P) thon

• \\ 0rJ..ing 11 ith P) thon

• P) thon Operators

• Control Statements

• Functions

• Strings

• List and Dictionary

• Tuple and Set

• OOPs Concept

• Exception Handling

ADVANCEPROGRAMMINGlNPYTHONSYLLABUS ~

• Brush-up Session

• File Operation

• Multi-Threading

• Python Database

• Regular Expressions

• Email

• Networking

• GUI Programming

• Data Science

• Machine Learning
6

1 2, 4
cl~
nt(I, b. C, d)

[on_true] if[cxpressionJ else [on_false]

Ex.: 2 '"...Multi
Line
String"""

The _ referencce the output of the last


c~~
1
1,111nN Iii 11 1 1,,tU
r,rca sof1WAR[ SOLUTION S

~rrini;! l\lrthocl,
ll, , ,.11p1 l1111
._,nhl\
:inn , t:, 1p1 l ii Ill I l I 1111\ l II 11 11 I 11 I ' li .11 h 11 I l '1 111 111 I l I

1 l 11m,·11 , , 11111 1• 111'1• 111\\1 1 , , ,.


, tr ill!'l " ' ' h hl()
, , .-1lh 11 k nl' th . , h,11 ,1, 1,1 l l{. 111111, 11 u ·111l1ul , 111111•
11111
, ll,1111 1( , ,1h1,'. ,t,11 I r nd) lh 111111, th , 1111111li1·1 111 111111 I H ~1•..:1 ii ll ii \ ,11!11 il l I Ill
11111
111 ,l '-11111!'
,trill L!. l'll\\ 1lk()
lh·111111, ,lll l' lll'lllkd \l' J ,1(1111 11 th l , 111111•
~ir11 1, l'nd,\\ 1th\, ,tluc. -,t.irt. l'lld) Rl'lurns tllll' 11' till' , 111111• ,·1111 , \\llh lh L' ~111•1. il11.: d
\ :tllll'
~iring lindl, ,1lm:. ~tart. c11d) S,·:11l'111' '> th,• ,111111• 1111 11 ,pn 1111.·d ,.,111t1,· 1111d 1~111111 ~
llw pn, 1111111111 \\h1·11· ii 1\,1, 101111d
,uinL! ti.irmnt(\rtlucl . ,aluc2... ) l m111uts spcril'1L·d , nhlL'" 111 n ..,,, 111 1•
,1ri11g.intlc,(, aim:. start. end) SL·:11d11·s thi: sll ing Im :i "Pl'l' il1L·d 1.ilm· ,11,d ll' l11111 s
the position ofwhn1· ii w11, 101111d
,tring. isn lnum() Returns l'rui: if 1111 l'lwrnL' li:1:-. 111 Jill' ... 1,i1ll' illl
alph1111umcric
string.isalpha() Returns rrni: ii' all 1:hni:1l"k'rs in 1111· . . tiinl' :itl' i11 th e
nlphabi:t
string.isdecimal() Rl!turns 'I rue if all ch11r111:t1·rs 111 lhL' slri11g llll'
decimnls
string.isdigit() Returns True if' ull clwraclL'f'S in the string nre digits
string. is identifier() Returns True if the string is nn identilicr
string. is lower() Returns True if all clrnrncters in the siring nrc lower
case
string. isprintable() Returns True if nil characters ill the siring arc
numeric
f. Returns True if' nil characters in the string an:
string. isspace()
'" hitespaccs
string. istitle() Returns True if the string follows the rules of a title
Returns True if all characters in the string arc upper
string.isupperO
case
string.join( iterable) Joins the elements ol' nn iternblc 10 the end or the
siring
string.lower() Converts a string into lower case
string. lstri p( characters) Returns a left trim version or the siring
string.part it ion(value) Returns n tuple where the string is pnrtcd into three
parts
string.replace(oldvalue, newvalue. Returns a string where a specified value is replaced
count) with a specified value
string.rfind(value, start, end) Searches the string for a specified value and returns
the last position of where it was found
string.rindex(value. start. end) Searches the string for a specified value and returns
thi.: last position of where it was found
s1ring.rjust( length. character) Returns a right-justified version of the string
string rpartit ion(\ alue) Returns a tuple where the string is parh:d into tlm:c
parts
'>Iring rspht( separator. max) Splits the string at the spccitied separat0r. and returns
a list
flYTHON 31Pa
ge lo o1
l4HQ SO FTWARESOLUTIONS 3l

Rrturn 111 hi 1, 1111 , c 1 10 11 L'f the "lri1111


Inn ~trql\d1:11 ll l.i ) 11' 11 th c;p1:c.1I 1cd .. p.irntot 1111 ,. ,,.
\p I1I IIIt 1111 ~ • urn
lrlll ' phll t p ~l I ' I, 1111\ l 11 11',l , l
I stt1n11t:- Ill hue hrc1111. 111L ri: 111111 1 h 1
Spllls 11(
~,rru ~rhtlllll ,( Is Cl. iihn,·llll,,1-~lIl
1
lk Iurn<, 1rtl i1 1hc st1111 • 'ii 11t \\1tl1 th P f,
' 1,1
,,\\llh(\ 11110. ~,,111. <,;Ill
~111ll , aim:
- the lr111g
ed ,u.,1011111
l{ c t11t115 n I' 1111111
, 11111 ~lllp(Ch,11,lllll 'i ) • c, . the lo,\ct tu~c bccLirnes the upnn
.s,\np, ens ,,. r
11111' \\\,lpc•a,l() und , ice versa
(.•onvcrts the lir<;I charadcr of cnch \\ ord t , upix-,
~tnng trtk() case
Converts a string mto upp~r ca~c
m,ng upp~r()
I ills the stri11g " 1th a , pcc11icd number ot Ovali.;es at
~,ring zftll( len)
the beginning

Built-in List Functions & Mefltods


S)Ohl\ Description .
rn1p( h~t 1. li,C l Compare~ elements of both lists.

kn(list) G1,es the total length of the list.

ma,(list) Returns item from the list with max value.

min(list) Returns item from the list with min value.

list(seq) Converts a tuple into the list.

S~·ntax Description
list.append(obj) Appends object obj to list
list.count(obj) Returns count of ho\\ many times obj occurs in the list
list.e.\tend(seq) Appends the contents of seq to list
list.index(obj) Returns the lowest index in the list that obj appears
list.pop( obj=list[-1]) Removes and returns last object or obj from list
list.remove(obj) Removes object obj from list
list.re,erse()
Reverses objects of the list in place
Iist.sort([ func])
Sorts objects of list. use compare func if given

Built-in Tuple Functions


S~ntax Description
cmp(tuple I. tuple2) Compares elements of both tuples.
len(luple) Gives the total length of the tuple.
max/tuple) Relurns item from the tuple with max value.
mm(tuple) Returns item from the tuple with min value.
turle(se4) Coll\erts a list into tuple.
U 12

.....nl(ftllUI,)
. . . . . .ll(IIII

i&tllllnm•Jupdate()
)

Rem -I
other peclfltd )
Rlhlml whllhlr - - L.-• _..-, ,_liilill[lll!!llal'IIII-
Retuml whldllr IIIOlhll' NI
Rtluml~th ...
Remov11111 eltrnent hm dr, •
Rtmov11 the lpldW 11 • __. .....
1
Returnl I llt with the ay....-1, t1111 11
lell
IIINrtl Che IJIIIDletriO diAe-
tnodler
Return a let containinJ the onion ~-"'"-:;:;,_
Update the let with lhe IUDOII o/111111t•_11

Dllcription
The copyQ mclbed retul'III I - - ~
dictionary.
The ,lear() method lallOVCI all itmll ima dll
T4TtQ SOFTWARE SOLUTIONS
PYTHON 3jp
age ii
Of 3~
PR \(TICF rxr:«c1s1 :s

Bru!lh-up PrnJ!r:nns in Oprralm,. nIuJ Control Slntrml'nts:


.. I·u1 1:i 1o.:, the rnoh of a Quadrntic l·quat1on .
I. \\ ril~ a pn1gram to ut

-btJbL 4oc
x=
20

Tl'st Case 1: Test Case 2:

J/P: l/P:

-9 -6
20 9
0/P: 0/P:
54 33

2. Write a program to find the biggest & smallest of given numbers using a logical op?
Test Case I: Test Case 2:
I/P: 1/P:
12 17
14 12
17 257
0/P: 0/P:
17 12
257 12

3. Write a program to check whether a triangle is Equilateral. lsosceles, or Scalene.


Equilateral - all sides are equal
Isosceles - any two sides are equal
Scalene - no sides are equal
Test Case 1:
Test Case 2:
1/P:
[/P:
12
17
12
12
I'.!
17
0/P:
0/P:
E4uila1~ral
lslht.:eli:s
PY TIION 3 IPdge
14 Of3~

OLUTIONS
T4HQ ~on WAR( s , ·· 111 he cxp11.:"~cd .I!, ~1111, uf I
• '11 11111111K I I,; , I
' 1'I\ ~
IIll t
111 CIIll
.. ~ \\ Ill·thi:1 vn IIll.! )
\\ I lh,' .1 fun,11,,11. I no,1!1:.tll
, ·t··d
ti \ l11,l •
l )11tpt1 ()/fl J 111c
\flllll' 1111111h·1'
l
!IP · 20 OIi' htbi.!
il''' c.1, 1.' I
, ., 11r · l 7 ·,1tcgi,c11 nu111 bcr.
1,.:-t l ,l~~ - - l th!.! ractoriol of
I" \\ tit.: ,1 r~•( u 1,1, l• fu11dit11l IC1 I llll O/P : 120

. r.:st Case I I P:5 O/P : 3628800


1/P: 10 b•r or not?.
T.:, t Ca~c 2 ber is a happy num e
. fi d the given num • ,
16 \\ nt.: 3 funct,on 10 Ill ➔ I 00 ➔ ,2 + o~+ 02:::: I]
, ,~ ➔ 6--1+-I == 68 ➔ 62+ g2➔ 36 + 64
I E.g. n - 8~ ➔ 8· + - O/P : happy
1/P: 19
Test Case I: O/P : not
C '>· 1/P: 54 b ?
Test ase - · . . d' ·t from the oiven num er .
. the part1cula1 ,g, , o
17 \\'rite a function to remo, e
· Test Case 2:
Test Case I:
1/P:
1/P:
11004422
20164
6
0 /P: 0/P:

2014 4422

Programs in String:

18. Write a program to find the GCD for the Unicode values of the given string?
Test Case I: 1/P : sinZ 0/P 5
Test Case 2: 1/P: TEQ O/P
19 Write a program to remove the next char, near each vowel of the given string?
Test Case I: 1/P : Nama Company O/P : NaaCopay
Test Case 2: 1/P : Science Fiction O/P : SciceFiti
20. Write a program to find the frequency of chars in the given string, and print the 1110s1
frequent character of the string?
Tc)t Case 1: 1/P : charaCteR

0 /P : c-2 h- l a-2 r-2 t-1 e-1


C

1/P : t4tcq
(l 'f' : t-2c. ( q-1
,,,1osOrTWARI OLU11nt~ 11

It ltl',I thl I\ II 11111 1, 11, 1111 I 1111111 !I'll

I I' l II Ill ( 1/1' 1111,!pl 1111

l I I' I lll'q I, l 1I ( )/1' 11111

\\ ('ll 111 1,lll11n I pLiu lhl \•01d or1I 111 lhl 111 lrl 1111 IIIIClllL~ 111 lit~ l'IVCII ,11111 11

1, ,1 ( 11,,. I : 1'1•, 1 ( a~• 2:


1
Il : 1/1' :
, , 1,1 /1 Ill 1111•11 I I /Im, 111,1111•11, 1,,11 1, /,/r1r 1 /,/11 ,, 1~ thril ~rJ/r / lov l,/111• l,/11

111a11ro hln1.
npp k red
0/P ; 0 /P :
11/'f'/, If ///.Ill' mr111P11 i1 re/Im, rt/!/1/c• is 11111.1 ,,,rJ I', blr1r ,. that ym,, ! lol'i' 11'/I hllie

Lisi Prohlrm~:

~1 \\ rile a rrognun to so11 the pos iti ve and negative nurnbcrs from a !isl of11111nhcr,. (/.cro
should he co nsidered a negati ve number)
lc~t Case J: Test Case 2:
1/P; l/P:
I 2 I4 -5 18 -6 -7 -12 -14 0 -18 S -6 -7
0/P: 0/P:
I 12,14,18,-7,-6,-5] [5,-18,-14,-12,-7,-6,0J

0, @. Write a program to get the fibonacci series till the given value (dynamic programming)
Tc~, Case I: 1/P : 100 O/P : 0 I I 2 3 5 8 13 21 34 55 89
Test Case 2: 1/P : 52 O/P :0112358132134
25. Write a Python program to count the number of strings where the string length is 2 or
more a11d lhe first and last characlers are same from a given li st of strings.
Test Case I : 1/P : abc xyz aba 1221 O/P: 2
Tesl Case 2: 1/P: treat the students like a king O/P: 2
26. Wrik a program to split every Nth element in a list.
• • • iii "
1 est Case I: 1/P abcaefghijklmn
3
O/P ['adgjm', 'bchkn', 'cfil'l
Ti:~t Ca,c 2: 1/P t4teqsoflwares
2
0/P l'llqolac·. '4csfwrs']
T4T£Q SOFTWARE: SOLUTION~ PYTHON lJp
ag" lr,
r,f 31
\l.i ( ) \\ fl'l' l1 . t u~lllf J{.idix ~,,11 All'"l1tltm 1
prr>rrn111 ,,, ~ort th~ g1, l II 11~

1/P . I -q ' I 'i I) 1.23. 12, 7 ()/1'; 7, I ~.23.12,r) I ,121


lc<.!lN'I:
I/P 12 ,23 ,is, 11,S<i,72,37 0/1': 13,23,37,4s.s,>, 2,r;i
I\ \I t •,l,l' ,. •
1
7
• Il1l' , l'rfi
2~ \\ rlli.' ,1 pro!!ra lll Ill lrml 1 \:f .:1: betwee n ~um of 1111.: 11ppc1 n11d lowLr tr··l<1J1µic r,f
• ..l.I 1,,
the square malri, ?
rc~t Case I: 1/P : 3

O/P: 27
29. Write a program to find the multiplication of2 identical matrices?
Test Ca~e I: 1/P : 3
I 2 3
4 5 6
7 8 9

9 8 7
65 4
32 I
O/P:

30 24 18
84 69 54
138 114 90
Set, Tuples and Dictionary Problems:

30. Write a program to reverse each number from the given tuple?
Test Case I: 1/P 123, 15,91 ,23,42,7
0/P 321,51,19,32,24,7
Test Case 2: 1/P 19,45,67,34
0 /P 91,54,76,43
31. Write a program to find the intersection and union of the given ru o sets ½ithout using
pre-defined functions?
1est Case I: r;p
1,2,3,4,5,6
4.6,8,IO
0 /P {4,6} { 1,2,3,4,5,6,8, IO}
r,na SOFTWARE ~OLUT IONS F'fl11r 1 N 1r ,, 11,137

fl ,I l. ~.· ' 11' I ' I I. I 1


I ', l 1 I I
(l I' II 1 1l I J: l I ', 11, 1 11
, \\ rit,· ,I J'li't'nlill to r111d th,·,,
·• lllllll' lt ll' dill•, ·t•'ll
, ll , J 1,' f lh','11 I \\ll Mo.'~
I '/

I I' I,', l, I,~,<,

I.C,.H. I 0
0/P { I .:,I,.~ 8, 10)
Ii.:~t Case 2: l,P 12. IJ. l •I
12, 13. I •1
0 /P {}
33. \\ rite a prog1am to get the nth biggest clement rrom beg i1111i11g and e11d of a tuple'/
fest Case I : 1/P : 123, 15,9 1,23,42,7 -~, l•,t9d/4?>)~il, 1;,~
4 IJ , \ :{ / J I
0 /P 42 23 0 .i
Test Case 2: 1/P 19,45,67,34
2
0 /P 34,45
34. Write a program to convert all the elements from decimal to binary from the given tuple?
Test Case I: 1/P 123, 15,23,42,7
O/P I I I IO I I, 11 11. IO I I I, IO IO I0, I I I

Test Case 2: 1/P 19,45,67,34


O/P I00 I I, IOI 10 I, 10000 I I, I000 I0

35. Write a program to split all the number in the tuples to digits, and remove the
duplication?
Test Case I: 1/P 23,49. 122, 135.98

O/P 2J,4,9, 1,5,8

Test Case 2: f/P 19,45,67,34


O/P 1,9,4,5,6.7.3
36. Write a program to split all the related ilcms in the given tuple?
Test Case f : 1/P 23,tuple,3.14,7.5,rock.7
O/P 23,7
tuple.rod.
3.l •U.5
J Ylli()N I

l4Tt(} '-l'nWARL SOLUTIONS

. , Ji • (\ , ,, 11h 1h1. 111\l'll s1udc11I~ 111arks li~J ,t iHJ


1 \\ rtll.' ,I l'll');llllll Ill 1.1,· l II. ,I I.
11 1111
' • u11111 r

,,,_.,1dmg 111 thl.'ir 1111,d 111 i11b 1

J'N t'.N: 1 Iii'


Akil 90 95 96
Shnnkar 20 1,l ,15
Ra, i 20 45 •14
O/P Aki!. Ravi. Shankar

Problems" ith 'Object Oriented Problems:

38 V. rite a class to find the set of three elements that sum to zero.
1/P
-25,-10, -7. -3. 2. 4,8.10
Test Case 1:
O/P [[-I0,2,8] , (-7 , -3, 10]]

Test Case 2: 1/P 1.-2,-3,4,5

O/P [[-2,-3,5]]
39. Write a class to create five user defined string functions and access them with an objecr
• String Length
• String Compare
• String Reverse
• Vowel Count
• String Zipper
40. Write a program to solve the following problem using exception handling?
Test Case I : 1/P : 3 5 O/P : 8
Test Case 2: J/P : 1era so ft O/P : teraso ft

MINI PROJECT
I. Examination System
a. Staff Login
i. Approve Students
ii. Create Exams & generate Report in File
b. Student Login
i. Create Students
ii. Attend Exam & Report
2. Flight Reservation System
a. Passenger
1. Sign in

ii. Check availability & Fare


iii. Book l icket
h. Cashier
i. Approve
ii. h\uc I icket
T4ll n \QI 1WI\RI 1101ll llllNS I Vllf, N 11
20 t a1

IN I 1 l{VIFW T·\SI\S
1 Tl

lotH 11 , 11111111 til 1 \\llll ,1 p1,, 1,1,1111 t11 l11ul 1111,l\11ll111111111111l 1l'r that cnn he lo1 111 ~d
11s111t• ,II 111 tin· d11•11 , 11I 1h1, 1111111hl' I
I I' ~N"•>'l lh ( l I' 1lN /(l 111 l
" ( h1·1. " it 1111.· I' iH·ll , 111111• s IS ,I 11.lllpl:1111 Ill 11111 A p.111!'1,llll 1, a ,c11ICllCl' co11tain1ng
nvl\ kth'1 111 tlw I 1ll'l1~h i\lphalwt
t i1H·11,1 , ,illll· I h1.· 1,1,I-. "to l111d IHi\\ lllilll) 1111111lw1 s k'ss than or equal to N ha\c
111111ih1.·1s 111 d1, 1'1Hs l''\i11.·th 1.·q11,d to 1
t ii.'! .1 1111111h1.·1 , di\ ilk till' n11111b1.·r \\ ith all !Is cl1v1sor, 1111d ,11111 it.
l' 1 1' 111 l11111 p:11ts (I'\ I 1/1, 11/ 1,1~/hl
1 {6, I, U) ➔ 6 11t1-+2 15
' \ I m·.i, N11llllll'1 i, 111111111b1.·r \\hich is n:pn:scnlcd by the following rccurrcncc
I II I 11 1 1 I " , for n I
I ll ,,
l1 1/P : 9 O/P : 76
h. ('011111 Di, isors
, 1.111 h:1' c IK·1.·11 gi\'1.'11 1 intcgcrs I. r nnd 1-. . rind h0\1 mnny numbers between I and r
tboth 111cl11si,c) arc di,isiblc b) 1-.. You do 1101 nccd to print these numbers, you just
hav1.• to tind their co11111. 1/P : IO 20 2 O/P : 6
E,ptaualion : numbers di, isiblc b) 2 in the range IO to 20 are I0, 12, 14.16.18,20 :
l'ount - {J
7. Lnsl O Bils - Occimnl \'nluc
l'hc prngr:un must accept two positive integers N and Das the input. Then the program
mu:;t print the dccimnl ,:due represented b) the last D bits in the binal) representation
ofN. l/P:10 3 O/P : 2
faplanation : Binar) cqui,alent of IO is IO I0. last 3 digit are O10, decimal value of
010 is 2
8. l\tulliplcs in Range
fhc program 11111st :iccept vc integers A. B. X. Y and Z as the input. The program must
print the multipll's of X. Y and 7 in the range from A to B (inclusi\'e of A and B) as
thcoutput. I/P:215 3-16 0 /P : J-16 891215
9. Sum and Average - E\'cn and Odd
rhc program must accept a list of integers as the input. The program must print the
sum of e\'en integers in the list then the program must print the average of odd integers
in the list \\ ith the precision up lo one decimal place. If there is no e\en integer odd
integer in the list, the program must print -1 .

10. String - Decimal


The program must accept a string S containing only a and bas the input. The program
must form the binaf) represention of an integer X by replacing ab) I and b b) 0 in the
string S. Then the program must prim the\ alue of:\ as the output
lnpul: aabba Output: 25
faplanation: Afta replacing all the occurrences of a b~ 1 and b b~ 0. the smnc
hC'd)ml'~ 11001. So the decimal equi,alent of(I IOOJ ) is 25.
T4TEQ SOFTWARE SOLUTIONS PYTHON 3 I Page 21 of 32

11. Common Fort ors - nc,c end ing Ord er


"t ,15 the input. 1 he program must
The program mu~t accept t\\ o posit I\ c integers X nnd
11 order.
print the common focton. of X nnd 'I 111 the dcsl:cndi11
12. l nit Digit - Rcplarl' h~ 0
t I he program must replace all the
1l1e program must accept an integer N a<; the inpu
N. finally. the program must print
occurrence!, of the unit digit ofN by 0 in the 111teger
th .. mod ied, alue of N as the output.
I 021 Ou put: 20
Input:
replacing all the occurrence of I by
E,planatioa: TI1e unit digit of 1021 is I. So after
0. the mteger becomes 0020.
U. Palindrome - Binary Representation
program must print YES if the
TI1e program must accept an integer N as the input. The
the program must print NO as the
bina~ representation of N is a palindrome. Else
output.
Input: 5 Output: YES
Explanation: The binary representation of 5 is IO
I. Output is YES
14. Yowel Positions
t. The program must print the vowel
The program must accept a string value S the inpu
t-I as the output.
positions. If there are no such vowels in S then prin
15. Reframe with Hundredth Digit
value X (sum of unit digit, tenth digit
The program must accept an integer Nan da sum
redth digit is removed from N. The
and hundredth digit of N) as the input. The hund
by reframing it as the output.
program must nd the hundredth digit and print N
1269 20 Output: 12569
Input:
is 15. The deference between 20
Exp lanation: The sum of the last two digits in 1269
r reframing the N is 12569.
and 15 is 5 (20- 15). So the hundredth digit is 5. Afte

Q.No. Sign Q.N o. Sign


Q.No. Sign

6 1I
I

7 12
2

13
.,
"\ 8

9 14
4 ,1

.
10 15
5
I
T4TEQ SOFTWARE SOLUTIONS PY'THON 3 I Page 20
a

IN I FIH IEW 'I ASKS


1111 11 1 111
( ll \1.: 11 o numb 1. \\ Ill 1 pr,, 'l il lll 10 111111 1111 1\1 11111111 111 rh.,t '-• he lurrncrt
nil ,,f 1hc it,
11 111 1 11 of 1111 111111111 ,

IP 3X:: 1111h7 (l / 1'. 'IX 7h'l1U


.., Cl " t I . I A 1w11••1 ,11n I a sc11t1.11c 1.11111,1 111,
ll'.CI\ I t IC g t\CII S il 111 g ", j, ,l 1',111g 1alll (11 IHI " '

, ('kiter in the I ngli~h i\ lph;1hd


C\er~
, ,hcr, lcs'i llw11 or equa l to "II II
'· \n lui.:. I he task i, lo find l11n~ mun) nun
II\ en a v
number-, of di\ isors e\nclh equal to 1 d .
Get a number divide 1hc. ,;umber\\ ith nll ,ts c(,v ,,o, ' all sum ,t.
' / } /641 2 l ➔ 6 43 l2 I S
e.g. 12 in fo ur part<,
. l 12 2 12/3. 12/4.12
. • .6 • • itccl •by•the lollow111g
. recurrence
5. A Lucas Number ,s n number wl11ch 1s n,;pn.:scr
Ln L n-1 + Ln, fo r 11 I

Lo 2
1/P : 9 O/P : 76
L 1= I
6. Count Divisors . . rand k Find how many number5 between I and r
You have been given integers - 1,
. . d' •·'bl b k You do · not need to print
3 . these num bers, you jusi
(both 1nclus1ve) are 1v1s 1 e Y · • 0 /P : 6
1 20 2
have to find their count. 1/P · O
Explanation : numbers divisible by 2 in the range I O to 20 are I 0, 12, 14, 16.18,20 .

Count - 6
7. Last D Bits - Decimal Value
The program must accept two positive integers N and D '.35 t_he inpu_t. Then the program
must print the decimal value represented by the last D bits 111 the bmary representation
ofN. UP : IO 3 0 /P : 2
Explanation : Binary equivalent of IO is IO I0, last 3 digit are OI 0, decimal value of

010 is 2
8. Multiples in Range
The program must accept ve integers A, 8, X, Y and Z as the input. The program must
print the multiples of X, Y and Z in the range from A to 8 (inclusive of A and 8) as
the output. 1/P : 2 15 34 6 0 /P : J 4 6 8 9 12 15
9. Sum and Average - Even and Odd
The program must accept a list of integers as the input. The program must print the
sum of even integers in the list then the program must print the average ofodd integers
in the list with the precision up to one decimal place. If there is no even integer odd
integer in the list, the program must print -1 .

JO. String - Decimal


The program must accept a string S containing only a and bas the input. The program
must form the binary represent ion of an integer X by replacing a by I and b b) 0 in the
siring S. Then the program must print the value of X as the output.
Jnput: aabba Output: 25
Explanation: /\fier replacing all lhe occurrences or a b\ 1 and b b) 0, the sinn!,\
becomes 11001 . So lhl! dec imal equivalenl of( 11001) is 25.
32
so f'T WA R[ SOLUTIO
NS PYTHON 31 Page 21 of
r1TEQ

( ommon f err or s - Dr
,re nd ing On h•r
11. •
•·c , \ .. , 1"-' n~ I1ll: 111pu1 I he propram 11111,1
lcp l t\\u ()l rti l lllk , " 11 r
I he 1,ro mm 11111<;1 nc
m 01 X and 't 111 the cfo
scL·nding 11rdcr.
prrnl &he l·o mm on foc1< O
_ nir Digir - lfr ph ll'(•
b~ fl I
12 1 N a • ti · · I program must replace n t 1e
I h,. pro •mm lllt hl acc. ep. .
t an ..int ••g er s 1e 111put. r 1c
program mw,t print
• th c 111111 drg,t of N b} 0 in the integer N. rinally, the
lll'l um·nccs of
the output.
thr modicd \aluc of N as 20
I 021 Ou put:
Input : occurrence of I by
e un it dig it of I 021 is I. So after replacing all the
i:,planation: Th 20.
n. the rnteger becomes 00
JJ. Palindrome - Bina
ry Representation
print YES if the
pt an int eg er N as the input. The program must
The program must acce must print NO as the
tation of N is a pa lin drome. Else the program
binar: represen
output.
Output: YES
Input: 5
I. Output is YES
representation of 5 is IO
Explanation: The binary
14. Vowel Positions nt the vowel
a str ing va lue S the input. The program must pri
The program must accept nt -I as the output.
such vowels in S then pri
positions. If there are no
redth Digit
15. Reframe with Hund val ue X (sum of unit digit, ten
th digit
an int eg er Na nd a sum
The program must accept The hundredth digit is rem
oved from N. The
it of N) as the inp ut.
and hundredth dig it as the output.
st nd the hu nd red th dig it and print N by reframing
program mu 12569
69 20 Output:
Inp ut: 12 e deference between 20
Th e sum of the las t tw o digits in l 269 is 15. Th
Explanation: raming the N is 12569.
is 5 (20 -15 ). So the hu ndredth digit is 5. After ref
and 15

Q.No. Sign
Q.No. Sign
Q.No. Sign
11
6
I
12
7
2
13
8
J
,- 14
9

-
4
15
10
5

~
~
pnHON 3IP 22 32
' 0 c•
' ~~ ', • @(I (I FTWARE SOLUTIONS
T4T£QSO
. w Questions
Python 3 - 1nterv1e
1 "hut i, r, thon} . , I scripting l,111r u,1gc. P) them
. . . i ohjc:d-011c:11tl.:l .
. . . ·I ti:rpil'h:d. i111i:-i.1cllH .,m · . . ui.:ntl\~ " 111.:rc ns other
p, thon i:, ti h1gh-k," · 111 • . h ~i.:\ \Hinh 1n;q
. ll It use-; l·ng 1 ,~ . I
• •1 . ,J t" lP lrn!hl,• rcadn 1 c. · · , • . I con~truc l. ._ th:m pthcr angungcs.
·
1:- uc:--1i;_1h: ,. " - 1011
. ,1 11 d 't1 ha,
'-
rcwcr S\· nrnt!H;,l
l:lngu.igi:-~ ll'•l' puni:-1uat1011.

2. Numl' soml' of thl' fl'atures of P) thon.

·, t fratures of python -

Folll)\\tn!! are some ol• the sa 111.::n
~ d roornmming met1,o ds as well as OOP.
st
• It supports functional and ructure P t i ' . b,te-code for building
• lt can be used as a . .
scnptmg language 0 r can be compiled to ·
large applications. . k·
. d
• It provides very high-level dynamic data t)pes an supp orts dvnam1c
· t) pe chec ·mg.

• II suppons automatic garbage collection


3. What is the purpose of PYTHONPATH environment variable?

PYTHONPATH - It has a role similar to PATH. This variable tells the Python interpreter
,,here to locate the module files imported into a program. It should include the Python source
library directory and the directories containing Python source code.

4. What is the purpose of PYTHONSTARTUP environment variable?

PYTHONSTARTUP - lt contains the path of an initialization file containing Python source


code. It is executed every time you start the interpreter. It is named as .pythonrc.py in UNIX
and it contains commands that load utilities or modify PYTHONPATH.

5. What is the purpose of PYTHONCASEOK environment rnriable?

PYTHONC ASEOK - lt is used in Windows to instruct Python to find the first case-insensiti,·e
match in an import statement. Set this variable to an) value to acti\'ate it.

6. What is the purpose of PYTHONHO!WE environment variable?

PYTHONHOME - It is an alternative module search path. It is usually embedded in th~


PYTHONSTARTUP or PYTHONPATH directories to make S\\itchino odule 1·ti
i:,
111 1 r.1r1~., l."a,)
7. Is fl) thou a casl' sensilh e language?

Yes' P) thon is a ca~e ~ensiti,e programming l:rnguage.


,,na SOITWARl SOlllTIONS PYTtlDN ~ IPag 23 of 32

I! \\ h,11 llll' thl' ,u pp111h'd dalu hill'' 111 l'\lhon''

p, th, ,n ha~ II\ l' ~tand.1rd dat,1 t} pcs

• Numhl!h
• St1ing
• l i,t
• I 11pk
• D1ctionn1)

9. What is the output of print str if str = 'Hello World!'?

It ,\ill print complete string. Output would be Hello World!.

IO. What is the output of print str!OI if str = 'Hello World!'?

It \\ill print first character of the string. Output would be H.

11. What is the output of print strl2:SJ if str = 'Hello World!'?

It will print characters starting from 3rd to 5th. Output would be llo.

12. What is the output of print str[2:) if str = 'Hello World!'?

II will print characters starting from 3rd character. Output would be llo World! .

13. What is the output of print str * 2 if str = 'Hello World!'?

It will print string two times. Output would be Hello World!Hello World! .

What is the output of print str + "TEST" if str = 'Hello World!'?

II will print concatenated string. Output would be Hello World 1TEST.

14. What is the output of print list iflist = I 'abed', 786, 2.23, 'john', 70.2 J?

It will print concatenated lists. Output would be [ 'abed', 786, 2.23, 'john', 70.2 ].

15. What is the output of print list IOI if list = I 'abed', 786, 2.23, 'john', 70.2 I?
It "ill print first element of the list. Output would be abed.

16. What is the output of print list I l :3) if list = I 'abed', 786, 2.23, 'john', 70.2 I?
It v.ill print elements starting from 2nd till 3rd. Output would be [786, 2.23].
T4TEQ SOFTWARE SOLUTIONS

· 1·1st! 2: 1I·11·1st •
17. \\ hat is thl' 111111ml 11fp1111I
I' I II·" 'I' , 7HC 1 , 2 •l\~, 'John'. 711 •2 \?
, 21 '10h11',
It \\1II p11nt ck111~11ts tu1ti11g lwm 1111 ~k:111c11t t l111p11t \\uuhl he \.. •

"'0 .:?0000000lH)llll001 l

I H. \\ hat is tht• output of print tin~ li'.--1 * 2 if lin) li..,t • 112.\, 'john'!'!
11
It" ill pr111t li,t '"'' ti1111;":, l h1tp11t \\lllild \ll;' 112\ ',ioh11'. 123, 'joh 'I •
23 '1'ohn', 70.l
. . . 1·. • 2 'fl" t t '·1hcd' 1Ht,, 2 . •
t '>. \\ hat is tht• outpul of pnnt h,t -I t111y isl 1 1s • • •

I nnd tinylist ""' \ 123, 'john'\'!


, 78< ., 23 'john' .
Output would b1.: ['abed• '• .. ' ·
It "ill pnnl Cl1ncah:11atcd lists.
70.200000000000003 , 121. ',1oh11') .

20. Whnt arc tuples in P) thon'!


. . . - t /\ tuple consists of a number
/\ tupk is another seqw.:ncl;' data type that 1s similar to I11c 1,~ •
•' l u 1•1. 1· 1 t I· •tr• c,1,·loscd within 11arcnthc::-c::; .
o f va Iues separateu J) commas n 1r.c l'>tS. 10\\C\Cr, up c:. • ~ "

21. What is the difference between luple, and lists in Python'!

The main differences between lists and tuples arc - Lists arc enclosed in brackl.!ts ( { I ) and
their elements and si7e can be changed. while tuples arc enclosed in parentheses ( ( ) ) and
cannot be updated. Tuples can be thought or as read-only lists.

22. What is the output of print tuple if tuple= ( 'ahcd', 786 , 2.23, 'john', 70.2 )?

It \\ill print complete tuple. Output would be ('abed', 786, 2.23, 'john'. 70.200000000000003).

23. What is the output of print tuplclOI if tu11lc = ( 'abed' , 786 ,2.23 , ,J
· o , 70
h n , . 2 ).?

It will print first clement of the tuple. Output would be ahcd.

24. What iii the output of print tuple! I :31 1·rt I - i


• • up e - ( abed'. 786 , 2.23, 'john' , 70.2 )?
It\\ ill rmnt elements starting from 2nd till 3 d 0
r . utput would be (786, 2.23 ).
25. What is the output of print tuplcl2 · I if t I -
It w II • · upe-('ahcd' , 786 , 2.23, 'john', 70.2 )."
i print elements starting fi
rom 3rd elem
70 200000000000003). ent. Output would be (2.23 , 'john'.
T4TEQ SOFTWARE SOLUTIONS flYTHON 31Page 25 of 32

26. \\ hat i\ the output of print tinytuple • 2 if tinytuplc = (123, 'john')?

It \\ tll print tuple t\,o times. Output would be (123 , 'john'. 123, 'john').

27. What is the output of print tuple+ tinytuple if tuple= ( 'abed', 786, 2.23, 'john',
70.2) and tinytuple = (123, 'john')?

It will print concatenated tuples. Output would be ('abed', 786, 2.23, 'john',
70.200000000000003, 123,1ohn1.

28. What are Python's dictionaries?

Python's dictionaries are kind of hash table type. They work like associative arrays or hashes
found in Perl and consist of key-value pairs. A dictionary key can be almost any Python type,
but are usually numbers or strings. Values, on the other hand, can be any arbitrary Python
object.

29. How will you create a dictionary in python?

Dictionaries are enclosed by curly braces ( { }) and values can be assigned and accessed using
square braces ([]).

diet {)
diet (' n ~ II
diet 2, tw
tinydiet : .- q, '. '
- - -
30. How will you get all the keys from the dictionary?

Using dictionary.keysQ function , we can get all the keys from the dictionary object.

print diet.keys # Prints all the keys

31. How will you get all the values from the dictionary?

Using dictionary .valuesO function, we can get all the values from the dictionary object.

print diet.values (, # Prints all the values

32. How will you convert a string to an int in python?


l
int(x [,base])_ Converts x to an integer. base specifies the base if x is a string.

33. How will you convert a string to a long in python?

long(x (.base])_ Converts x to a long integer. base specifies the base ifx is a string.
PYl HON 3 IP;ige 26 of 32
1•HQ 1;011WARI ~Pl\lTl(lN~

I ,,
q ))t,,, ,11l1 \1•1111•11\t II U ,1111tU to II 111 11\I Ill pit \OIi ,

,,
\Ci llo\\ "ill, 1111 win,.,11111 c•hlnl 11111 ~ll 1111! 111 JI) I I11111

,11,,l ( 1•11,,·1h1•li1n1, 11,,,,1,11,l' ll'l'l•''l' lll,1111 111


1111 th
·'" l l1m "ill, 1111 ,·e11n 1•11 1111 ohjl'l'I 11111 n•gulur 1•,11n•~~• in Jl) on '!

.17 llo\\ "ill HIii ,•1111, ,·rl II Strini.: IO 1111 ohjN't in python'!

l'' .,It ,1,) I , ,ll11ah·, ., ~, ri 11!' ,111d , -:turn~ an ohJl'rl

.HI. l11m "ill )Oll rnnwrt n string ton tuple in python'!

111pk(~) l\)11\l'lh s ton 1uph.:.

J'l. llo," "ill )OU cmwrrl :i string to a list in pylhon?

list(~) - Clmwrts s ton list.

40. llo" \\ill you convert a string to a set in python?

sct(s) Converts s ton set.

41. How will you creale a dictionary using tuples in python?

Jict(d)- Creates a dictionary. d must be :i sequence of(key.valuc) tuples.

42. How will you convert a string to a frozen set in python?

fro1cnsct(s) - Converts s to a frozt!n set.

43. How,, ill you converl an integer to a character in python?

chr(x) - Converts an integer to a character.

44. How will you convert an integer to an unicode character in python?

unichr(x) - Converts an integer to a Unicode character.

45. How ,,ill you convert a single character to its integer v.1lue in python?

ord(;.) - Converts a single 1.:haraeter to it~ integer value.

46. flow will you convert an integer to hexadccinrnl string in python?

l1cl(i.) (. omt:rls an integer 10 a hexn<lc1.:imal siring


r.r£Q SOITWAR[ SOl UTIONS
PVHl N3jP 1127 of32

4... Ihm ,, ill ) IIU conH'rl un inkgn lo octal ,tring in p~thon'1

l I. t 'I. )
- c1,n, crt, nn 111tcgcr to nn oc1,,1 string.
.ss. \\ bat is the purpose of •• operator?
•• E.,pt,ncnt - Performs e,ponential (power) calculation on operators. au b = IO to the power
: oifa= 10andb = 20.

49. \\ bat is the purpose of// operator?

floor Di\ is ion -The division of operands where the result is the quotient in which the digits
after the decimal point are removed.

50. What the purpose is of is operator?

is - E,aluates to true if the variables on either side of the operator point to the same object
and false otherwise.xis y, here is results in I if id(x) equals id(y).

51. What is the purpose of not in operator?

not in - Evaluates to true if it does not finds a variable in the specified sequence and false
otherwise. x not in y, here not in results in a I if xis not a member of sequence y.

52. What is the purpose break statement in python?

break statement - Terminates the loop statement and transfers execution to the statement
immediately following the loop.

53. What is the purpose continue statement in python?

continue statement - Causes the loop to skip the remainder of its body and immediately retest
its condition prior to reiterating.

54. What is the purpose pass statement in python?

pass statement - The pass statement in Python is used when a statement is required
syntactically but you do not want any command or code to execute.

SS. How can you pick a random item from a list or tuple?

choice(seq) - Returns a random item from a list, tuple, or string.

S6. How can you pick a random item from a range?

r drnn e (( tart,] stop [,step]) - returns a randomly sc Ieel!! d eIemt.:·nl from range(start. ~11,p.
Step)
T4TEQ SOFTWARE SOLUTIONS PYTHON 3 j Page 28 of
32

57. llo" ran )Ou J:!rl u random numbrr in p)thon'!

random() - returns a random float r. such that Ois 11:ss than or equal to rand r is less than 1,

SS. How nill )Ou set the starting value in generating random number~?

,1,;i:d([,j) Sets the integer starting \alue used in generating random numbers. Call this
!unction before calling anj other random module function. Returns None.

59. Ho" "ill )Ou randomizes the items of a list in place?

shutlle(lst) - Randomizes the items of a list in place. Returns None.

60. How will you capitalizes first letter of string?

capitalize() - Capitalizes first letter of string.

61. How will you check in a string that all characters are alphanumeric?

isalnum() - Returns true if string has at least I character and all characters are alphanumeric
and false otherwise.

62. How will you check in a string that all characters are digits?

isdigit() - Returns true if string contains only digits and false otherwise.

63. How will you check in a string that all characters are in lowercase?

islowerO - Returns true if string has at least I cased character and all cased characters are in
lowercase and false otherwise.

64. How will you check in a string that all characters are numerics?

isnumeric() - Returns true if a unicode string contains only numeric characters and false
otherwise.

65. How will you check in a string that all characters are whitespaces?

isspace() - Returns true if string contains only whitespace characters and false otherwise.

66. How will you check in a string that it is properly titlecased?

istitle() - Returns true if string is properly "titlecased" and false othem ise.

67. How will you check in a string that all characters :ire- in uppercase:'

isuppcr() - Returns true if string hns :it lcn\t om: cased d1:irnctcr nnd nil ca,~•d d1ar.1l'tcr, nr.:
111 uppcn.:ase and fal')c otherwise.
T4TEQSOFTWARE SOLUTIONS
PYTHON 3 IPage 29 of 32

6~. Ho\\ "ill~ ou mrrgr rlrmrnt ' Ill


· I.I ~l'l)ll\'lll'l'?

join(,cq) - ~kr •i:-, lu111c,1t1:11nll',l


. thl· strin g 1cpr(',l'lll,1ti1111s iii ckmcnls 111 • .
1 111 11
n ,tnn•1, "1th c;.:p.1mt.1r ,t 1m~. !;cqucncl! sct 1

t,9. llo" "ill •, ou 1•t.'t


" thl' knoth
t- of ti It.' stnng'?
.

ld1(,tringl Rl!tum~ tht' kngth of the string.

~n. Ho\\ will ·\OU "'oet a Sp'lC"-padcl


• .. - • rd st nng
. 'ti • .
total of" idth columns? w1 I the ongmal string left-justified to a

ljust(" idth[.'dfillchar])
I - Returns a space-padded st1_.mg with
. the ong111al
. . string left-justified to
a tota I o f \\ 1 t 1 columns.

71. How will you connrt a strina"' to all lowercase?

lowl!rO - Con,erts all uppercase letters in string to lowercase.

72. How will you remove all leading whitespace in string?

!strip() - Removes all leading whitespace in string.

73. How will you get the max alphabetical character from the string?

max(str) - Returns the max alphabetical character from the string str.

74. How will you get the min alphabetical character from the string?

min(str) - Returns the min alphabetical character from the string str.

75. How will you replaces all occurrences of old substring in string with new string?

replace(old, new(, max]) - Replaces all occurrences of old in string with new or at most max

occurrences if max given.


76. How will you remove all leading and trailing whitespace in string?

strip([ chars]) - Performs both Istrip() and rstrip() on string.


• • ?
':7. How will you change case for all letters m strtng •

sv, apcase{) - Inverts case for all letters in string.

78. llow ~ ill you get titlecased version of string?


. . . words begin with uppercase and the
11
titleO - Returns 'titkcac;ed" version of stnng. that is. a

rci,t are Jov, crease.


PYTHON 3 I Page 30 of 32
T4TEQ SOFTWARE SOLUTIONS

79. Jfo,, "ill) ou com c11 a string lo all uppcrcn,c?

upp~r() - Coml.!rts all lom:rcasc letters in string to uppercase .

80. How'" ill you check in a string that all characters arc decimal'!

isdecimal() - Returns true if a Unicode string contains only decimal characters and false

othem ise.
81. What is the difference between del() and remove() methods of the list?

To remove a list element, you can use either the dcl statement if yo u know exactly which

element(s) you are deleting or the remove() method if you do not know.

82. What is the output of leo([l, 2, 31)?

83. What is the output of [l, 2, 3] + [4, 5, 6)?

[!, 2, 3, 4, 5, 6]

84. What is the output of ['Hi!'] * 4?

['Hi!', 'Hi!', 'Hi!', 'Hi!']

85. What is the output of3 in (1, 2, 3]?

True

86. What is the output of for x in [1, 2, 31: print x?

123

87. What is the output of L[2] if L = [1,2,3]?

3, Offsets start at zero.

88. What is the output of L[-2 I if L = [1,2,3 I?


LI-I].,. 3. L[-2]=2, L[-3]=1

89. What is the output ofLll:J ifL = 11,2,3)?


2, 3, Slicing frtd1es ~ections

90. How will you compare two lists'!


PV1H
T4TEQ SOFTWARE SOLUTIONS

C \ tP{llo:;11. Ii , ... ) ~ pnJJ'lfl.' clC'llH,111'- l'f 1,01'1 11 IS

QI. Hm, "ill ,- o u f!CC Ch i' lc nf! th ofa lbt '!

len(li~t) - GiH:s th.: tot.ii length of th1.• list

92. Ho" "ill you get the m:n. "alued item on a list?

max(list) - Returns item from the 11st "ith ma:-.. \nlu.:.

93. Ho" "ill you get the min valued item of a list?

min(list) - Returns item from the list,, ith min value.

94. How will you get the index of an object in a list?

list. index(obj) - Returns the lowest index in the list that obj appears.

95. How will you insert an object at the given index in a list?

list.insert(index. obj) - Inserts object obj into list at offset index.

96. How will you remove the last object from a list?

list.pop(obj=l ist[-1]) - Removes and returns last object or obj from list.

97. How will you remove an object from a list?

list.remo\'e(obj) - Removes object obj from list.

98. How will you reverse a list?

list. reverse() - Reverses objects of the list in place.

99. How will you sort a list?


. f • mpare func if given.
list.sort([func]) - Sorts obJects O ltSI, use co
T4TEQ SOFTWARE SOLUTIONS
PYTHON 3 I Page 32 of 32

The ASCII code


lf 1l t rl I I I II T4TEQ
ASCII control chilract•rs ASCII printable characters
DEC HEX S1mbolo ASCII DEC HEX Slmbolo DEC HEX S1mbolo DEC HEX S1mbolo
mu 32 espacio 64 06
:>OH <el
33 I

03
SlX 34 .. 65
66
A
B
97
98
0
b
ETX
04 35 # 67 C 99
EOT C
5 Et.a
36 s 68 D 100 d
06 ACI<
37 ,0 69 E 101 e
07 38 & 70 F 102
BEL 39 f
8 BS 71 G 103
•etr Cf'S' 40 g
09 HT 72 H 104
t3b t>o•i.:crn, 41 h
10 LF 73 I 105
SB '0~ -:a 42
11 VT 74 J 106
tab rcr: ~a 43 j
12 FF + 75 J< 107
'er 'e:-~ 44 k
13 CR 76 L 108
e•orrio oe e4rro 45 I
14 so {S 't )u·
77 M 109
15 46 m
16
SI s" fl kl 47
78 u 110 n
OLE din rr,. e!ca:,e I 79 0
17 48 111 0
DC1 "e. ic, cor.,ro 1 0 80 p 112
18 49 1 81 p
DC2 0=, ~e ct~:ro : Q 113
19 OC3 50 2 q
{d~. cecor-t o: 82 R 114
20 DC4 51 3 r
21
J:!.-:cccntro.:
UAK nega•. ~ ec 52 4
83
84
s 115 s
22 SYN
C\' = 53 5
T 116
t
S) cr•,nous ·..e 85 u
23 ETB 54 6 117
:-:lc,(•a..,~b"c• 86 V u
24 CAtl 55 7 118
ceni:~
56 87 w V
25 EP1 8 119
26
~ j O; /llEll:u
57 88 X 1//
sue St;t_s• ..,•e 9 89 120 X
27 ESC 58 y 121
csca:e 90 y
28 FS "'-!:s".a o't
59
91
z 122
z
29 GS 60 [
~re ;, 'Sf.,:i• ator < 92 123 {
RS 61 \ 124
re .:m !e:;.-.u:,tc• = 93
31 us 62 ] 125
I
127 i..ri S!;a"!tor > 94 }
DEL 6J /\
Oe- '" ? 95 126

You might also like