You are on page 1of 5

Assignment1-PS(IV)

1. Create variable in all data types

Immutable Data types-

Source Code :

#ImmutableDataTypes
a=5
print("Type of a: ", type(a))

b = 4.3
print("\nType of b: ", type(b))

c = 2 + 4j
print("\nType of c: ", type(c))

str1 ='Hello World'


print(str1)

Tuple1 = ('5', '6','7')


print(Tuple1)

Output :
Mutable Data type

Source Code :

#MutableDataTypes
List = ["khushi", "abhay", "tanishq"]
print(List[2])

set = {"jatin","saurabh","maitri"}
print(set)

Dict = {1: 'sparsha', 2: 'ashish', 3: 'abhishek'}


print(Dict)
print(Dict.get(3))

Output :
2. take input from the user and Implement operators in python

source Code :

3. #Taking Input & using operators


4. a = int(input("Enter an Integer: "))
5. b = int(input("Enter an Integer: "))
6. print(a+b)
7. print(a*b)
8. print(a-b)
9. print(a > 3 and a < 10)
10. print(a <= b)
11.

Output :
3. Implement different arraysmethods

source Code :

#Array
Num=["3","2","1"]
Num.append("5")
print(Num)
Num.sort()
print(Num)
Num.pop(1)
print(Num)

Output :
4. Implement different string methods

source Code :

#String
str='Kenneth'
print(str.upper())
print(str.lower())
print(str.swapcase())
print(str.rfind('h'))
print(str.replace('eth','y'))

Output :

You might also like