n uppercase are:", uppercase)
# Example 5: Finding the length of each word in a sentence using list comprehension
sentence = "The quick brown fox jumps over the lazy dog"
lengths = [len(word) for word in sentence.split()]
print("The lengths of words are:", lengths)
`
Sure, here are five examples of if statements in Python:
1. Checking if a number is positive or negative:
num = -5
if num >= 0:
print("The number is positive")
else:
print("The number is negative")
2. Checking if a number is even or odd:
num = 7
if num % 2 == 0:
print("The number is even")
else:
print("The number is odd")
3. Checking if a string is empty or not:
string = ""
if len(string) == 0:
print("The string is empty")
else:
print("The string is not empty")
4. Checking if a number is divisible by both 3 and 5:
num = 15
if num % 3 == 0 and num % 5 == 0:
print("The number is divisible by both 3 and 5")
else:
print("The number is not divisible by both 3 and 5")
5. Checking if a person is eligible to vote based on their age:
age = 17
if age >= 18:
print("You are eligible to vote")
else:
print("You are not eligible to vote yet")
# Example 5: Finding the length of each word in a sentence using list comprehension
sentence = "The quick brown fox jumps over the lazy dog"
lengths = [len(word) for word in sentence.split()]
print("The lengths of words are:", lengths)
`
Sure, here are five examples of if statements in Python:
1. Checking if a number is positive or negative:
num = -5
if num >= 0:
print("The number is positive")
else:
print("The number is negative")
2. Checking if a number is even or odd:
num = 7
if num % 2 == 0:
print("The number is even")
else:
print("The number is odd")
3. Checking if a string is empty or not:
string = ""
if len(string) == 0:
print("The string is empty")
else:
print("The string is not empty")
4. Checking if a number is divisible by both 3 and 5:
num = 15
if num % 3 == 0 and num % 5 == 0:
print("The number is divisible by both 3 and 5")
else:
print("The number is not divisible by both 3 and 5")
5. Checking if a person is eligible to vote based on their age:
age = 17
if age >= 18:
print("You are eligible to vote")
else:
print("You are not eligible to vote yet")