Skip to content

Commit acdfe31

Browse files
author
abregman
committed
Add a couple of exercises
Related to numbers and variables.
1 parent 591c734 commit acdfe31

File tree

7 files changed

+85
-1
lines changed

7 files changed

+85
-1
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
:information_source:  This repo contains questions and exercises to learn and practice Python
44

5-
:bar_chart:  There are currently **49** exercises and questions
5+
:bar_chart:  There are currently **53** exercises and questions
66

77
# Python Exercises
88

@@ -35,6 +35,8 @@
3535
| Locations or Names | [Exercise](exercises/variables/locations_or_names.md) | [Solution](solutions/variables/locations_or_names.md) | |
3636
| Types | [Exercise](exercises/variables/types.md) | [Solution](solutions/variables/types.md) | |
3737
| Multiple Value Assignment | [Exercise](exercises/variables/multiple_value_assigment.md) | [Solution](solutions/variables/multiple_value_assigment.md) | |
38+
| Copying Variables | [Exercise](exercises/variables/copying_variables.md) | [Solution](solutions/variables/copying_variables.md) | |
39+
| Mutable Objects | [Exercise](exercises/variables/mutable_objects.md) | [Solution](solutions/variables/mutable_objects.md) | |
3840

3941
## Booleans
4042

@@ -58,6 +60,7 @@
5860

5961
|Name|Objective & Instructions|Solution|Comments|
6062
|--------|--------|------|----|
63+
| What is the result? | [Exercise](exercises/numbers/what_is_the_result.md) | [Solution](solutions/numbers/what_is_the_result.md) | |
6164
| Palindrome | [Exercise](exercises/numbers/palindrome.md) | [Solution](solutions/numbers/palindrome.md) | |
6265

6366
## Lists
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## What is the result?
2+
3+
What is the value of each of the following variables?
4+
5+
1. `x = 5,000`
6+
2. `x = 5_000`
7+
3. `x = 5_0_0`
8+
9+
### Solution
10+
11+
Click [here](solutions/numbers/what_is_the_result.md) for the solution
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Copying Variables
2+
3+
1. True or False?
4+
5+
Running `var = 3` creates an object. Running `another_var = var` creates another object with the value of `var`
6+
7+
### Solution
8+
9+
Click [here](solutions/variables/copying_variables.md) to view the solution.
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Mutable Objects
2+
3+
1. What would be the output of the following program? explain
4+
5+
```
6+
x = [1, 2 ,3]
7+
y = x
8+
print(x)
9+
print(y)
10+
x[0] = 0
11+
print(x)
12+
print(y)
13+
```
14+
15+
### Solution
16+
17+
Click [here](solutions/variables/mutable_objects.md) to view the solution
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## What is the result?
2+
3+
What is the value of each of the following variables?
4+
5+
1. `x = 5,000`
6+
2. `x = 5_000`
7+
3. `x = 5_0_0`
8+
9+
### Solution
10+
11+
1. `(5,0)`
12+
2. `5000`
13+
3. `500`
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Copying Variables
2+
3+
1. True or False?
4+
5+
Running `var = 3` creates an object. Running `another_var = var` creates another object with the value of `var`
6+
7+
### Solution
8+
9+
False. `another_var = var` makes `another_var` to point to the same object `var` points to. It doesn't creates another object.
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Mutable Objects
2+
3+
1. What would be the output of the following program? explain
4+
5+
```
6+
x = [1, 2 ,3]
7+
y = x
8+
print(x)
9+
print(y)
10+
x[0] = 0
11+
print(x)
12+
print(y)
13+
```
14+
15+
### Solution
16+
17+
```
18+
[1, 2, 3]
19+
[1, 2, 3]
20+
[0, 2, 3]
21+
[0, 2, 3]
22+
```

0 commit comments

Comments
 (0)