Escolar Documentos
Profissional Documentos
Cultura Documentos
Informatics
Practices
Class XI ( As per Computer
CBSE Board) System
Overview
New
Syllabus
2018-19
Data vs Information
Data are raw numbers or other findings which, by themselves, are
of limited value.
Information is data that has been converted into a meaningful and
useful context.
A hard disk is a set of stacked disks. Each disk has data recorded
electromagnetically in concentric circles, or tracks, on the disk
Hard Drive Types
1. Parallel Advanced Technology Attachment (PATA)
2. Serial ATA (SATA)
3. Small Computer System Interface (SCSI)
4. Solid State Drives (SSD)
2. IPS (In-Place Switching) LCDs are somewhat the advanced version of TFT LCDs in
a way that they offer improved displays and are more battery friendly. Hence, they are
found in high end phones.
4.OLED (Organic Light Emitting Diode) is a newer technology used in mobiles and
monitors for display. They are better than LCDs because they offer fast response
times, wider viewing angles and higher brightness. AMOLED (Active-Matrix Organic
Light-Emitting Diode) and SUPER AMOLED displays are types of OLED display.
OLED types include passive-matrix OLEDs, active-matrix LEDs and transparent OLEDs
Lithium ion batteries are advanced and allow for a high charge capacity based on the size
and weight of the battery. However, these these are slightly expensive. these lithium ion
batteries will not remember the charge cycle, and as a result, the battery capacity will not be
reduced.
Nickel Cadmium These are the cells that suffer from memory effect. And, the memory
effect will result in reducing the capacity of the battery and its lifespan as well.
Nickel Metal Hydride batteries are kind of an upgrade to the Nickel Cadmium batteries,
and they boast of the same size as the latter. Nickel Metal Hydride batteries offer 30 to 40
percent more battery juice than the others
Informatics
Practices Getting
Class XI ( As per
CBSE Board)
Started
With
Python
It is used for:
software development,
web development (server-side),
system scripting,
Mathematics.
4. A new Python <version> Setup pop-up window will appear with a Setup
Progress message and a progress bar.
5. Soon, a new Python <version> Setup pop-up window will appear with
a Setup was successfully message
Informatics
Practices
Class XI ( As per
Python
CBSE Board)
Fundamentals
as finally or
continue if return
del in while
elif is with
except
\\ Backslash (\)
Types of Operators
1. Arithmetic Operators.
2. Relational Operators.
3. Assignment Operators.
4. Logical Operators.
5. Bitwise Operators
6. Membership Operators
7. Identity Operators
= Assigns values from right side operands to left side operand a=b
//= Perform floor division on 2 numbers and assigns the result to left operand. a//=b
**= calculate power on operators and assigns the result to left operand. a**=b
a=30
b=20
if(a==30 and b==20):
print('hello')
Output :-
hello
not in return true if value does not exists in the sequence, else false. a not in list
E.g.
a = 22
list = [22,99,27,31]
In_Ans = a in list
NotIn_Ans = a not in list
print(In_Ans)
print(NotIn_Ans)
Output :-
True
False
Visit : python.mykvs.in for regular updates
Operators continue
7. Identity Operators
Identity operators in Python compare the memory locations of two objects.
Operators Description Example
is returns true if two variables point the same object, else false a is b
is not returns true if two variables point the different object, else false a is not b
e.g.
a = 34
b=34
if (a is b):
print('both a and b has same identity')
else:
print('a and b has different identity')
b=99
if (a is b):
print('both a and b has same identity')
else:
print('a and b has different identity')
Output :-
both a and b has same identity
a and b has different identity
Visit : python.mykvs.in for regular updates
Punctuators
Used to implement the grammatical and structure of a Syntax.Following
are the python punctuators.
fun()
print(x) #error will be shown
2. Global Variable
x=8
def fun():
print(x) # Calling variable ‘x’ inside fun()
fun()
print(x) # Calling variable ‘x’ outside fun()
print('hello India')
Output :-
hello India
print(‘Computer',‘Science')
print(‘Computer',‘Science',sep=' & ')
print(‘Computer',‘Science',sep=' & ',end='.')
Output :-
Computer Science
Computer & Science
Computer & Science.
Informatics
Practices
Class XI ( As per Data
CBSE Board)
Handling
Data Types
Data Type specifies which type of value a variable can
store. type() function is used to determine a variable's
type in Python.
1. Number In Python
It is used to store numeric values
a= 100
b= -100
c= 1*20
print(a)
print(b)
print(c)
Output :-
100
-100
200
Visit : python.mykvs.in for regular updates
Data type continue
Type Conversion of Integer
int() function converts any data type to integer.
e.g.
a = "101" # string
b=int(a) # converts string data type to integer.
c=int(122.4) # converts float data type to
integer.
print(b)
print(c)Run Code
Output :-
101
122
Visit : python.mykvs.in for regular updates
Data type continue
2. Floating point numbers
It is a positive or negative real numbers
with a decimal point.
e.g.
a = 101.2
b = -101.4
c = 111.23
d = 2.3*3
print(a)
print(b)
print(c)
print(d)Run Code
Output :-
101.2
-101.4
111.23
6.8999999999999995
Output :-
301.4
121.0
Output :-
(5+0j)
(101+23j)
Output
str- computer science
str[0]- c
str[1:3]- om
str[3:]- puter science
str *2- computer sciencecomputer science
str +'yes'- computer scienceyes
e.g.
str='comp sc'
for i in str:
print(i)
Output
c
o
m
p
s
c
Output
False
OUTPUT
55
9
Output
{33, 11, 22}
Output
{'Subject': 'comp sc', 'class': '11'}
Subject : comp sc
class : 11
** Exponent - left operand raised to the power of right x**y (x to the power y)
OUTPUT
('x + y =', 9)
('x - y =', 1)
('x * y =', 20) • Write a program in python to calculate the
('x / y =', 1) simple interest based on entered amount ,rate
('x // y =', 1) and time
('x ** y =', 625)
# driver code
principal = 10000;
rate = 10;
time = 2;
emi = emi_calculator(principal, rate, time);
print("Monthly EMI is= ", emi)
> Greater that - True if left operand is greater than the right x>y
< Less that - True if left operand is less than the right x<y
Output
('x > y is', False)
('x < y is', True)
('x == y is', False)
('x != y is', True)
('x >= y is', False)
('x <= y is', True)
Outpur
('x and y is', False)
('x or y is', True)
('not x is', False)
e.g.
a=5
b = 10
list = [1, 2, 3, 4, 5 ]
if ( a in list ):
print ("Line 1 - a is available in the given list")
else:
print ("Line 1 - a is not available in the given list")
if ( b not in list ):
print ("Line 2 - b is not available in the given list")
else:
print ("Line 2 - b is available in the given list")
output
Line 1 - a is available in the given list
Line 2 - b is not available in the given list
e.g.
a = 10
b = 10
print ('Line 1','a=',a,':',id(a), 'b=',b,':',id(b))
if ( a is b ):
print ("Line 2 - a and b have same identity")
else:
print ("Line 2 - a and b do not have same identity")
OUTPUT
('Line 1', 'a=', 10, ':', 20839436, 'b=', 10, ':', 20839436)
Line 2 - a and b have same identity
OUTPUT
('Data type of num_int:', <type 'int'>)
('Data type of num_str before Type Casting:', <type 'str'>)
('Data type of num_str after Type Casting:', <type 'int'>)
('Sum of num_int and num_str:', 57)
('Data type of the sum:', <type 'int'>)
floor(n) It returns the largest integer less than or equal to n math.floor(4.2) returns 4
Informatics
practices
Conditional
Class XI ( As per
CBSE Board)
&
Looping
Constructs
Output :-
condition matcing the criteria
-----------------------------------------------------------
a=100
if not(a == 20):
print('a is not equal to 20')
Output :-
a is not equal to 20
OUTPUT
less than 100
1. While Loop
2. For Loop
x=1
while (x < 3):
print('inside while loop value of x is ',x)
x=x+1
else:
print('inside else value of x is ', x)
Output
inside while loop value of x is 1
inside while loop value of x is 2
inside else value of x is 5
Output
Inside loop
Inside loop
…
…
e.g.
for i in range(3,5):
print(i)
Output
3
4
Output
5
4
range() Function Parameters
start: Starting number of the sequence.
stop: Generate numbers up to, but not including this number.
step(Optional): Determines the increment between each numbers
in the sequence.
Output
1
2
3
4
No Break
Output
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
print("The end")
Output
s
t
r
The end
Visit : python.mykvs.in for regular updates
Iteration Statements (Loops)
2.continue
It is used to skip all the remaining statements in
the loop and move controls back to the top of the loop.
e.g.
for val in "init":
if val == "i":
continue
print(val)
print("The end")
Output
n
t
The end
OUTPUT
My program
OUTPUT
n
t
a
L
NOTE : continue forces the loop to start at the next
iteration while pass means "there is no code to execute
here" and will continue through the remainder or the loop
body.
Visit : python.mykvs.in for regular updates
Chapter 6 :
Informatics
Practices
Class XI ( As per List
CBSE Board) Manipulation
Indexing of list
e.g.
list =[3,5,9]
for i in range(0, len(list)):
print(list[i])
Output
3
5
9
e.g.
list =['I','N','D','I','A']
print(list[0:3])
print(list[3:])
print(list[:])
Output
['I', 'N', 'D']
['I', 'A']
['I', 'N', 'D', 'I', 'A']
e.g.
list=[1,2]
print('list before append', list)
list.append(3)
print('list after append', list)
Output
('list before append', [1, 2])
('list after append', [1, 2, 3])
e.g.
list=[1,2]
print('list before append', list)
list.append(3)
print('list after append', list)
Output
('list before append', [1, 2])
('list after append', [1, 2, 3])
OUTPUT
[1,2,3,4]
Output
e.g.
del list[0:2] # delete first two items
del list # delete entire list
Visit : python.mykvs.in for regular updates
List Manipulation
Basic List Operations
return max
print(max_num_in_list([1, 2, -8, 0]))
Visit : python.mykvs.in for regular updates
List Manipulation
Some Programs on List
* find the mean of a list
def Average(lst):
return sum(lst) / len(lst)
# Driver Code
lst = [15, 9, 55, 41, 35, 20, 62, 49]
average = Average(lst)
Output
Average of the list = 35.75
Note : The inbuilt function mean() can be used to calculate the mean(
average ) of the list.e.g. mean(list)
found = False
for i in range(len(list_of_elements)):
if(list_of_elements[i] == x):
found = True
print("%d found at %dth position"%(x,i))
break
if(found == False):
print("%d is not in list"%x)
OUTPUT
Original List : [101, 101,101, 101, 201, 201, 201, 201]
Frequency of the elements in the List : Counter({101: 4, 201:4})
Informatics
Practices
Class XI ( As per
CBSE Board) Dictionary
OUTPUT
{'Class': '11', 'Subject': 'Informatics Practices'}
('Subject : ', 'Informatics Practices')
('Class : ', 11)
Visit : python.mykvs.in for regular updates
Dictionary
Iterating Through A Dictionary
Following example will show how dictionary items can be
accessed through loop.
e.g.
dict = {'Subject': 'Informatics Practices', 'Class': 11}
for i in dict:
print(dict[i])
OUTPUT
11
Informatics Practices
Output
('before del', {'Class': 11, 'Subject': 'Informatics Practices'})
('after item delete', {'Subject': 'Informatics Practices'})
('after dictionary delete', <type 'dict'>)
Output
('before del', {'Class': 11, 'Subject': 'Informatics Practices'})
('after item delete', {'Subject': 'Informatics Practices'})
('after clear', {})
Questions.
1. Create dictionary to store 4 student
details with rollno,name,age field.Search
student in list.
2. Create dictionary for month and
noofdays for a year. User is asked to
enter month name and system will show
no of days of that month.
Informatics
Practices
Class XI ( As per
CBSE Board) Text
Handling
str='Computer Sciene'
('str-', 'Computer Sciene')
print('str-', str) ('str[0]-', 'C')
print('str[0]-', str[0]) ('str[1:4]-', 'omp')
print('str[1:4]-', str[1:4]) ('str[2:]-', 'mputer Sciene')
print('str[2:]-', str[2:]) ('str *2-', 'Computer ScieneComputer
print('str *2-', str *2 ) OUTPUT Sciene')
print("str +'yes'-", str +'yes') ("str +'yes'-", 'Computer Scieneyes')
C
e.g. o
m
p
u
str='Computer Sciene‘ OUTPUT t
for i in str: e
print(i) r
S
c
i
e
n
e
OUTPUT
('Updated String :- ', 'Comp Sc with Python')
e.g.
Str1 = “””This course will introduce the learner to text
mining and text manipulation basics. The course
begins with an understanding of how text is handled by
python”””
Method Result
str.capitalize() To capitalize the string
str.find(sub) To find the substring position
String consists of only alphanumeric characters (no
str.isalnum()
symbols)
str.isalpha() String consists of only alphabetic characters (no symbols)
str.islower() String’s alphabetic characters are all lower case
str.isnumeric() String consists of only numeric characters
str.isspace() String consists of only whitespace characters
str.istitle() String is in title case
str.isupper() String’s alphabetic characters are all upper case
str.lstrip(char) Returns a copy of the string with leading/trailing
str.rstrip(char) characters
string=raw_input("Enter string:")
count1=0
count2=0
for i in string:
if(i.isdigit()):
count1=count1+1
count2=count2+1
print("The number of digits is:")
print(count1)
print("The number of characters is:")
print(count2)
Output
str.count(sub, 4, 40) : 2
Informatics
Practices
Class XI ( As per
Python
CBSE Board)
Modules
e.g.
1. Create file a.py with following code
student = {
"name": "Vijay Shanti",
"age": 36,
"country": "India"
}
2. Save it
3. Create b.py with following code
import a
s = a.person1["age"]
print(s)
4. Run it
e.g.
Informatics
Practices
Class XI ( As per
Python
CBSE Board)
Pandas
1. Array
2. Dict
3. Scalar value or constant
e.g.
Output
Series([], dtype: float64)
Output Output
0 a 100 a
1 b 101 b
2 c 102 c
3 d 103 d
dtype: object dtype: object
Note : default index is starting
from 0 Note : index is starting from 100
Output Output
a 0.0 b 1.0
b 1.0 c 2.0
c 2.0 d NaN
dtype: float64 a 0.0
dtype: float64
Output
0 5
1 5
2 5
3 5
dtype: int64
Note :- here 5 is repeated for 4 times (as per no of index)
Visit : python.mykvs.in for regular updates
Python Pandas
Pandas Series
Accessing Data from Series with Position
e.g.
import pandas as pd1
s = pd1.Series([1,2,3,4,5],index = ['a','b','c','d','e'])
print (s[0])# for 0 index position
print (s[:3]) #for first 3 index values
print (s[-3:]) #for last 3 index values
Output
1
a 1
b 2
c 3
dtype: int64
c 3
d 4
e 5
dtype: int64
Output
c 3
d 4
dtype: int64
Output
a 1
b 2
c 3
dtype: int64
Return first 3 elements
Output
c 3
d 4
e 5
dtype: int64
Return last 3 elements
Rows
e.g.2
import pandas as pd1
data1 = [['Freya',10],['Mohak',12],['Dwivedi',13]]
Name Age
df1 = pd1.DataFrame(data1,columns=['Name','Age'])
0 Freya 10
print (df1) output 1 Mohak 12
2 Dwivedi 13
Output
Name Age
0 Freya 9
1 Mohak 10
Output
x y z
0 1 2 NaN
1 5 4 5.0
Output
one 2.0
two 2.0
Name: b, dtype: float64
Output
one 3.0
two 3.0
Name: c, dtype: float64
df1 = df1.append(df2)
print (df1)
Deletion of Rows
# Drop rows with label 0
df1 = df1.drop(0)
Output
freya 10
mohak 1
Output
freya 10
mohak 1
Output
0 1 2
0 1 4 7
1 4 10 16
2 9 18 27
Output
0 1 2
0 2 8 14
1 4 10 16
2 6 12 18
Note :- similarly we can use sub,mul,div functions
Visit : python.mykvs.in for regular updates
Python Pandas
Pandas DataFrame
Output
add 88 1
radd 99 1
add 88 <__main__.Commuter object at 0x02181370>
Output
add 88 1
radd 99 1
add 88 <__main__.Commuter object at 0x02181370>
OUTPUT
name age
0 freya 10
Output
Greater than:
0 True
1 True
2 True
3 True
4 False
dtype: bool
Visit : python.mykvs.in for regular updates
Python Pandas
Pandas DataFrame
Merging/combining dataframe
e.g.
import pandas as pd
left = pd.DataFrame({
'id':[1,2],
'Name': ['anil', 'vishal'],
'subject_id':['sub1','sub2']})
right = pd.DataFrame(
{'id':[1,2],
'Name': ['sumer', 'salil'],
'subject_id':['sub2','sub4']})
print (pd.merge(left,right,on='id'))
Output
id Name_x subject_id_x Name_y subject_id_y
0 1 anil sub1 sumer sub2
1 2 vishal sub2 salil sub4
Visit : python.mykvs.in for regular updates
Python Pandas
Pandas DataFrame
Merging/combining dataframe(different styles)
Informatics
Practices
Data Transfer
Class XI ( As per
CBSE Board)
between CSV
files/SQL DB
& DataFrame
E.g.
import pandas as pd
raw_data = {'name': ['freya', 'Mohak', 'Dwivedi'],
'age': [9, 2, 36]}
df = pd.DataFrame(raw_data, columns = ['name','age'])
df.to_csv('d:\\myfirstcsvfile.csv')
E.g.
import pandas as pd
df = pd.read_csv('d:\myfirstcsvfile.csv')
print(df)
Mysql
SQLite
SQL Server
Etc.
First of all we must have created database and table in mysql and
posses following.
• Username
• Password
• Server name(path)/localhost
• Database name
• Table name
Now create a python program like a.py and save with following code.
import pandas as pd
from sqlalchemy import create_engine
cnx = create_engine('mysql+pymysql://root:root@localhost:3306/bank').connect()
sql = 'select * from bmaster'
df = pd.read_sql(sql, cnx)
print(df)
tablename
The downloaded file is in the ZIP format and its size is quite small
Informatics
Practices
Class XI ( As per Relational
CBSE Board) Database
New
Concepts
Syllabus
2018-19
Informatics
Practices
Class XI ( As per
CBSE Board)
SQL
Commands
New
Syllabus
2018-19
Informatics
Practices
Class XI ( As per Cyber
CBSE Board) Safety
New
Syllabus
2018-19
Secure Connections
A secure connection refers to the connection which is encrypted by one
or more security protocols for security of data flowing between two or
more nodes. When it is not encrypted, it can be easily listened by
anyone with the knowledge on how to do it.
How it works
TLS uses a combination of symmetric and asymmetric cryptography
both for better security.With symmetric cryptography, data is encrypted
and decrypted with a secret key known to both sender and recipient;
typically 128 but preferably 256 bits in length (anything less than 80
bits is now considered insecure). Symmetric cryptography uses a
common secret key ,which is shared a secure manner.
Asymmetric cryptography uses 2 keys – a public key, and a private key.
The public key of the recipient to be used by the sender to encrypt the
data they wish to send to them, but that data can only be decrypted
with the private key of the recipient.