0% found this document useful (0 votes)
2 views20 pages

Python Basics for C-DAC Internship

Uploaded by

chirag607
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views20 pages

Python Basics for C-DAC Internship

Uploaded by

chirag607
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

C-DAC COMPUTER

(GOVT. OF INDIA)
Internship Program (19-06-2025 to 03-07-2025)

WELCOME UPL STUDENTS


What is Python?
Python is a popular programming language. It
was created by Guido van Rossum, and
released in 1991.
It is used for:
web development (server-side),
software development,
mathematics,
system scripting.
What can Python do?
Python can be used on a server to create web
applications.
Python can be used alongside software to
create workflows.
Python can connect to database systems. It
can also read and modify files.
Python can be used to handle big data and
perform complex mathematics.
Python can be used for rapid prototyping, or
for production-ready software development.
Why Python?
Python works on different platforms (Windows,
Mac, Linux, Raspberry Pi, etc.).
Python has a simple syntax similar to the English
language.
Python has syntax that allows developers to write
programs with fewer lines than some other
programming languages.
Python runs on an interpreter system, meaning
that code can be executed as soon as it is written.
This means that prototyping can be very quick.
Python can be treated in a procedural way, an
object-oriented way or a functional way.
Python Syntax
Basic Programs :-
print("Hello, World!")
OUT-PUT :-
Hello, World!
Python Comments

1. Single-line Comments

2. Multi-line Comments
Python Comments
1. Single-line Comments

Start with a hash symbol (#).


Everything after # on that line is ignored by the Python interpreter.

2. Multi-line Comments

Python doesn't have a specific syntax for multi-line comments like some other languages
(e.g., /* ... */ in C/C++).
But you can use multiple single-line comments, or multi-line strings (usually with triple quotes)
that aren't assigned to any variable.
Best Practices

• x = 10 # Set x to 10 # ❌ Unhelpful
• x = 10 # Initial balance in dollars # ✅ Helpful
Python Variable

• Introduction
In Python, a variable is a name that refers to a value stored in
memory. You can use variables to store data like numbers, text,
and more.
How to Declare a Variable

Syntax :-
variable_name = value
Best Practices

x=5
name = "Alice“
price = 10.99
Rules for Naming Variables

•Must start with a letter (a–z, A–Z) or an underscore


(_)
•Cannot start with a number
•Can include numbers, letters, and underscores
•Case-sensitive (age and Age are different)
Valid AND Invalid VARIABLES
✅ Valid: ❌ Invalid:

• my_var = 10 • 1name = "error“


• _name = "John“ • my-var = 5
• price1 = 100
Common Data Types in Variables

• Int
• Float
• Str
• Bool
• List
• dict
Example
x = 10
pi = 3.14
name = "Alice"
is_active = True
nums = [1, 2, 3]
person = {"name": "Tom", "age": 30}
Changing Values

You can reassign a variable to a


different value or type:
x = 10x = "Now I'm a string"
Printing Variables

name = "Alice“
print(name) # Output:
Alice
Python - Variable Names

A variable can have a short name (like x and y) or a more descriptive name (age, car name, total
volume).

Rules for Python variables:


 A variable name must start with a letter or the underscore character
 A variable name cannot start with a number
 A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
 Variable names are case-sensitive (age, Age and AGE are three different variables)
A variable name cannot be any of the Python keywords.
Assign Multiple Values

In Python – Declaring Multiple Variables


We can declare multiple variables in one line:
a = 10b = 20c = 30
Or:
a, b, c = 10, 20, 30
Same value to all:
x = y = z = 100

You might also like