Science, asked by ashiarora3053, 2 months ago

3) Write the output of the
following programs *

a) four=4
three =3
seven =four + three
print(seven)

b) (i) print ("52" *5)
(ii) print("52*5")

where are every one gone plz ans naa yaar​

Answers

Answered by DrNykterstein
29

NOTE: Given program is in Python programming language.

Question (a)

Program:

four = 4

three = 3

seven = four + three

print(seven)

Output : 7

Explanation:

1. There are two variables four, three assigned values 4 and 3 respectively (Integers).

2. In this step, the variable seven is assigned the sum of values of the variables four and three.

3. This line prints the value of the variable seven. Which is the sum of values of four and three. Hence, seven = 4 + 3 = 7

Question (b)

(i) print("52"*5)

Here, A string is being multiplied by an integer, which makes no sense, right? But, In python, mathematical operators +, * are true for strings as well.

We know,

=> 4 * 3 means 4 + 4 + 4

Similarly, Here

=> "52" * 5 means "52" + "52" + "52" + "52" + "52"

And, We know string concatenation which is joining of two or more than two strings in one.

So,

Output : 5252525252

(ii) print("52*5")

Since, the program is printing the string that has value 52*5.

Whatever mathematical operators are in string, It doesn't not matter to Python and hence it won't work it out and will just print whatever that string is.

Output: 52*5

Answered by 2008shrishti
0

Answer:

NOTE: Given program is in Python programming language.

Question (a)

Program:

four = 4

three = 3

seven = four + three

print(seven)

Output : 7

Explanation:

1. There are two variables four, three assigned values 4 and 3 respectively (Integers).

2. In this step, the variable seven is assigned the sum of values of the variables four and three.

3. This line prints the value of the variable seven. Which is the sum of values of four and three. Hence, seven = 4 + 3 = 7

Question (b)

(i) print("52"*5)

Here, A string is being multiplied by an integer, which makes no sense, right? But, In python, mathematical operators +, * are true for strings as well.

We know,

=> 4 * 3 means 4 + 4 + 4

Similarly, Here

=> "52" * 5 means "52" + "52" + "52" + "52" + "52"

And, We know string concatenation which is joining of two or more than two strings in one.

So,

Output : 5252525252

(ii) print("52*5")

Since, the program is printing the string that has value 52*5.

Whatever mathematical operators are in string, It doesn't not matter to Python and hence it won't work it out and will just print whatever that string is.

Output: 52*5

Explanation:

Hope this answer will help you.

Similar questions