Python_Lab_Manual_All_Programs (1)
Python_Lab_Manual_All_Programs (1)
num1 = 5
num2 = 2.0
num3 = 1 + 2j
a=7
b=2
print('Sum: ', a + b)
print('Subtraction: ', a - b)
print('Multiplication: ', a * b)
print('Division: ', a / b)
print('Modulo: ', a % b)
print('Power: ', a ** b)
3. Program to Demonstrate Assignment Operators
a = 10
b=5
a += b
print(a)
a *= 2
print(a)
a=5
b=2
print('a == b =', a == b)
print('a != b =', a != b)
print(not True)
x1 = 5
y1 = 5
x2 = [1, 2, 3]
y2 = [1, 2, 3]
print(x1 is y1)
a = 33
b = 200
if b > a:
elif a == b:
else:
myit = iter(mytuple)
print(next(myit))
print(next(myit))
print(next(myit))
import math
print(math.sqrt(16))
print(math.pi)
a = "Hello, World!"
print(mytuple[1])
mylist.append('orange')
print(mylist)
mylist.remove('banana')
print(mylist)
mydict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
print(mydict)
print(mydict["brand"])
print(myset)
with open("sample.txt", "w") as f:
import numpy as np
print(arr)
import numpy as np
print(arr[1])
import numpy as np
newarr = arr.reshape(2, 3)
print(newarr)
18. Program to Demonstrate Math Module
import math
x = math.sqrt(64)
print(x)
import pandas as pd
series = pd.Series(data)
print(series)
import pandas as pd
data = {
df = pd.DataFrame(data)
print(df)
x = [1, 2, 3]
y = [4, 5, 6]
plt.plot(x, y)
plt.show()
x = [1, 2, 3]
y = [4, 5, 6]
plt.plot(x, y, marker='o')
plt.show()
plt.bar(x, y)
plt.show()
plt.pie(sizes, labels=labels)
plt.show()
x = [1, 2, 3, 4]
y = [2, 4, 6, 8]
plt.scatter(x, y)
plt.show()