Python Codes
Python Codes
d=a+b+c
print(d)
#2.Program to obtain length and breadth of a rectangle and calculate its area.
#3.Program to get selling price and GST rate and print invoice with CGST and SGST
sgst = cgst
print("\nInvoice:")
A,B,C,D = 9.2,2.0,4,21
print(A/4)
print(A//4)
print(B**C)
print(D//B)
print(A%C)
i=2 #integer
fl=4 #integer
A=(ch+i)/db #expression 1
B=fd/db*ch/2 #expression 2
print(A)
print(B)
#7.Program to display given code.
a=5
b = -3
c = 25
d = -10
a+b+c>a+c-b*d
a = 3 + 5/8
b = int(3 + 5/8)
c = 3 + float(5/8)
d = 3 + float(5)/8
e = 3 + 5.0/8
f = int(3 + 5/8.0)
print(a,b,c,d,e,f)
PV = 100000
FV = PV * (1+r)**n
#11. Program to check if the first number is divisible by the second number
if num2 == 0:
else:
if num1 % num2 == 0:
else:
if num % 2 == 0:
else:
else:
# 15.Program to calculate the amount payable after sales discount and sales tax
else:
print("Invalid sales tax rate. Please enter a value between 5% and 12%.")
#16. Program to print an invoice for the sale of "Amul Butter 100 gms"
quantity = 4
price_per_item = 45
tax_rate = 0.05
print("Invoice")
print("-" * 30)
print("Item:",item_name)
print("Quantity:",quantity)
print("Total: Rs.",total)
SI = (P * R * T) / 100
return SI
A = P * (1 + R / (n * 100)) ** (n * T)
return A
print("Menu:")
if choice == 1:
SI = calculate_simple_interest(P, R, T)
elif choice == 2:
n = int(input("Enter the Number of Times Interest is Compounded per Year (n): "))
A = calculate_compound_interest(P, R, T, n)
CI = A - P
else:
# 18.Program that reads two numbers and an arithmetic operator and displays the computed results.
if operator == '+':
if num2 != 0:
else:
else:
result = "Invalid operator"
print("Result:”,result)
numbers.sort()
print("Item Code:",item_code)
num = 5
#22. Program to print sum of natural numbers between 1 to 7 . Print the sum progressively, i.e.,after adding each
natural numbers , print sum so far.
total_sum = 0
total_sum += number
total_sum = 0
total_sum += number
total_transactions = 0
total_items_sold = 0
print("Day", day)
total_transactions += transactions
total_items_sold += items_sold
if total_transactions > 0:
else:
print("Illustration of 'break':")
if i == 4:
break
print("Value:", i)
print("\nIllustration of 'continue':")
if i == 4:
print("Encountered 4, skipping this iteration.")
continue
print("Value:", i)
total_sum = 0
while True:
if number < 0:
break
total_sum += number
if choice == "no":
break
else:
def is_consonant(c):
return True
return False
longest_substr = ""
current_substr = ""
if is_consonant(char):
current_substr += char
else:
longest_substr = current_substr
current_substr = ""
longest_substr = current_substr
def capitalize_alternate(input_string):
result = ""
for i in range(len(input_string)):
if i % 2 == 0:
result += input_string[i].lower()
else:
result += input_string[i].upper()
return result
if __name__ == "__main__":
result_string = capitalize_alternate(input_string)
def validate_email(email):
if email.endswith('@edupillar.com'):
return True
else:
return False
if __name__ == "__main__":
if validate_email(email):
else: