Docs
Docs
s
a = 6; b = 3;
c = a + b
print(c)
c = a - b
print(c)
c = a * b
print(c)
c = a / b
print(c)
Output:- 9
3
18
2.0
2.#Program to find area of square/rectangle/circle
l = 4;b =5;r = 7;
print("Area of rectangle = ",l * b)
print("Area of square = ",l * l)
print("Area of circle = ",3.14 * r * r)
Output:- Area of rectangle = 20
Area of square = 16
Area of circle = 153.86
# Tuples
t = (1, 2, 3)
print("Tuple:", t)
print("First element:", t[0])
print("\nTuple length:", len(t))
print("Tuple max value:", max(t))
print("Tuple min value:", min(t))
Output:-
Tuple: (1, 2, 3)
First element: 1
Tuple length: 3
Tuple max value: 3
Tuple min value: 1
Output:-
List: [10, 20, 30]
Appended List: [10, 20, 30, 40]
List length: 4
Sum of List elements: 100
Sorted List: [10, 20, 30, 40]
# Dictionary
d = {'name': 'John', 'age': 25, 'city': 'New York'}
print("\nDictionary:", d)
print("Name:", d['name'])
d['job'] = 'Engineer'
print("Updated Dictionary:", d)
print("\nDictionary keys:", d.keys())
print("Dictionary values:", d.values())
print("Is 'age' key in the dictionary?", 'age' in d)
Output:-
Dictionary: {'name': 'John', 'age': 25, 'city': 'New York'}
Name: John
Updated Dictionary: {'name': 'John', 'age': 25, 'city': 'New York', 'job': 'Engineer'}
Dictionary keys: dict_keys(['name', 'age', 'city', 'job'])
Dictionary values: dict_values(['John', 25, 'New York', 'Engineer'])
Is 'age' key in the dictionary? True