Question: Exercise 4 Print Statement Challenge - Write a Python program that asks the user to enter one letter, one digit and one special symbol (such
Exercise 4
Print Statement Challenge - Write a Python program that asks the user to enter one letter, one digit and one special symbol (such as "!") using 3 separate input() statement, then, our program must :
1. display to the user each of the three values on a separate line using as many print() statements as needed.
Hint: string formatting.
2. display to the user the three values on the same line, each value separated by a space, using only 1 print()
Hint: concatenation operator.
3. display to the user each of the three values on a separate line using only 1 print()
Hint: newline character and concatenation operator or string formatting (seen in Problem 3 above).
4. display to the user the three values on the same line, however, there shall be ***no*** spaces between the three values, using only 1 print()
Hint: Look up the separator sep= argument to the print() built-in function.
Exercise 2
Incrementally Constructing a String Create a Python program by translating each of the following instructions of the algorithm described below (executing the instructions in the following order):
- Assigns the empty string to a string variable named varS
- Ask the user for a name
- Concatenate the name to the string in varS
- Print the content of the variable varS (at this point it should only contain the name)
- Ask the user for a number
- Concatenate the number (which should be a string) to varS, separating the previous content of varS from the number with a space
- Display to the user the content of the variable varS (it should now show the name, a space and the number)
- Ask the user for a code with special symbols
- Concatenate this code to varS, separating the previous content of varS from the code with a space
- Display the content of the variable varS
Note: Incrementally or cumulatively constructing a string is a very useful process we may encounter often while developing software.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
