CBSE CS and IP

CBSE Class 11 & 12 Computer Science and Informatics Practices Python Materials, Video Lecture

Showing posts with label Class 12 CS. Show all posts
Showing posts with label Class 12 CS. Show all posts

CLASS 12 CS (1 MARK QUESTIONS)


CBSE Class 12 Computer Science (CS) 1 Marks Board Questions

TOPICS

ACCORDING TO THE SYLLABUS 2020-21

Unit I: Computational Thinking and Programming

  1. Evolution of Networking
  2. Data Communication Terminologies
  3. Transmission Media
  4. Network Devices
  5. Network Topologies and Types
  6. Network Protocols
  7. Mobile Telecommunication Technologies
  8. Network Security Concepts
  9. Introduction to Web Services
  10. E-commerce Payment Transactions

Unit III: Database Management

CLASS 12 CS (2 MARKS QUESTIONS)

CBSE CLASS 12 CS (2 MARKS QUESTIONS)

TOPICS

ACCORDING TO THE SYLLABUS 2020-21

Unit I: Computational Thinking and Programming

  1. Evolution of Networking
  2. Data Communication Terminologies
  3. Transmission Media
  4. Network Devices
  5. Network Topologies and Types
  6. Network Protocols
  7. Mobile Telecommunication Technologies
  8. Network Security Concepts
  9. Introduction to Web Services
  10. E-commerce Payment Transactions

Unit III: Database Management

CLASS 12 CS (4 MARKS QUESTIONS)

CBSE Class 12 Computer Science (CS) 4 Marks Board Questions

TOPICS

ACCORDING TO THE SYLLABUS 2020-21

Unit I: Computational Thinking and Programming

  1. Revision of basics of Python
  2. Functions
  3. File Handling
  4. Using Python Libraries
  5. Recursion
  6. Idea of Efficiency
  7. Data-Structures

Unit II: Computer Networks

  1. Evolution of Networking
  2. Data Communication Terminologies
  3. Transmission Media
  4. Network Devices
  5. Network Topologies and Types
  6. Network Protocols
  7. Mobile Telecommunication Technologies
  8. Network Security Concepts
  9. Introduction to Web Services
  10. E-commerce Payment Transactions

Unit III: Database Management

CLASS 12 CS (3 MARKS QUESTIONS)

TOPICS

ACCORDING TO THE SYLLABUS 2020-21

Unit I: Computational Thinking and Programming

  1. Evolution of Networking
  2. Data Communication Terminologies
  3. Transmission Media
  4. Network Devices
  5. Network Topologies and Types
  6. Network Protocols
  7. Mobile Telecommunication Technologies
  8. Network Security Concepts
  9. Introduction to Web Services
  10. E-commerce Payment Transactions

Unit III: Database Management

PYTHON MODULES, PACKAGES, LIBRARIES & FRAMEWORK


PYTHON MODULES, PACKAGES, LIBRARIES & FRAMEWORK

MODULE

1.A module in python is a “.py file” that defines one or more function/classes which you intend to reuse in different codes of your program.
2.To reuse the functions of a given module you simply need to import the module using:
  • import <modulename> # to import the entire module
  • from <modulename> import <functionname> # imports a function from a module
3.Python treats the file name as the module names.

PACKAGES

1.A Python package refers to a directory of Python module(s). This feature comes in handy for organizing modules of one type at one place.
2.A python package is normally installed in:
3.C:\Users\Tanmay\AppData\Local\Programs\Python\Python37\Lib\si te-packages # for windows
4.Python Packages are collection of Modules under the common namespace. This common Name space is created via directory that contains all related modules.
5.NOT ALL folders having multiple .py files (modules) are Packages. An __init__.py (even if empty) file must be a part of the folder.

LIBRARIES

1.It is collection of various packages.
2.Conceptually there is no difference between package and python library.

Some of the commonly used python Libraries :

a..Python Standard Library : Distributed with python. Commonly used modules of Python Standard Library are :
  • math module
  • random module
  • statistics module
