Character - Python Programming Exercise

This Python program prompts the user to input three letters and then displays them in reverse order. The program uses basic input and string manipulation techniques to achieve the desired result. After receiving the three letters from the user, the program stores them in a variable and then reverses the string using Python's string slicing feature. The reversed string is then printed to the screen, showcasing how simple string operations can be used to manipulate and display data in various ways. By utilizing string slicing in Python, this program demonstrates a fundamental concept in Python programming that can be applied in various scenarios. The ability to reverse a string is a common task, and the program not only provides a practical example of this but also highlights the importance of understanding user input handling and string manipulation in Python. With just a few lines of code, this program delivers an efficient solution to reverse the order of letters entered by the user.

 Category

Python Data Types

 Exercise

Character

 Objective

Develop a Python program to prompt the user for three letters and display them in reverse order.

 Example Python Exercise

 Copy Python Code
# Prompt the user for three letters
letter1 = input("Enter the first letter: ")
letter2 = input("Enter the second letter: ")
letter3 = input("Enter the third letter: ")

# Display the letters in reverse order
print(f"The letters in reverse order are: {letter3} {letter2} {letter1}")

 Output

Case 1:
Enter the first letter: a
Enter the second letter: b
Enter the third letter: c
The letters in reverse order are: c b a

Case 2:
Enter the first letter: x
Enter the second letter: y
Enter the third letter: z
The letters in reverse order are: z y x

 Share this Python Exercise

 More Python Programming Exercises of Python Data Types

Explore our set of Python Programming Exercises! Specifically designed for beginners, these exercises will help you develop a solid understanding of the basics of Python. From variables and data types to control structures and simple functions, each exercise is crafted to challenge you incrementally as you build confidence in coding in Python.

  •  Triangular Shape

    This Python program prompts the user to input a symbol and a width, then displays a triangle of the specified width using that symbol for the inner part...

  •  String Password

    This Python program prompts the user for a username and a password (both should be strings) and repeats the process until the correct credentials are en...

  •  Arithmetic - Conditional

    This Python program prompts the user for two numbers and an operation to perform on them, such as addition (+), subtraction (-), multiplication (*), or divisio...

  •  Double Value

    This Python program calculates the perimeter, area, and diagonal of a rectangle, based on the given width and height. The perimeter is cal...

  •  Evaluate Function Outputs

    This Python program displays the values of the function y = x² - 2x + 1 for integer values of x ranging from -10 to +10. The function is a quadratic equation, ...

  •  Show Function

    This Python program "draws" the graph of the function y = (x-4)² by displaying a series of asterisks on the screen. For each x value ranging from -1 to 8, the ...