0% found this document useful (0 votes)
4 views7 pages

A Getting Started With Python 2025 - Jupyter Notebook

The document is a Jupyter Notebook tutorial on getting started with Python, covering various data types and their usage. It explains the difference between text and code cells, demonstrates basic data types like integers, strings, and booleans, and introduces advanced data types such as dictionaries and tuples. The tutorial includes examples of creating and manipulating these data types in Python.

Uploaded by

Jairo Romero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views7 pages

A Getting Started With Python 2025 - Jupyter Notebook

The document is a Jupyter Notebook tutorial on getting started with Python, covering various data types and their usage. It explains the difference between text and code cells, demonstrates basic data types like integers, strings, and booleans, and introduces advanced data types such as dictionaries and tuples. The tutorial includes examples of creating and manipulating these data types in Python.

Uploaded by

Jairo Romero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

4/7/25, 1:27 PM A Getting Started with Python - Jupyter Notebook

In [1]:  1 # types of cells in jupyter notebook


2 # Text Cells: Text cells allow you to write and render Markdown (es
3 # syntax. This is where you can describe and document your workflow.
4 # Code Cells: Code cells allow you to write and run programming code

A Getting Started with Python


In [2]:  1 print ('Nora')

Nora

In [3]:  1 # the below is a mistake , because, Nora, is a text, therefore it ne


2 print (Nora)

-----------------------------------------------------------------------
----
NameError Traceback (most recent call l
ast)
~\AppData\Local\Temp\ipykernel_27540\3584459162.py in <module>
1 # the below is a mistake , because, Nora, is a text, therefore
it needs the two single or double qoutes
----> 2 print (Nora)

NameError: name 'Nora' is not defined

In [4]:  1 # here we print a number like a student ID, we define it to be a num


2 print (20253454)

20253454

In [5]:  1 # here we print a number like a student ID, we define it to be a tex


2 print ('20253454')

20253454

In [6]:  1 # let's print the student ID after assigning it to a variable, calle


2 i = 20253454
3 print (i)

20253454

localhost:8889/notebooks/anaconda3/A_BigData2024/A Getting Started with Python.ipynb# 1/7


4/7/25, 1:27 PM A Getting Started with Python - Jupyter Notebook

In [7]:  1 # let's fetch the type of the variable i at this point by using func
2 # arg above refers to argument, which is any variable like i
3 # functions are like transitive verbs should take something with it,
4 ​
5 type (i)

Out[7]: int

In [8]:  1 # please, be careful, do you observe the difference here


2 i = 20253454
3 print ('i')

In [9]:  1 # let's assign student ID to i, but as a text data type


2 i = '20253454'
3 print (i)

20253454

In [10]:  1 type (i)

Out[10]: str

Python like any programming language, updates the variable


assigned value as you progress

In [11]:  1 # whether you surround the string with single or double qoates
2 print ("Nora")

Nora

In [12]:  1 x= 2

In [13]:  1 x

Out[13]: 2

In [14]:  1 x=3
2 x

Out[14]: 3

Basic Generic Data Types


localhost:8889/notebooks/anaconda3/A_BigData2024/A Getting Started with Python.ipynb# 2/7
4/7/25, 1:27 PM A Getting Started with Python - Jupyter Notebook

In [15]:  1 i = 4 # this is an integer type of data


2 i # this is how we call i

Out[15]: 4

In [16]:  1 type (i)

Out[16]: int

In [17]:  1 i = (7)
2 type (i)

Out[17]: int

In [18]:  1 s = nora

-----------------------------------------------------------------------
----
NameError Traceback (most recent call l
ast)
~\AppData\Local\Temp\ipykernel_27540\2084618326.py in <module>
----> 1 s = nora

NameError: name 'nora' is not defined

In [19]:  1 8

Out[19]: 8

In [20]:  1 # to define any variable, as in , T, you need to assign a numerical


2 T

-----------------------------------------------------------------------
----
NameError Traceback (most recent call l
ast)
~\AppData\Local\Temp\ipykernel_27540\2803120700.py in <module>
1 # to define any variable, as in , T, you need to assign a numer
ical value to it
----> 2 T

NameError: name 'T' is not defined

localhost:8889/notebooks/anaconda3/A_BigData2024/A Getting Started with Python.ipynb# 3/7


4/7/25, 1:27 PM A Getting Started with Python - Jupyter Notebook

In [21]:  1 S="Sharkasi"
2 S

Out[21]: 'Sharkasi'

In [22]:  1 f = 3.5 + 0.1


2 f

Out[22]: 3.6

In [23]:  1 type (f)

Out[23]: float

In [24]:  1 f = 0.3+ 0.7


2 f

Out[24]: 1.0

In [25]:  1 type (f)

Out[25]: float

In [26]:  1 b = true

