0% found this document useful (0 votes)
2 views

personal notes - study about Python Basics- Variables and Data Types

This document introduces the basics of Python programming, focusing on variables and data types. It explains how to use variables as labels for storing values and outlines common data types such as integers, floats, strings, booleans, lists, tuples, and dictionaries. Understanding these concepts is essential for effectively working with information in Python.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

personal notes - study about Python Basics- Variables and Data Types

This document introduces the basics of Python programming, focusing on variables and data types. It explains how to use variables as labels for storing values and outlines common data types such as integers, floats, strings, booleans, lists, tuples, and dictionaries. Understanding these concepts is essential for effectively working with information in Python.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

# Python Basics: Your First Building Blocks

Alright, let's dive into some of the very first things you'll encounter in Python: how to store
stuff and the different kinds of stuff you can store.

1. Think of Variables Like Labels:


- Imagine you have a bunch of boxes, and you want to put things in them and remember
what's inside. In Python, variables are like those labels you stick on the boxes. You give the
box a name (the variable name) and put a value inside.
- To put something in a box, you use the equals sign (`=`).
- Just a heads-up, Python cares about uppercase and lowercase in names (`myVar` is
different from `myvar`). Also, stick to letters, numbers, and underscores for your labels, and
make sure they start with a letter or an underscore.
- For example:
```python
your_name = "Your Name Here"
your_age = 28
loves_python = True
favorite_number = 3.14 # Yep, decimals too!
```

2. The Different Kinds of Stuff (Data Types):


- Python's pretty good at knowing what kind of information you're dealing with. Here are
some common types:
- **Whole Numbers (int):** Like counting apples – 1, 5, -10, that sort of thing.
```python
number_of_students = 25
```
- **Numbers with Decimal Points (float):** For things like prices or temperatures – 9.99,
-2.7, 1.0.
```python
coffee_price = 3.50
```
- **Text (str):** Anything you want to represent as words or letters goes in quotes (either
single or double, just be consistent!).
```python
greeting = "Hello!"
your_city = 'Galway'
```
- **True or False (bool):** These are special keywords for representing whether something
is true or not. Super useful for making decisions in your code.
```python
is_raining = False
user_logged_in = True
```
- **Lists (list):** Imagine a shopping list – it's an ordered collection of items, and you can
change it. You put them in square brackets `[]` and separate them with commas. You can
even mix different types of items in one list.
```python
my_shopping_list = ["milk", "eggs", "bread"]
random_stuff = [1, "hello", 2.5, False]
```
- **Tuples (tuple):** Similar to lists, but once you create them, you can't change them
(they're like a fixed record). They use parentheses `()`.
```python
important_dates = (2024, 1, 1)
```
- **Dictionaries (dict):** Think of a real dictionary – you look up a word (the "key") to find its
definition (the "value"). In Python, dictionaries store pairs of keys and values inside curly
braces `{}`. Keys have to be unique.
```python
my_details = {"name": "You", "age": 28, "country": "Ireland"}
```

Getting comfortable with variables and these basic data types is the very first step in being
able to tell Python what to do with information.

You might also like