Question
1. Write a program that reads a string and reverses it. Your program must be able to save the new reversed string in another variable.
1. Write a program that reads a string and reverses it. Your program must be able to save the new reversed string in another variable. You must use "for loop" and indexing to accomplish this task. Compare your reversed string with the reversed string produced using the built in syntax such as s[: : -1] to see if they look the same (using comparison operator "==").
2. Write a program that reads in a continuous input of decimal numbers, stops when the user enters "stop". Think carefully about the most appropriate loop to use for this task. Upon entry into the loop body, keep track of the largest number input. Once input is complete, the program should output the largest number received accurate to the 3rd decimal place.
Hint: to keep track of the largest number during the input, you can use a variable, such as largest, to keep the running largest number. Each time you get a new number from the user, compare it with the largest. If it is larger than the largest, you update the largest. But what initial value should you give to variable largest? It should be the smallest possible value! In Python, the smallest possible float number is float('-Infinity').
Step by Step Solution
3.38 Rating (151 Votes )
There are 3 Steps involved in it
Step: 1
Program 1 Reversing a String Python Code originalstring inputEnter a string reversedstring for i in ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started