Python Assignment 1 - sayandeep routh7
Python Assignment 1 - sayandeep routh7
1. Write a Python program to rotate the value of x, y, z such that x has the
value of y, y has the value of z and z has the value of x
=> print("Enter the value of three variable ")
temp = x
x=y
y=z
z = temp
print(x)
print(y)
print(z)
flag = 0
if string[i] == char:
flag = 1
if(flag == 1):
print("Found")
else:
print("Not Found")
5. Write a Python program that prints out the decimal equivalents of 1/2,
1/3, 1/4,...., 1/10 using for loop.
=> a=[]
for i in range(2,11):
a.append(1/i)
print(a)
=> list1 = []
list1.append(element)
list1.sort()
[4, 9, 5],
[0, 0, 0, 0],
[0, 0, 0, 0]]
for i in range(len(A)):
for j in range(len(B[0])):
for k in range(len(B)):
for r in result:
print(r)
10. Write a Python program to reverse all the elements in a tuple without
using the tuple function.
t1 = tuple(reversed(t1))
print(t1)
=>
if "mpv" in tuple
15. Write a Python program to define a function to compute GCD and LCM of
two numbers hence to
if x > y:
smaller = y
else:
smaller = x
GCD = i
return GCD
if x > y:
greater = x
else:
greater = y
while(True):
LCM = greater
break
greater += 1
return LCM
num1 = 25
num2 = 20