Professional Documents
Culture Documents
XI IP Python Fundamentals
XI IP Python Fundamentals
INFORMATICS PRACTICES
PYTHON FUNDAMENTALS
GRADE: XI
INTRODUCTION
Computer actions are governed by the IPO cycle. A program is a
set of instructions that govern the processing.
Letters:A to Z , a to z
Digits:0 to 9
Special symbols:*, < ,@, _ etc
White spaces :tab,newline
Other charcaters :can process all ASCII and Unicode characters as apart of
data or literals
● Keywords
● Identifiers
● Literals
● Punctuators
● Operators
❖ Case sensitive
❖ Unlimited in length
Python allows non graphic characters- those characters that cannot be typed
directly from the keyboard. (\t,\n)
Multiline strings
For eg:
Text='hello\
world'
print(Text)
Output
helloworld
BIRLA PUBLIC SCHOOL, DOHA-QATAR
INFORMATICS PRACTICES
PYTHON FUNDAMENTALS
GRADE: XI
For eg:
print('''hello
everyone ''')
Output
hello
everyone
for eg:
print("""hello
everyone
""")
Output
hello
everyone
Size of strings
‘abc’ :size is 3
Ash\’s birthday : size is 14
For eg:
text="Ash\'s birthday"
print(len(text))
Output
14
Integer literals: 10
BIRLA PUBLIC SCHOOL, DOHA-QATAR
INFORMATICS PRACTICES
PYTHON FUNDAMENTALS
GRADE: XI
Floating point literals:12.5
Boolean literal:True or False
Special Literal:None
It indicates the absence of a value
Output
5
-15
Binary:two operands
Arithmetic Operators
a+b
a-b
a*b
a/b
a%b
a//b(floor division( divides and discards the fractional part )
BIRLA PUBLIC SCHOOL, DOHA-QATAR
INFORMATICS PRACTICES
PYTHON FUNDAMENTALS
GRADE: XI
Relational <,<=,>,>=,!=
a+=10
a-=10
a*=10
a/=10
a%=10
a//=10
a**=10
Logical operators
Logical AND
Logical OR
a=10
b=15
if a is b:
print("yes")
else:
print("no")
For eg:
a=[10,20,30]
if 30 not in a:
print("yes")
else:
print("no")
BIRLA PUBLIC SCHOOL, DOHA-QATAR
INFORMATICS PRACTICES
PYTHON FUNDAMENTALS
GRADE: XI
Barebones of a program
Single line
'''
Text here
'''
Mutiline
"""
Text here
"""
⮚ Function is a code that has a name and that it can be reused (executed
again ) by specifying its name in the program where needed
def add(a,b):
c=a+b
print(c)
a=6
b=2
add(a,b)
For eg:
Sum=a+b
BIRLA PUBLIC SCHOOL, DOHA-QATAR
INFORMATICS PRACTICES
PYTHON FUNDAMENTALS
GRADE: XI
Creating a variable
Marks=70
Name=’Jake’
Multiple assignments
For eg:
a,b,c=10,4,5
print(a,b,c)
Output:
10 4 5
Dynamic typing:
A variable pointing to a value of a certain type can be made point to a value /
object of different type.
For eg:
a=10
print(type(a))
print(id(a))
a="hello"
print(type(a))
print(id(a))
syntax:
<variablename>=int(input(<prompt string>))
Reading numbers
print () – without any value or name or expression prints a blank line
Example
Output