-----------------------------------------------------------------------
----
NameError Traceback (most recent call l
ast)
~\AppData\Local\Temp\ipykernel_27540\1691629399.py in <module>
----> 1 b = true

NameError: name 'true' is not defined

In [27]:  1 b = 'true' # this is here a string


2 type (b)

Out[27]: str

In [28]:  1 b = True
2 type (b)

Out[28]: bool

localhost:8889/notebooks/anaconda3/A_BigData2024/A Getting Started with Python.ipynb# 4/7


4/7/25, 1:27 PM A Getting Started with Python - Jupyter Notebook

Advanced Data Types with Python

Python dictionary
A dictionary in Python is an unordered collection of key-value pairs. Each key must be
unique, and it is associated with a specific value. Dictionaries provide a flexible and efficient
way to store and retrieve data using meaningful identifiers.

Python tuples
are a type of data structure that is very similar to lists. The main difference between the two is
that tuples are immutable, meaning they cannot be changed once they are created. This
makes them ideal for storing data that should not be modified, such as database records.
Tuples are used whenever you want to return multiple results from a function. Since they're
immutable, they can be used as keys for a dictionary

In [29]:  1 # create a list by using []


2 L = [1, 0.5, "nora"]
3 L

Out[29]: [1, 0.5, 'nora']

In [30]:  1 type (L)

Out[30]: list

In [31]:  1 # can I create an empty list ?


2 My_list = []

In [32]:  1 # answer is yes you can create an empty list


2 type (My_list)

Out[32]: list

In [33]:  1 # Method 1 to create a dictionary, use functio dict ({})


2 D = dict ({
3 2034094 : "Nora Sharkasi" , 345432 : "Quen",
4 3940404 : "Lura Smith"
5 })

localhost:8889/notebooks/anaconda3/A_BigData2024/A Getting Started with Python.ipynb# 5/7


4/7/25, 1:27 PM A Getting Started with Python - Jupyter Notebook

In [34]:  1 # calling the dictionary , D, it should show a key-value pairs


2 D

Out[34]: {2034094: 'Nora Sharkasi', 345432: 'Quen', 3940404: 'Lura Smith'}

In [35]:  1 # Method 2 to create a dictionary


2 D = dict ([(234555, "Nora"), (34455, "Sara") ])
3 D

Out[35]: {234555: 'Nora', 34455: 'Sara'}

In [36]:  1 # Method 3 to create a dictionary


2 D = {2034094 : "Nora Sharkasi" , 345432 : "Quen",
3 3940404 : "Lura Smith"
4 }
5 D

Out[36]: {2034094: 'Nora Sharkasi', 345432: 'Quen', 3940404: 'Lura Smith'}

In [37]:  1 # What is the difference between method 1, 2 and 3 ???


2 # method 1 we used dict ({}) ,
3 # however in method 2, we used dict ([])
4 # while in method 3 we used just {}

In [38]:  1 # can we embed a dictionary in a list ?


2 L = [2, 3.2 , 'nora', {394874 : "Sara", 394875 : "Amal" }, 7 ]
3 L

Out[38]: [2, 3.2, 'nora', {394874: 'Sara', 394875: 'Amal'}, 7]

In [39]:  1 L = [ 2, 3.4 , 'Nora', dict[( 3, 3, 'Nora'), (2,4)]]


2 L

Out[39]: [2, 3.4, 'Nora', dict[(3, 3, 'Nora'), (2, 4)]]

In [40]:  1 type (L)

Out[40]: list

In [41]:  1 T = [(3, 2.1, 'Nora')]


2 type (T)

Out[41]: list

localhost:8889/notebooks/anaconda3/A_BigData2024/A Getting Started with Python.ipynb# 6/7


4/7/25, 1:27 PM A Getting Started with Python - Jupyter Notebook

In [42]:  1 T = ([(3, 2.1, 'Nora')])


2 type (T)

Out[42]: list

In [43]:  1 # when we define the number 7 as an integer we simply use i = 7 or i


2 # however, i = [7] define it as a list, or i = ([7])
3 ​
4 i = [7]
5 type (i)

Out[43]: list

Type Markdown and LaTeX: 𝛼2


In [44]:  1 age = [5,6]
2 weight = [16,17]
3 k = [age,weight]
4 k

Out[44]: [[5, 6], [16, 17]]

In [45]:  1 type (k)

Out[45]: list

In [46]:  1 F =[age,weight]
2 F

Out[46]: [[5, 6], [16, 17]]

In [47]:  1 type (F)

Out[47]: list

In [48]:  1 W = tuple ([3, 202, 'Nora', (3,5), [3,5]])


2 type (W)

Out[48]: tuple

localhost:8889/notebooks/anaconda3/A_BigData2024/A Getting Started with Python.ipynb# 7/7

You might also like