Day 13 : Python Basics

What is Python?

Python is a high-level, interpreted, and general-purpose programming language known for its simplicity and readability. It was created by Guido van Rossum in 1991 and is widely used across various fields, including web development, data analysis, artificial intelligence, scientific computing, automation, and more

Key Features of Python:

  1. Easy to Learn and Use:

    • Python has a simple syntax that resembles natural language, making it beginner-friendly.
  2. Versatile and Cross-Platform:

    • Python runs on various platforms, including Windows, macOS, and Linux.
  3. Interpreted Language:

    • Python code is executed line by line, making it easier to debug and develop.
  4. Extensive Libraries and Frameworks:

    • Python has a rich ecosystem of libraries like NumPy, Pandas, TensorFlow, Flask, Django, and Boto3, enabling rapid development in diverse domains.
  5. Dynamic Typing:

    • Variables don’t need explicit type declarations; Python infers the type at runtime.
  6. Open Source:

    • Python is free to use and distribute, supported by a large global community.
  7. Object-Oriented and Procedural:

    • Python supports multiple programming paradigms, including object-oriented, functional, and procedural.

Where is Python Used?

Python is used in multiple fields such as Web Development, Data Science and Machine Learning, Automation/Scripting, Cloud and Devops, Game Development & Cybersecurity and Networking.

What makes python different from other programming language?

  • Beginner-Friendly: Easy syntax, widely taught as a first language.

  • Versatile: Applicable in multiple domains, from web development to AI.

  • Demand in Industry: High demand for Python skills in the job market.

  • Community Support: Large community for support, tutorials, and problem-solving.

Python's motto, "Batteries Included," reflects its rich standard library, enabling developers to solve real-world problems efficiently.

How to install Python?

You can install Python in your System whether it is window, MacOS, ubuntu, centos etc. Below are the links for the installation:

Tasks

  1. Install Python in your respective OS, and check the version.

  2. Read about different Data Types in Python

Python provides a variety of built-in data types that define the type of value a variable can hold. These data types can be broadly categorized into basic types, collections, and more specialized types.


1. Basic Data Types

TypeDescriptionExample
intInteger values.x = 10
floatDecimal numbers (floating-point).y = 3.14
complexComplex numbers with real and imaginary parts.z = 3 + 4j
boolBoolean values: True or False.is_valid = True
strString (text).name = "Python"
NoneTypeRepresents the absence of a value or null.x = None

2. Sequence Types (Collections)

TypeDescriptionExample
listOrdered, mutable collection of items.fruits = ["apple", "banana"]
tupleOrdered, immutable collection of items.point = (1, 2, 3)
rangeSequence of numbers (useful for loops).r = range(1, 10)
strSequence of characters (immutable).text = "Hello"

3. Set Types

TypeDescriptionExample
setUnordered collection of unique items.nums = {1, 2, 3}
frozensetImmutable version of a set.fs = frozenset([1, 2])

4. Mapping Types

TypeDescriptionExample
dictKey-value pairs.person = {"name": "John", "age": 30}

5. Binary Types

TypeDescriptionExample
bytesImmutable sequence of bytes.b = b"hello"
bytearrayMutable sequence of bytes.ba = bytearray(b"hello")
memoryviewMemory view of a byte array.mv = memoryview(b"hello")

6. Specialized Data Types

  • Enumerations: Created using the enum module.

  • Custom Classes: User-defined types using classes.

7. None Type

Represents the None object, which is used to indicate the absence of a value or a null value.