Skip to content

Commit bd32539

Browse files
author
alicevillar
committed
update
1 parent 2943b33 commit bd32539

5 files changed

+108
-56
lines changed

.idea/workspace.xml

+52
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
#######################################################################################################
3+
# Conditionals - Lab Exercise 4
4+
#
5+
# Use the variable x as you write this program. x will represent a string.
6+
# Write a program using the elif keyword that determines if x is a primary color (red, blue, or yellow).
7+
# If yes, print _ is primary color, where the blank is the value of x.
8+
# If no, print _ is not a primary color, where the blank is the value of x.
9+
#
10+
# Expected Output:
11+
# If x is red, then the output would be: red is a primary color.
12+
# If x is teal, then the output would be: teal is not a primary color.
13+
#
14+
#######################################################################################################
15+
16+
x='blue'
17+
if x == "red":
18+
print("x is red is a primary color")
19+
elif x == "blue":
20+
print("blue is a primary color")
21+
elif x == "yellow":
22+
print("yellow is a primary color")
23+
24+
# Output => blue is a primary color
+32-14
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,42 @@
11

22
#######################################################################################################
3-
# Conditionals - Lab Exercise 4
3+
# Conditionals - Lab Exercise 5
44
#
55
# Use the variable x as you write this program. x will represent a string.
6-
# Write a program using the elif keyword that determines if x is a primary color (red, blue, or yellow).
7-
# If yes, print _ is primary color, where the blank is the value of x.
8-
# If no, print _ is not a primary color, where the blank is the value of x.
6+
# Write a program that determines if x is a vowel (a, e, i, o, and u ).
7+
# If yes, print _ is a vowel, where the blank is the value of x.
8+
# If no, print _ is not a vowel, where the blank is the value of x.
99
#
1010
# Expected Output:
11-
# If x is red, then the output would be: red is a primary color.
12-
# If x is teal, then the output would be: teal is not a primary color.
11+
# If x is a, then the output would be: a is a vowel.
12+
# If x is z, then the output would be: z is not a vowel.
1313
#
1414
#######################################################################################################
1515

16-
x='blue'
17-
if x == "red":
18-
print("x is red is a primary color")
19-
elif x == "blue":
20-
print("blue is a primary color")
21-
elif x == "yellow":
22-
print("yellow is a primary color")
16+
x='a'
17+
if x in 'aeiouAEIOU':
18+
print(x, "is a vowel")
19+
else:
20+
print(x, "is not a vowel")
2321

24-
# Output => blue is a primary color
22+
# Output => a is a vowel
23+
24+
x='z'
25+
if x in 'aeiouAEIOU':
26+
print(x, "is a vowel")
27+
else:
28+
print(x, "is not a vowel")
29+
30+
# Output => z is not a vowel
31+
32+
#######################################################################################################################
33+
# ALTERNATIVE SOLUTION:
34+
#######################################################################################################################
35+
36+
x='a'
37+
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":
38+
print(x + " is a vowel")
39+
else:
40+
print(x + " is not a vowel")
41+
42+
# Output => a is a vowel

conditionals/conditionals_exercise5.py

-42
This file was deleted.

0 commit comments

Comments
 (0)