0% found this document useful (0 votes)
14 views14 pages

Understanding Python Program Structure

Uploaded by

6hg9fx4wqm
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)
14 views14 pages

Understanding Python Program Structure

Uploaded by

6hg9fx4wqm
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

PYTHON PROGRAM STRUCTURE

• A python program is a collection of instructions written in the python


programming language. These instructions tell the computer what to do.
Just like a recipe tells you how to make a cake, a python program tells the
computer how to perform a task.
• Example:
• Here’s a simple python that prints “Hello,world!”:
• # python 3
• Print (“Hello , world ! “)
.EXPLANATION:

• Print is a built-in function in python that is used to


display output on the screen.
• “Hello, world!” Is a string, which is a sequence of
characters enclosed in quotation marks.
BASIC STRUCTURE OF
PYTHON PROGRAM
A PYTHON PROGRAM TYPICALLY CONSISTS OF THE FOLLOWING ELEMENTS

• Comments: These are lines of text that are ignored by


the computer. they are used to explain what the codes
does.
• Variables: Variables are used to store data .they can
hold numbers, text, or other types of data.
• Indentation: Indentation is very important in python. It
is used to define blocks of code. All statements within a
block must have the same indentation level.
HERE ARE THE EXPLANATION OF BASIC
STRUCTURE OF PYTHON

• COMMENTS: Comments are used to explain what the code does. They are ignored
by the computer. They are two types of comments in python:
• Single-line comments: start with a # symbol.
• Multi-line comments: Enclosed between triple quotes(‘’’)
• Example: # This is a single-line comment
• ‘’’
• This is a multi-line comment.
• ‘’’
.VARIABLE
S
• Variables are used to store data. They can hold numbers, text,
or other types of data. Create a variable, you need to give it a
name and assign a value to it. In python variables are
dynamically typed, meaning they hold different types of data.
• Example:
• X=5
• name = ‘Ayzal’
INDENTATION

• Indentation is very important in python. It is used to


define blocks of code. All statements within a block
must have the same indentation level.
• Example:
• If 5 > 2:
• Print (“Five is greater than two! “)
CONSTANTS/LITERALS

• Constants literals are values that are directly specified in


your python code. They can be of different data types, such
as numbers, strings, and booleans. These constants are
fixed, immutable values that remain unchanged throughout
the program. They Play A crucial role in defining Data that
doesn’t require computation or manipulation, ensuring
consistency and reliability.
• NUMBERS:
• Integers: These are whole numbers without decimal points.
For example: 10, -5.
• Floating-point numbers: These are numbers with decimal
points. For example: 3.14, -2.5, 1.0e6.
• Complex numbers: These are number with a real and
imaginary part. For example: 2+3j
• STRINGS:
• Strings are sequence of character enclosed in
STRINGS
• Strings are sequences of characters enclosed in quotation marks. You
can use either single quotes (‘) or double quotes (“) (“ ‘ “ ‘ or “”” ) to
define strings.
• Example:
• Name = “Ayzal”
• Messages = ‘ Hello , world ! ‘
• # Used to enclose multi-line strings .
• String 1= ‘ ‘ ‘ Hello , world ! ‘’’
.Booleans
• Booleans represent truth values. They can be either True or False.
• Example:
• Is_raining = True
• Is_sunny = False
DATA TYPES
. Data types in python define ( Figure 3.1) the kind of value a
variable can hold. Python has several built-in data types:
Numbers: int float, complex
String: str
Booleans: bool
Lists: list
Tuples: tuple
Dictionaries: dict
Sets: set
SPECIAL
LITERALS
• Special Literals: Special literals are unique values that
represent specific meanings in a programming language. The
most common special literals.
• Examples:
• X= 5 >>> Y
• Y= none none
• >>>x
•5
• MADE BY:
• PANKAJ
• ABHISHEK BHARDWAJ

• THANKS FOR WATCHING


• Submitted
• To Richa Mam

You might also like