b.Numpy Library
c.SciPy Library
d.matplotlib Library
e.tkinter Library

Framework

1.It is a collection of various libraries which architects the code flow.
Ex:- Django . This has various in-built libraries like Auth, user, database connector etc. for web development.

Interesting Example in Recursion


There are two cases :

# Example 1:
def fun(n):
    if(n == 0):
        return
    print(n)
    fun(n-1)
fun(5)


# Example 2:
def fun(n):
    if(n == 0):
        return
    fun(n-1)
    print(n)
fun(5)



In Example-1 the print statement will execute first then the fun(n-1) will run and it will go into the stack.

Interesting Example in Recursion



In Example-2 fun(n-1) will execute first so the stack will be created and the print will execute after the result of the fun(n-1) is returned. Till then the print statement will wait in the stack. Hence in this case the output's order will be reversed.

Interesting Example in Recursion



Files Opening Modes in Python File Handling

encode() String Function

encode() The string encode() method returns encoded version of the given string.
Since Python 3.0, strings are stored as Unicode, i.e. each character in the string is represented by a code point. So, each string is just a sequence of Unicode code points.

For efficient storage of these strings, the sequence of code points are converted into set of bytes. The process is known as encoding. There are various encodings present which treats a string differently. The popular encodings being utf-8, ascii, etc. By default, Python uses utf-8 encoding.

decode() String Function

This method is used to convert from one encoding scheme, in which argument string is encoded to the desired encoding scheme. This works opposite to the encode. It accepts the encoding of the encoding string to decode it and returns the original string.

Read Mode (r, r+, rb, rb+)

  • Read pointer moves as we read in the file. If we give.
  • In r+ mode read and write pointer move together.
  • In rb mode the data is read in the Bytes format.

Write Mode (w, w+, wb, wb+)

  • We can write only strings not numbers.
  • Write-Pointer Moves as we write in the file.
  • “w+” create a new file and overwrite if file already
  • existing. “r+” overwrite characters not file.
  • To write in the binary mode the string should be
  • converted into bytes format using (bytes() or encode() orusing b ’ ‘)

Append Mode (a, a+, ab, ab+)

  • Pointer will be at the end when we open the file. So, a+ and ab+ will not read anything if we want to read using them.
  • After Opening file, If we write anything it will write at the
  • end.

File Object Attributes

Python’s open() function creates a file object which serves as a link to the file residing on your
computer.

File Object Methods

File Object Methods (read)


Read Functions

read()

  • read() will read full file at once and move the file pointer at the end.
  • read(n) , will read n bytes from it’s current position.

readline()

  • readline() reads one line at a time. It searches “\n” and read the file till “\n”.
  • If I use readline(n), then it read the n bytes or upto “\n” (whichever comes first) from current position.

readlines()

  • Read all the lines in the list.
  • readlines(n), reads all lines where nth bytes is present.

File Object Methos (write)

Write Function

write(<string>)

This will write given string in the file and the pointer moves as we write into the file.

writelines(<list>)

  • Using this function we can give list of lines to write into the file.
  • The important thing to remember here is you have to give ‘\n’ manually at the end of eachline in the list to tell the python to write it into separate lines.
  • Ex:- [‘1st Line \n’, ‘2nd Line \n’, ‘3rd Line’]

File Object Methods (seek & tell)

File Object Methods (seek & tell)

seek() :

<file_obj>.seek(<Offset>,<from_where>)
<from_where> options 1 & 2 does not work with text file if <offset> is other than 0.

Read file character by character


Question:

Count the Number of Characters?

Read file word by word

Question:

Count the number of particular word.?

Read file line by line

Question:

Count the number of lines in the file ?

General Errors during file Handling

1.While writing integers -> TypeError: write() argument must be str, not int

  • We can write only string in file handling
  • If we need to write integers, we have to convert it into strings using type casting

2.While writing in Binary File -> TypeError: a bytes-like object is required, not 'str‘

  • In Binary files only Binary data can be written.
  • We have to convert the string data to bytes format using, bytes() function.