Cs File
Cs File
print(m)
a=int(input("enter number"))
b=int(input("enter number"))
if a>b:
print("a is greater")
else:
print("b is greater")
a=int(input("enter number"))
b=int(input("enter number"))
c=int(input("enter number"))
if a>b and a>c:
print("a is greatest")
elif b>a and b>c:
print("b is greatest")
else:
print("c is greatest")
for i in range(1,6):
for j in range(0,i):
print("*",end="")
print()
for i in range(5,0,-1):
for j in range(1,i+1):
print(j,end="")
print()
for i in range(1,6):
s=65
for j in range(0,i):
print(chr(s),end="")
s=s+1
print()
#1+x+x^2+x^3+x^4+ ............x^n
import math
x = int(input("Enter value of x:"))
n=int(input("Enter value of n:"))
s=0
for i in range(n+1):
k=math.pow(x,i)
s+=k
print("answer is",s)
#1-x+x^2-x^3+x^4+ ............x^n
x = int(input("Enter value of x:"))
n=int(input("Enter value of n:"))
s=0
j=1
for i in range(n+1):
j=math.pow(-1,i)
k=math.pow(x,i)
k=k*j
s+=k
print("answer is",s)
x = int(input("Enter the value of x "))
n = int(input("Enter the value of n "))
sum = 0
for i in range(1, n + 1) :
term = x ** i / i
sum += term
print("Sum =", sum)
import math
x = int(input("Enter the value of x "))
sum = 0
m = 1
for i in range(1,x+1) :
term = x ** i / math.factorial(i)
sum += term
print("Sum =", sum)
# Create a dictionary with the roll number, name and marks of n students in a class
#and display the names of students who have marks above 75.
n = int(input("Enter the number of students"))
data = {}
for i in range(n):
roll_number = int(input("Enter roll number for student: "))
name = input("Enter name for student: ")
marks = int(input("Enter marks for student: "))
data[roll_number] = {'name': name, 'marks': marks}
print(data)
print("Students who have secured marks above 75")
for roll_number, details in data.items():
if details['marks'] > 75:
print(details['name'])
# list of numbers
list1 = [509, 10, 18, 39, 109, 95]
list1.sort()
print("Smallest element is:", list1[:1])
# GCD PROGRAM
a = int(input("Enter 1st number: "))
b = int(input("Enter 2nd number: "))
i = 1
while(i <= a and i <= b):
if(a % i == 0 and b % i == 0):
gcd = i
i = i + 1
print("Greatest Common Divisor (GCD) is ", gcd)
# LCM PROGRAM
if a > b:
greater = a
else:
greater = b
while(True):
if((greater % a == 0) and (greater % b == 0)):
lcm = greater
break
greater += 1
print("The Least Common Multiple (LCM) is ", lcm)