Saturday, 21 December 2019

Python for Beginners 2

A beginners guide to learning Python.
It's a great language to learn if you are getting started in the world of computer programming.

Python for Beginners 1 is here:
Python for beginners
It contains episode 1, 2& 3.
Covers topics like IDEs, if, else statements, variables and functions.
Really basic stuff to get you started.

+++++++++++++++++++++++++++++++++++++++++++++++++++
-------------------------------------------------------------------------------------

Episode 4 
Introduction To Lists In Python (Python Tutorial #4)

Lists are a type of data like strings and intergers. 
Similar to arrays (in others languages like java).

Two of the most common commands/functions:
a.append() ..... this adds to a list
a.pop() ............. this removes from a list

a[0]  ............... retreive the first item in the list
a[1] ................. get the second item in the list
a[0] = 100  .......... this assigns 100 to the first item in the list

------------------------------------------------------
two ways to swap variables in a list"

temp = b[0]
b[0] = b[2]
b[2] = temp


or 

b[0], b[2] = b[2], b[0]

++++++++++++++++++++++++++++++++++++++++++++++++++

Episode 5 ..
Introduction to For Loops in Python (Python Tutorial #5)


a = ["banana", "apple", "microsoft"]
for element in a:
    print(element)
    print(element)
# This is a for loop .... it prints all the elements in the list

------------

for element in a:
    print(element)
# this can be substituted by
for e in a:
    print(e)

-----------------
b = [20, 10, 5]
total = 0
for e in b:
    total = total + e
print(total)

# answer is :
35

--------------------------
# the range function
# this creates a list containing a range of numbers starting at 1 and ending at 4
# 1, 2, 3, 4
c = list (range (1, 5))
[1, 2, 3, 4]

for i in range(1, 5):
      print(i)
#answer:
1
2
3
4
------------------------------------
+=
-------------------------------------------------------
# modulo operator
# gives the remainder of 4 divided by 3
# answer is 1
print(4 % 3)

++++++++++++++++++++++++++++++++++++++++++++++++++++

Episode 6
While Loops and The Break Statement in Python (Python Tutorial #6)


---------------------------------------------------------------------------------------
Links
+Download Python
https://www.python.org/
+ PYO - Ajaz sound studio
+ Wikipedia
+ https://www.simplifiedpython.net/

Basics.
Choosing a IDE(integrated Development Enviroment)
 https://www.simplifiedpython.net/6-best-python-ides/
+ PyCharm
+ Anaconda 


Tutorial Videos
+ CS DoJo
+ https://www.youtube.com/watch?v=_uQrJ0TkZlc 


No comments:

Post a Comment