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):

  1. Assigns the empty string to a string variable named varS
  2. Ask the user for a name
  3. Concatenate the name to the string in varS
  4. Print the content of the variable varS (at this point it should only contain the name)
  5. Ask the user for a number
  6. Concatenate the number (which should be a string) to varS, separating the previous content of varS from the number with a space
  7. Display to the user the content of the variable varS (it should now show the name, a space and the number)
  8. Ask the user for a code with special symbols
  9. Concatenate this code to varS, separating the previous content of varS from the code with a space
  10. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!