High School

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!

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. Display the value-added tax (VAT) at 15%.
4. Ask the user for a string and a number, then print out that string that many times. For example, if the string is "Python" and the number is 3, you should print out "PythonPythonPython".
5. Prompt the user to enter a weight in pounds and height in inches, and calculate the body mass index using the formula:
\[ \text{BMI} = \frac{\text{Weight (kg)}}{\text{Height (m)}^2} \]
6. Take a float number as input from the user and print it.
7. Read a Celsius degree from the console, convert it to Fahrenheit, and display the result. The formula for the conversion is:
\[ \text{Fahrenheit} = \left(\frac{9}{5}\right) \times \text{Celsius} + 32 \]
8. Accept the user's first and last name, and print them in reverse order with a space between them.

Lab 2: Mathematical Functions and Strings

1. (Geometry: area of a pentagon) Write a program that prompts the user to enter the side of a pentagon and displays the area. A regular polygon is an \(n\)-sided polygon in which all sides are of the same length and all angles have the same degree (i.e., the polygon is both equilateral and equiangular). The formula for computing the area of a regular polygon is:
\[ \text{Area} = \frac{n \times s^2}{4 \times \tan\left(\frac{\pi}{n}\right)} \]
2. Write a program to calculate the number of characters in your string.
3. Using escape sequences, print the following strings:
\[ \text{print('Hi, I'm from ToolsQA')} \]

Lab 3: Selections

1. Write a Python program to generate a random number.
2. Write a Python program to generate a random number from 1 to 100.
3. Write a Python program to generate a random element from specific lists.
4. Write a Python program to generate even numbers from the following range (1, 20).
5. Write a program to check whether the entered number is less than 10. If yes, display "Same".
6. Write a program to check whether the candidate's age is greater than 17. If yes, display "Eligible for Voting".
7. Write a Python program to find student grades in 5 subjects.

Lab 4: Conditional Statements

1. Write a program to read the Richter magnitude value from the user and display the result for the following conditions using if...elif...else statement.
2. Write a Python program that returns a sequence of integer numbers from (1, 20) using for loops.
3. Write a Python program that calculates the summation of the following range (1, 40) using for loop.
4. Write a for loop that iterates through a string and prints every letter.
5. Write a Python program that calculates the summation of the following range (1, 40) using while loop.

Lab 5: Data Structures

1. Write a Python program to sum all the items in a list.
2. Write a Python program to multiply all the items in a list.
3. Write a Python program to get the largest number from a list.
4. Write a Python program to remove an empty element from a list.
5. Write a program in Python to choose a random item from a list.
6. Create a new dictionary for fruits and call it "prices". For each key, print out the key along with its price.
- Adding a new element to the dictionary
- Editing an existing element
- Removing an element
7. Password Generator: Make a random password generator for your friends and family to keep their accounts secure. The password must contain numbers, characters, and symbols.
8. Rock, Paper, Scissors Game: One of the most beloved games of all time and a simple Python project to test your skills.
9. Ticket office system (roller coaster): You've got a job as a programmer at a theme park. Your first job is to build an automatic ticket office system.
- You should build your program based on the following park rules:
- Guests must be at least 140 cm tall.
- Guests must be above 7 years old.
- Ticket prices based on age:
- \( \leq 12 \): $11
- \( \leq 18 \): $15
- \( \geq 45 \) and \( < 55 \): Free
- Guest photo: extra $5
10. Write a Python program that creates a list of 10 random integers. Then create two lists that have all odd and even values of the original list.

Lab 6: Functions

1. Write a program using functions to perform arithmetic operations.
2. Write a function that shows the summation of a digit number.
3. Write a function that shows the maximum number in a list.
4. Write a function that shows the minimum number in a list.
5. Write a function that takes a string as an argument and displays the letters backwards, one per line.
6. Write a program using functions to do the following tasks:
1. Convert Celsius to Fahrenheit.

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!

Rewritten by : Barada