. . Programs using Tuples a = int(input("Enter value of A: ")) b = int(input("Enter value of B: ")) print("Value of A = ", a, "\n Value of B = ", b) (a, b) = (b, a) print("Value of A = ", a, "\n Value of B = ", b) Output: Enter value of A: Enter value of B: Value of A = Value of B = Value of A = Value of B = Program : Write a program to swap two values using tuple assignment 12th Computer Chapter - - pi = . def Circle(r): return (pi*r*r, *pi*r) radius = float(input("Enter the Radius: ")) (area, circum) = Circle(radius) print ("Area of the circle = ", area) print ("Circumference of the circle = ", circum) Output: Enter the Radius: Area of the circle = .
Circumference of the circle = .400000000000002 Program : Write a program using a function that returns the area and circumference of a circle whose radius is passed as an argument.two values using tuple assignment Numbers = ( , - , , , - , , ) Positive = ( ) for i in Numbers: if i > : Positive += (i, ) print("Positive Numbers: ", Positive) Output: Positive Numbers: ( , , , , ) Program : Write a program that has a list of positive and negative numbers. Create a new tuple that has only positive numbers from the list Sets . Introduction In python, a set is another type of collection data type. A Set is a mutable and an unordered collection of elements without duplicates.
That means the elements within a set cannot be repeated. This feature used to include membership testing and eliminating duplicate elements. 12th Computer Chapter - - Lists, Tuples, Sets and Dictionary . .
Creating a Set A set is created by placing all the elements separated by comma within a pair of curly brackets. The set() function can also used to create sets in Python. Syntax: = {E1, E2, E3 …….. En} >>> S1={ , , ,'A', .