#Print the given strings as per stated format.
# Given strings:
# "Data" "Science" "Mentorship" "Program"
# "By" "CampusX"
# Output:
# Data-Science-Mentorship-Program-started-By-CampusX
'''
print('data',end='-')
print('Science',end='-')
print('Mentorship',end='-')
print('Program',end='-')
print('By',end='-')
print('CampusX')
#Q2:- Write a program that will convert celsius value to fahrenheit.
f=int(input("Enter the value of f : "))
c=f*9/5+32
print(c)
#Q3:- Take 2 numbers as input from the user.Write a program to swap the
numbers without using any special python syntax
num1=int(input("Enter the value of num1 : "))
num2=int(input("Enter the value of num2 : "))
print("before swap num1 : ",num1)
print("before swap num2 : ",num2)
num3=num1
num1=num2
num2=num3
print("after swap num1 : ",num1)
print("after swap num2 : ",num2)
#Write a program to find the euclidean distance between two
coordinates.Take both the coordinates from the user as input.
import math
x1=int(input("Enter thr value of x1 : "))
x2=int(input("Enter thr value of x2 : "))
y1=int(input("Enter thr value of y1 : "))
y2=int(input("Enter thr value of y2 : "))
euclidean_distance=math.sqrt(pow((x2-x1),2)+pow((y2-y1),2))
print('euclidean distance is : ',euclidean_distance)
#Write a program to find the simple interest when the
# value of principle,rate of interest and time period is provided by
the user.
principle=int(input("Enter the value of principle : "))
rate_of_interest=int(input("Enter the value of rate_of_interest: "))
time=int(input("Enter the value of time : "))
SI = (principle * rate_of_interest * time) / 100
print("simple interest is : ",SI)
# write a program to area and parameter of square ,rectangle and circle
side=int(input("Enter the side : "))
Length=int(input("Enter the Length : "))
Width=int(input("Enter the Width : "))
radius=int(input("Enter thr radius : "))
area_of_square=side*side
parameter_of_square=4*side
area_of_rectangle=Length*Width
parameter_of_rectangle=2*(Length+Width)
area_of_circle=3.14*radius*radius
parameter_of_circle=2*3.14*radius
print("area_of_square : " ,area_of_square)
print("parameter_of_square : ", parameter_of_square)
print("area_of_rectangle : ",area_of_rectangle)
print("parameter_of_rectangle",parameter_of_rectangle)
print("area_of_circle : " ,area_of_circle)
print('parameter_of_circle : ',parameter_of_circle)
#Given the first 2 terms of an Arithmetic Series.Find the Nth term of
the series.
# Assume all inputs are provided by the user.
num1=int(input("Enter the value of num1 : "))
num2=int(input("Enter the value of num2 : "))
n=int(input("Enter thr value of nth term : "))
diff=num2-num1
nth=num1+(n-1)*diff
print(nth)
# Given 2 fractions, find the sum of those 2 fractions.Take the
numerator
# and denominator values of the fractions from the user.
from fractions import Fraction
n1=int(input("Enter thr value of n1 : "))
n2=int(input("Enter the value of n2 : "))
d1=int(input("Enter thr value of d1 : "))
d2=int(input("Enter thr value of d2 : "))
f1=Fraction(n1,d1)
f2=Fraction(n2,d2)
print(f1+f2)
# Given the height, width and breadth of a milk tank, you have to find
out how many
# glasses of milk can be obtained? Assume all the inputs are provided
by the user.
# Input:
# Dimensions of the milk tank
# H = 20cm, L = 20cm, B = 20cm
# Dimensions of the glass
# h = 3cm, r = 1cm
# Dimensions of the milk tank (in cm)
h = int(input("Enter the height of the milk tank (h): "))
l = int(input("Enter the length of the milk tank (l): "))
b = int(input("Enter the breadth of the milk tank (b): "))
# Dimensions of the glass (in cm)
gh = int(input("Enter the height of the glass (gh): "))
gr = int(input("Enter the radius of the glass (gr): "))
# Volume of milk tank (cuboid): V = l × b × h
volume_tank = l * b * h
# Volume of glass (cylinder): V = π × r² × h
volume_glass = 3.14 * gr**2 * gh
# Number of glasses
glasses = volume_tank / volume_glass
print(f"Number of glasses of milk: {int(glasses)}")
'''
# Problem 1: Write a program that will give you in hand monthly salary
after
# deduction on CTC - HRA(10%), DA(5%), PF(3%) and taxes deduction as
below:
# Salary(Lakhs) : Tax(%)
# Below 5 : 0%
# 5-10 : 10%
# 10-20 : 20%
# aboove 20 : 30%
salary=int(input("Enter the salary : "))
hra=salary*0.1
da=salary*0.05
pf=salary*0.03
if salary<=500000:
print("you no need to pay any tax")
elif salary>500000 and salary<10000000:
print("you have to pay 10% tax ")
tax_calculation=(salary-500000)*0.1
ctc=salary-(hra+da+pf+tax_calculation)
monthly_salary=ctc/12
print("salary in hand : ",ctc)
print("monthly salary is : ",monthly_salary)
elif salary>=1000000 and salary<2000000:
print("you have to pay 20% tax ")
tax_calculation=500000*0+500000*0.1+(salary-1000000)*0.2
ctc=salary-(hra+da+pf+tax_calculation)
monthly_salary=ctc/12
print("salary in hand : ",ctc)
print("monthly salary is : ",monthly_salary)
elif salary>=2000000:
print("you have to pay 20% tax ")
tax_calculation=500000*0+500000*0.1+1000000*0.2+(salary-2000000)
ctc=salary-(hra+da+pf+tax_calculation)
monthly_salary=ctc/12
print("salary in hand : ",ctc)
print("monthly salary is : ",monthly_salary)
Loops
#pin change,check balance,add money,widraw exit
'''
print('----------welcome-----------------------')
pin=input("Enter your pin : ")
amount=5000
if pin=='1234':
print('1.pin chnage')
print('2.balance check')
print('3.add money')
print('4.widraw')
print('5.exit')
choice=input("Enter your choice : ")
if choice=='1':
new_pin=input("Enter your pin : ")
pin=new_pin
print("your new pin is : ",pin)
elif choice=='2':
print('your balance is : ',amount)
elif choice=='3':
print("your previous amount is : ",amount)
add_money=int(input("Enter the amount which you want : "))
amount=amount+add_money
print("your net amount is now : ",amount)
elif choice=='4':
print("your net amount is : ",amount)
widrew_money=int(input("Enter the amount : "))
print("you want to widraw the money is : ",widrew_money)
if widrew_money>amount:
print("dont have sufficient balanace")
else:
amount=amount-widrew_money
print("after widraw your net amount is : ",amount)
elif choice=='5':
print("you want to exit the program")
else:
print('your pin is incorrect')
# Write a program to calculate the electricity bill (accept number of
unit from user) according to the following criteria:
# Unit Price
# First 100 units no charge
# Next 100 units Rs 5 per unit
# After 200 units Rs 10 per unit
# (For example if input unit is 350 then total bill amount is Rs 2000)
unit=int(input("Enter the unit : "))
if unit<=100:
print("no charges")
elif unit>100 and unit<=200:
charge_on_first_100unit=0
unit_left=unit-100
charges=unit_left*5
print("you have to pay : ",charges)
elif unit>200:
charge_on_first_100unit=0
charge_on_second_100unit=100*5
unit_left=unit-200
charges=unit_left*10+charge_on_first_100unit+charge_on_second_100unit
print('you have to pay :',charges)
# Write a program to accept the cost price of a bike and display the
road tax to be paid according to the following criteria:
# Cost price (in Rs) Tax
# > 100000 15 %
# > 50000 and <= 100000 10 %
# <= 50000 5 %
cost=int(input("Enter the cost : "))
if cost<=50000:
print("tax to be paid is 5%")
tax_to_be_paid=cost*0.05
net_amount_to_be_paid=cost+tax_to_be_paid
print("net amount to be paid : ",net_amount_to_be_paid)
elif cost>50000 and cost<=100000:
print("tax to be paid is 10%")
tax_to_be_paid_on_first_50000=50000*0.05
tax_to_be_paid_on_second_50000=(cost-50000)*0.1
net_amount_to_be_paid=cost+tax_to_be_paid_on_first_50000+tax_to_be_paid
_on_second_50000
print("net amount to be paid : ",net_amount_to_be_paid)
elif cost>100000:
tax_to_be_paid_on_first_50000=50000*0.05
tax_to_be_paid_on_second_50000=50000*0.1
tax_to_be_paid_after_100000=(cost-100000)*0.15
net_amount_to_be_paid=cost+tax_to_be_paid_on_first_50000+tax_to_be_paid
_on_second_50000+tax_to_be_paid_after_100000
print("net amount to be paid : ",net_amount_to_be_paid)
#Write a program to find the sum of squares of first n natural numbers
where n will be provided by the user.
n=int(input("Enter the value of n : "))
i=1
sum=0
while i<=n:
sum=sum+pow(i,2)
i+=1
print(sum)
'''