create example for basics

This commit is contained in:
michivonah 2023-10-08 15:25:43 +02:00
parent 9f569cac7b
commit 3798905807
2 changed files with 56 additions and 0 deletions

9
basics/basics.md Normal file
View file

@ -0,0 +1,9 @@
# Basics in Python
## String functions
## Core concepts
Check if execution is in main program
````python
if __name__ == '__main__':
````

47
basics/main.py Normal file
View file

@ -0,0 +1,47 @@
# Basics in Python
# Michi von Ah - October 2023
# Data structures
# Array
brands = ["Apple", "Samsung", "Google", "OnePlus"]
# Dictionary
phone = {
"brand": "Apple",
"model": "iPhone 14 Pro",
"cameras": 3
}
# Dictionaries in Array
phones = [
{
"brand":"Apple",
"model":"iPhone 14 Pro",
"cameras":3,
"memory":"6GB"
},
{
"brand":"Samsung",
"model":"Galaxy S23",
"cameras":3,
"memory":"8GB"
}
]
# Split strings into Array
fruits = "Apple,Banana,Pear,Cherry"
split = fruits.split(",") # Output: ['Apple', 'Banana', 'Pear', 'Cherry']
# Transform text
text = "I love Python!"
upper = text.upper() # Output: I LOVE PYTHON!
lower = text.lower() # Output: i love python!
# Convert String-To-Int and Int-To-String
number = 12
numberConverted = int("12")
string = "Hello World"
combined = string + str(numberConverted) # Output: Hello World12