Add 57 new questions and exercises

This commit is contained in:
abregman
2021-08-13 09:23:50 +03:00
parent 6e01886e6b
commit 3b05d95256
27 changed files with 1981 additions and 242 deletions

View 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

View 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'

View 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?

View File

@ -0,0 +1,3 @@
## Reverse a String
Write a code that reverses a string

View 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'} -> set
2. b = {'1': '2'} -> dict
4. c = ([1, 2, 3]) -> list
4. d = (1, 2, 3) -> tuple
4. e = True+True -> int

View 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(...)`

View 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
```