Implement a program that prompts the user for the name of a variable in camel case and outputs the corresponding name in snake case. Assume that the user's input will indeed be in camel case.
for c in list[1:] # Starting at second character
list.append(word)
.lower()
"_".join(list) # Joins list elements into a string with specified separator
Coke machine sells a bottle for 50 cents and only accepts 25, 10 and 5 cents.
Implement a program that prompts the user to insert a coin, one at a time, each time informing the user of the amount due.
- Once the user has inputted at least 50 cents, output how many cents in change the user is owed.
- Assume that the user will only input integers, and ignore any integer that isn't accepted
while count < 50:
…
if coin == 25 or coin == 10 …
# Ensure the change is not negative
print(f"Change Owed: {count - 50}")
Implement a program that prompts the user for a str
of text and then outputs that same text but with all vowels A, E, I, O, and U
omitted, whether imputed in uppercase or lowercase.
.append()
"".join(list)
Implement a program that prompts the user for a vanity plate and then output Valid
if it meets all of the requirements or Invalid if it does not.
- Assume that any letters in the user’s input will be uppercase
Is_valid()
returnsTrue
ifs
meets all the requirements andFalse
if it does not.- Assume that
s
will be astr
Requirements:
- Start with at least 2 letters
s[0].isalpha() == False or s[1].isalpha() == False
- Maximum 6 characters (letters or numbers)
len(6)
- Minimum 2 characters
len(2)
- Numbers must come at the end after the letters
if c.isalpha() and i != 0 (range) and s[i - 1].isdigit()
- First number can't be
0
(if c == "0"
) and no digit was found before - No periods, spaces, or punctuation marks
if c.isalnum() == False:
zero_digit_found = False
# If current char is a digit equal to zero
# and there was no digit before it (first char is 0) return False
if c.isdigit():
if c == "0" and zero_digit_found == False:
return False
elif c != "0":
zero_digit_found = True
for i, c in enumerate(s)
Implement a program that prompts users to input a fruit (case-insensitive) and outputs the number of calories in one portion of that fruit, per the FDA’s poster for fruits.
- Assume that users will input fruits exactly as written in the poster.
- Ignore any input that isn't a fruit
dictionary = {"key1": "value1", "key2": "value2"}
if fruit in fruit_dict:
return fruit_dict[fruit]
For the function not to return dictionary value: In
main()
, only printif result != None