0% found this document useful (0 votes)
44 views10 pages

Python Crash Course 1683722343

Uploaded by

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

Python Crash Course 1683722343

Uploaded by

Bruno Giordani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 10
# Running the Hello World Pmgram => Print (Hello Python World") Hello Python World ¥ Variables Variables are containers for Sorting data Values meesage = “Hello Python World” Paint (tmeasape) Hetlo Python world! & Strin 4 String isa Sequence of chavacterg Name = Ada Lovelace Print (name. upper) Print (name. tower C)) ADA LoveLAace Ada lovetaee a= % Combining or Concalenating Strings => © message =" Hello, "+ full name. tittec) +" 1" ® Print (message) & Numbers Integers: you can add (+) ,Substract (-) Thaltiply(t), and divide (/) integers in python. a 243 >>> 34 Fp >>> 243% 777 3-2 4 eK m 4 yy 3**3 Y>y(a43)*y rrr 3%, oF 20 6 te 3/2 2>> 10 *6 1a 1000000 4 What is 0 List? A List a Collection of items in a particular order, you can make a list that indudes the letters of the alphabet, the digit from 0-901 the name oF all tte People in cour family + you can pur anything you wont in o list. # Accessing Elements in O List bicycles = ("trek’, cannondale’ ‘redline’ ‘Specialised “J © Print Cbfoyctes fo) bi cycles =[‘krek’ cann ondale, Vedi", “Specialised” J Point (bicyeles [oJ title ()) F Index Positions bicycles =["trek’ camondale’® ‘vedlins!, ‘Specialized ] Print (bi oydes (13) Print (bicyctet [3]) motorcycles. oppend ( ducati’) Print (motorcycles) [honda’ ‘yamaha, ‘Suzuke ‘] f honda’, gamaha | Suzuki lucati’] * Removin det motorcyces (2) Print (matortycle} Fwiow. bepec-in {‘honda', ‘yamaha’ _ ‘Suuki?] C'honda’, ‘yamaha’ J * Popping Fitst owned = motorcycle . pop (0) Print (the first motorcycle T owned was a't fixek_ — Owned. titlec)+ '.*) The first motoycycle T owned was a tonda. 4 Removing an item by value motorcycles = [ao " ‘gamaha! Suzuki; ducati?) Print ( motoreyctes) motorcycles. vemove (ducati) Print (motoroydes) * Sovt cors = [“bmuo! , ‘audi’ * toyota’ , Subaru”) Cors . Sort (revers =True) Paint Ccars> 3) Se Btoyots''cubarw’,'biw’, ‘oudi’] + Looping Omagician = [ alice’, david, Corofina ') @ fos magician in rnagictans ; ® Printing (magicians) * Using Range function for value in ranges C15): ao Fox value in vange (1,6): 4 Print (value) E 4 i 5 4 5 # Squares © Square =( J © fet lac in vange (4,44): ® re = value* *g © Squores. append. (square) © print CSquores) (1. 4,9 te, 25,36, 49, 614, Bt, too] er Tuple ee ons = ’ for dimension in linear print (dimension) 200 50 & Lf Statement cors = Laud?’ ‘bmw’, Subiru, toyota] for car incars © if cr == ‘bmw’; Print (car. upper()) print (cor. title CD) Audi BMW Subisu Toyota. Checking whether a value is not ina tist banned_users = [andrew corolin’, david J users = marie ® if user not in banned uSere: Print (usertitlet) +" qou con post a response if you . wish") & Voting age =(§ © if afe > =18 © — Priat (you are old enough to vote!) qyou are old enough to vote! fimusement Pork. (e afe 4: Print (“your admission cost is $0.) + Dictionary uStY_O = ‘username’ ‘eferm?’ “finst’ s “enrico’, ‘last’ s * 5 fermi’, WD tor Key Value In User_o. items¢): @ print ("\nkey + " +key) ® Print (“value: " 4 value) fork, V im USer_o. items C) > alien_o = {colour : 5 reer’, ‘points ‘s 54 alten.d = { ‘colous’ 2° yellow! , Points’: lof alien. 2 = { colour’ s * ved! ~ points’ 1154 ® aliens = Calien.o, alent, alten] for ahen in aliens: Print alien) {totowr 5 ‘Green, Paints” 254 { volour': “yellow: Points’: toy f cotour’ : “Red * Points : sy + Lrput function are = impukCplease enter your name: " Print (Hello, "+ names “1") F wa. bepee-i0] Ylease enter your name: Eric Hello, Erie | = Height = input (How tall are gov. in inch") height = int (height) it height > = 36 Print (“\nyoutre tall ermugh to vide") How tall ave you in inches $1 Youre Fall enough to vide! = while loops CurrenE number =41 while cuwent_ number 2=5: Print (curent_number) Current. number +=1 => pete [dog eat’, dog’, Goldsicn ‘nt’ rabbit’, at”) Print (pets) while ‘cat! in pets: Pets. remove (‘cat’) Print pets) asap yrunre # Defining a Function ® def Great_user(): @ “"" Display a Simple Breeling avo @ Print (Hetlo") ® Greet_userc ) Hetlo | => def make pizza C(“toppings) s "eink te list of toppings that have been requested." "" Print ( toppings) ‘make, piz3a ( "pepperont }) mane ~ pizza (Mushrooms Green peppers’ extra cheek) (' Pepperont ' > Crushrooms, ‘green peppert’‘extva. cheete’) ea

You might also like