Vous êtes sur la page 1sur 3

Python is an object oriented hat mean we don’t need to declare veriavle on the beging

And do not specic verible

-+ - / * % **

#comment

Veriable-name of verible and a number by using name =number

Open file in terminal- ls – cd>name directory- pythin./ filen ame

Syntax-is like grammar in English

If else- declare a value- declare statement and comment

String operation-text that can be defined as anything between the qutos

String=”====”

Bollean value-veraivle=true /false/not true/not false

Operator- string=”word”> string in [“ “ ,” “ ]>print (“ “)

String=print(input(‘===’))

String-string=”==”

Print(string.upper/lower())

New line-\n

Combing string-string=”==” >string=(“string+string”)

Str func=if we want to combine string sentec and intger

Myname=”edcecd”

Age=32

Total=(myname+str(age))

Title function-for capitalize the fis ;etter in word

Print(string.title())

Lists-squere bracket[] but each elemnt separate by commas,

Animal=[“ddd”,”dd”]

Print(animal[1].title())

Print(animal[-1].title())

Combine lists=

Msd=”dsfdeffef”

Print)msd+animal[1].title())

Or

Print(“efwffw”+” “+animals[1].title())

For change branch =string[1]=”dddd”


Delet- del string[1]

Sort and reverse= a-z

list[“aa”,”bbb”]

list.sort

list.sort(reverse=true)

Len=how many elemnt in the list

Print(len(list))

Loops=loop in list help us to print each element indiviualy

For list in list:

Print(“I love “+list)

For loop with range()-genertae numbr that we specific

For value in range(1,5):

Min,max,sum=listnum=[1,2,3,4]

Print(min(listnum))=1

Print(max(listnum)) = 4

Print(sum(listnum)) = 10

Making slicing list-we need to specific the last and first element [:]

Loop with slicing liost=

List=[‘ccc’,’ccc’]

For list in list[0:5]:

Coping list using slicing list-if we want to add new element to your slice list or edit it

List=[‘ddd’,’ddd,’ddd’]>cpy_list=list[:]>cpy_list.append()

Tuples-that imutable pythion object that like list but we can change that

Tup = ( , , )

If else statement if; <<< else:

Eauel greater or less than- that mathematic staatment instead if else

< > = <= =>== != and or

Compare string- string = “ “ string2= “ “

Checking value if else statement- if (__ in list);

Checking value if else not statement- if (__not in list);

If elif else

Elif ( ) :
Dictionary in python-collection similar to list the allow connect pieces of information so we can acess thes information inside
oure dictionaris and change information

dic={ “Toyota”:”camery”,”cylinder”:”v6” }

adding new value- dic[“color”]=”white”

filling empty dictionary-dic={}>dic[“Toyota”]= “ “

edit value in dictionary=dic[“___”]=” “

delete key from dictionary=del dic[“___”]=” “

input-

classes- class Name ():

Vous aimerez peut-être aussi