Calculator
BMI Calculator
Number guessing game
Library
Random
100

What is the output of the following code?``` def add(x, y):

           return x + y

       Print (add(20,30))

30

100

Question: What does BMI stand for?

Body mass index 

100

Question: How can you generate a random number between 1 and 100 in Python?

random.randint(1,100)

100

Question: How can you import the math module in Python?

Answer: By using the import keyword. For example, import math.

100

Question: What is the result of `3 ** 2` in Python?

   Answer: 9 (The `**` operator performs exponentiation)

200

Question: What is the result of the expression 2 + 3 * 4?

14

200

Question: How do you calculate BMI?

Answer: BMI is calculated by dividing a person's weight in kilograms by the square of their height in meters.

200

Question: Write a Python program that allows a player to guess a randomly generated number between 1 and 10.

import random


number = random.randint(1, 10)

guess = int(input("Guess the number between 1 and 10: "))


if guess == number:

    print("Congratulations! You guessed correctly.")

else:

    print("Sorry, wrong guess. The number was", number)


200

Question: What are some functions available in the math module?

Answer: Examples of functions in the math module include sqrt(), sin(), cos(), exp(), log(), and more.

200

2. Question: How can you check if a number is even in Python?

Answer: By using the modulo operator `%`. If the result of `number % 2` is 0, then the number is even.

300

Question: How can you calculate the square root of a number in Python?

math.sqrt()

300

Question: Write a Python function that calculates BMI given weight in kilograms and height in meters.

def calculate_bmi(weight, height):

    bmi = weight / (height ** 2)

    return bmi


weight = float(input("Enter weight in kilograms: "))

height = float(input("Enter height in meters: "))

bmi = calculate_bmi(weight, height)

print("Your BMI is", bmi)


300

Question: What is the purpose of the input() function in Python?

To get the user input from the keyboard 

300

Question: How can you use the random module to generate a random number between 1 and 10?

Answer: By using the random.randint() function. For example, random.randint(1, 10).

300

3. Question: How can you concatenate two strings in Python?

Answer: By using the `+` operator. For example, `"Hello, " + "World!"` will result in the string "Hello, World!".

400

Question: How can you convert a string containing a number to an integer in Python?

Answer: By using the int() function. For example, int("42") will convert the string "42" to the integer 42.

400

Question: Is a BMI of 25 considered overweight or underweight?

Overweight 

400

Question: How can you check if a guessed number is higher or lower than the target number in a number guessing game?

Answer: By using conditional statements such as if and else. For example, if guess > target: print("Too high").

400

Question: What is the purpose of the datetime module in Python?

Answer: The datetime module provides classes for working with dates, times, and intervals.

400

Question: How can you create a list containing the numbers 1, 2, and 3 in Python?

Answer: By using square brackets and separating the elements with commas. For example, `[1, 2, 3]`.

500

What is a def function 

I will decide the definition 

500

Question: What are the BMI categories according to the World Health Organization (WHO)?

Answer: Underweight: BMI < 18.5, Normal weight: 18.5 <= BMI < 25, Overweight: 25 <= BMI < 30, Obesity: BMI >= 30

500

Question: How can you convert a string input to an integer in Python?

Answer: By using the int() function. For example, int(input("Enter a number: ")).

500

What is a while loop and for loop

I will decide the answer 

500

Question: What is the purpose of the `len()` function in Python?

Answer: The `len()` function is used to determine the length or size of a sequence (e.g., a string, list, or tuple).

M
e
n
u