Python - Part 1

| March 21, 2024, 3:26 p.m.

placeholder

Python - As a programming language 1

So i thought we might start with the basics of my absolute favourite programming language and go on from there. Python is a great language, it works in many fiels and is easy too learn. Too code in python you can download anaconda, its easy and you can run the code throughout the coding session, if you wanna build a bigger program you could use gitpod with github. 

Starting with Data types in Python there are different types. But what is an Data type? A Data type is a way to classify different types of data regarding their content and the way they stores in in the computers memory. You can also create your own costume Data types, which are called classes. In Python classes are a type of Data that allows you to define your own objects with their own attributes and methods. A class acts as a blueprint or template for creating objects with similar properties and behaviours. By using classes you can structure your code in a more modulare and reusable way.  

In Python, there are several built-in data types that serve different purposes. Here are some common data types in Python along with their purposes:

    Integer (int): Represents whole numbers without any fractional part. Used for counting and indexing.

      Floating-point (float): Represents real numbers with a decimal point or an exponent notation. Used for calculations involving decimal numbers.

        String (str): Represents sequences of characters enclosed within single, double, or triple quotes. Used for text manipulation and representation.

          Boolean (bool): Represents the two truth values True and False. Used for logical operations and conditional statements.

            List: Represents ordered collections of items enclosed within square brackets []. Used for storing and manipulating sequences of items.

              Tuple: Represents ordered collections of items enclosed within parentheses (). Similar to lists but immutable (cannot be modified after creation).

              Dictionary (dict): Represents unordered collections of key-value pairs enclosed within curly braces {}. Used for mapping keys to values.

              Set: Represents unordered collections of unique elements enclosed within curly braces {}. Used for mathematical set operations like union, intersection, etc.


              NoneType (None): Represents the absence of a value or a null value. Used as a default return value of functions that don't explicitly return anything.


              So i gonna provide you with some code ex of the different data types:

              Int:

              age = 25

              print(age) #Outputs 25.

              Here the 'age' is a variable and holds 25 as it’s value. 25 is an integer. 


              Float:

              temperature = 98.7 

              print(temperature) #outputs 98.7

              Here the 'temperature' is a variable and holds 98.7 as it’s value. 98.7 is an float.


              String(str):

              name = "John Doe"

              print(name) #outputs John Doe

              Here the 'name' is a variable and holds John Doe as it’s value. John Doe is an string.


              Boolean(bool):

              is_raining = True

               print(is_raining#outputs True

              Here the 'is_raining' is a variable and holds True as it’s value. is_raining is an boolean and can only handle True/False.


              Too check types of data type you use type() function. Too know data types is a good foundation to start out with.