Embark on your data science journey with our Day 1 guide to learning Python for Data Science. Understand Python’s key features, variable assignments, and the importance of comments in coding. Read more

Day 1 of learning Python For data science
Introduction to Python
Python is a high level and versatile programming language known for its readability and simplicity. It is widely used in various fields, including web development, data science, artificial intelligence, and automation.
Created in the late 1980s by Guido Van Rossum, it has grown into one of the most popular languages for beginners and expert programmers. Vast libraries, dynamic typing, and cross-platform compatibility are key reasons for its popularity.
Key Features of Python
- Ease of use and readability: Python’s syntax is clean and easy to understand, making it beginner friendly yet powerful.
- Interpreted language: Python code is executed line by line allowing for quick testing and debugging.
- Extensive libraries and frameworks: Python offers libraries like NumPy, Pandas and TenserFlow for machine learning, Flask and Django for web development and many others for different domains.
- Cross platform support: Python is compatible with other operating systems, enabling developers to work seamlessly across platforms.
Variables
What are variables in Python?
Variables act as containers for storing data values, it can also be defined as variables are the names that holds values which can be used and modified throughout the program.
How to create variables in Python?
Naming Rules: Unlike other languages, Python does not require explicit declaration of variable types but there are a few rules about naming the variables, that must be followed.
- Variable names
must start with
eighter with aletter
or anunderscore
(_)
. They cannot start with a number. - Variable names
can contain letters, numbers, and underscore only
, cannot contain special characters. - Python is a
case sensitive
language, hencename
andName
are treated asdifferent variables
.
Example for creating variables:
x = 10
name = "Python"
pi = 3.14
Python also allows to create multiple variables at the same time.
a, b = 5, 10
print(a, b)
5 10
Using the same method values from these variables can be swapped.
a, b = b, a
print(a, b)
10 5
Comments
Comments are used to add notes or explanations to codes without affecting its execution. They help make the code more readable and understandable, especially for complex logic or when working in a team. Comments are ignored by Python interpreter.
Types of comments:
Single line comments:
These comments begin with # symbol and continue to the end of the line. They are typically used for short explanations or clarify specific lines of code.
# this is a comment.
x = 5 # Assigning value to x
Multiline comments:
Multiline comments are often created using triple quotes (”’ or “””). While triple quotes are typically used for multiline strings they can also serve as multiline comments until they are not assigned to a variable.
"""
This is a multi-line comment.
It can span multiple lines.
"""
print("Hello, World!")
You can also check out our podcast on this topic
Practice
It is important to practice your learning in order to solidify your knowledge.
- What are some key fields where Python is widely used?
- Why is Python considered an easy-to-learn language?
- What makes Python different from compiled languages?
- What does it mean when we say Python is dynamically typed?
- Name two Python libraries commonly used in data science.
- Why is Python considered cross-platform?
- How does Python’s interpreted nature help in debugging?
- How do you assign a value to a variable in Python? Provide an example.
- What are the rules for naming variables in Python?
- Is Python case-sensitive when it comes to variable names? Explain with an example.
- What happens if you assign
x = 10
in Python without declaring a type? - What is the output of the following code? a = 5 b = 10 | a, b = b, a | print(a, b)
- What is the purpose of comments in Python?
- How do you write a single-line comment in Python?
- How do you write a multi-line comment in Python?
- What is the difference between single-line and multi-line comments?
- How can comments help in debugging?
- What is the significance of using
#
in Python? - Can a variable name in Python start with a number? Why or why not?
- What is the output of the following code?
- Write a Python program to print “Welcome to Python Programming!” using the
print()
function. - Create three variables:
name
,age
, andcity
. Assign them your name, age, and city respectively. Then, use theprint()
function to display their values in a sentence. - Create two variables
x
andy
. Assign any two numbers to them. Calculate their sum, difference, product, and quotient. Print each result. - Write a Python program to swap the values of two variables without using a third variable. Example: If
a = 3
andb = 5
, after swappinga
should be 5 andb
should be 3. - Write a Python script that includes both single-line and multi-line comments.
- Variables and Assignment: Create a variable language and assign it the value “Python”. Print the variable.
- Basic Data Types: Declare a variable for each of the following data types: integer, float, and string. Print their values.
- Dynamic Type Change: Assign the value 10 to a variable and print its type. Change its value to 10.5 and print its type again. Finally, assign “Ten” to the same variable and print its type. Explain why Python allows this.
- Write a single line of code to assign the values “Apple”, 20, and 3.14 to three different variables. Print all three variables in a single print() statement, ensuring they are separated by ” | “.
The answer for these is shared here: click here for answers
This concludes Chapter 1. In the next chapter, we will explore Python’s data types and operations in detail.
We hope this article about Day 1 of Learning Python for Data Science was helpful for you and you learned a lot of new things from it. If you have friends or family members who would find it helpful, please share it to them or on social media.
Join our social media for more..
Also Read:
- Dimensions and Measures in Tableau
- Practice Questions and Answers for Day 1 of learning python for data science
- Day 1 of learning Python For data science: A Beginner’s Guide
- Amazon’s Most Asked SQL Interview Questions: Curious Club
- Data Analyst Interview Questions Experience at Flipkart
Hi, I am Vishal Jaiswal, I have about a decade of experience of working in MNCs like Genpact, Savista, Ingenious. Currently i am working in EXL as a senior quality analyst. Using my writing skills i want to share the experience i have gained and help as many as i can.