Vai al contenuto

CBSE Class 12 Computer Science

Class 12 · CBSEComputer Science31 appunti in 7 cartelle, 140 KB

31 note di ripasso, create da cookie, in 3 sezioni che seguono gli argomenti del corso.

Notes for CBSE Class 12 Computer Science (083), in folders for the three units of the 2026-27 curriculum in its order: computational thinking and programming (Python revision, functions, exceptions, file handling, stacks), computer networks, and database management (SQL and Python-MySQL connectivity). Code is in Python and MySQL. The practical list and project are not covered.

Aggiungendole, ne verrà copiata una versione nelle tue note, in una cartella dedicata con le cartelle qui sotto. Potrai modificarle e trasformarle in flashcard o in un mazzo di domande. Scaricandole otterrai un file zip con file markdown, che si aprono in qualsiasi app per prendere appunti.

Contenuto

  • Computational thinking and programming
    • Python revision
      • Python basics6 KB
      • Data types, operators and expressions7 KB
      • Conditional statements and loops6 KB
      • Strings6 KB
      • Lists5 KB
      • Tuples4 KB
      • Dictionaries4 KB
      • Modules4 KB
    • Functions and exceptions
      • Functions4 KB
      • Arguments, parameters and scope6 KB
      • Exception handling4 KB
    • File handling
      • Files and paths3 KB
      • Text files5 KB
      • Binary files5 KB
      • CSV files3 KB
    • Stacks
      • Stacks5 KB
  • Computer networks
    • Evolution of networking3 KB
    • Data communication4 KB
    • Switching techniques3 KB
    • Transmission media4 KB
    • Network devices5 KB
    • Network types and topologies4 KB
    • Network protocols4 KB
    • Web services4 KB
  • Database management
    • Database concepts and the relational model4 KB
    • SQL: defining databases and tables4 KB
    • SQL: inserting, updating and deleting data3 KB
    • SQL: selecting data5 KB
    • SQL: aggregate functions, group by and having4 KB
    • SQL: joins4 KB
    • Connecting Python to MySQL6 KB

La prima nota

Computational thinking and programming / Python revision / Python basics

What Python is

Python is a high-level, general-purpose programming language. It is interpreted, which means a program is translated and run one statement at a time by the Python interpreter rather than being compiled to a separate machine-code file first. It is dynamically typed, so a variable has no declared type and takes the type of whatever value it currently refers to. It is free and open source, runs on Windows, Linux and macOS without changes to the program, and has a large library of ready-made modules. Python is case-sensitive, so Total and total are two different names, and it uses indentation, not braces, to mark where a block of statements begins and ends.

Execution modes

Python can be used in two ways.

In interactive mode each statement is typed at the >>> prompt and executed at once, and the result of an expression is shown straight away. This suits trying out a single idea, but nothing is saved.

>>> 6 * 7
42
>>> print("hello")
hello

In script mode the statements are written in a file saved with the extension .py, and the whole file is run. The value of a bare expression is not printed in a script, so print() is needed to show output. A first program is one line:

print("Hello, world")

Python character set and tokens

The character set is the group of characters Python recognises: letters, digits, special symbols such as + - * / % ( ) [ ] { } , : ; ., white space (space, tab, newline) and other Unicode characters, which may appear inside strings and comments.

A token is the smallest unit of a program that has a meaning to the interpreter. There are five kinds.

TokenMeaningExamples
KeywordA reserved word with a fixed meaning, which cannot be used as a nameif, else, while, for, def, return, True, None, import
IdentifierA name given by the programmer to a variable, function or other objectmarks, total_2, _count
LiteralA fixed value written directly in the code25, 3.14, "cat", True, None
OperatorA symbol that acts on operands+, ==, and, in
PunctuatorA symbol that organises the code( ) [ ] { } , : . = #
Rules for identifiers

An identifier may contain letters, digits and the low line _, and it must not start with a digit. It cannot contain spaces or other symbols and cannot be a keyword. Because Python is case-sensitive, Name and name are different identifiers. 2nd_place and my-name are invalid; second_place and my_name are valid.

Kinds of literal

A literal can be a number (integer, floating point or complex), a string in single, double or triple quotes, a Boolean (True or False), the special literal None meaning no value, or a collection such as a list, tuple or dictionary written out in full.

Variables

A variable is a name that refers to a value stored in memory. It is created the first time a value is assigned to it, with no separate declaration.

age = 17
price = 49.5
name = "Asha"

The same name may later refer to a value of a different type, because the type belongs to the value, not to the name. id(x) gives the identity of the object a name refers to, and type(x) gives its type.

Several assignments may be made at once:

a, b = 3, 8      # a is 3 and b is 8
x = y = 0        # both names refer to 0
a, b = b, a      # swaps the two values
l-value and r-value

In an assignment, the expression on the left of = is the l-value. It is the name (a location in memory) that will receive the value. The expression on the right is the r-value, the value that is produced. In total = price * 3, total is the l-value and price * 3 is the r-value. A literal such as 5 can only be an r-value, so 5 = x is an error.

Comments

A comment is text that the interpreter ignores, written to explain the code to a reader. A single-line comment starts with # and runs to the end of the line. A multi-line comment can be made by starting each line with #, or by using a triple-quoted string that is not assigned to anything.

# area of a circle
r = 4
area = 3.14 * r * r   # uses the approximate value of pi

Errors

There are three kinds of error in a program.

A syntax error is a breach of the rules of the language, such as a missing colon, unbalanced brackets or wrong indentation. The interpreter finds it before running the statement and refuses to run it, so the program does not start until it is fixed.

A run-time error happens while the program is running, when a statement is correct but cannot be carried out. Dividing by zero, converting "abc" to an integer or using an index that does not exist all stop the program with a message such as ZeroDivisionError or ValueError.

A logical error is a fault in the reasoning of the program. It runs without complaint but gives wrong results, for example using + where * was meant, or an average calculated as a + b / 2 when (a + b) / 2 was needed. The interpreter cannot detect it, so it is found by testing the output against results worked out by hand.

Problem solving with algorithms

Solving a problem by program goes through analysing the problem, developing an algorithm, coding, testing and debugging. Analysis decides what the inputs and outputs are. An algorithm is a finite, ordered set of unambiguous steps that solves the problem. It is shown as pseudocode, which is plain English steps written like code, or as a flowchart, which uses standard shapes joined by arrows.

Flowchart shapeUse
OvalStart or stop
ParallelogramInput or output
RectangleA process, such as a calculation or assignment
DiamondA decision, with two or more exits such as Yes and No
ArrowDirection of flow

Pseudocode for the larger of two numbers:

INPUT a, b
IF a > b THEN
    PRINT a
ELSE
    PRINT b

Decomposition means breaking a large problem into smaller sub-problems that are each easier to solve, and then combining the solutions. A payroll program, for example, can be split into reading employee records, calculating pay, calculating deductions and printing payslips, and each part can be written and tested alone. Testing runs the program on chosen inputs, including ordinary, boundary and invalid ones, and debugging is locating and removing the faults that testing reveals.

E altre 30 dopo averle aggiunte o scaricate.

Valutazioni

Non ci sono ancora recensioni scritte. Aggiungi queste note alle tue e potrai essere il primo a lasciarne una.