PPT-2 - Copy
PPT-2 - Copy
”””
Write a program to find the total marks scored by a
student in the subjects
”””
’’’
Write a program to find the total marks scored by a
student in the subjects
’’’
Comments in Python
➢ Python supports only single line comments.
➢ Multiline comments are not available in Python.
➢ Triple double quotes or triple single quotes are actually not multiline
comments but they are regular strings with the exception that they can
span multiple lines.
➢ Use of ’’’ or ””” are not recommended for comments as they internally
occupy memory.
Variables in Python
➢ In many languages, the concept of variable is
connected to memory location.
➢ In python, a variable is seen as a tag
that is tied to some value.
➢ Variable names in Python can be any length.
➢ It can consist of uppercase and lowercase letters (A-Z,
➢ a-z), digits (0-9), and the underscore character (_).
➢ A restriction is that, a variable name can contain digits, the first
character of a variable name cannot be a digit.
Datatypes in Python
➢ A datatype represents the type of data stored into a variable or
memory.
➢ The datatypes which are already avaiablein Python
language are called Built-in datatypes
➢ The datatypes which are created by the programmers are called User-
Defined datatypes.
Built-in Datatypes
➢ None Type
➢ Numeric Types
➢ Sequences
➢ Sets
➢ Mappings
None Type
➢ ‘None’ datatype represents an object that does not contain
➢ any value.
➢ In Java, it is called ‘Null’ Object’, but in Python it is called ‘None’ object.
➢ In Python program, maximum of only one ‘None’ object is
➢ provided.
➢ ‘None’ type is used inside a function as a default value of the
arguments.
➢ When calling the function, if no value is passed, then the
➢ default value will be taken as ‘None’.
➢ In Boolean expressions, ‘None’ datatype is represents ‘False’
Numeric Type
➢ int
➢ float
➢ complex
Int DataType
➢ The int datatype represents an integer number.
➢ An integer number is a number without any decimal
point or fraction part.
➢ int datatype supports both negative and positive integer numbers.
➢ It can store very large integer numbers conveniently.
a = 10
b = -15
Float DataType
➢ The float datatype represents floating point numbers.
➢ A floating point number is a number that contains a decimal point.
x = 22.55e3
#here the float value is 22.55 x 103
Bool DataType
➢ The bool datatype in Python represents
➢ boolean values.
➢ There are only two boolean values True or False that can be represented
by this datatype.
➢ Python internally represents True as 1 and
➢ False as 0.
Bool DataType
➢ The bool datatype in Python represents
➢ boolean values.
➢ There are only two boolean values True or False that can be represented
by this datatype.
➢ Python internally represents True as 1 and
➢ False as 0.
Print Statement
>>> print 25
25
>>> print 2 + 5 + 9
16
Print Statement