Skip to content

Alicade123/Python_learning

Repository files navigation

Python_learning

Welcome to my Python learning repository! This project contains clean code snippets and simple notes covering the fundamental building blocks of Python programming.

Table of Contents


Variables & Data Types

Variables are containers for storing data. Python automatically detects the data type.

name = "Alicade"      # String (str)
age = 25            # Integer (int)
height = 5.8        # Float (float)
is_student = True   # Boolean (bool)

Typecasting

Typecasting is converting a variable from one data type to another.

# Convert string to integer
age_str = "25"
age_int = int(age_str)

# Convert integer to float
price = float(10)  # Results in 10.0

Arithmetic Operators

Used with numeric values to perform common mathematical operations.

addition = 10 + 5       # 15
subtraction = 10 - 5    # 5
multiplication = 10 * 5 # 50
division = 10 / 5       # 2.0
modulus = 10 % 3        # 1 (returns the remainder)

Data Collections

Python uses four built-in data types to store collections of data.

1. Lists

Ordered, changeable, and allows duplicate values.

fruits = ["apple", "banana", "cherry"]

2. Tuples

Ordered, unchangeable, and allows duplicate values.

coordinates = (10.0, 20.0)

3. Sets

Unordered, unchangeable*, and unique values only (no duplicates).

unique_numbers = {1, 2, 3, 3, 4}  # Stores as {1, 2, 3, 4}

Summary Cheat Sheet

Collection Ordered? Changeable? Duplicates? Syntax
List Yes Yes Yes [ ]
Tuple Yes No Yes ( )
Set No No* No { }

*Set items are unchangeable, but you can remove items and add new items.


How to Run

  1. Make sure you have Python Installed.
  2. Clone this repository:
    git clone https://github.com/Alicade123/Python_learning.git
  3. Run any script using your terminal:
    python filename.py

About

This repo is for learning the python basics and scripting through the cloud engineering specialization in theGym, Ojemba and [MaibornWolff](https://www.maibornwolff.de/en/)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages