← Back to Dashboard

Variables DataTypes Operators: Medium Exercises MEDIUM

"""
Topic 02: Variables, Data Types & Operators - MEDIUM Exercises (10)
"""

# Exercise 1: Swap the values of two variables 'x' and 'y' without using a third variable.
# x = 5, y = 10 -> After swap: x = 10, y = 5
# Write your code below:


# Exercise 2: Take a user's birth year as input and calculate their current age.
# Hint: Use input() and int() conversion.
# Write your code below:


# Exercise 3: Create a program that converts Celsius to Fahrenheit. 
# Formula: (Celsius * 9/5) + 32
# Write your code below:


# Exercise 4: Ask the user for two numbers and print if the first number is greater than or equal to the second.
# Output should be a Boolean value.
# Write your code below:


# Exercise 5: Verify if a number entered by the user is even. 
# Print True if even, False otherwise. (Hint: Use %)
# Write your code below:


# Exercise 6: Given a string s = "Python", print the string in reverse using slicing.
# Hint: [::-1]
# Write your code below:


# Exercise 7: Calculate the BMI (Body Mass Index) using weight (kg) and height (m).
# Formula: weight / (height**2)
# Write your code below:


# Exercise 8: Use the 'not' operator to reverse a Boolean value and print it.
# Write your code below:


# Exercise 9: Create a variable 'sentence' = "I love Python". 
# Check if the word "love" exists in the sentence using the 'in' operator.
# Write your code below:


# Exercise 10: Perform the following operation and explain the result in a comment:
# result = 10 / 2
# What is the data type of 'result'?
# Write your code below: