Chapter 6
Python Fundamentals
Input in Python
• input() function is used to take input in Python. By default, the value is treated as a text value.
• We can use int() to convert it to an integer, float() to convert it to a floating point number or
complex() to convert it to a complex number.
Output in Python
• print() function is used to display the output in Python.
print('Good Morning')
print('First line\nSecond line\nThird line')
print("St. Stephen's Senior Secondary School")
print('St. Stephen\'s Senior Secondary School')
Escape Sequences - They are special characters which can be used in a print statement.
\n new line \t Tab (horizontal)
\' ' \" " \\ \
Expression - A legal combination of operators and operands.
c=a+b av=(a+b+c)/3 i=p*r*t/100
Statement - An executable line of coding is known as a statement.
print('Hello')
a=int(input('Enter a number '))
c=a*a*a
Variable - They are named memory locations whose values can be manipulated during program
[Link]: a=10 marks=70
Dynamic Typing
A variable is defined by assigning a value to it.
For example x=10 defines a variable which refers to a value of int type.
Later, if we reassign a value of some other type to it, no error is raised. x="Python".
In Python, a variable is treated like a label associated with objects(stored in memory). A variable pointing to
a value of a certain type can be made to point to a value of different type.
This is called Dynamic Typing.
Comments - They are non-executable statements given in the program for explanatory [Link]
provides two types of comments:
• Single line comments– Creating by putting a # sign and then typing the comment.
• Multiple line comments – The lines are to be enclosed within triple quotes. (''')
Blocks and Indentation - A block is a group of statements that is a part of another statement or function.
Blocks are represented through indentation.
if s=='science':
print('Physics')
print('Chemistry')
print('Maths/Bio/[Link].')