You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add a couple of exercises
Also fixed the link for kubernetes exercises.
* Fix kubernetes images
Also fixed the link to containers exercises.
* Move Python exercises to a separate repository
This is the first part in moving Python exercises
into their own repository.
@@ -2840,263 +2840,6 @@ Yes, it's a operating-system-level virtualization, where the kernel is shared an
2840
2840
The introduction of virtual machines allowed companies to deploy multiple business applications on the same hardware while each application is separated from each other in secured way, where each is running on its own separate operating system.
| Identify the data type | Data Types | [Exercise](exercises/python/data_types.md) | [Solution](exercises/python/solutions/data_types_solution.md)
2850
-
| Identify the data type - Advanced | Data Types | [Exercise](exercises/python/advanced_data_types.md) | [Solution](exercises/python/solutions/advanced_data_types_solution.md)
<summary>What is mutability? Which of the built-in types in Python are mutable?</summary><br><b>
2885
-
2886
-
Mutability determines whether you can modify an object of specific type.
2887
-
2888
-
The mutable data types are:
2889
-
2890
-
List
2891
-
Dictionary
2892
-
Set
2893
-
2894
-
The immutable data types are:
2895
-
2896
-
Numbers (int, float, ...)
2897
-
String
2898
-
Bool
2899
-
Tuple
2900
-
Frozenset
2901
-
</b></details>
2902
-
2903
-
#### Python - Booleans
2904
-
2905
-
<details>
2906
-
<summary>What is the result of each of the following?
2907
-
2908
-
- 1 > 2
2909
-
- 'b' > 'a'
2910
-
* 1 == 'one'
2911
-
- 2 > 'one'</summary><br><b>
2912
-
2913
-
* False
2914
-
* True
2915
-
* False
2916
-
* TypeError
2917
-
</b></details>
2918
-
2919
-
<details>
2920
-
<summary>What is the result of `bool("")`? What about `bool(" ")`? Explain</summary><br><b>
2921
-
2922
-
bool("") -> evaluates to False<br>
2923
-
bool(" ") -> evaluates to True
2924
-
</b></details>
2925
-
2926
-
<details>
2927
-
<summary>What is the result of running <code>[] is not []</code>? explain the result</summary><br><b>
2928
-
2929
-
It evaluates to True.<br>
2930
-
The reason is that the two created empty list are different objects. `x is y` only evaluates to true when x and y are the same object.
2931
-
</b></details>
2932
-
2933
-
<details>
2934
-
<summary>What is the result of running <code>True-True</code>?</summary><br><b>
2935
-
2936
-
0
2937
-
</b></details>
2938
-
2939
-
#### Python - Strings
2940
-
2941
-
<details>
2942
-
<summary>True or False? String is an immutable data type in Python</summary><br><b>
2943
-
2944
-
True
2945
-
</b></details>
2946
-
2947
-
<details>
2948
-
<summary>How to check if a string starts with a letter?</summary><br><b>
2949
-
2950
-
Regex:
2951
-
2952
-
```
2953
-
import re
2954
-
if re.match("^[a-zA-Z]+.*", string):
2955
-
```
2956
-
2957
-
string built-in:
2958
-
2959
-
```
2960
-
if string and string[0].isalpha():
2961
-
```
2962
-
</b></details>
2963
-
2964
-
<details>
2965
-
<summary>How to check if all characters in a given string are digits?</summary><br><b>
2966
-
2967
-
`string.isdigit`
2968
-
</b></details>
2969
-
2970
-
<details>
2971
-
<summary>How to remove trailing slash ('/') from a string?</summary><br><b>
2972
-
2973
-
`string.rstrip('/')`
2974
-
</b></details>
2975
-
2976
-
<details>
2977
-
<summary>What is the result of of each of the following?
2978
-
2979
-
- "abc"*3
2980
-
- "abc"*2.5
2981
-
- "abc"*2.0
2982
-
- "abc"*True
2983
-
- "abc"*False</summary><br><b>
2984
-
2985
-
* abcabcabc
2986
-
* TypeError
2987
-
* TypeError
2988
-
* "abc"
2989
-
* ""
2990
-
</b></details>
2991
-
2992
-
<details>
2993
-
<summary>Improve the following code:
2994
-
2995
-
```
2996
-
char = input("Insert a character: ")
2997
-
if char == "a" or char == "o" or char == "e" or char =="u" or char == "i":
2998
-
print("It's a vowel!")
2999
-
```
3000
-
</summary><br><b>
3001
-
3002
-
```
3003
-
char = input("Insert a character: ") # For readablity
3004
-
if lower(char[0]) in "aieou": # Takes care of multiple characters and separate cases
3005
-
print("It's a vowel!")
3006
-
```
3007
-
OR
3008
-
```
3009
-
if lower(input("Insert a character: ")[0]) in "aieou": # Takes care of multiple characters and small/Capital cases
3010
-
print("It's a vowel!")
3011
-
```
3012
-
</b></details>
3013
-
3014
-
#### Python - Functions
3015
-
3016
-
<details>
3017
-
<summary>How to define a function with Python?</summary><br><b>
3018
-
Using the `def` keyword. For Examples:
3019
-
3020
-
```
3021
-
def sum(a, b):
3022
-
return (a + b)
3023
-
```
3024
-
</b></details>
3025
-
3026
-
<details>
3027
-
<summary>In Python, functions are first-class objects. What does it mean?</summary><br><b>
3028
-
3029
-
In general, first class objects in programming languages are objects which can be assigned to variable, used as a return value and can be used as arguments or parameters.<br>
3030
-
In python you can treat functions this way. Let's say we have the following function
3031
-
3032
-
```
3033
-
def my_function():
3034
-
return 5
3035
-
```
3036
-
3037
-
You can then assign a function to a variables like this `x = my_function` or you can return functions as return values like this `return my_function`
3038
-
</b></details>
3039
-
3040
-
#### Python - Integer
3041
-
3042
-
<details>
3043
-
<summary>Write a function to determine if a number is a Palindrome</summary><br><b>
0 commit comments