-
Notifications
You must be signed in to change notification settings - Fork 0
/
conditionals_exercise4.py
42 lines (34 loc) · 1.39 KB
/
conditionals_exercise4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#######################################################################################################
# Conditionals - Lab Exercise 5
#
# Use the variable x as you write this program. x will represent a string.
# Write a program that determines if x is a vowel (a, e, i, o, and u ).
# If yes, print _ is a vowel, where the blank is the value of x.
# If no, print _ is not a vowel, where the blank is the value of x.
#
# Expected Output:
# If x is a, then the output would be: a is a vowel.
# If x is z, then the output would be: z is not a vowel.
#
#######################################################################################################
x='a'
if x in 'aeiouAEIOU':
print(x, "is a vowel")
else:
print(x, "is not a vowel")
# Output => a is a vowel
x='z'
if x in 'aeiouAEIOU':
print(x, "is a vowel")
else:
print(x, "is not a vowel")
# Output => z is not a vowel
#######################################################################################################################
# ALTERNATIVE SOLUTION:
#######################################################################################################################
x='a'
if x == "a" or x == "e" or x =="i" or x == "o" or x == "u" or x == "A" or x == "E" or x =="I" or x == "O" or x == "U":
print(x + " is a vowel")
else:
print(x + " is not a vowel")
# Output => a is a vowel