0% found this document useful (0 votes)
11 views3 pages

Class Notes of Python 1st Day

This document serves as an introductory guide to Python programming, covering fundamental concepts such as what Python is, how to write a simple program, and the use of variables and basic data types. It also explains how to take user input, use comments, and perform basic arithmetic operations. Additionally, it includes practice problems to reinforce learning on the first day of Python programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Class Notes of Python 1st Day

This document serves as an introductory guide to Python programming, covering fundamental concepts such as what Python is, how to write a simple program, and the use of variables and basic data types. It also explains how to take user input, use comments, and perform basic arithmetic operations. Additionally, it includes practice problems to reinforce learning on the first day of Python programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

🐍

Of course! Here are some class notes for the first day of learning Python.

Day 1: Introduction to Python


Welcome to your first day of Python programming! Today, we'll cover the absolute basics to get
you started. Remember your goal of scoring well in your exams; mastering these fundamentals
is the first step!

What is Python?
Python is a high-level, interpreted, and general-purpose programming language.
●​ High-Level: It's written in a way that is easy for humans to read and write.
●​ Interpreted: It runs code line by line, which makes it easier to debug (find and fix errors).
●​ General-Purpose: You can use it for almost anything—web development, data science,
automation, AI, and more!

Your First Python Program: "Hello, World!"


The first program anyone writes in a new language is one that prints "Hello, World!". In Python,
it's just one line.
print("Hello, World!")​

●​ print() is a built-in function that displays output to the screen.


●​ The text inside the quotation marks " " is called a string.

Variables and Basic Data Types


A variable is like a container used to store data. You can give it a name and assign a value to it
using the equals sign =.
Python has several data types, but let's start with the three most common ones:
1.​ String (str): Textual data. It's always enclosed in single ' ' or double " " quotes.​
name = "Alice"​
greeting = 'Welcome to Python!'​

2.​ Integer (int): Whole numbers, without any decimal points.​


age = 25​
quantity = 100​

3.​ Float (float): Numbers with a decimal point.​


price = 19.99​
pi = 3.14​

You can print variables to see their values:


student_name = "Ravi"​
score = 95​
print(student_name) # Output: Ravi​
print(score) # Output: 95​
Taking Input from the User
You can make your programs interactive by asking the user for input using the input() function.
The input() function always returns the data as a string.
# Ask for the user's name and store it in a variable​
user_name = input("What is your name? ")​

# Print a greeting using the user's name​
print("Hello, " + user_name + "!")​

Note: If you need a number from the user for calculations, you must convert the string input into
an integer (int()) or a float (float()).
age_str = input("Enter your age: ")​
age_int = int(age_str) # Convert the string to an integer​
next_year_age = age_int + 1​
print("Next year, you will be", next_year_age, "years old.")​

Comments
Comments are notes in your code that are ignored by Python. They are used to explain what
the code does, which is very helpful for yourself and others.
Use the hash symbol # to start a comment.
# This is a comment. It won't be executed.​

# Assigning a value to the variable 'x'​
x = 10 # This is an inline comment explaining this specific line.​

Basic Arithmetic Operations


You can perform mathematical calculations just like on a calculator.
●​ Addition: +
●​ Subtraction: -
●​ Multiplication: *
●​ Division: /
Example:
a = 10​
b = 5​

sum_result = a + b # 15​
diff_result = a - b # 5​
product_result = a * b # 50​
div_result = a / b # 2.0 (Division always results in a float)​

print("Sum:", sum_result)​
print("Product:", product_result)​

Practice Problems for Day 1


1.​ Write a program that prints your name and your city.
2.​ Create a program that asks the user for two numbers, adds them together, and prints the
result. (Hint: Remember to convert the input to numbers!)
3.​ Write a program that calculates the area of a rectangle. Ask the user for the length and
width. (Area = length * width).

You might also like