What do these 3 lines print?>>> s1 = "Best School">>> s2 = s1>>> print(s1 == s2)
Question
What do these 3 lines print?
s1 = "Best School"
s2 = s1
print(s1 == s2)
Solution
These three lines of code are written in Python. Here's what they do:
-
s1 = "Best School"
: This line creates a variable nameds1
and assigns the string "Best School" to it. -
s2 = s1
: This line creates another variable nameds2
and assigns it the value ofs1
, which is "Best School". -
print(s1 == s2)
: This line prints the result of the comparison betweens1
ands2
. The==
operator in Python checks if the values of two operands are equal. In this case, it checks ifs1
ands2
are equal.
Since s1
and s2
both contain the string "Best School", the comparison s1 == s2
is True
. Therefore, the output of these three lines of code will be True
.
Similar Questions
What do these lines print?a = 12if a < 2: print("Holberton")elif a % 2 == 0: print("C is fun")else: print("School")HolbertonC is funSchool
What do these lines print?if 12 == 48/4: print("Holberton")else: print("School")HolbertonSchool
What do these lines print?>>> for i in ["Hello", "Holberton", "School", 98]:>>> print(i, end=" ")0 1 2 31 2 3 4Hello Holberton School 98
What will be the output of the following code snippet? a = 3 b = 1 print(a, b) a, b = b, a print(a, b)
What do these lines print?>>> for i in range(0, 3):>>> print(i, end=" ")1 2 30 1 2 30 1 2
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.