Python for Dummies

For anyone who want to know Python and desired to learn it, so here I write down about what I'd remembered:
  1. Python are basically interpreter, the same way with HTML processing on browser since it executed line by line.
  2. 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 :)
  3. How to print out on screen?
    print("Hello","World","?")
  4. Learn about variable assignment and data type:
    #int x = 0 #float y = 4.3 #string z = "z"
    x = 0
    y = 4.3 z = "z"
    print(x,y,z)
    type(z)
  5. Python is about sequences:
    a = 1 a = a + 1 b = 2 c = a + b type(c) c = str(c) print(c)
  6. Math operation:
    print(c*2)
    49**0.5
  7. Ask for input:
    print("Name?") name = input() print("Hi",name)
  8. 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)
  9. Looping:
    for num in range(1,4):   print(4-num)
  10. Array:
    daftar_nama = ["saya","kamu","dia","mereka","kita"] for angka in range(len(daftar_nama)):   print(daftar_nama[angka])
  11. Quit from looping:
    for nama in range(len(daftar_nama)):   print(nama)   if (nama==2):     break
  12. Function:
    def add(a,b):   return a+b
    add(3,2) 
      I wrapped it on 2 videos below if you want to make a practice:


    That's it for today. Happy Python!

Labels: ,


PS: If you've benefit from this blog,
you can support it by making a small contribution.

Enter your email address to receive feed update from this blog:

Post a Comment

 

Post a Comment

Leave comments here...