
Bryce H.
asked 02/17/23how to code this in python?
- Using escape characters, print out the phrase “Welcome to O’Neil’s Boat Rentals!”
- Initialize one string variable to the following sentence:
“Hello there! How are you? I'm doing fine."
Using the print() function and escape characters, make the output look exactly as below: (Be sure there’s a single quote in the word I’m.
- Initialize a string variable to “hello python” and print it out in all uppercase using a string function.
- Write a small program using a ‘while’ loop (while True).
- Prompt the user to enter their age.
- Using a string function, check if the input is a decimal value, if true then break from the loop.
- Continue prompting the user until a whole number (isdecimal) has been entered.
- Using a string function, print your first and last name with the * symbol on both sides of your name with a max of 25 characters.
1 Expert Answer

Jonathan S. answered 02/20/23
Experienced Math Educator and Former Google Software Engineer
Using escape characters, print out the phrase “Welcome to O’Neil’s Boat Rentals!”
`print("Welcome to O\'Neil\'s Boat Rentals!")`
Initialize one string variable to the following sentence:
“Hello there! How are you? I'm doing fine."
Using the print() function and escape characters, make the output look exactly as below: (Be sure there’s a single quote in the word I’m.
```
sentence = "Hello there! \nHow are you? \nI\'m doing fine."
print(sentence)
```
Initialize a string variable to “hello python” and print it out in all uppercase using a string function.
```
string_var = "hello python"
print(string_var.upper())
```
Write a small program using a ‘while’ loop (while True).
Prompt the user to enter their age.
Using a string function, check if the input is a decimal value, if true then break from the loop.
Continue prompting the user until a whole number (isdecimal) has been entered.
```
while True:
age = input("Please enter your age: ")
if age.isdecimal():
break
else:
print("Invalid input, please enter a whole number.")
print(f"Your age is {age}.")
```
Using a string function, print your first and last name with the * symbol on both sides of your name with a max of 25 characters.
```
first_name = "John"
last_name = "Doe"
max_length = 25
# Concatenate the first and last name with the * symbol on both sides
full_name = f"*{first_name}* *{last_name}*"
# Truncate the name if it exceeds the max length
if len(full_name) > max_length:
full_name = full_name[:max_length]
# Print the name
print(full_name)
```
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Juliet C.
02/18/23