We appreciate your visit to Write a program to 1 Print Python is fun 2 Read two integers and perform mathematical operations on them addition subtraction multiplication and division 3. This page offers clear insights and highlights the essential aspects of the topic. Our goal is to provide a helpful and engaging learning experience. Explore the content and find the answers you need!
Answer :
Python program implements tasks: printing "Python is fun!", performing math operations on two integers, calculating and displaying 15% VAT, printing a string multiple times, calculating BMI, taking a float input.
Python program that implements the given tasks:
import math
# Task 1: Print Python is fun!
print("Python is fun!")
# Task 2: Perform mathematical operations on two integers
def add(a, b):
return a + b
def subtract(a, b):
return a - b
def multiply(a, b):
return a * b
def divide(a, b):
if b == 0:
raise ValueError("Cannot divide by zero.")
return a / b
num1 = int(input("Enter the first integer: "))
num2 = int(input("Enter the second integer: "))
print("Sum:", add(num1, num2))
print("Difference:", subtract(num1, num2))
print("Product:", multiply(num1, num2))
print("Quotient:", divide(num1, num2))
# Task 3: Calculate and display the value-added tax (VAT) 15%
def calculate_vat(price):
return price * 0.15
price = float(input("Enter the price: "))
vat = calculate_vat(price)
print("VAT 15%:", vat)
# Task 4: Print a string multiple times
string = input("Enter a string: ")
num_times = int(input("Enter the number of times to repeat: "))
print(string * num_times)
# Task 5: Calculate the Body Mass Index (BMI)
def calculate_bmi(weight, height):
height_meters = height / 100
return weight / (height_meters * height_meters)
weight = float(input("Enter weight in pounds: "))
height = float(input("Enter height in inches: "))
bmi = calculate_bmi(weight, height)
print("BMI:", bmi)
# Task 6: Take a Float Number as Input from the User and Print it
float_num = float(input("Enter a float number: "))
print("You entered:", float_num)
# Task 7: Convert Celsius to Fahrenheit
def celsius_to_fahrenheit(celsius):
return (9/5) * celsius + 32
celsius = float(input("Enter the temperature in Celsius: "))
fahrenheit = celsius_to_fahrenheit(celsius)
print("Temperature in Fahrenheit:", fahrenheit)
You can add more functions and features as per the requirements of each task. Feel free to expand upon the existing program or add new tasks as needed.
To know more about Python visit:
https://brainly.com/question/26497128
#SPJ11
Thanks for taking the time to read Write a program to 1 Print Python is fun 2 Read two integers and perform mathematical operations on them addition subtraction multiplication and division 3. We hope the insights shared have been valuable and enhanced your understanding of the topic. Don�t hesitate to browse our website for more informative and engaging content!
- Why do Businesses Exist Why does Starbucks Exist What Service does Starbucks Provide Really what is their product.
- The pattern of numbers below is an arithmetic sequence tex 14 24 34 44 54 ldots tex Which statement describes the recursive function used to..
- Morgan felt the need to streamline Edison Electric What changes did Morgan make.
Rewritten by : Barada