Welcome to the very first issue of Pandas Daily — your 5 minute daily dose of Python. Today: Understand some of Python’s data types with examples and clean output. “Data Types” help the computer understand what you're working with—numbers, text, or something else. Common Data Types 1. NumbersReminder: As seen below, "In [1]" is the code input we will type in and "Out [1]" is the output of code once executed
In [1]: # Integers (anything starting with '#' is a comment and not executed)
8
Out [1]: 8
In [2]: # Floating numbers(decimal ones)
4.22
Out [2]: 4.22
✅ To check in case I am lying - use "type" command
In [3]:
type(8)
Out [3]: int
In [4]:
type(4.22)
Out [4]: float
📚📈 What "Math" you can do with numbers
In [5]: # Addition (or subtraction)
8 + 4.22
Out [5]: 12.22
In [6]: # Multiplication
8 * 4.22
Out [6]: 33.76
In [7]: # Division
8 / 4
Out [7]: 2.0
In [8]: # Exponents (2 to the power of 3 -> 2 X 2 2 X 2 = 8)
2 ** 3
Out [8]: 8
♾️ Convert int to float and vice versa
In [9]:
int(2.8)
Out [9]: 2
In [10]:
float(2)
Out [10]: 2.0
2. Booleans (don't worry, just a fancy name) - True, False basically
In [11]:
True
Out [11]: True
In [12]:
False
Out [12]: False
🤜🤛Again use "type" to check in case I am lying about bools. Yes "bool" is for "booleans".
In [13]:
type(True)
Out [13]: bool
🚨📝 They are primarily used to check some conditions or do comparisons
In [14]: # Is 12 greater than 0?
12 > 0
Out [14]: True
In [15]: # Is 12 less than 5?
12 < 5
Out [15]: False
💡Why the below error?
In [16]:TRUE
Out [16]:
NameError: name 'TRUE' is not defined 😭Because Python is (CASE) sensitive 🧠🚀 "True" is also considered as 1 and False as 0. See below:
In [17]:
True + True
Out [17]: 2
In [18]:
True + False
Out [18]: 1
In [19]:
True + 1
Out [19]: 2
Coming up tomorrow and beyond: Strings, lists, dictionaries - all keeping it simple!!
|
Beginner to Expert in Python in just 5 minutes
Welcome back to Pandas Daily! Your daily 5-minute boost to becoming confident in Python. Today: Let’s dive into Python "Dictionaries", the toolbox for storing data with labels and values. If you are an absolute beginner you can glance through previous issues as well Think of Python Dictionaries like a real world dictionary: you look up a word (key) and find its meaning (value). Data is basically stored as key-value pair. Use when you want to connect a label (like a name) to information (like...
Welcome back to Pandas Daily! Your daily 5-minute boost to becoming confident in Python. Today: Get hands-on with Python lists — master storing and managing of multiple items in one place. If you are an absolute beginner you can glance through previous issues as well A "list" is a datatype that can store multiple values as one variable. Yes you can stuff numbers, strings, anything together 🔍 What does it look like? Reminder: print() is often used to display output In [1]: # List is...
Welcome back to Pandas Daily! Your daily 5-minute boost to becoming confident in Python. Today: Dive into Python strings — learn how to create, manipulate, and explore them. "String" is any sequence of characters (letters, numbers, symbols etc.) in quotes. Can be represented in single ☝️ or double quotes ✌️ In [1]: # String in single quotes 'I love Pandas Daily' Out [1]: 'I love Pandas Daily' In [2]: # String in double quotes "I love Pandas Daily" Out [2]: 'I love Pandas Daily' ↩️ Slight...