Python Tutorials

Python While Loop Programs 0

Python While Loop Programs

Program 1 # Program of factorial # n=int(input(“Enter a number”)) # f=1 # while(n!=0): # f=f*n # n=n-1 # print(“Factorial is “,f) # Addition of digit # n=int(input(“Enter a number”)) # s=0 # while(n!=0):...

While Loop in Python Part – 1 0

While Loop in Python Part – 1

Program 1 # i=1 # intializtion # while(i<=10): # condition # print(i) # i+=1 # increment # Table of a Number # n=int(input(“Enter a number”)) # # i=1 # intializtion # while(i<=10): # condition...

Conditional Statements in Python 0

Conditional Statements in Python

Program 1 #conditional Statements # n=int(input(“Enter a number”)) # if(n>50): # print(“Hello Friends”) # print(“DataFlair”) # print(“Bye Bye”) #Word format of number # n=int(input(“Enter a number”)) # if(n==1): # print(“One”) # if(n==2): # print(“Two”)...

Python Dictionaries 0

Python Dictionaries

Program 1 # Dictionary in Python #myd={101:’CSE’,102:’IT’,103:’Civi’,104:’MBA’,105:’Account’,102:’ITDept’} # myd={101:’CSE’,102:’IT’,103:’Civi’,104:’MBA’,105:’Account’} # print(myd.keys()) # print(“———————————-“) # print(myd.values()) # print(“———————————-“) # print(myd.items()) #print(len(myd)) # print(“Before Pop: “) # print(myd) # myd.popitem() # print(“After Pop: “) # print(myd)...

Python Set Methods 0

Python Set Methods

Program 1 #Methods of Set Collection # myset={10,”Indore”,89.99,True} # myset.add(“Mumbai”) # print(myset) # myset.clear() # print(myset) # myset1=myset # print(myset) # print(myset1) # myset.add(“Mumbai”) # myset.add(“Mumbai”) # print(len(myset)) # print(“Before Remove: “,myset) # myset.remove(“Indore”)...

Python Sets 0

Python Sets

Program 1 # Set Collection # myset1={10,20,30,40,50,30,60,20} # print(len(myset1)) #myset2={101,”Vivek”,True,98.66,13+5j} # print(type(myset1)) # print(type(myset2)) #print(myset1) #print(myset2) #myset={10,20} # mydict={} # myset=set({}) # myfset=frozenset({}) # print(type(mydict)) # print(type(myset)) # print(type(myfset)) # myset=set({}) # n=int(input(“Enter the...

List vs Tuples in Python 0

List vs Tuples in Python

Program 1 import sys #Difference between List and Tuple # mylist=[101,”Vivek”,89.99,True,10+5j,”Vivek”] # Mutable # mytuple=(101,”Vivek”,89.99,True,10+5j,”Vivek”) # Immutable # print(“Size of List: “,sys.getsizeof(mylist)) # print(“Size of Tuple: “,sys.getsizeof(mytuple)) # print(type(mylist)) # print(type(mytuple)) # print(mylist) #...

Tuples in Python 0

Tuples in Python

Program 1 #Program for Tuple Data type (Collection) #mytuple1=(10,20,30,40,50,60,70) # for x in mytuple1: # print(x) # for i in range(0,len(mytuple1),1): # print(mytuple1[i]) # i=0 # while(i<len(mytuple1)): # print(mytuple1[i]) # i+=1 #mytuple1[4]=600 # Error...

Searching Algorithms in Python 0

Searching Algorithms in Python

Program 1 # Program for Linear Search mylist=[] n=int(input(“Enter the limit”)) print(“Enter elements in list”) for i in range(0,n,1): x=int(input()) mylist.append(x) s=int(input(“Enter an element for search”)) flag=False for m in mylist: if(s==m): flag=True break...

Python List Collection Part – 2 0

Python List Collection Part – 2

Program 1 # Program of List Data Type in Python # Program for Linear search mylist=[] n=int(input(“Enter the limit”)) print(“Enter elements in list”) for i in range(0,n,1): x=int(input()) mylist.append(x) s=int(input(“Enter an element for search”))...