Posts

Showing posts from May, 2022

while loop in python

 while loop in python # while loop : """ while(i<45): print(i) i = i + 2 while(i<200): i = i + 1 print(i) """ i= 0 while ( True ): if i+ 1 < 5 : i=i+ 1 continue print (i+ 1 , end = " " ) if (i== 44 ): i = i + 1 break

for loop

for loop in python   # for loop: # for i in range (11): # print(i) list1 = [ [ "Jetha" , 10 ],[ "Nihil" , 200 ],[ "Goli" , 60 ],[ "Daya" , 9 ],[ "Hathi" , 250 ]] for i1,dabeli in list1: if dabeli >= 1 : print (i1, "Eats" ,dabeli, "Dabeli" )

If ,else and elif

If ,else and elif    # if, else and elif: var1 = 6 var2 = 56 var3 = int ( input ()) if var3>var2 : print ( "Greater" ) elif var3<var2: print ( "Lesser" ) else : print ( "Equal" ) #list = [4,7,8,9] #print(7 in list) #Quiz """print("What is your age ?") age = int(input()) if age>100: print("Enter valid age.") elif age>18: print("You can drive.") elif age==18: print("We cant decide you have to come here.") else: print("You can't drive.")"""

Sets in python

Sets in Python   s = set () print ( type (s)) s.add( 1 ) s.add( 2 ) s1 = { 4 , 8 } print (s.isdisjoint(s1)) print (s.union(s1)) print (s.intersection(s1))

Dictionary and its functions

Dictionary and its functions # Dictionary & It's Functions dt = { "event" : "annual function" , "author" : "ngoyp" , "subject" : "pollution" , "standad" : "8" , "year" : "tewnty one" } #print(dt.get("author")) """dt.update("rank" "first") print(dt) """ #Exercise 1 : d2 = { "see" : "watch" , "laugh" : "mock" , "tough" : "hard" , "know" : "inquire" , "happy" : "joy" } ipt = input () print (ipt + " meaning is :" +d2[ipt])

Python list and listing functions

Image
Python list and listing functions  #listing functions #list = ["parth","gayatri","vaishu","naru",7,8.90] #print(list) #pa = [1,1,4,2,9,0] #pa.sort() #pa.reverse() #pa.remove(2) #pa.append(90) #pa.insert(3,4) """print(pa[1]) pa.pop() print(pa) pa[1]=98 print(pa) """ #mutable = can change #immmutable = can't change """tp = (1,2,3) print(tp) a = 4 b = 5 a,b=b,a print(a,b) """ #pa.pop(2) #print(pa) pa = [ 'almond' , 'cashew' , 'nut' , 'kismis' , 'kismis' , 'almond' ] pa.reverse() print (pa) pa.append( 'pista' ) print (pa) pa.pop( 2 ) print (pa)

String slicing and related functions

Image
 String slicing and related functions str = "my cat is piebald" print (str) """ print(len(str)) print(str[12]) print(str[0:6]) print(str[0:17:2]) print(str[-12])""" print (str[::- 1 ]) #print(str[::]) """print(str.isalnum()) print(str.isalpha()) print(str.endswith("is")) print(str.endswith("ld")) print(str.count("i")) print(str.capitalize()) print(str.upper()) print(str.lower()) print(str.replace("cat","dog")) print(str.find("is")) """

comments ,escape Sequnces

Image
 comments ,escape Sequnces import os print ( "Hello Nisha" ) #This is a comment #print(os.listdir()) """ Name Panchal Parth Date 25 \12\202 0 Place Ahmdbd """ #print("* my name is parth *", end="") # Print like calc """print(" \n 15 * 8 =" ,end=' ') #comment after code print(15*87) print("79 / 5456 =",end=' ') print(79/5456) print("22 / 7 =",end=' ') print(22/7)""" #variable, Data type a = "demo xyz" #this is string var b = 34 #this is num var c = 23.45 #this is float var #print(type(a)) print ( "Enter your name" ) name = input () print ( "Your name is" , name) # Two value calculator user based """" print("Enter first value ") input1 = input() print("Enter second value") input2 = input() print("Your answer is :" ,end='') print(int(input1)+int(input2)) ...

Hello world

Image
Hello world print ( "hello world!" ) #to print hello world message= "parth panchal" #storing variable print (message.title()) #to print in title case print (message.upper()) #to print message in upper case print (message.lower()) #to print message in lower case private = 3 #to storing value in interger type public = 7 total = private + public #sum of that stored value print ( " \n Total Post:" ) print (total) #print of total value score= 40 + 4 print ( " \n TOTAL SCORE" ) print (score)