From 379890580704bec5b12c981f5e86d0b7a22b23ce Mon Sep 17 00:00:00 2001 From: michivonah Date: Sun, 8 Oct 2023 15:25:43 +0200 Subject: [PATCH] create example for basics --- basics/basics.md | 9 +++++++++ basics/main.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 basics/basics.md create mode 100644 basics/main.py diff --git a/basics/basics.md b/basics/basics.md new file mode 100644 index 0000000..1c6555b --- /dev/null +++ b/basics/basics.md @@ -0,0 +1,9 @@ +# Basics in Python + +## String functions + +## Core concepts +Check if execution is in main program +````python +if __name__ == '__main__': +```` \ No newline at end of file diff --git a/basics/main.py b/basics/main.py new file mode 100644 index 0000000..d900614 --- /dev/null +++ b/basics/main.py @@ -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