CT Hndpyth
CT Hndpyth
This allows you to work with a list of values and is mutable (changeable, editable). [ ] is the
symbol used in a list.
SET
This is a collection of values with no duplicates where outputs keep changing when run multiple
times.
TUPLE
This also allows you to work with a list of values that is immutable (cannot be changed or edited)
1. APPEND
2. EXTEND
3. POP
4. INSERT
5. REMOVE
6. INDEX uses [ ]
7. LEN
Example
If you are to use append, you use it to add something to a LIST or replace something with
another. e.g. Take this List of subjects:
subjects = [‘CTE_323’,’COM_316’,’COM_325’]
When you are to append(add another course to the list above), just use the python command
below:
subjects.append(‘Agric’)
print(subject)
OUTPUT
subjects = [‘CTE_323’,’COM_316’,’COM_325’,’Agric’]
EXTEND
first_name = [‘Jade’,’Joshua’,’Jamal’,’Jabar’]
last_name = [‘Bamidele’,’Bode’,’Braimah’,’Biliamin’]
first_name.extend(last_name)
print(first_name)
OUTPUT
[‘Jade’,’Joshua’,’Jamal’,’Jabar’,’Bamidele’,’Bode’,’Braimah’,’Biliamin’]
POP function
Using the above example in Extend, if you type first_name.pop() as shown below:
first_name = [‘Jade’,’Joshua’,’Jamal’,’Jabar’]
first_name.pop()
print(first_name)
OUTPUT
[‘Jade’,’Joshua’,’Jamal’]
REMOVE function
This is similar to pop() but you use it to specifically remove an item at any location in a List.
Example
first_name = [‘Jade’,’Joshua’,’Jamal’,’Jabar’]
first_name.remove(‘Joshua’)
print(first_name)
[‘Jade’,’Jamal’,’Jabar’]
INSERT (It is used to add to a specific location in a list)
first_name = [‘Jade’,’Joshua’,’Jamal’,’Jabar’]
first_name.insert(4,‘President_Tinubu’)
print(first_name)
OUTPUT
[‘Jade’,’Joshua’,’Jamal’,’Jabar’,’President_Tinubu’]
Comment
You must choose a location when using insert; it makes it different from append
first_name = [‘Jade’,’Joshua’,’Jamal’,’Jabar’]
last_name = [‘Jide’,’Josh’]
first_name.insert(0, last_name)
print(first_name)
OUTPUT
[‘Jide’,’Josh’,‘Jade’,’Joshua’,’Jamal’,’Jabar’]
LEN function
first_name = [‘Jade’,’Joshua’,’Jamal’,’Jabar’]
print(len(first_name))
OUTPUT
first_name = [‘Jade’,’Joshua’,’Jamal’,’Jabar’]
print(first_name[0])
OUTPUT
[‘Jade’]
Using same example, to print from Jade to Joshua or to index Jade and Joshua only, use the
code below to get 2 items from the list:
first_name = [‘Jade’,’Joshua’,’Jamal’,’Jabar’]
print(first_name[0:2])
OUTPUT
[‘Jade’,’Joshua’]
OUTPUT
[‘Jade’,’Joshua’,’Jamal’]
Difference Between Tuple and List
Tuple is another sequence data type that is similar to the list. It consists of a number of values
separated by commas. Lists are enclosed in brackets [ ] and their elements and size can be
changed (mutable), while Tuples are enclosed in parentheses ( ) and cannot be updated, Tuple is
read only lists. e.g tuple = (‘abcd’,‘786’, ‘2.23’, ‘John’)
1. Python Default
2. Python Keyword
3. Python Arbitrary
1. Arithmetic Operator
2. Argument Operator
3. Logical Operator
4. Bitrise Operator
5. icantity Operator
Tuple
TUPLE
Same as above but if you change lagos_1 = tuple_1 and lagos_2 = tuple_2, also in the print
statements:
If you change any particularly in lines to tuple_1(0) = ‘Art’ you will receive an error code
because it is immutable.
If you want something you can modify, use list but use tuple if you are not ready to modify.
If you want something you can modify, use list but use are not modifying.
SET
print (CS_Courses)
OUTPUT
PYTHON PROGRAMMING
Python is a multipurpose programming long for variety of different tasks. It can be use for
machine learning and Al, data science projects, web developments.
it is the No 1 language for A1, machine learning and data science projects. Use python and a
framework of Django, one can build amazing websites. Website powered with Django are
Youtube, Sporty, Pinterest, Instagram, Dropbox. One can use python in Automation, it can save
your time in automating repetitive tasks.
The first thing is to head over to python.org and select the latest version of python (Go to
download, and select the latest version.
Install a code editor, e.g Most popular ( You will get it from jetlorams.com/pycharm). This is
used to write the code and execute it.
There are two download: The professional and community edition which is free and open source.
Pycharm
Either single or double quote is acceptable in python
print (“Hello.World”)/lower case
PYTHON
An amazing programming application that can be used to develop any specific application right
from the social media apps like pinterest and instagram.
Python is available across many platforms including windows linux and MAC OS. Due to its
inherently easy to learn nature, along with its objects oriented features, python is used to develop
and demonstrate application quickly.
Python has the “batteries included” philosophy compared with the rich set of built-in libraries.
IDENTIFIERS
e.g A B C D E F G H I J K L M N O P Q R S T U V W X Z Y
A B C D E F G H I J K L M N O P Q R S T U V W X Z Y_0 1 2 3 4 5 6 7 8 9
User Input
X=Input ( )
X= Input ( )
Output
12
Text Entered: 12
Type:<class ‘str;>
Print ( )
Output
ABC
Sum=Num1 + Num2
Output
12+5 =17
While Loop
Count = 1
print (count)
count = 1
OUTPUT
2
3
Sum = 0
Sun = sum + n
Sum 1
Sum 3
Sum 6
Sum 10
Sum 15
Sum 21
Sum 28
Sum 36
Sum 45
Sum 55
Sum 66
Sum 78
Sum 91
Answer
Print (n)
Output
21 18 15 12 9 6 3
DEVELOPMENT TOOL
In the Data Science Community, Python is one of the most popular programming language. It is
popular because of the following reasons:
1. Python has a very simple syntax almost equivalent to mathematical syntax hence can be
easily understood and learned.
2. It offers extensive coverage libraries and tools for scientific imputing and data science
PYTHON TOOLS
1. Scikit learn: This is an open source tool depend for data science and machine leaning
engineer ,developers and data scientist for data mining and data analysis .it offer a consistent
and user ,friendly application program Interface (APL) along with grind and random searches
2. KERAS: This is an open source ,high level reduce network library written in python . suited
for machine leaning and deep leaning .four core principles of keras are user friendliness ,
modularity easy extensibility and working with python
3. THEANO: This is an python library designed exphaty for expressing must dimensional
arrays . It allows you to define optimize ,and evaluate mathematical computations comprising
multi-dimensional array
4. SAIPY: An open source python based library ecosystem used for scientific and technical
computing
1. Beautiful soup: python library for extracting data from HTML and XML files
2. LXML: python based tool for C – libraries : libxml2 and libxslt
3. SCRAPY: for developing web spiders that crawl website and extract data from them
4. URLLIB: for collecting and opening URLs