text
stringlengths
0
312
else:
min_ = b
while True:
if min_%a==0 and min_%b==0:
break
min_+=1
return min_
# Write a program to print the unique elements in a list
my_list = [1, 2, 4, 5, 2, 3, 1, 5, 4, 7, 8, 2, 4, 5, 2, 7, 3]
print(set(my_list))
# Write a function that returns the sum of digits of a given number
def digisum(num):
sum_=0
while num > 0:
dig = num % 10
sum_+=dig
num//=10
return sum_
# Write a program to check and print whether a number is palindrome or not
num = 12321
temp = num
rev = 0
while num > 0:
dig = num % 10
rev = rev*10 + dig
num//=10
if temp==rev :
print("The number is a palindrome!")
else:
print("The number isn't a palindrome!")
# Write a function that prints a given value, n number of times
def print_n(val, n):
for _ in range(n):
print(val)
# Write a function to find the area of sqaure
def square_area(a):
return a*a
# Write a function to find the perimeter of a square
def square_perimeter(a):
return 4*a
# Write a function to find the area of rectangle
def rectangle_area(l, b):
return l*b
# Write a function to find the permieter of a rectangle
def rectangle_perimeter(l, b):
return 2*(l+b)
# Write a python function to find the area of a circle, whose radius is given
def findArea(r):
PI = 3.142
return PI * (r*r)
# Write a function to calculate and return electricity bill. Units used are given. Price per unit is fixed and is increased after 750 units.
def calc_elect_bill(units):
if units > 0:
if units <= 750:
return 5*units
else:
return 5*(750) + 7*(units-750)
else:
return -1
# Write a function to return day of a week, given the number
def give_day(n):
day_dict = {1: 'Sunday', 2: 'Monday', 3: 'Tuesday', 4: 'Wednesday', 5: 'Thursday', 6: 'Friday', 7: 'Saturday'}
return day_dict[n]
# Write a program to calculate and print the volume of a cylender
r = 3
h = 5
pi = 3.14
volume = pi*(r**2)*h
print(volume)
# Write a function to calculate and return the average of input numbers
def calc_avg(*args):
if len(args) > 0:
return sum(args)/len(args)