Day 1 in Python

Day 1 in Python

Learning Python Basics and Data Types

Embarking on my first day of learning Python was an exciting journey filled with discovery and enthusiasm. Contrary to my initial unease, Python's simple syntax and versatility made it an accessible and enjoyable language to delve into.

In this blog post, I'll recap my Day 1 experience, focusing on Python's introduction and essential data types.

Python Introduction

Python stands out as a high-level interpreted language renowned for its simplicity and readability. Its expressive syntax caters to both novice and experienced programmers, making it an ideal choice for beginners.

Features of Python

Clear syntax – It is designed to be easy to understand and make it accessible for newbies and enjoyable for experienced programmers.

Interpreted - Python is an interpreted language which means you can run code line by line making it great for interactive sessions.

Versatility – It is used in various domains such as web development, data science, artificial intelligence, and more. Which makes a wider range of Python in the industry.

Data Types in Python

Understanding data types forms the foundation of Python programming. Python offers a rich array of built-in data types, each with unique properties catering to diverse programming needs.

Python data types are used to define the type of a variable. It defines what type of data we are going to store in a variable. The data stored in memory can be of many types.

  • String data type (str): Strings represent sequences of characters and are enclosed within single or double quotes. They are indispensable for handling textual data in Python programs.
str1 = 'Hi My name is Pooja'
str2 = "Hi My name is Neeraj"
print(str1)
print(str2)
  • Numeric Data Types: Python supports numeric data types to represent numerical values, including integers, floats, and complex numbers.

a. Integers(int) – Integers are numbers without any decimal values. These can be positive or negative values.

num = -5 
Print("value stored in variable num is " , num)

b. Float(float) – Float represents decimal values and can be positive or negative.

fl_num = 4.9  
print("value stored in fl_num is", fl_num)

c. Complex (complex) – These numbers are used to represent real numbers with an imaginary part. These are represented as x+yj, where y is the imaginary part.

  • Collection Data Types:

Python's collection data types facilitate the organization and manipulation of data in various structures.

a. List: Lists are versatile, ordered, and mutable collections capable of storing heterogeneous data types. They are denoted by square brackets and commas, offering flexibility in data management.

#list of integers, string, float
a = ["Tiger", 18.5, 15 ]
print("list a contains", a)

b. Tuple: Tuples resemble lists but are immutable, meaning their elements cannot be modified after creation. They are enclosed within parentheses and are ideal for representing fixed sequences of data.

#tuple of int, str, float
b = ("Tiger", 18.5 , 15 )
print("tuple contains", b)

c. Dictionary: Dictionaries epitomize unordered and mutable collections of key-value pairs, enabling efficient data retrieval based on keys. They play a pivotal role in representing associative data structures in Python programs.

#dictionary 
my_dict = {
"name":  "Pooja",
"age":  25,
"city":  "Rishikesh"
}

name, age, and city are key & pooja, 25, and Rishikesh are values.

Conclusion

My inaugural day in Python served as a foundation for understanding its fundamental concepts, including syntax basics and essential data types. Python's user-friendly design and comprehensive data structures set the stage for further exploration and learning. As I progress on my Python learning journey, I'm excited about learning more advanced topics and harnessing Python's power across diverse applications.

Stay tuned for more updates on my Python learning adventure! <3