0% found this document useful (0 votes)
2 views

Syntax & Fundamental Data Types in Python - 2 Updated

The document outlines the basic syntax and fundamental data types in Python, including integers, floats, strings, and booleans. It covers essential syntax rules such as comments, indentation, variable declaration, and the use of keywords. Additionally, it includes pre-assessment questions, tasks for writing Python programs, and a reflection on syntax examples.

Uploaded by

noormuneer.malik
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 views

Syntax & Fundamental Data Types in Python - 2 Updated

The document outlines the basic syntax and fundamental data types in Python, including integers, floats, strings, and booleans. It covers essential syntax rules such as comments, indentation, variable declaration, and the use of keywords. Additionally, it includes pre-assessment questions, tasks for writing Python programs, and a reflection on syntax examples.

Uploaded by

noormuneer.malik
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
You are on page 1/ 14

Syntax &

Fundamenta
l data types
in python
M Shajitha Begum
Learning Objectives: Learning Outcomes:
1. Demonstrate
1. Basic syntax
knowledge of Python's
understanding
basic syntax rules.
2. Commenting mastery
2. Understand and use
fundamental data types 3. Variable declaration
such as integers, floats, 4. Statement formation
strings, and Boolean.
5. Data types
implementation
Big Question
 In what scenarios would you choose to use
integers over floats or vice versa?
Pre Assessment
1. Which data type is suitable for representing numbers with
decimal points in Python?
a) Integer b) Float
2. How is a string enclosed in Python?
a) (“ “ ) b) " " c) ' ‘ d) [ ]
3. What happens if you try to use a Python keyword as a variable
name?
a) No effect, python allows it. b) A syntax error occurs
Pre Assessment
1. Which data type is suitable for representing numbers with
decimal points in Python?
a) Integer b) Float
2. How is a string enclosed in Python?
a) ( ) b) " " c) ' ‘ d) [ ]
3. What happens if you try to use a Python keyword as a variable
name?
a) No effect, python allows it. b) A syntax error occurs
Syntax in python
Syntax in python
1. Comments:
Use the # symbol for single-line comments.
Employ triple quotes (''' or """) for multi-line comments.

2. Indentation:

Python uses indentation to define blocks of code.


Use consistent indentation (usually four spaces or a tab) for code within the same block.

3. Statements and Lines:

Each statement is typically written on a separate line.


Use a backslash (\) to continue a statement onto the next line.

4. Variables:

Variables are created by assigning a value to a name.


Variable names should be descriptive and follow the rules for identifiers.
Syntax in python
5. Keywords:

Avoid using Python keywords as variable names.

6. Data Types:

Python supports various data types, including integers, floats, strings, booleans, lists, and more.
Variables should be assigned values of the appropriate data type.

7. Quotation Marks:

Strings can be defined using either single (') or double (") quotation marks.

8. Colon (:) for Blocks:

Use a colon to indicate the beginning of a new block of code (e.g., in if statements, loops, and function
definitions).
Reflection
Identify the given examples of which
syntax.
TASKS

Write a python program to


Add suitable comments input user’s name, age,
for the following program. height and weight with
num = int(input("Enter a
appropriate variable names
number: ") and comments.
if num> 0:
print("Number is positive") Write the comments for the following
elif number < 0: program & Identify the keywords and
print("Number is negative") highlight them.
else: print("Number is zero")
num = int(input("Enter a number: ")
if num> 0:
print("Number is positive")
elif number < 0:
print("Number is negative")
else: print("Number is zero")
Extended task

WRITE A PYTHON PROGRAM TO FIND L.C.M OF


TWO NUMBERS
Plenary
 Describe the rules for naming variables in
Python. Why are these rules important?

You might also like