Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

**By using Python** 1) Give an example of a one-line script that does display so

ID: 3661982 • Letter: #

Question

**By using Python**

1) Give an example of a one-line script that does display something on the screen when the script is executed, but displays something different on the screen when that line is entered into the interactive shell.

2) Give an example of a one-line script that displays something on the screen when the script is executed, and also displays the exact same thing on the screen when that line is entered into the interactive shell.

3) Give an example of a one-line script that displays something on the screen when the script is executed, but that doesn't display anything on the screen when that line is entered into the interactive shell.

Explanation / Answer

1) Give an example of a one-line script that does display something on the screen when the script is executed, but displays something different on the screen when that line is entered into the interactive shell.
Answer:
The following is the example
# An example of a one-line script

# take input from the user
my_str = input("Enter a string: ")

# make it suitable for caseless comparison
my_str = my_str.casefold()

print("Chegg")

if list(my_str) == list("Chegg"):
print("Chegg is Good")


2) Give an example of a one-line script that displays something on the screen when the script is executed, and also displays the exact same thing on the screen when that line is entered into the interactive shell.
The following is the example


# An example of a one-line script

# take input from the user
my_str = input("Enter a string: ")

print("Chegg")
print(my_str)

3) Give an example of a one-line script that displays something on the screen when the script is executed, but that doesn't display anything on the screen when that line is entered into the interactive shell.
The following is the example

# An example of a one-line script

# take input from the user
my_str = input("Enter a string: ")

# make it suitable for caseless comparison
my_str = my_str.casefold()

print ("Chegg")   

if list(my_str) == list("Chegg"):
print(" ")