Showing posts with label CollectionTypePython. Show all posts
Showing posts with label CollectionTypePython. Show all posts

50 Program to demonstrate methods and functions of Dictionary in Python

Program 1: #getting keys and values material={"books":10,"pens":20,"chairs":30} print(material.keys())  #p...
Read More

49 Program for modifying,adding and printing an element of dictionary in Python

Program: #modifying,adding and printing an element of dictionary std={"name":"kumar","height":5.6,"we...
Read More

48 Program for mathematical operations using SET methods in Python

Program: #mathematical operations using set methods A={10,20,30,40,50} B={10,20,60,70,80} print(A) print(B) print(A|B) print(B|A) ...
Read More

47 Program applying functions on SET in Python

Program: #applying functions on set x={40,10,30,20,50} print(x) print(type(x)) print(len(x)) print(sum(x)) print(max(x)) print(min...
Read More

46 Program to create SET object in Python

Program: #creating set object x={10,20,30,40,50}  #homogeneous elements print(x) print(type(x)) y={501,6.1,True,"hello"} ...
Read More

45 Program to demonstrate Type-Casting for Collection Type in Python

Program: #case 1: Converting List to tuple x=[10,20,30,40,50] print(x,type(x)) y=tuple(x) print(y,type(y)) #case 2: Converting T...
Read More

44 Program for tuple with different elements in Python

Program: #tuple with different elements x=((10,20,30),[40,50,60],"hello",4.5,True) #here elements of a tuple can be either mut...
Read More

43 Program to compute sum of tuple elements using for and while in Python

Program: #computing sum of tuple elements using for and while x=(10,20,30,10,50) # using for-loop sum=0 for p in x:     sum=sum+...
Read More

42 Program to demonstrate nested list in Python

Program: x=[[10,20,30],[40,50,60],[70,80,90]] print(x) print(type(x)) print(len(x)) print(x[0],type(x[0])) #1st list print(x[1],ty...
Read More

41 Program to demonstrate List Functions in Python.

Program: #Functions which can be applied on lists #ex:- len(),max(),min(),sorted(),reversed() x=[60,10,40,30,20,50] print(len(x)) p...
Read More

40 Program to demonstrate List with heterogeneous elements in Python

Program: #list with heterogeneous elements x=[501,6.1,True,"python"] print(x[2]) print(x[3][2]) for p in x:     print(p,ty...
Read More

24 Program to print the number in words for example: 1234=> One Two Three Four in Python

Program: num = int(input("Enter any number:")) t = list() while num > 0:     rem = num %10       if rem == 0:      ...
Read More

23 Program to find the repeated items of a tuple using Python

Program: t = [int(x) for x in input("Enter any value:").split()] t = tuple(t) print("Repeated Values:") for i in range...
Read More

22 Program to create a tuple and find the minimum and maximum number from it using Python

Program: t = tuple() t = [int(x) for x in input("Enter any 5 value:").split() ] minimum = t[0] maximum = t[0] for i in ...
Read More

21 Program to select the even items of a list using Python

Program: l = list() l = [x for x in input("Enter any number of value: ").split()] length = len(l) print("Even items...
Read More

20 Program to find common items from two lists using Python

Program: l1 = list() l1 = [x for x in input("Enter any 5 value for l1: ").split()] l2 = list() l2 = [x for x in input(...
Read More

19 Program to reverse a list using Python

Program: l = list() l = [x for x in input("Enter any 5 value: ").split()] length = len(l) print("Reverse List:",...
Read More

18 Program to get the smallest number from a list using Python

Program: l = list() l = [int(x) for x in input("Enter any 5 value: ").split()] small = l[0] for i in l:     if small ...
Read More

17 Program to get the largest number of a list using Python

Program: l = list() l = [int(x) for x in input("Enter any 5 value: ").split()] large = l[0] for i in l:     if large ...
Read More