The document provides a comprehensive overview of Python programming basics, including data types, arithmetic, comparison, and logical operators. It also covers decision-making structures, loops, and list operations, demonstrating various functionalities through code snippets. Additionally, it introduces tuples and their immutability in Python.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
4 views3 pages
Basics of Python
The document provides a comprehensive overview of Python programming basics, including data types, arithmetic, comparison, and logical operators. It also covers decision-making structures, loops, and list operations, demonstrating various functionalities through code snippets. Additionally, it introduces tuples and their immutability in Python.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3
BASICS OF PYTHON
# print("hello i am hp talking to you!!!!!!!!!!!")
# age=18 #intiger number #in python we have fout type of data mainly that is number string boolean and the float # price=890000.78 #floating point # first_name="jinson" #string # is_online=False #boolean # print(is_online) # name="john smith" # age=40 # new=True # name=input("hello what is your name ") # print("hello welcome "+name) # birth_year=input("enter your birth year") # age=2024-int(birth_year) # print(age) # int() # float() # bool() # str() # first_number=input("enter the first number") # second_number=input("enter the second number") #sample float number calculator # sum=float(first_number)+float(second_number) # print("sum"+str(sum)) # name=" python for me " # print(name.lower()) # print(name.upper()) # print(name.find("for")) # print(name.replace("for","4")) # print(name.replace("python","java")) # print(name.rstrip()) # print("for" in name) ###ARITHEMATIC OPERATOR################# # print(49+9) # print(45*6) # print(59-89) # print(49/7) # print(47%5)#reminder is the modulo operator # print(10//3)#its the floor division i will print only the digit before the decimal # print(2**3)# its is the power operator # x=10 # #x=x+34 # x+=34#augmented assignment # x-=90 # x*=90 # x/=78 ###########COMPARISON OPERATOR################# # x= 3<+2 # print(x) # > # >= # < # <= # == # != ###########LOGICAL OPERATOR################ # price=45 #print(price>25 and price <50) # print(price>50 or price ==46) # print( not price >50) # and(both) # or(at least one) # not(inverse) ###########decision making########## # temprature= int( input("enter the temprature")) # if temprature>=30: # print("its a hot day") # print("drink plenty of water") # elif temprature >20 and temprature<30: # print("its a good day") # print("enjoy everyday") # elif temprature >10: # print("its a little bit cold out there ") # print("wear winter clothes") # else: # print("its too cold make sure you are safe ") # print("done") # weight=float(input("wieght: ")) # name=input("(K)g or (L)bs") # if name.upper()== "k" or "K": # print("weight in pound:"+str(weight*2.20462)) # elif name.upper()=="l"or"L": # print("wieght in kg:"+str(weight/2.20462)) ##################while loop############################## # i=1 # while i<=5: # print("*"*i) # i+=1 # print(i) #######################list################################ # names=['johan','jinson','jissa','jijy'] # print(names[0]) # print(names[1:4]) ###################using of loops##################### # numbers=[1,2,3,4,5] # for item in numbers: # print(item) # i=0 # while i<5: # print(numbers[i]) # i+=1 ##############list methods############## # numbers=[1,2,3,4,5] # numbers.append(6) # print(numbers) # numbers.insert(2,45) # print(numbers) # numbers.remove(45) # print(numbers) # print(len(numbers)) #####################range################ # number=range(5,19) # for i in range(4,56): # for j in number: # these range is use to print a sequence of numbers # print("hackin nasa") # number=range(5,19) # for i in range(4,56,2): # print(i) #################tuples################## #these tuples are immutable lists # numbers=(1,2,3,4) # print(numbers.count(2))