Question 1:Write a program find the addition, subtraction, multiplication, division of two numbers input from user.
Solution:
print('\n\tEnter the two number(execpt zero)')
x = int(input("\n\tEnter the number 1: ")) # input of number 1
y = int(input("\tEnter the number 2: ")) # input of number 2
addition = int(x+y) # adding statement
subtaction = int(x-y) # subtracting statement
multiply = int(x*y) # multiply statement
divide = int(x/y) # divide statement
print("-----------X-----------X-----------X-----------")
print("\tThe addition of this numbers is: ", addition)
print("\tThe subtraction of this numbers is: ", subtaction)
print("\tThe multiplication of this numbers is: ", multiply)
print("\tThe division of this numbers is: ", divide)
You can check the solution:- Check here
Question 2:Write a program find the area of rectangle take input from user.
Solution:
l=float(input("\nEnter the length of rectangle: "))
b=float(input("Enter the breath of rectangle: "))
area= l*b
print("The area of give length and breath rectangle is: ",area)
You can check the solution:- Check here
Question 3:Write a program find the BMI of person take input from user.
Solution:
w=float(input("Enter your weight(in kg): "))
h=float(input("Enter your height(in m): "))
B_M_I=w/(h*h)
print("The BMI of your body is: ",B_M_I)
You can check the solution:- Check here
Question 4:Write a program to calculate Simple interest and compound interest input from user.
Solution:
print("\n\t||********** Interest Calculator **********||")
p = int(input("Enter the principal amount: "))
r = float(input("Enter the rate of interest: "))
t = int(input("Enter the time in year: "))
si = float((p*r*t)/100)
a = float((p*pow(1+(r/100), t)))
ci = float(a-p)
print("\n\t||********** Simple interest **********||")
print("\t\t\t", si)
print("\n\t||********** Compound interest **********||")
print("\t\t\t", ci)
You can check the solution:- Check here
Question 5:Write a Program to calculate total salary based upon the following:-
HRA = 3 % of Basic salary, TA = 5 % of Basic salary, DA = 3 % of Basic salary.
Solution:
print("\n||********Calculating total salary********||")
basic=int(input("\n\tEnter Basis Salary: "))
hra=float(basic * 3 / 100)
ta=float(basic * 5 / 100)
da=float(basic * 3 / 100)
total_sal=float(basic + hra + ta + da )
print("\n\tTotal Salary: " ,total_sal)
You can check the solution:- Check here
Question 6:Write a program to convert temperature from Celsius to Fahrenheit.
Solution:
print('\n\t||********** Convert temperature from Celsius to Fahrenheit **********||')
c=float(input("\n\tEnter the temperature in celsius: "))
f=float((c*9)/5+32)
print('\n\tThe converted temperature in celsius is: ',f)
print('\n\t\t||********** End is here **********||')
You can check the solution:- Check here
Question 7:Program to enter an character and display the ASCII code associated with it
Solution:
print("\n\t||********** Display the character associated with ASCII code **********||")
code=(input("\n\tEnter the value of code: "))
print("\tThe ASCII value of '" + code + "' is", ord(code))
You can check the solution:- Check here
Question 8: Program to determine the value of a variable num2 depending on num1
Solution:
print("\n\t||********Calculating num2 wrt num1********||")
num1 = int(input("\tEnter the value of num1: "))
num2 = 1 if num1 > 10 else 0
print("\tThe value of num2:", num2)
You can check the solution:- Check here
Question 9: Write a Program to swap two numbers (integers) using third variable
Solution:
x = input('Enter value of x: ')
y = input('Enter value of y: ')
# create a temporary variable and swap the values
temp = x
x = y
y = temp
print('The value of x after swapping: {}'.format(x))
print('The value of y after swapping: {}'.format(y))
You can check the solution:- Check here
Question 10:Write a Program to swap two numbers (integers) without using third variable
Solution:
x = input('\nEnter value of x: ')
y = input('Enter value of y: ')
x, y = y, x
print('The value of x after swapping: {}'.format(x))
print('The value of y after swapping: {}'.format(y))
You can check the solution:- Check here
Question 11:Write a program to input 3 sides of triangle and calculate area.
Solution:
print("\n\t||********Calculating Area Of Triangle********||")
a = int(input("\tEnter side a: "))
b = int(input("\tEnter side b: "))
c = int(input("\tEnter side c: "))
s = (a+b+c)/2
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print("\nThe area of the triangle is: %0.2f" % area)
You can check the solution:- Check here
Question 12:Write a program which takes no of days as input and convert it into no. of year, month, week, and days
Solution:
print("\nEnter the days::")
d, y, w = int(input()), None, None
# d = days
# y = years
# w = weeks
# Conversion of days in to years, weeks and days
y = (int)(d / 365)
w = (int)((d % 365) / 7)
d = (int)(d - ((y * 365) + (w)))
# Output
print(y, " Year, ", w, " Weeks, and ", d, " Days\n")
You can check the solution:- Check here
Question 13: Write the program to convert the amount (in integer) into the smallest possible banknotes.
Solution:
Amount = int(input("\nPlease Enter Amount for Withdraw :"))
print("\nRequired notes of 100 is : ", int(Amount / 100))
print("Required notes of 50 is : ", int((Amount % 100) / 50))
print("Required notes of 10 is : ", int((((Amount % 100) % 50) / 10)))
print("Amount still remaining coin is : ", int(((Amount % 100) % 50) % 10))
You can check the solution:- Check here
0 Comments
If you are a good learner please leave a challenging question on comment box for us when you visited this website ( Coding with Fun).