Difference between revisions of "User:Praveer-mathur-9f3d@uni-bonn.de"

From HPC Wiki
Jump to navigation Jump to search
Line 163: Line 163:
 
+  Click and submit to see the answer
 
+  Click and submit to see the answer
 
|| <code>True True</code>
 
|| <code>True True</code>
 +
</quiz>
 +
{{hidden end}}
 +
 +
=== Short Quiz: String Concatenation === <!--T:5-->
 +
 +
<code>str1 = "Uni" <br> str2 = "Bonn" <br> str3 = str2 + str1 <br> str4 = str1 * 3</code>
 +
 +
{{hidden begin
 +
|title = What output do you expect after doing <code>print(str3)</code>?
 +
}}
 +
<quiz display=simple>
 +
{
 +
|type="()"}
 +
+  Click and submit to see the answer
 +
|| <code>BonnUni</code>
 +
</quiz>
 +
{{hidden end}}
 +
 +
{{hidden begin
 +
|title = What output do you expect after doing <code>print(str4)</code>?
 +
}}
 +
<quiz display=simple>
 +
{
 +
|type="()"}
 +
+  Click and submit to see the answer
 +
|| <code>UniUniUni</code>
 
</quiz>
 
</quiz>
 
{{hidden end}}
 
{{hidden end}}

Revision as of 17:52, 9 March 2026

Short Quiz: Variable Assignment

What values do the two variables "mass" and "age" have in the following lines?

mass = 47.5
print(mass)

Click and submit to see the answer

age = 122
print(mass, age)

Click and submit to see the answer

mass = mass * 2.0
print(mass, age)

Click and submit to see the answer

age = age - 20
print(mass, age)

Click and submit to see the answer

Short Quiz: Data Types

planet = 'Earth'
What datatype does the variable planet have?

Integer
String
Boolean
Float

apples = 5
What datatype does the variable apples have?

Integer
String
Boolean
Float

distance = 10.5
What datatype does the variable distance have?

Integer
String
Boolean
Float

false = 7 > 2
What datatype does the variable false have?

Integer
String
Boolean
Float

Short Quiz: Boolean Operations

var1 = True
var2 = False
What is the value of each variable after each of the following print statements?

print(var1, var2)

Click and submit to see the answer

var2 = var1 or var2
print(var1, var2)

Click and submit to see the answer

var1 = var1 and not var2
print(var1, var2)/code>

Click and submit to see the answer

var1 = not(var1 and not var1)
print(var1, var2)

Click and submit to see the answer

Short Quiz: String Concatenation

str1 = "Uni"
str2 = "Bonn"
str3 = str2 + str1
str4 = str1 * 3

What output do you expect after doing print(str3)?

Click and submit to see the answer

What output do you expect after doing print(str4)?

Click and submit to see the answer