Given strings s and t, ``s = "Hello"`` and ``t = "World"`` and an integer r, ``r = 2``. What is the output of s * r + s * t?
Answers
Answered by
1
Language using : Python Programming.
Program :
s = "Hello"
t = "World"
r = 2
print( s * r + s * t )
Output : RAISES AN ERROR.
TypeError: can't multiply sequence by non-int of type 'str'
Reason :
s * r gives HelloHello as the string 'Hello' which is in the variable s is printed for r times (r contains 2)
But, when it comes to s * t, the values present in both variables are of type string. A string can't be multiplied with another string. So, it raises a TypeError.
Learn more :
1. Program to perform Arithmetic operations using function.
https://brainly.in/question/18905944
2. Write a simple python function to increase the value of any number by a constant "C=5"
https://brainly.in/question/16322662
Similar questions