0% found this document useful (0 votes)
16 views23 pages

Python 2

Uploaded by

lamaqadan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views23 pages

Python 2

Uploaded by

lamaqadan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

input :

I- ·
raise s posite 8 ..
///seGin :
W W3SK-
int : .
, ...

86/po/py : 1628351

/Estring / Etrue/false /04/ :


WP-

joek(17 skS96(11 Vi nk J& N


-

· , 00167 ,
:

. as Jes fina fa ikledo Cash like


7) Oji/aossa God : SN-
while /if avariable/shape This has a
.

X ~
t =
Px tr tax-price tax-rate : skind has No a & fur bes case sign

side &fa
· 26

5 / "Hello" /True / 1 . 0 :
160 , (5) aia'de' y (6 :
0012 =

bool float
int string
ifran slob
·
ud or
835 . Oh , at

in + (17) / int (12 51/Str (float() / Str(20)


.
: 801a'd st a

17 2 '1 01 .
'201

String
&' 1194 Said 51 151714119 012'
-

..
ord (a)- 978 sess , 23"NO 120N yuire :
is &

1 . 2 ... 10 . . .
96 cox [int]
4 3 .

,
. 5,
0 he . -

Eloat] 8" &NN82206-

2 + hj . ..
.

complex 9'6366 <419 05 -


Div = do'ds
aise(**: 201 sita-
**

2 z =
128

t
4/2
= 2 . 0 end caod ass and odle a laun ye if (1)
·
7141 da Stifin ()
128 % 10 = 8 ! -128 % 10 =
2 aib = a -

(allb)
+
b se

:2 -

i'v

d
- 162() C) :
salat > 30-
Y

-
x +X

*
1 11 %
,

/1
(N)D + -

X =

y3x x //y=
X-
-

x =
- x+
3 =
3- 6 - X = = 1 + 5084X + =
3 X+ 3 =? 196

None/0/0 0/7)/(53) .
> False + rue =1 bool : < <
g'odk fr
j'c
2 lo false = 0

·
/
LX = H
True
1 3 E

true
.
stonemas i
S
1+ 2 ! = 7 true
true

6'12a1k
·
"Elf

"not's
post

IE back fina :
slady

-
A se A or sina &

&B inc'sna sack · False hid & & & 20 &K A ise A and B not

214) na
Ov
: Braidin-said circa

8 las & sen KIS Nist use shalls star it's arrar

% False i plex -10

wo es
·
ril and

· True Or LI

·( , .
Round

round (7/2) /roundfalze


= :
~93 sit' osi 0 5
. /31 2204D k

·
sind eas Sind UTG's input
num-ist (input) 20 K sk

Print (14)

30

II'd'a

statemente
header : : 1 31p6
Foll header
3
Statement 1 165' sinsid 13a k a
ita - . Code ...

Leader : if expressive : : Less sigia


:

d
True
-

False
Statements
if
a
if-else

&
expression
-

...
Some code-
&
Trul If expression :
Fa Isl
State. 1
S+ 1 S+ 2

else :

State
. 2

...
More code..

:
if-elif-3al if S31 I'd
: - elses if jig li

print (pi , epsilon , trp ...


) : al &

g3 . !

[J ... O
8 "F" format

pu - gas
(s4
in &

↑ <bab 120 1 48167 pyski link Shaw J &poil' J. W


.
j's *

[per-month 273
: as
- ski 2006 , All
&
8 . 33. unka 20's

&er-month : 6 . 25] : oalle ja dist Loud rat & & 3 -

- 8 33
.

(11)
: 311N I'll S
Hello
Print (Helldnlama) Lama > 10246 In

print (Hello Lana") Hello Lama (ab) fold It


-
wi

print (I want to l be a billionare"X") ·


135"koldad \"

"I want to be a billionare" ( · sodad

i is alr

Print ("Hello" , end (end = "In (


I

print ("world Nig -


*
- -

>
- Hello World ·

i and & -
: bool , y i j


S

s -

-X False si or 1% .

·
"False je' 5
j -
i Q - ↑

- &-
ik &
S ! "X
-
V + rue
~ False Ge
-
kuf -

x'sjy g5s
(Trueji)(1jlj5.

& -

xi) -
.i Q
- ·

ele ,
I don't care Vtrue
Or and -

True Usi False Usi


tree Sid
False
ji True &
·
30 - while

True

Lo
expres

Jale
103 al Nashe spitals
yo <03961 ,00 accoon ·

· Use
zures busin , rad ris's -

False
Used 17 cok

· >
or

break
a are :

Lettiest (ink eit ent affa -32 s 31 s

leften Da dire daide fin


jik
· p . so and pio sa : While s else

·
Fill is else see
bitisk ,
Break 213
3r IN"sox

·
(Bod jewel enfid sp tr : continue

: pass

Unicode & Ord()/chr)


ONL Is Sid : Old
unicole da ad Chr
/Pi >
-
~ sid :

-
A
uni extende Orig
:

Old
-
t

& 114ND A Joe

-
: '
os
Alon's 4012
A B C . .

Small letter : Lowercase capital letter .

Uppercase
·a -
da fa fac
Greatest common Divisor ·
1's 125k

n= q X1 + r

find

Sen
, T
~ Sa Fina fat :
GCD &

·
140 11343
sig
mino .
(in

his has 14 da3 4 - 14 for and


ple disan ye

> : Index : 1)
&

1 = 0
empty list- [J list)
,

j, [tli bye , Love ]


I
O

25
1
-
3 -

Opal ·

.
-
1
& peka"
· ↳Seked'en/ank lead) my-list .
Append() : ' for par found is

grades : [ . . . .
I

(3) .

81952 25. 5..

grades(] =
grades(2] + 5 :
Index $304 Eig .
0

x = []

de is x deli

·
Corint skisent .

id"y ena flow new & shenoid list .


Extend

j45 -

+
a : I' &
-
* [2 : 8 : 2] 1: ~ .131 when use : Slice
-

1 7
-

cak18 . Se + T D
*
[3

* [3 ]
&
:
[ 2] ::
as
55
Js/1g j42c2k s 2 < 324 =
[S1
2121k3

est
list(range (x y ,
I
))
= :
range
3
I' . 1124

· -
. it d'383 AND

H e llo
1234
indet
0

-
5
-

4 -
3 -

2 -
1

6 job'
&
Season small list Mower

· Sec Capital is's list-


Upper

: sidised to spa
↑ 193 / 550/fresne pla : endswith/Startswith &
-1 user & X
opside- i used find
/ K was e
pale : y

'ad X & dra Sidd / <210


: COUNTIX'

· Stres 3 70 Iid is -12 :


isdigital
[1 , , 3 / (7 ..
) S is alpha
new-se Sell & 2 Per replace (5 news) ,

you synd remove insert ( )


2
-

:
·

siy D'317
- Da01 & and
.
< p(/2)
·

sand/deld N sal al of it seald : "It ack


if x in [ij , i]
PriH -- .

not in

(""" String in da Misty sin stat :


Split
"
.

j5 ·
Split
~21049j31)

OWandT

·
06 20N W
my str =
"Hi"
/Split : ei ,
my lis
+ = list (ny str)
-

"W Djood :
1Sled
x= Hello

Print(x[-1) Print (x[0]) · side is sind is sear ple


= O >
-
H

Stu "Hello Worl & 05


picks immutable 2104 signed
=
:
is say in :

Str[0] = k

X
: ank add called do

- a Pint . ~net So spe 124l fra al si disded fo as y

(spisk

join(i:Slee
·
e

-
> ind'7

ssiend added salk


paca In :
separator

·
6TNd 186 Sund in & side

&
- singly index slij
. d Qs)

(join) send's pil jyy

J19

For
- + 3)

·
gjd

--

list comprehen
x'k
<3 , 9:3172
- ↑

. 12145

-
x37127
enumerate
M[]12 16 . (14) : <132X
E
1 index 319U index

0 1 2
O

-
--
4 =
8 dec 30 + &N

jew S Sit
D's

-
nat-jEjio e) 1330a
-
dise &
·
for iin
range)]
>
-

([0. 1, 2] , [0 1 2) , .
, (0 1
, .

2)
D >R C

* nat =
[] - 5) I

for i in
range (3) : ja j

>a
tmp(st = []
for
j in
range (3) :
= nat ([0 2]] ,
1,

Emplst Append (j) .

mat .

Append (tmplst

:
113' 24 Fr ifra

[s:
.57
2
,,a , ,
J : >3 4 316)

!
- 10
- 7
mat[2[o]

nat [b][t] + es (2) is


-
=

· del mat[0] . jas *


del Mat[o][o] : <jk + Ts(3)
[[4 , 5, 6) [7 8 93]
, , , [12 35 2 5 63
, ,
.
, , [7 8 93]
1 ,

* (st =
[1 2 3],
,
S & [1 , 2 3) :
11D 636 and

&
,

-
1,
15 + 1 est 34 1S)
-
-

-
&

est Jan I ..
15+ 1

↑ 15t =
[1 2 3] , ,
g -

T1Xi 1st = []
F s

15+ 1 =
1st [ ] :
S - -
- 1st - 5]

D
-C

:
nat1 = nat

nat[0] =
[5 ,
6 , 53

o 5'51
>
-
.

& /j
I
·
sk
·

Si iN23/2 >
IJS

nat [0](0] = <2)


matt =

[at[i][j]forj in
range) (3 for ; in
range kjewa

nate =
[] ma + 1
=
[2012 ,
3] [4
. . 5 .
67 [7 8
, , ,
93]
for 1
i in
range) :

trp/st =
[]

for (
rage)
:
in
j
tmp/st Append (mat[i][j]
.

nat 1 Append (tmp(st)


.
137)b-
def (define -I -
-

31 S Ne

-
.

def name of function (x)


:

·
Break 3 as drassa ston return

a sea ski asini stra po dir


(aconcas acco stan id

GCD
·3
/adisket is sided yay) Jia & abled yadie jad s& spod : return

·
Bisy3/ ise
&

< "3T

swas

gia Gal

:
Scope : D and

·SO SU

! n kr

·
3 G set 10 Celt as "a"
dir set fal sea
X = .... ]
[ x= < ... ] 92 : fantable) side/SW)
I = x[]
:
2 831
. "Like = X

: Cimmutable) sisied/paod
DOS1)

pr sure
FIN3UT SIT -

&SN'sNx

( O Up SJ
-

↳a ar sid air Bre less-

- ↓ 25 OS (b) 50001)

& at

&
of je uses

-
133018

J
4 3 ,2
, ,
1

ser 'N

Had said
3 SCOT
-
S4355410STDO 3)
p's - single
·

sesini stadas Y
'I !
k '
Y
Cs

· ans as

Plid I'nd als


ODT /N sa Wild

ja Man
jd
·
O :
Eso) old da
Selection sort/bubble sort -
O(t His
Dy
psa
:

merge sort OGlogy

- Return &S al 3/126


41877 $150 Joy
pass
.

1 I'd or dis scised

You might also like