camelCase



Source: en.wikipedia.org/wiki/Camel_case

In some languages, it's common to use camel case (otherwise known as "mixed case") for variables' names when those names comprise multiple words, whereby the first letter of the first word is lowercase but the first letter of each subsequent word is uppercase. For instance, whereas a variable for a user's name might be called name, a variable for a user's first name might be called firstName, and a variable for a user's preferred first name (e.g., nickname) might be called preferredFirstName.

Python, by contrast, recommends snake case, whereby words are instead separated by underscores (_), with all letters in lowercase. For instance, those same variables would be called name, first_name, and preferred_first_name, respectively, in Python.

In a file called camel.py, 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.

Hints

Before You Begin

Use ssh program such as putty to login to practice server (158.108.112.10) with your account:

Then execute

cd cpe113

to change directories into that folder.

Then execute

mkdir camel

to make a folder called camel in your cpe113 folder. Then execute

cd camel

to change directories into that folder. You can now execute

nano camel.py

to make a file called camel.py where you'll write your program.

Demo


How to Test

Here's how to test your code manually:

Run your program with python camel.py. Type name and press Enter. Your program should output:
name
Run your program with python camel.py. Type firstName and press Enter. Your program should output:
first_name
Run your program with python camel.py. Type preferredFirstName and press Enter. Your program should output:
preferred_first_name
You can execute the below to check your code using check50, a program that cpe113 will use to test your code when you submit. But be sure to test it yourself as well!

check50 thanawat-ku/problems/cpe113/2022/camel

Green smilies mean your program has passed a test! Red frownies will indicate your program output something unexpected. Visit the URL that check50 outputs to see the input check50 handed to your program, what output it expected, and what output your program actually gave.

How to Submit

In your terminal, execute the below to submit your work.

submit50 thanawat-ku/problems/cpe113/2022/camel