To solve these problems you need to use input() input function which is an inbuilt function in Python to take input from the user. The output data type of the function is str.

x = input(‘Enter you first name’)

Problem 1:

Write a program that takes a secret word from the user and performs a series of operations to “encode” it.

Encoding Steps:

  1. Convert the whole word to uppercase.
  2. Reverse the word.
  3. Find the length of the original word and add it to the end of the reversed word.
  4. Print the final encoded secret.

Requirements:

  • You must use at least three different string methods.
  • You must use the len() function.

Expected Output:

Enter the secret word: Python

Your encoded secret is: NOHTYP6

*(Explanation: “Python” -> “PYTHON” -> “NOHTYP” -> “NOHTYP6” because the length is 6)*

Problem 2:

Write a program that generates a silly story by asking the user for 5 different pieces of information (e.g., an adjective, a noun, a verb, a place, a famous person’s name).

Then, use all these inputs to fill in the blanks in a pre-written story template.

Requirements:

  • Your story must be at least 3 lines long.
  • You must use the + operator for string concatenation at least once.
  • You must use the .title() or .capitalize() method on at least one of the inputs.

Expected Output:

Enter a silly adjective: fluffy

Enter a plural noun: bananas

Enter a type of vehicle: unicycle

Enter a famous person: beyonce

Enter an emotion: confusion

Last night, I had the most fluffy dream!

I was riding a unicycle with Beyonce.

Suddenly, we were attacked by a horde of bananas! We felt a deep sense of confusion.

Problem 3:

Write a program that takes a sentence from the user and then prints out a short report.

The Report Should Include:

  1. The original sentence.
  2. The sentence in all lowercase letters.
  3. The sentence in all uppercase letters.
  4. The number of characters (including spaces) in the sentence.
  5. A boolean (True/False) indicating if the sentence starts with the word “The”.

Expected Output:

Enter a sentence: The quick brown fox jumps.

— Sentence Report —

Original: The quick brown fox jumps.

Lowercase: the quick brown fox jumps.

Uppercase: THE QUICK BROWN FOX JUMPS.

Length: 25 characters

Starts with ‘The’: True

MCQS

q) What does the following code print?

s = “Python”

print(s[::-1][::-1])

  1. ‘onhtyP’
  2. ‘nohtyP’
  3. ‘Python’
  4. Error

Q) What is the output of this code?

s = “hello”

print(s.replace(“”, “-“))

  1. -h-e-l-l-o-
  2. h-e-l-l-o
  3. ’——’
  4. Error

Q) What is the output of this code?

s = “Hello World!”

x = s.find(“World”)

print(x)

  1. True
  2. False
  3. 6
  4. Error