Diese Präsentation wurde erfolgreich gemeldet.

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
×

1 von 3 Anzeige

# python.pdf

Python for Beginners.

Python for Beginners.

Anzeige
Anzeige

## Weitere Verwandte Inhalte

Anzeige

### python.pdf

1. 1. age = 50 temp = 35.8 name = "Nambi" is_offline = False # Answer for data types for all variables type(age) type(temp) type(name) type(is_offline) # Connect Numbers with string print("Age of the xyz is" +str(age)) # Receiving Input birth_year = int(input("Enter your birth year")) 1994 age = 2023 - birth_year print("Age of XYZ is"+str(age)) #String Operations Title = "Python for Beginners" Title.upper() Title.find('y') Title.replace('for','4') print("for&quot ;in Title) #Arithmetic Operators 10+3 22*3 10/3 10//3 #It gives whole Numbers(Round no) 10%3 10**3 # It means 10 to the power of 3 x = 10 x += 3 print(x) # Adding the same(x)integers with easy and faster way. # Operator Procedence x = (10 + 5)*2 print(x) # Comparison operators 3>2 # Greater than 3<2 5>=7 5<=7 5==6 # Eaual to equal to 4!=6 # Not Equal to # Logical Operators # and(both true) # or(atleast 1 true) #not(inverse of our result) age = 25 age > 10 and age < 30 age = 5 age > 10 or age < 30 age = 5 not age > 5 not age < 10
2. 2. # IF Statement # if stat is whenever we want to make a decision in our program. # : colon is everything below that colon is treat as block of code. temperature = 28 if temperature > 30: print("its a hot day!") print("its time for cola") elif temperature<30: print("its nice day!") elif temperature<10: print("its a cold day") print("Done") #While Loops # Sequence it means 1 to 5 or str 1 to 5(5 times). i = 1 while i<=5: print(i) i+=1 i = 1 while i<=10: print(i * 'Nambi') i+=1 # Lists names = ['elton','sam','Bob','Emma'] print(names) names[2] names[-1] names[0:2] names = ['elton','sam',0,0.1,True] #What ever we can give. numbers = [1,2,3,4,5] numbers.append(7) numbers.insert(0,0) numbers.clear(1) #for Loops numbers[1,2,3,4,5,6] for items in numbers: print(items) # Range function range(10) for number in range(5): print(number) for number in range(5,10,2): print(number) # Tuples numbers = (1,2,3,3) numbers.count(3)