For anyone who want to know Python and desired to learn it, so here I write down about what I'd remembered:
- Python are basically interpreter, the same way with HTML processing on browser since it executed line by line.
- Thanks to Google because they provide Python virtual environment so that everyone can use to learn it. First thing first, open https://colab.research.google.com/ from your browser and press New Notebook. Copy and paste the following syntax and have a fun modification :)
- How to print out on screen? print("Hello","World","?")
- Learn about variable assignment and data type:#int x = 0 #float y = 4.3 #string z = "z"x = 0y = 4.3 z = "z"print(x,y,z)type(z)
- Python is about sequences:a = 1 a = a + 1 b = 2 c = a + b type(c) c = str(c) print(c)
- Math operation:print(c*2)
- Ask for input:print("Name?") name = input() print("Hi",name)
- Branches:print("Name?") name = input()
if (name=="dodol"): print("Hi",name) else: print("I don't know u,",name) print("Age?") age = input() print("Age",name,":",age)
- Looping:for num in range(1,4): print(4-num)
- Array:daftar_nama = ["saya","kamu","dia","mereka","kita"] for angka in range(len(daftar_nama)): print(daftar_nama[angka])
- Quit from looping:for nama in range(len(daftar_nama)): print(nama) if (nama==2): break
- Function:def add(a,b): return a+b
That's it for today. Happy Python!
|PS: If you've benefit from this blog,
you can support it by making a small contribution.