Add 57 new questions and exercises
This commit is contained in:
9
exercises/python/advanced_data_types.md
Normal file
9
exercises/python/advanced_data_types.md
Normal file
@ -0,0 +1,9 @@
|
||||
## (Advanced) Identify the data type
|
||||
|
||||
For each of the following, identify what is the data type of the result variable
|
||||
|
||||
1. a = {'a', 'b', 'c'}
|
||||
2. b = {'1': '2'}
|
||||
4. c = ([1, 2, 3])
|
||||
4. d = (1, 2, 3)
|
||||
4. e = True+True
|
8
exercises/python/compress_string.md
Normal file
8
exercises/python/compress_string.md
Normal file
@ -0,0 +1,8 @@
|
||||
## Compress String
|
||||
|
||||
1. Write a function that gets a string and compresses it
|
||||
- 'aaaabbccc' -> 'a4b2c3'
|
||||
- 'abbbc' -> 'a1b3c1'
|
||||
2. Write a function that decompresses a given string
|
||||
- 'a4b2c3' -> 'aaaabbccc'
|
||||
- 'a1b3c1' -> 'abbbc'
|
12
exercises/python/data_types.md
Normal file
12
exercises/python/data_types.md
Normal file
@ -0,0 +1,12 @@
|
||||
## Data Types
|
||||
|
||||
For each of the following, identify what is the data type of the result variable
|
||||
|
||||
1. a = [1, 2, 3, 4, 5]
|
||||
2. b = "Hello, is it me you looking for?"
|
||||
3. e = 100
|
||||
4. f = '100'
|
||||
5. i = 0.100
|
||||
6. i = True
|
||||
|
||||
Bonus question: how to find out in Python what is the data type of certain variable?
|
3
exercises/python/reverse_string.md
Normal file
3
exercises/python/reverse_string.md
Normal file
@ -0,0 +1,3 @@
|
||||
## Reverse a String
|
||||
|
||||
Write a code that reverses a string
|
@ -0,0 +1,9 @@
|
||||
## (Advanced) Identify the data type
|
||||
|
||||
For each of the following, identify what is the data type of the result variable
|
||||
|
||||
1. a = {'a', 'b', 'c'} -> set
|
||||
2. b = {'1': '2'} -> dict
|
||||
4. c = ([1, 2, 3]) -> list
|
||||
4. d = (1, 2, 3) -> tuple
|
||||
4. e = True+True -> int
|
12
exercises/python/solutions/data_types_solution.md
Normal file
12
exercises/python/solutions/data_types_solution.md
Normal file
@ -0,0 +1,12 @@
|
||||
## Data Types - Solution
|
||||
|
||||
1. a = [1, 2, 3, 4, 5] -> list
|
||||
2. b = "Hello, is it me you looking for?" -> string
|
||||
3. e = 100 -> int
|
||||
4. f = '100' -> string
|
||||
5. i = 0.100 -> float
|
||||
6. i = True -> bool
|
||||
|
||||
### Bonus question - Answer
|
||||
|
||||
`type(...)`
|
16
exercises/python/solutions/reverse_string.md
Normal file
16
exercises/python/solutions/reverse_string.md
Normal file
@ -0,0 +1,16 @@
|
||||
## Reverse a String - Solution
|
||||
|
||||
```
|
||||
my_string[::-1]
|
||||
```
|
||||
|
||||
A more visual way is:<br>
|
||||
<i>Careful: this is very slow</i>
|
||||
|
||||
```
|
||||
def reverse_string(string):
|
||||
temp = ""
|
||||
for char in string:
|
||||
temp = char + temp
|
||||
return temp
|
||||
```
|
Reference in New Issue
Block a user