Computer Science
Find the output if the input string is 'Test'.
S = input("Enter String :")
RS = " "
for ch in S :
RS = ch + RS
print(S + RS)
Python
Python String Manipulation
11 Likes
Answer
TesttseT
Working
The for loop reverses the input string and stores the reversed string in variable RS. After that original string and reversed string are concatenated and printed.
Answered By
6 Likes
Related Questions
Carefully go through the code given below and answer the questions based on it :
in1Str = input(" Enter string of digits: ") in2Str = input(" Enter string of digits: ") if len(in1Str)>len(in2Str): small = in2Str large = in1Str else: small = in1Str large = in2Str newStr = '' for element in small: result = int(element) + int(large[0]) newStr = newStr + str(result) large = large[1:] print (len(newStr)) # Line 1 print (newStr) # Line 2 print (large) # Line 3 print (small) # Line 4
Given a first input of 123 and a second input of 4567, what result is produced by Line 3?
- 3
- 7
- 12
- 45
- None of these
Carefully go through the code given below and answer the questions based on it :
in1Str = input(" Enter string of digits: ") in2Str = input(" Enter string of digits: ") if len(in1Str)>len(in2Str): small = in2Str large = in1Str else: small = in1Str large = in2Str newStr = '' for element in small: result = int(element) + int(large[0]) newStr = newStr + str(result) large = large[1:] print (len(newStr)) # Line 1 print (newStr) # Line 2 print (large) # Line 3 print (small) # Line 4
Given a first input of 123 and a second input of 4567, what result is produced by Line 4?
- 123
- 4567
- 7
- 3
- None of these
Find the output if the input string is 'Test'.
S = input("Enter String :") RS = " " for ch in S : RS = ch + 2 + RS print(S + RS)
Find the errors. Find the line numbers causing errors.
- S = "PURA VIDA"
- print(S[9] + S[9 : 15])