Skip to main content

Python Notes for Beginners

🚀 Welcome to NiceinPythonlearn | 📘 Learn Python with Easy Tutorials, Notes & Practice Questions | 💻 Build Real-World Projects | 💬 Enjoying the content?Share your feedback! | 📝 If you have any questions, suggestions, or face any problems, please contact us using the Contact Form or leave a comment. We will do our best to solve it together. 🤝 | ⭐ Follow us for new updates and keep learning!

Introduction of Python Programming Language

Python is a simple, powerful, and beginner-friendly programming language created by Guido van Rossum. It is widely used because of its easy syntax, large community, and many useful libraries. Python can be used to build websites, automate tasks, create AI and machine learning applications, analyze data, develop games, improve cyber security, program smart devices (IoT), work in finance, and support education and research. The best way to learn Python is to understand the concepts, practice regularly, and build real-world projects.

Complete Python Setup Guide Vscode + Python


What is Python?

Python is a simple and beginner-friendly programming language used for web development, automation, AI, data science, and software development.

What is VS Code?

VS Code is a free code editor used to write, run, and debug Python programs.

Install Python

- Download Python from the official website. - Install it and enable Add Python to PATH. - Verify using "python --version".

Install VS Code

- Download and install VS Code. - Install the Python extension. - Select the Python interpreter.

Create and Run a Program

Python

print("Hello,World!")

- Create a ".py" file. - Write and save your code. - Run the program and check the output in the Terminal.
If you want to read the full guide on how to install Python and VS Code in detail, with images, click the button below.

Python Print Statement and Comments Explained with Examples

What is a print statement in Python?

A print statement Function is used to show output on the screen. In Python, we write print() with a small letter p, not a capital letter.
Example:

Python

print("Hello,World!")

Output (show in Terminal):

Terminal
Hello,World!

What is a comment in Python?

A comment is used to explain a line of code. In Python, a comment is written using #(hash) at the start of the line, and the shortcut key Ctrl + / can be used to add or remove comments,but comment doesn't show in output
Example:

Python

# print a I Love Python in python ----> is Called as Comments!
print("I Love Python!")
print(2+2)

Output (show in Terminal):

Terminal
I Love Python!
4

Python Variables and Data Types Explained with Examples

What is a Variable in Python?

A variable is a named container used to store data or information in a program. The stored data can be used, changed, or updated whenever the program runs.

What is a Data Types in Python?

A data type defines the type of value that can be stored in a variable.

Example:

Python

student_name="Ali"
roll_number=1
college_name="ABCD"
address="XYZ"
print("Student Name:",student_name)
print("Roll No:",roll_number)
print("College Name:",college_name)
print("Address:",address)

Output (show in Terminal):

Terminal
Student Name:Ali
Roll No:1
College Name:ABCD
Address:XYZ


Python Fundamental (int,float,str,bool) Data types Explained with Examples

What are Data Types?

Data Types define the type of value stored in a variable. Every variable in Python belongs to a specific data type.

Fundamental Data Types

Data Type Description Example
int Stores whole numbers (without decimal). 10, -5, 100
float Stores decimal (floating-point) numbers. 10.5, 99.99, 3.14
str Stores text or a sequence of characters. "Hello", "Python"
bool Stores only two values: True or False. True, False

type() Function

Used to check the data type of a variable.

Python

print(type(variable))

String Quotes

A string can be written using:
Single Quotes ' '
Double Quotes " "
Multiple Quotes ''' '''

Boolean Values

A Boolean stores only two values:
True
False
f-String
Used to print text and variables together.

Python

print(f"My name is {name}")

Python Input & Output – Notes

1. Input & Output



Input is used to receive data from the user, while Output is used to display results on the screen. Python mainly uses input() and print() for Input and Output.

2. print() Function

The print() function is used to display text, numbers, variables, and results on the screen.

Python

print("Hello World")

3. input() Function

The input() function is used to take data from the user. By default, input() returns the entered data as a string.

Python
name = input("Enter your name: ")

4. Type Casting with Input

int() converts input into an integer (whole number), while float() converts input into a decimal number.

Python
age = int(input("Enter age: "))
price = float(input("Enter price: "))

5. Multiple Input

.split() divides one input into multiple values, while map() applies a conversion function to multiple values.

Python

a, b = map(int, input("Enter two numbers: ").split())
print("Sum:", a + b)

6. f-String

An f-string is used to easily display variables inside a string. Variables are written inside { }.

Python
print(f"Name: {name}, Age: {age}")

7. print() Parameters

sep sets the separator between multiple values.

Python
print("Date", "Month", "Year", sep="/")

end controls what is printed after the output.

Python
print("Hello", end=" ")
print("World")

8. Escape Sequences

In Python, \ is the escape character. Common escape sequences are used to perform special actions inside strings.

\n → New line
\t → Tab space
\\ → Backslash
\' → Single quote
\" → Double quote

Python
print("Hello\nWorld")
print("Name:\tHamid")

Comments

Popular posts from this blog

Python Variables and Data Types Explained with Examples

🚀 Welcome to NiceinPythonlearn | 📘 Learn Python with Easy Tutorials, Notes & Practice Questions | 💻 Build Real-World Projects | 💬 Enjoying the content?Share your feedback! | 📝 If you have any questions, suggestions, or face any problems, please contact us using the Contact Form or leave a comment. We will do our best to solve it together. 🤝 | ⭐ Follow us for new updates and keep learning! Introduction Variables and Data Types are the fundamental concepts of Python programming. Variables are used to store data, while Data Types define the kind of data a variable can hold. These concepts form the foundation of every Python program, making code simple, organized, efficient, and easy to understand and maintain. Roman English: Variables data store karte hain, aur Data Types batate hain data kis type ka hai. Ye Python programming ki basic foundation hain. Learning Objectives After completing this topic, you will be able to: Underst...

Python input and output (I/O) Statements Explained with Examples

Introduction Python Input and Output are the foundation of interactive programming. Input allows users to enter information, while output displays results on the screen. By learning these concepts, you can create programs that communicate with users, solve real-world problems, and build applications that respond to user input effectively. Hinglish:Python Input aur Output interactive programming ki foundation hai. Input ka use karke user se information li jaati hai, aur Output ka use karke screen par result dikhaya jaata hai. In concepts ko seekhne ke baad aap aise programs bana sakte ho jo users se communicate karein, real-world problems solve karein, aur user ke input ke hisaab se response dene wale applications develop karein. Learning Objectives After completing this lesson, you will be able to: 1.Understand the concept of Input and Output in Python. 2.Use the input() function to take data from users. 3.Use the print() function to display info...

Python Print Statement and Comments Explained with Examples

1) Print Statement Function in Python A print statement Function is used to show output on the screen. In Python, we write print() with a small letter p, not a capital letter. Roman : Print statement Function screen par output dikhane ke liye use hota hai. Python me print() small letter p se likhte hain, kyunki Python case-sensitive hota hai. Example of Print Statement Function in Python : print("Hello World") Output(show on Terminal): Hello World Another Example of Print Statement Function in Python : print(10) print(2.0) print(True) print(10+5) print(2*5) print(0-0) Output(show on Terminal): 10 2.0 True 15 10 0 2) Comments in Python (Single and Multiples): Single Line Comments using Hash(#) in Python A comment is used to explain a line of code. In Python, a comment is written using #(hash...