Professional Documents
Culture Documents
MieTy Project
MieTy Project
➣ Basic Operations
x = 2
y = 3
s = x+y
subtraction = x-y
division = x/y
multiplication = x*y
po = x**y
square_root = x**(1/2)
print(s)
print(subtraction)
print(division)
print(multiplication)
print(po)
print(square_root)
➣ Fibonacci Series
def fibonacci(num: int) -> int:
"""
Function takes in a number and returns the fibonacci series
of that number
"""
if(num==1):
return 0
elif(num==2):
return 1
else:
fa, fb = 0, 1
for i in range(2, num + 1):
fa, fb = fb, fa + fb
return fb
storage = []
for i in range(1, 11):
storage.append(str(fibonacci(i)))
print(", ".join(storage))
t0 = time.time()
c = findPrime(100000)
print("Total prime numbers in range:", c)
t1 = time.time()
print("Time required:", t1 - t0)
➣ Kaprekar Number
number = 9
sum = 0
temp = number*number
while temp>0:
sum += temp%10
temp = temp//10
if sum == number:
print(f"{number} is a Kaprekar number")
else:
print(f"{number} is not a Kaprekar number")
Day 2 - (23/12/2022)
➣ Alphabetical Order (Reverse Sorting) [Remove duplicate]
data = ['a', 'a', 'b', 'c', 'd', 'e', 'e', 'a']
data = list(set(data))
data.sort(reverse=True)
print(data)
➣ Find the highest marks in a single semester and highest marks overall.
def highest(kwargs: dict) -> (str, str, int):
high = 0
marks = ""
sem = ""
for key, value in kwargs.items():
TempMarks, TempValue = highest_sem(value, key)
if TempValue>high:
high = TempValue
marks = TempMarks
sem = key
return (sem, marks, high)
marks = {
"sem1": {
"DSA": 10,
"CO": 11,
"IT": 10,
"MATHS": 4
},
"sem2": {
"DSA": 20,
"CO": 21,
"IT": 20,
"MATHS": 10
},
"sem3": {
"DSA": 15,
"CO": 17,
"IT": 16,
"MATHS": 20
}
}
n = 3
for i in range(1, n+1):
print(" "*(n-i), "*"*(i*2 - 1))
for i in range(n-1, 0, -1):
print(" "*(n-i), "*"*(i*2 - 1))
class FactorialError(Exception):
def __init__(self, message: str):
self.message = message
super().__init__(self.message)
n = -1
try:
fact = factorial(n)
print(fact)
except FactorialError as err:
print(err)
import pandas
from seaborn import load_dataset
df = load_dataset('penguins')
(df['body_mass_g'][i]/1000)/(df['bill_depth_cm'][i]*df['bill_dep
th_cm'][i]) for i in range(len(df['bill_depth_cm']))
]
print(df.head())
Day 4 - (04/01/2023)
➣ Take the input of name of object and it method and show the help of the
function closely related to the imputed method name.