Code Avengers Python 1 Answers Page
x = 5 if x > 10: print("x is greater than 10") elif x == 5: print("x is equal to 5") else: print("x is less than 10") The output of the code is x is equal to 5 .
In Python, variables can store different data types such as integers, floats, strings, and booleans. The == operator checks for equality in value, but not in data type. Exercise 2: Basic Operators Question: What is the output of the following code? code avengers python 1 answers
Conditional statements are used to execute different blocks of code based on conditions. The if statement checks a condition, and if it's true, executes the corresponding block of code. The elif statement checks another condition if the initial condition is false. The else statement executes a block of code if all conditions are false. Exercise 4: Loops Question: What is the output of the following code? x = 5 if x > 10: print("x
greet("John") The output of the code is Hello, John! . Exercise 2: Basic Operators Question: What is the
fruits = ["apple", "banana", "cherry"] for fruit in fruits: print(fruit) The output of the code is:
a = 10 b = 3 print(a + b) print(a - b) print(a * b) print(a / b) The output of the code is: