Difference between revisions of "User:Praveer-mathur-9f3d@uni-bonn.de"
Jump to navigation
Jump to search
What datatype does the variable planet have?
What datatype does the variable apples have?
What datatype does the variable distance have?
What datatype does the variable false have?
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | === Quiz === <!--T:5--> | + | === Short Quiz: Variable Assignment === <!--T:5--> |
What values do the two variables "mass" and "age" have in the following lines? | What values do the two variables "mass" and "age" have in the following lines? | ||
{{hidden begin | {{hidden begin | ||
| − | |title = mass = 47.5 | + | |title = <code>mass = 47.5 <br> print(mass)</code> |
| − | print(mass) | ||
}} | }} | ||
<quiz display=simple> | <quiz display=simple> | ||
| Line 16: | Line 15: | ||
{{hidden begin | {{hidden begin | ||
| − | |title = age = 122 | + | |title = <code>age = 122 <br> print(mass, age)</code> |
| − | print(mass, age) | ||
}} | }} | ||
<quiz display=simple> | <quiz display=simple> | ||
| Line 28: | Line 26: | ||
{{hidden begin | {{hidden begin | ||
| − | |title = mass = mass * 2.0 | + | |title = <code>mass = mass * 2.0 <br> print(mass, age)</code> |
| − | print(mass, age) | ||
}} | }} | ||
<quiz display=simple> | <quiz display=simple> | ||
| Line 40: | Line 37: | ||
{{hidden begin | {{hidden begin | ||
| − | |title = age = age - 20 | + | |title = <code>age = age - 20 <br> print(mass, age)</code> |
| − | print(mass, age) | ||
}} | }} | ||
<quiz display=simple> | <quiz display=simple> | ||
| Line 48: | Line 44: | ||
+ Click and submit to see the answer | + Click and submit to see the answer | ||
|| <code>95.0 102</code> | || <code>95.0 102</code> | ||
| + | </quiz> | ||
| + | {{hidden end}} | ||
| + | |||
| + | === Short Quiz: Data Types === <!--T:5--> | ||
| + | |||
| + | {{hidden begin | ||
| + | |title = <code>planet = 'Earth'</code> <br> What datatype does the variable planet have? | ||
| + | }} | ||
| + | <quiz display=simple> | ||
| + | { | ||
| + | |type="()"} | ||
| + | - Integer | ||
| + | || Explanation: Wrong | ||
| + | + String | ||
| + | || Explanation: Correct | ||
| + | - Boolean | ||
| + | || Explanation: Wrong | ||
| + | - Float | ||
| + | || Explanation: Wrong | ||
| + | </quiz> | ||
| + | {{hidden end}} | ||
| + | |||
| + | {{hidden begin | ||
| + | |title = <code>apples = 5</code> <br> What datatype does the variable apples have? | ||
| + | }} | ||
| + | <quiz display=simple> | ||
| + | { | ||
| + | |type="()"} | ||
| + | - Integer | ||
| + | || Explanation: Correct | ||
| + | + String | ||
| + | || Explanation: Wrong | ||
| + | - Boolean | ||
| + | || Explanation: Wrong | ||
| + | - Float | ||
| + | || Explanation: Wrong | ||
| + | </quiz> | ||
| + | {{hidden end}} | ||
| + | |||
| + | {{hidden begin | ||
| + | |title = <code>distance = 10.5</code> <br> What datatype does the variable distance have? | ||
| + | }} | ||
| + | <quiz display=simple> | ||
| + | { | ||
| + | |type="()"} | ||
| + | - Integer | ||
| + | || Explanation: Wrong | ||
| + | + String | ||
| + | || Explanation: Wrong | ||
| + | - Boolean | ||
| + | || Explanation: Wrong | ||
| + | - Float | ||
| + | || Explanation: Correct | ||
| + | </quiz> | ||
| + | {{hidden end}} | ||
| + | |||
| + | {{hidden begin | ||
| + | |title = <code>false = 7 > 2</code> <br> What datatype does the variable false have? | ||
| + | }} | ||
| + | <quiz display=simple> | ||
| + | { | ||
| + | |type="()"} | ||
| + | - Integer | ||
| + | || Explanation: Wrong | ||
| + | + String | ||
| + | || Explanation: Wrong | ||
| + | - Boolean | ||
| + | || Explanation: Correct | ||
| + | - Float | ||
| + | || Explanation: Wrong | ||
| + | </quiz> | ||
| + | {{hidden end}} | ||
| + | |||
| + | === Short Quiz: Boolean Operations === <!--T:5--> | ||
| + | |||
| + | <code>var1 = True <br> var2 = False</code> | ||
| + | What is the value of each variable after each of the following print statements? | ||
| + | |||
| + | {{hidden begin | ||
| + | |title = <code>print(var1, var2)</code> | ||
| + | }} | ||
| + | <quiz display=simple> | ||
| + | { | ||
| + | |type="()"} | ||
| + | + Click and submit to see the answer | ||
| + | || <code>True False</code> | ||
| + | </quiz> | ||
| + | {{hidden end}} | ||
| + | |||
| + | {{hidden begin | ||
| + | |title = <code>var2 = var1 or var2 <br> print(var1, var2)</code> | ||
| + | }} | ||
| + | <quiz display=simple> | ||
| + | { | ||
| + | |type="()"} | ||
| + | + Click and submit to see the answer | ||
| + | || <code>True True</code> | ||
| + | </quiz> | ||
| + | {{hidden end}} | ||
| + | |||
| + | {{hidden begin | ||
| + | |title = <code>var1 = var1 and not var2 <br> print(var1, var2)/code> | ||
| + | }} | ||
| + | <quiz display=simple> | ||
| + | { | ||
| + | |type="()"} | ||
| + | + Click and submit to see the answer | ||
| + | || <code>False True</code> | ||
| + | </quiz> | ||
| + | {{hidden end}} | ||
| + | |||
| + | {{hidden begin | ||
| + | |title = <code>var1 = not(var1 and not var1) <br> print(var1, var2)</code> | ||
| + | }} | ||
| + | <quiz display=simple> | ||
| + | { | ||
| + | |type="()"} | ||
| + | + Click and submit to see the answer | ||
| + | || <code>True True</code> | ||
</quiz> | </quiz> | ||
{{hidden end}} | {{hidden end}} | ||
Latest revision as of 14:21, 6 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)
age = 122
print(mass, age)
mass = mass * 2.0
print(mass, age)
age = age - 20
print(mass, age)
Short Quiz: Data Types
planet = 'Earth' What datatype does the variable planet have?
apples = 5 What datatype does the variable apples have?
distance = 10.5 What datatype does the variable distance have?
false = 7 > 2 What datatype does the variable false have?
Short Quiz: Boolean Operations
var1 = True
What is the value of each variable after each of the following print statements?
var2 = False
print(var1, var2)
var2 = var1 or var2
print(var1, var2)
var1 = var1 and not var2
print(var1, var2)/code>
var1 = not(var1 and not var1)
print(var1, var2)