Program
Program
Program
print(x)
print(type(x))
print(x)
print(type(x))
print(x)
print(type(x))
print(x)
print(type(x))
x=[]
for i in range(0,n):
x.append(ele)
print(x)
print(type(x))
x=('one','two','three')
print(x)
print(type(x))
x={}
for i in range(n):
x[key]=val
print(x)
print(type(x))
x=bool(input('Enter a boolean value True or False:'))
print(x)
print(type(x))
Program:
def add(n1,n2):
print("Addition: ",n1+n2)
def sub(n1,n2):
def mul(n1,n2):
def div(n1,n2):
def fdiv(n1,n2):
def power(n1,n2):
def mod(n1,n2):
add(num1,num2)
sub(num1,num2)
mul(num1,num2)
div(num1,num2)
fdiv(num1,num2)
power(num1,num2)
mod(num1,num2)
Program:
def concatenate_strings(str1, str2):
return full_string[start_index:end_index]
def main():
concatenated_string = first_string+second_string
start_index = 7
end_index = 12
main()
Program:
class check:
def _init_(self):
self.n=[]
def add(self,n):
self.n.append(a)
def remove(self,b):
self.n.remove(b)
def dis(self):
return (self.n)
obj=check()
choice=1
while choice!=0:
print("0. Exit")
print("1. Add")
print("2. Delete")
print("3. Display")
if choice==1:
obj.add(n)
print("List: ",obj.dis())
elif choice==2:
obj.remove(n)
print("List: ",obj.dis())
elif choice==3:
print("List: ",obj.dis())
elif choice==0:
print("Exiting!")
else:
print("Invalid choice!!")
print()
Program:
T = ("apple", "banana", "cherry","mango","grape","orange")
for x in T:
print(x)
if "apple" in T:
alice_score = student_scores['Alice']
student_scores['Bob'] = 80
student_scores['Charlie'] = 88
print("\nStudent Scores:")
print(f"{name}: {score}")
if 'Emma' in student_scores:
else:
del student_scores['John']
print(f"{name}: {score}")
Program:
def findLargest(numbers):
if not numbers:
return None
largest = numbers[0]
largest = num
return largest
elements = []
for i in range(n):
elements.append(element)
result = findLargest(elements)
if n == 1:
return n
else:
return n*recur_factorial(n-1)
if num < 0:
elif num == 0:
else:
n1, n2 = 0, 1
count = 0
if n <= 0:
elif n == 1:
print(n1)
else:
print("Fibonacci sequence:")
print(n1)
nth = n1 + n2
n1 = n2
n2 = nth
count += 1
Main Program:
import ex9mf
print(ex9mf.fib(x))
Module Program:
def rep(name,regno,dep,s1,s2,s3,s4,s5):
print("Name:",name)
print("Register No:",regno)
print("Department:",dep)
tot=s1+s2+s3+s4+s5
print("Total Mark:",tot)
ave=(s1+s2+s3+s4+s5)/5
print("Average:",ave)
per=(s1+s2+s3+s4+s5)/500*100
print("Percentage:",per)
Main Program:
import ex10mf
dep=input("Enter a Department:")
ex10mf.rep(name,regno,dep,s1,s2,s3,s4,s5)
Program:
try:
content = input_file.read()
except FileNotFoundError:
quit()
output_file.write(content)
fh = open(fname)
lst = list()
words=[];
words += line.split()
words.sort()
if word in lst:
continue
else:
lst.append(word)
print(word)
Program:
class py_solution:
val = [
10, 9, 5, 4,
syb = [
"I"
roman_num = ''
i=0
roman_num += syb[i]
num -= val[i]
i += 1
return roman_num
num=int(input('Enter a Number:'))
print(py_solution().int_to_Roman(num))
Program:
class py_solution:
return x
if x==-1:
if n%2 ==0:
return 1
else:
return -1
if n==0:
return 1
if n<0:
return 1/self.pow(x,-n)
val = self.pow(x,n//2)
if n%2 ==0:
return val*val
return val*val*x
print(py_solution().pow(x,n));
Program:
def reverseWord(s, start, end):
start = start + 1
end = end - 1
s = input("Enter a String:")
s = list(s)
start = 0
while True:
try:
start = end + 1
except ValueError:
break
s.reverse()
s = "".join(s)
print(s)