KENDRIYA VIDYALAYA SANGATHAN CHENNAI REGION Session 2022-23 Class XI Computer Science Based on Latest CBSE Exam Pattern KENDRIYA VIDYALAYA SANGATHAN CHENNAI REGION OUR PATRONS Smt. T RUKMANI Offg. DEPUTY COMMISIONER KVS RO CHENNAI Sh. P.I.T. RAJA ASSISTANT COMMISSIONER KVS RO CHENNAI MEMBERS AND DETAILS OF TOPICS ALLOTTED Name of the co-ordinator – Mr. Steevan Fernandez, KV CRPF Avadi S.No. Name of the Teacher 1 2 3 Name of the Chapter allotted Computer System and KV Organisation , Boolean Ms. Shweta Arora Vijayanarayanam logic,Number system, Encoding schemes Introduction to Problem KV No.2 Smt. Reenu Rani solving, Getting started Kalpakkam with Python Smt. Anjum Flow of control, KV NLC Neyveli Akhthar Functions Name of the KV 4 Smt. Anju Rani KV OCF Strings, Lists 5 Smt. Smitha V Priya KV No.2 Trichy Tuples and Dictionaries, Societal Impacts With support of other contractual PGT CS of different KVs of Chennai Region COURSE DIRECTOR Sh. N. RAKHESH PRINCIPAL KV VIJAYANARAYANAM, CHENNAI INDEX Sl.No Contents 1 Curriculum 2022-23 2 Computer Systems and Organisation 3 Data Representation 4 Boolean Logic 5 Introduction to Problem Solving 6 Getting Started with Python 7 Flow of Control 8 Strings 9 Lists 10 Tuples 11 Dictionaries 12 Cyber Safety / Security / Society Law And Ethics 13 Sample Question Paper - I 14 Sample Question Paper - II 15 Sample Question Paper - III 16 Sample Question Paper - IV 17 Sample Question Paper - V COMPUTER SYSTEM AND ORGANISATION CONTENT – REVIEW ● Basic Computer Organisation: Introduction to computer system, hardware, software, input device, output device, CPU, memory (primary, cache and secondary), units of memory (Bit, Byte, KB, MB, GB, TB, PB) ● Types of software: system software (operating systems, system utilities, device drivers), programming tools and language translators (assembler, compiler & interpreter), application software ● Operating system (OS): functions of operating system, OS user interface Computer: Computer is an advanced electronic device that takes raw data as input from the user and processes these data under the control of set of instructions (called program) and gives the result (output) and saves output for the future use. It can process both numerical and nonnumerical (arithmetic and logical) calculations. Computer System: All of the components of a computer system can be summarized with the simple equations. COMPUTER SYSTEM = HARDWARE + SOFTWARE+ USER • Hardware = Internal Devices + Peripheral Devices All physical parts of the computer (or everything that we can touch) are known as Hardware. • Software = Programs Software gives “intelligence” to the computer. • USER = Person, who operates computer. Characteristics of computer: Speed, accuracy, diligence, versatility, huge memory, no IQ, lack of decision making. Functional Units of a computer: Input Unit, Central Processing Unit (CPU), Storage Unit and Output Unit. Input Unit: The data and instructions for their processing are entered into the computer through the input unit. They are stored in the memory (storage unit). Eg: keyboard, mouse, scanner, mic, digital camera, Joystick, Trackball, Light pen, Barcode Reader, OMR, OCR, MICR etc. Central Processing Unit: CPU is the brain of the computer. It consists of three componentsArithmetic Logic Unit (ALU), Control Unit (CU) and registers. ALU performs calculations and logical operations such as comparisons and decision making. CU manages and co-ordinates all other units of the computer. Registers are temporary storage elements that facilitate the functions of CPU. Storage Unit: It holds data and instructions required for processing, intermediate results for ongoing processing and final results of processing. Output Unit: The information obtained after data processing is supplied to the outside world through this unit. Monitor, Projector, Sound Speaker, Plotter and printer are the commonly used output devices. Memory of Computer Memory refers to the place where data is stored temporarily or permanently. Computer Memory is basically of 2 types: 1. Primary Memory Primary or main memory stores information (data and instruction) 2. Secondary Memory Stores the data permanently for future retrieval Primary Memory ❖Random Access Memory (RAM) ● It is the working memory, right from the booting of computer till the computer is shutdown, this memory is in use to store all the operation done by the computer ● It is used for primary storage in computers to hold active information of data and instructions. ● It holds data temporarily i.e. Volatile Memory ● Data is lost if Power Off ❖Read Only Memory (ROM) ● ROM (Read Only Memory) is used to store the instructions provided by the manufacturer, which holds the instructions to check basic hardware inter connecter and to load operating system from appropriate storage device ● It is also known as FIRMWARE ● Its data is stored permanently on it so it is non-volatile device. Units of Memory 4 BITS = 1 NIBBLE 8 BITS = 1 BYTE 1024 BYTES = 1 KILO BYTE(KB) 1024 KB = 1 MEGA BYTE(MB) 1024 MB = 1 GIGA BYTE(GB) 1024 GB = 1 TERA BYTE(TB) 1024 TB = 1 PETA BYTE(PB) The elementary unit of memory is a bit (binary digit) i.e. Zero(0) & One(1) Secondary Storage Devices ● If we want to save data for future reference and retrieval then it needs to be saved in memory other than primary memory, which is called secondary memory, or auxiliary memory. Normally hard disk of computer is used as secondary memory but this is not portable so there are many other secondary storage media in use. Example: Hard Disk , CD/DVD , Pen Drive , Floppy, etc. 1. HARD DISK : ● A hard disk drive (HDD; also hard drive, hard disk, or disk drive) is a device for storing and retrieving digital information, primarily computer data. ● It consists of one or more rigid (hence "hard") rapidly rotating discs (often referred to as platters), coated with magnetic material and with magnetic heads arranged to write data to the surfaces and read it from them. ● Generally hard disks are sealed units fixed in the cabinet. It is also known as fixed disk 2. FLOPPY DISK : ● It is a data storage medium that is made up of a disk of thin, flexible magnetic material enclosed in a cover. Its capacity is 1.44 MB. 3. COMPACT DISK (CD) : ● Capacity of standard 120mm CD is 700MB. It is a thin optical disk which is commonly used to store audio and video data. Transfer speed is mentioned as multiple of 150 KB/s. 4x means 600 KB/s. 4. DIGITAL VIDEO DISK (DVD) : ● This is an optical disc storage device. It can be recorded on single side or on double side. Its capacity may range from 4.7 GB to 8.5 GB. 5. PEN DRIVE : This is small, portable memory, which can be plugged into a computer with USB Port. They have capacity lesser than hard disk but much larger than a floppy or CD. They are more reliable also. Operating system (OS): A set of programs that acts as an interface between the user and computer hardware. It controls and co-ordinates the operations of a computer. It acts as the resource manager of the computer system. Function of OS: Process management, memory management, file management, device management, security management and command interpretation. Computer languages: Broadly classified into low level languages and high level languages. Machine language and assembly language are the different low level languages. The language, which uses binary digits 0 and 1, is called machine language. Assembly language use mnemonics. Mnemonic is a symbolic name given to an operation. High Level Languages are like English languages and are simpler to understand. Language processors: These are the system programs that translate programs written in high level language or assembly language into its equivalent machine language. Types of language processors: Assembler (translates the program code written in assembly language to machine language), Interpreter (converts a HLL program into machine language line by line) and Compiler (translates a program written in high level language into machine language). Utility software: A set of programs which help users in system maintenance tasks. Some of them are compression tools, disk defragmenter, backup software and antivirus software. Compression utility: Large files can be compressed so that they take less storage area. These compressed files can be decompressed into its original form when needed. Compression of files is known as zipping and decompression is called unzipping. WinZip, WinRAR, etc. are examples. Disk defragmenter: A program that rearranges files on a computer hard disk. This enables the computer to work faster and more efficiently. Backup utility: These programs facilitate the backing up of disk. Antivirus programs: A utility program that scans the computer system for viruses and removes them. Norton Antivirus, Kaspersky, etc. are examples. General purpose software: These are used to perform tasks in a particular application area. General purpose software is classified as word processors, spreadsheet software, presentation software, database software and multimedia software. Word processing software: It is designed for creating and modifying documents. It helps to create, edit, format and print textual matters easily. Formatting features include different font settings, paragraph settings, bullets and numbering, alignments and more. In addition to this it can check spelling and grammar in the document, insertion of pictures, charts and tables. We can specify headers and footers for every page in the document. The most popular examples of this type of software are MS Word, Open Office Writer, Apple iWork Pages, etc. Spreadsheet software: This software allows users to perform calculations using spreadsheets. It also allows us to insert drawing objects in the worksheet and create different types of charts for graphical representation of numerical data. Microsoft Excel, Open Office Calc, Lotus 1-2-3 and Apple iWork Numbers are some examples of spreadsheet software. Presentation software: The software is used to display information in the form of a slide show. Presentation software allows preparing slides containing pictures, text, animation, video and sound effects. Microsoft PowerPoint, Apple iWork Keynote and Open Office Impress are examples for presentation software. Database software: Database is an organised collection of data arranged in tabular form. Database Management System (DBMS) consists of a collection of interrelated data and a set of programs to access those data. They provide privacy and security to data and enforce standards for data. Examples of DBMS software are Microsoft Access, Oracle, Postgres SQL, My SQL, etc. Multimedia software: Multimedia is the integration of multiple forms of media. This includes text, graphics, audio, video, etc. Some multimedia software allows users to create and edit audio and video files. Audio converters, audio players and video editing software are some forms of multimedia software. Examples are VLC Player, Adobe Flash, Real Player, Media Player, etc. WORKSHEETS Worksheet- LEVEL-1 1. Name the software required to make a computer functional. Write down its two primary services. 2. What is the need for secondary memory? 3. Draw the block diagram of a computer system. Briefly write about the functionality of each component. 4. Why is primary memory termed as “destructive write” memory but “non- destructive” read memory? 5. Discuss the role of utility software in the context of computer performance? 6. Write equivalent memory units of the following: 1. 596 MB = __________ KB 2. 14 PB = ____________ GB 3. 135 YB = __________ PB 4. 10000 MB = ________ PB 5. 1000000 KB = _______GB 7. What is the need of RAM? How does it differ from ROM? 8. Name the input or output device used to do the following: a) To output audio b) To enter textual data c) To make hard copy of a text file d) To display the data or information e) To enter audio-based command f) To build 3D models g) To assist a visually-impaired individual in entering data 9. What is Operating system. Write any three functions of Operating System. 10. SRAM is faster memory than DRAM. (True/False) Computer Systems and Organization Worksheet- LEVEL-2 1. State the basic units of Computer along with its sub units and their functions. 2. Differentiate between RAM and ROM. 3. What is the role of CPU in Computer System. 4. Arrange the memory units from smallest to biggest: Giga Byte, Tera Byte, Mega Byte, Byte, Peta Byte, Kilo Byte. 5. What is the importance of an OS? 6. What is the difference between an interpreter and a compiler? 7. What is an application software? Why it is required? 8. What is volatile memory? 9. Write equivalent memory units of the following: 1. 596 MB = __________ KB 2. 14 PB = ____________ GB 3. 135 YB = __________ PB 4. 10000 MB = ________ PB 5. 1000000 KB = _______GB 10. Write short notes on Assembler, Compiler and Interpreter. Worksheet- LEVEL-3 1. Name any four secondary storage media. 2. Define software. Explain with examples- a) System Software b) Utility Software c) Application Software. 3. Write short notes on Assembler, Compiler and Interpreter. 4. The computer follows the IPO cycle that refers to Input-PerformanceOutput. (True/False) 5. The software provided in Operating Systems to assist the user is known as _______. 6. The _______ software rearranges the files in the computers and cleans up the memory. 7. Draw the basic computer system architecture. 8. What are the types of language processors? 9. What is an application software? Name some popular application softwares. 10. Identify the category (system, application, programming tool) of the following software: a) Compiler b) Assembler c) Ubuntu d) Text editor DATA REPRESENTATION CONTENT – REVIEW Number systems are the technique to represent numbers in the computer system architecture, every value that you are saving or getting into/from computer memory has a defined number system. Computer architecture supports following number systems. 1. Binary number system 2. Octal number system 3. Decimal number system 4. Hexadecimal (hex) number system BINARY NUMBER SYSTEM A Binary number system has only two digits that are 0 and 1. Every number (value) represents with 0 and 1 in this number system. The base of binary number system is 2, because it has only two digits. OCTAL NUMBER SYSTEM Octal number system has only eight (8) digits from 0 to 7. Every number (value) represents with 0,1,2,3,4,5,6 and 7 in this number system. The base of octal number system is 8, because it has only 8 digits. DECIMAL NUMBER SYSTEM Decimal number system has only ten (10) digits from 0 to 9. Every number (value) represents with 0,1,2,3,4,5,6, 7,8 and 9 in this number system. The base of decimal number system is 10, because it has only 10 digits. HEXADECIMAL NUMBER SYSTEM A Hexadecimal number system has sixteen (16) alphanumeric values from 0 to 9 and A to F. Every number (value) represents with 0,1,2,3,4,5,6, 7,8,9,A,B,C,D,E and F in this number system. The base of hexadecimal number system is 16, because it has 16 alphanumeric values. Here A is 10, B is 11, C is 12, D is 14, E is 15 and F is 16. Number system Base(Radix) Used digits Example Binary 2 0,1 (11110000)2 Octal 8 0,1,2,3,4,5,6,7 (360)8 Decimal 10 0,1,2,3,4,5,6,7,8,9 (240)10 Hexadecimal 16 0,1,2,3,4,5,6,7,8,9, A,B,C,D,E,F (F0)16 CONVERSIONS DECIMAL TO OTHER 1. DECIMAL TO BINARY Decimal Number System to Other Base To convert Number system from Decimal Number System to Any Other Base is quite easy; you have to follow just two steps: A) Divide the Number (Decimal Number) by the base of target base system (in which you want to convert the number: Binary (2), octal (8) and Hexadecimal (16)). B) Write the remainder from step 1 as a Least Signification Bit (LSB) to Step last as a Most Significant Bit (MSB). Decimal Conversion to Decimal (12345)10 Number Binary Result is : Binary Number is (11000000111001)2 2. DECIMAL TO OCTAL Decimal to Octal Conversion Result Decimal Number is : (12345)10 Octal Number is (30071)8 3. DECIMAL TO HEXADECIMAL Decimal to Conversion Hexadecimal Result Example 1 Decimal Number is : (12345)10 Hexadecimal Number is (3039)16 Example 2 Decimal Number is : (725)10 Hexadecimal Number is (2D5)16 Convert 10, 11, 12, 13, 14, 15 to its equivalent... A, B, C, D, E, F BINARY TO OTHER A) Multiply the digit with 2(with place value exponent). Eventually add all the multiplication becomes the Decimal number. 1. BINARY TO DECIMAL 2. BINARY TO OCTAL An easy way to convert from binary to octal is to group binary digits into sets of three, starting with the least significant (rightmost) digits. Binary: 11100101 11 = 100 101 011 100 101 Pad the most significant digits with zeros if necessary to complete a group of three. Then, look up each group in a table: Binary: 000 001 010 011 100 101 110 111 Octal: 0 1 2 3 4 5 6 7 Binary = 011 100 101 Octal = 3 4 5 = 345 oct 3. BINARY TO HEXADECIMAL An equally easy way to convert from binary to hexadecimal is to group binary digits into sets of four, starting with the least significant (rightmost) digits. Binary: 11100101 = 1110 0101 Then, look up each group in a table: Binary: 0000 0001 0010 0011 010 0101 0 0110 011 1 Hexadecimal: 0 1 2 3 4 6 7 Binary: 100 0 100 1 101 0 101 1 110 0 110 1110 1 111 1 Hexadecim al: 8 9 A B C D F Binary = 1110 0101 Hexadecimal = E 5 5 E = E5 hex OCTAL TO OTHER 1. OCTAL TO BINARY Converting from octal to binary is as easy as converting from binary to octal. Simply look up each octal digit to obtain the equivalent group of three binary digits. Octal: 0 1 2 3 4 5 6 7 Binary: 000 001 010 011 100 101 110 111 Octal = 3 4 5 Binary = 011 100 101 = 011100101 binary 2. OCTAL TO HEXADECIMAL When converting from octal to hexadecimal, it is often easier to first convert the octal number into binary and then from binary into hexadecimal. For example, to convert 345 octal into hex: (from the previous example) Octal = 3 4 5 Binary = 011 100 101 = 011100101 binary Drop any leading zeros or pad with leading zeros to get groups of four binary digits (bits): Binary 011100101 = 1110 0101 Then, look up the groups in a table to convert to hexadecimal digits. Binary: 0000 0001 0010 0011 0100 0101 011 0 0111 Hexadecimal: 0 1 2 3 4 5 6 7 Binary: 1000 1001 1010 1011 1100 1101 1110 1111 Hexadecimal : 8 9 A B C D E F Binary = 1110 0101 Hexadecimal = E 5 = E5 hex Therefore, through a two-step conversion process, octal 345 equals binary 011100101 equals hexadecimal E5. 3. OCTAL TO DECIMAL The conversion can also be performed in the conventional mathematical way, by showing each digit place as an increasing power of 8. 345 octal = (3 * 82) + (4 * 81) + (5 * 80) = (3 * 64) + (4 * 8) + (5 * 1) = 229 decimal HEXADECIMAL TO OTHER 1. HEXADECIMAL TO BINARY Converting from hexadecimal to binary is as easy as converting from binary to hexadecimal. Simply look up each hexadecimal digit to obtain the equivalent group of four binary digits. Hexadecimal: 0 1 2 3 4 5 6 7 Binary: 0000 0001 0010 0011 0100 0101 0110 0111 Hexadecimal: 8 9 A B C D E F Binary: 1000 1001 1010 1011 1100 1101 1110 1111 Hexadecimal A 2 D E = Binary = 1010 0010 2. HEXADECIMAL TO DECIMAL 1101 1110 = 1010001011011110 binary Convert 42A.1216 into a decimal number. SolutionThe hexadecimal number given is 4 2 A. 1 2 Positional weights 2 1 0 -1-2 The positional weights for each of the digits are written in italics below each digit. Hence the decimal equivalent number is given as: 4 × 162+ 2 ×161 + 10 × 161 + 1 × 16−1 + 1 × 16−2 = 1024 + 32 + 10 + 0.0625 + 0.00390625 = (1066.06640625)10 3. HEXADECIMAL TO OCTAL Given hexadecimal number is A 7 2 E Binary equivalent is 1010 0111 0010 1110 = 1010011100101110 Forming groups of 3 bits from the LSB 001 010 011 100 101 110 Octal equivalent 1 2 3 4 5 6 Hence the octal equivalent of (𝐴72𝐸)16 is (123456)8 . ENCODING SCHEMES American Standard Code for Information Interchange (ASCII) In the early 1960s, computers had no way of communicating with each other due to different ways of representing keys of the keyboard. Hence, the need for a common standard was realised to overcome this shortcoming. Thus, encoding scheme ASCII was developed for standardising the character representation. ASCII is still the most commonly used coding scheme. Initially ASCII used 7 bits to represent characters. Recall that there are only binary digits (0 or 1). Therefore, total number of different characters on the English keyboard that can be encoded by 7-bit ASCII code is 27 = 128. Following Table shows some printable characters for ASCII code. But ASCII is able to encode character set of English language only. Indian Script Code for Information Interchange (ISCII) In order to facilitate the use of Indian languages on computers, a common standard for coding Indian scripts called ISCII was developed in India during mid 1980s. It is an 8-bit code representation for Indian languages which means it can represent 28=256 characters. It retains all 128 ASCII codes and uses rest of the codes (128) for additional Indian language character set. Additional codes have been assigned in the upper region (160– 255) for the ‘aksharas’ of the language. UNICODE There were many encoding schemes, for character sets of different languages. But they were not able to communicate with each other, as each of them represented characters in their own ways. Hence, text created using one encoding scheme was not recognised by another machine using different encoding scheme. Therefore, a standard called UNICODE has been developed to incorporate all the characters of every written language of the world. UNICODE provides a unique number for every character, irrespective of device (server, desktop, mobile), operating system (Linux, Windows, iOS) or software application (different browsers, text editors, etc.). Commonly used UNICODE encodings are UTF-8, UTF-16 and UTF-32. It is a superset of ASCII, and the values 0–128 have the same character as in ASCII. Unicode characters for Devanagari script WORKSHEETS Write base values of binary, octal and hexadecimal number system. 1. Write full form of ASCII and ISCII. 2. Write the following conversions. (i) (514)8 = (?)10 (iv) (4D9)16 = (?)10 (ii) (220)8 = (?)2 (v) (11001010)2 = (?)10 (iii) (76F)16 = (?)10 (vi) (1010111)2 = (?)10 3. Do the following conversions from decimal number to other number systems. (i) (54)10 = (?)2 (iv) (889)10 = (?)8 (ii) (120)10 = (?)2 (v) (789)10 = (?)16 (iii) (76)10 = (?)8 (vi) (108)10 = (?)16 4. Express the following octal numbers into their equivalent decimal numbers. (i) 145 (ii) 6760 (iii) 455 (iv) 10.75 5. Express the following decimal numbers into hexadecimal numbers. (i) 548 (ii) 4052 (iii) 58 (iv) 100.25 6. Express the following hexadecimal numbers into equivalent decimal numbers. (i) 4A2 (ii) 9E1A (iii) 6BD (iv) 6C.34 7. Convert the following binary numbers into octal and hexadecimal numbers. (i) 1110001000 (ii) 110110101 (iii) 1010100 (iv) 1010.1001 8. Convert the following binary numbers into octal and hexadecimal numbers. (i) 1110001000 (ii) 110110101 (iii) 1010100 (iv) 1010.1001 9. Write binary equivalent of the following octal numbers. (i) 2306 (ii) 5610 (iii) 742 (iv) 65.203 10.Write binary representation of the following hexadecimal numbers. (i) 4026 (ii) BCA1 (iii) 98E (iv) 132.45 11.How does computer understand the following text? (hint: 7 bit ASCII code). (i) HOTS (ii) Main (iii) CaSe 12.The hexadecimal number system uses 16 literals (0 – 9, A– F). Write down its base value. 13.Let X be a number system having B symbols only. Write down the base value of this number system. 14.Encode the word ‘COMPUTER’ using ASCII and convert the encode value into binary values. BOOLEAN LOGIC CONTENT – REVIEW Boolean logic: NOT, AND, OR, NAND, NOR, XOR, truth table, De Morgan’s laws and logic circuits ● Number system: Binary, Octal, Decimal and Hexadecimal number system; conversion between number systems. ● Encoding schemes: ASCII, ISCII and UNICODE (UTF8, UTF32) BOOLEAN LOGIC ● Boolean logic refers to Boolean Algebra which values of variables are the truth values True or False. These values have two states either on or off denoted by 0 or 1. ● George Boole invented the first way of manipulating symbolic logic, which later became known as Boolean Algebra. Because of its vast applications in switching theory, developing basic electronic circuits, and designing digital computers, Boolean algebra has become a vital tool in computer science. 1. NOT OPERATION: It handles only a single variable. The operation performed by NOT is known as complementation. A A’ 0 1 1 0 2. OR OPERATION: It is also a binary operator that operates on two variables. The result of the OR operator is also known as logical addition. The symbol is used for OR is plus (+). The output is true if either one or two inputs are “true”. IF both false it produce false result. X Y X+Y 0 0 0 0 1 1 1 0 1 1 1 1 3. AND OPERATION: It is a binary operator that operates on two variables and the result of the AND operator is known as logical multiplication. To denote AND operator dot(.) symbol is used. AND means that A & B. When both inputs are true then it produce true result, otherwise false. X Y X.Y 0 0 0 0 1 0 1 0 0 1 1 1 4. NAND OPERATION: It stands for NOT AND that produce reverse result of AND gate. X Y (X.Y)’ 0 0 1 0 1 1 1 0 1 1 1 0 5. NOR OPERATION: It stands for NOT OR. It produces reverse output than the OR gate. X Y (X+Y)’ 0 0 1 0 1 0 1 0 0 1 1 0 6. XOR OPERATION: It produces high output if the input of 1s is odd, otherwise false. X Y X⊕Y 0 0 0 0 1 1 1 0 1 1 1 0 7. EX-NOR OPERATION: X Y (X⊕Y)’ 0 0 1 0 1 0 1 0 0 1 1 1 Basic Laws De Morgan's Law: First De Morgan's Law states that when two or more input variables (A, B) are OR’ed and then negated, the result is equal to the AND of the complements of the individual input variables. (A+B)’ = A’ . B’ To prove this theorem we can use the truth table as given below: A B A+B (A+B)’ A’ B’ A’.B’ 0 0 0 1 1 1 1 0 1 1 0 1 0 0 1 0 1 0 0 1 0 1 1 1 0 0 0 0 Second De Morgan's Law states that when two or more input variables are AND'ed and negated, then the obtained result will be equal to the OR of the complements of the individual variables. (A.B)’ = A’+B’ Using the truth table, we can prove this as follows: A B A.B (A.B)’ A’ B’ A’+B’ 0 0 0 1 1 1 1 0 1 0 1 1 0 1 1 0 0 1 0 1 1 1 1 1 0 0 0 0 WORKSHEETS LEVEL-1 1. The input to the following digital circuit are as shown below. Answer the following: a) Write expression for the output Y. b) Which logic gates are used in the given digital circuit? 2. State De Morgan’s theorems of Boolean algebra. Give proof for any one theorem. 3. Draw the equivalent logic circuit for the following Boolean Expression: A.(B+C ̅) 4. Name the law shown below and verify it using a truth table: A+B.C=(A+B).(A+C) 5. Which are the universal gates ? Why are they called universal gates? 6. Name the following law and verify them using a truth table: a. x + x’ = 1 b. x + y = y + x c. x + (y + z ) = (x + y ) + z d. x + xy = x e. (x + y)’ = x’.y’ 7. Draw logical circuits for the following: Y = ab + bc + ca Y = (a+b)’ . (a+b) Y = a’.b’ + (a.b)’ 8. Fill in the blanks and name the law : (i) X + X’ = ________ (ii) X’’= _______ 9. Find the complement of the following function F=xy+y’z+z’z 10.X.(X+Y)=X represents ____ law of Boolean relation. Worksheet- LEVEL-2 1. Verify using truth table that X +XY =X for each X, Y in (0,1) 2. Design a logic circuit for the Boolean function f(x, y)= x .y + x’ +y’ 3. What is a truth table? What is its significance ? 4. Which are the universal gates ? Why are they called universal gates? 5. Name the following law and verify them using a truth table: a. x + x’ = 1 b. x + y = y + x c. x + (y + z ) = (x + y ) + z 6. Draw logical circuits for the following: 1. Y = ab + bc + ca 2. Y = (a+b)’ . (a+b) 3. Y = a’.b’ + (a.b)’ 7. Which gate returns true if both inputs are similar otherwise false. 8. Which of the following gate is also known as an inverter. 9. Which of the following gate returns a true result if both inputs are true otherwise false. 10.Write logic expression for the following logic diagram: Worksheet- LEVEL-3 1. The gate which is used to reverse the output obtained is _____ a. NOR b. NAND c. EXOR 2. x * y = y * x is the __________ a. commutative law b. inverse property c. associative law d. identity element 3. Draw the truth table for XOR and OR gate. 4. Identify the logic gate of the following Truth table: Inputs Output A B Y 0 0 1 0 1 0 d. NOT 1 0 0 1 1 0 5. Prove the following by truth table: a. xy + x'y' + xz b. (a + b)(a' + b') 6. A dot (.) is used to show the ____ operation. 7. Output is 1 only when both the inputs are 1 otherwise result is 0 using ____ gate. 8. An input that is AND´ed or OR´ed with itself equals same input represents ____ law. 9. State and verify Involution law. 10.Write logic expression for the following logic diagram: COMPETENCY BASED 1. How many two input AND gates and 2 input OR gates are required to realize Y= BD+CE+AB 2. The output of an EX-NOR gate is 1. Which input combinations correct? (i) A=1, B=0 (ii) A=0, B=1 (iii) A=0, B=0 (iv) A=0, B’=1 3. Determine the values of A, B, C, and D that make the sum term equal to zero. 4. Surveying the rules for Boolean multiplication, the 0 and 1 values seem to resemble the truth table of a very common logic gate. Which type of gate is this, and what does this suggest about the relationship between Boolean multiplication and logic circuits? 5. There are three fundamental operations in Boolean algebra: addition, multiplication, and inversion. Each of these operations has an equivalent logic gate function and an equivalent relay circuit configuration. Draw the corresponding gate and ladder logic diagrams for each: 6. A student makes a mistake somewhere in the process of simplifying the following Boolean expression: Determine where the mistake was made, and what the proper sequence of steps should be to simplify the original expression. AB + A(B + C) AB + AB + C AB + C 7. A riddle based on Boolean logic You are walking and arrive at a dead end with 2 doors. You must get past this, but you are told that only one door is correct, leading you on your path and the other door is not correct and leads to something perilous. In front of each door is a guard. One guard always tells the truth and the other always lies. You may ask one of the guards one question, and then you must pick your door and go through it. What question do you ask, which door do you pick based on the answer, and why? INTRODUCTION TO PROBLEM SOLVING CONTENT – REVIEW S.NO TOPIC 1. Introduction 2. Steps for Problem Solving 3. Algorithm 4. Representation of Algorithms 5. Flow of Control 6. Verifying Algorithms 7. Comparison of Algorithm 8. Coding 9. Decomposition 1. INTRODUCTION • Computers are used for solving various day-to-day problems. • It is pertinent to mention that computers themselves cannot solve a problem. • Precise step-by-step instructions should be given by us to solve the problem. • Thus, the success of a computer in solving a problem depends on how correctly and precisely we define the problem, design a solution (algorithm) and implement the solution (program) using a programming language. • Thus, problem solving is the process of identifying a problem, developing an algorithm for the identified problem and finally implementing the algorithm to develop a computer program. 2. Steps for Problem Solving There are four steps in problem solving • Analysing the problem , Developing an Algorithm , Coding , Testing and Debugging 2.1 Analysing the problem • It is important to clearly understand a problem before we begin to find the solution for it. • If we are not clear as to what is to be solved, we may end up developing a program which may not solve our purpose. • By analysing a problem, we would be able to figure out what are the inputs that our program should accept and the outputs that it should produce. 2.2 Developing an Algorithm • The solution for a problem is represented in step by step procedure called an algorithm. • For a given problem, more than one algorithm is possible and we have to select the most suitable solution. 2.3 Coding • After finalising the algorithm, we need to convert the algorithm into the format which can be understood by the computer to generate the desired solution. 2.4 Testing and Debugging • The program created should be tested on various parameters. • The program should meet the requirements of the user. • In the presence of syntactical errors, no output will be obtained. • In case the output generated is incorrect, then the program should be checked for logical errors, if any. 3. Algorithm Algorithm is the step by step procedure for solving the problem. Suppose following are the steps required for an activity ‘riding a bicycle’: • remove the bicycle from the stand, • sit on the seat of the bicycle, • start peddling, • use breaks whenever needed and • stop on reaching the destination. Example: Algorithm to find square of a number. Step 1: Input a number and store it to num Step 2: Compute num * num and store it in square Step 3: Print square 3.1 Why do we need an Algorithm • Writing an algorithm is mostly considered as a first step to programming. • Once we have an algorithm to solve a problem, we can write the computer program for giving instructions to the computer in high level language. • If the algorithm is correct, computer will run the program correctly, every time. • So, the purpose of using an algorithm is to increase the reliability, accuracy and efficiency of obtaining solutions. Characteristics of a good algorithm • Precision — the steps are precisely stated or defined. • Uniqueness — results of each step are uniquely defined and only depend on the input and the result of the preceding steps. • Finiteness — the algorithm always stops after a finite number of steps. • Input — the algorithm receives some input. • Output — the algorithm produces some output. While writing an algorithm, it is required to clearly identify the following: • The input to be taken from the user • Processing or computation to be performed to get the desired result • The output desired by the user 4. Representation of Algorithms There are two common methods of representing an algorithm —flowchart and pseudocode. Either of the methods can be used to represent an algorithm while keeping in mind the following: • it showcases the logic of the problem solution, excluding any implementational details • it clearly reveals the flow of control during execution of the program 4.1 Flowchart — Visual Representation of Algorithms • A flowchart is a visual representation of an algorithm. • A flowchart is a diagram made up of boxes, diamonds and other shapes, connected by arrows. Symbols Functions Descriptions Start/End Also called “Terminator” symbol. It indicates where the flow starts and ends. Process Also called “Action Symbol,” it represents a process, action, or a single step. Decision A decision or branching point, usually a yes/no or true/ false question is asked, and based on the answer, the path gets split into two branches. Input/Output Also called data symbol, this parallelogram shape is used to input or output data Arrow Connector to show order of flow between shapes. Flowchart to calculate square of a number 4.2 Pseudocode A pseudocode (pronounced Soo-doh-kohd) is another way of representing an algorithm. It is considered as a non-formal language that helps programmers to write algorithm. The word “pseudo” means “not real,” so “pseudocode” means “not real code”. Following are some of the frequently used keywords while writing pseudocode: • INPUT / • COMPUTE / • PRINT / • INCREMENT / • DECREMENT • IF/ELSE, • WHILE , • TRUE / FALSE Example: Pseudocode for the sum of two numbers will be: input num1 input num2 COMPUTE Result = num1 + num2 PRINT Result 4.5 Flow of Control The flow of control depicts the flow of events as represented in the flow chart. 4.5.1 Sequence • Sometimes the algorithm to either does some routine tasks in a repeated manner or behave differently depending on the outcomes of previous steps. • The statements are executed one after another is known as sequence. 4.5.2 Selection Let us look at some other examples where decision making is dependent on certain conditions. For example, (i) Checking eligibility for voting. Depending on their age, a person will either be allowed to vote or not allowed to vote: • If age is greater than or equal to 18, the person is eligible to vote • If age is less than 18, the person is not eligible to vote (ii) Let us consider another example If a student is 8 years old and the student likes Maths put the student in Group A Otherwise Put the student in Group B Actions depending on true or false of a condition Conditionals are written in the algorithm as follows: If <condition> then steps to be taken when the condition is true/fulfilled There are situations where we also need to take action when the condition is not fulfilled (In above Figure). To represent that, we can write: If <condition> is true then steps to be taken when the condition is true/fulfilled otherwise steps to be taken when the condition is false/not fulfilled 4.6 Verifying Algorithms • The software designer should make sure that the functioning of all the components are defined correctly, checked and verified in every possible way. • When we were told that the formula for the sum of first N natural numbers is N(N+1) / 2 , how did we verify it? • Well, we can check this for small numbers, for which we can manually calculate the sum. • Let N = 6, then the sum is 1 + 2 + 3 + 4 + 5 + 6 = 21 Using formula we get sum = 6x(6+1) / 2 • The method of taking an input and running through the steps of the algorithm is sometimes called dry run. Such a dry run will help us to: 1. Identify any incorrect steps in the algorithm 2. Figure out missing details or specifics in the algorithm Write an algorithm to calculate the time taken to go from place A to C (T_total) via B where time taken to go from A to B (T1) and B to C (T2) are given. That is, we want the algorithm to add time given in hours and minutes. One way to write the algorithm is: PRINT value for T1 INPUT hh1 INPUT mm1 PRINT value for T2 INPUT hh2 INPUT mm2 hh_total = hh1 + hh2 (Add hours) mm_total = mm1 + mm2 (Add mins) Print T_total as hh_total, mm_total Now let us verify. Suppose the first example we take is T1 = 5 hrs 20 mins and T2 = 7 hrs 30 mins. On dry run, we get the result 12 hrs and 50 mins. This looks fine. 4.7 Comparison of Algorithm There can be four different ways to write algorithms to check whether a given number is prime or not as shown below: (i) Starting with divisor 2, divide the given number (dividend) and check if there are any factors. Increase the divisor in each iteration and repeat the previous steps as long as divisor < dividend. If there is a factor, then the given number is not prime (ii) In (i), instead of testing all the numbers till the dividend, only test up to half of the given value (dividend) because the divisor can not be more than half of the dividend (iii) In method (i), only test up to the square root of the dividend (numbers) (iv) Given a prior list of prime number till 100, divide the given number by each number in the list. If not divisible by any number, then the number is a prime else it is not prime All these four methods can check if a given number is prime or not. Now the question is which of these methods is better or efficient? Algorithm (i) requires large number of calculations (means more processing time) as it checks for all the numbers as long as the divisor is less than the number. If the given number is large, this method will take more time to give the output. Algorithm (ii) is more efficient than (i) as it checks for divisibility till half the number, and thus it reduces the time for computation of the prime number. Algorithm (iii) is even more efficient as it checks for divisibility till square root of the number, thereby further reducing the time taken. As algorithm (iv) uses only the prime numbers smaller than the given number for divisibility, it further reduces the calculations. But in this method we require to store the list of prime numbers first. Thus it takes additional memory even though it requires lesser calculations. Hence, algorithms can be compared and analysed on the basis of the amount of processing time they need to run and the amount of memory that is needed to execute the algorithm. These are termed as time complexity and space complexity, respectively. The choice of an algorithm over another is done depending on how efficient they are in terms of processing time required (time complexity) and the memory they utilize (space complexity). 4.8 Coding • Once an algorithm is finalised, it should be coded in a high-level programming language as selected by the programmer. • The ordered set of instructions are written in that programming language by following its syntax. • Syntax is the set of rules or grammar that governs the formulation of the statements in the language, such as spellings, order of words, punctuation, etc. 4.9 Decomposition • The basic idea of solving a complex problem by decomposition is to 'decompose' or break down a complex problem into smaller sub problems Answer the Following Questions (Very Short Annswers) 1. Define Algorithm 2. What is decomposition? 3. Why do we need Algorithm? 4. What is meant by Debugging? Answer the Following Questions (Short Answers) 1. Write an algorithm to find the greatest among two different numbers 2. Write a pseudocode to calculate the factorial of a number 3. Write an algorithm to fing greates among three numbers Answer the Following Questions (LongAnswers) 1. Write pseudocode and draw flowchart to accept numbers till the user enters 0 and then find their average. 2. Write a pseudocode and draw a flowchart where multiple conditions are checked to categorize a person as either child (<13), teenager (>=13 but <20) or adult (>=20),based on age specified: 3. Write an algorithm that accepts four numbers as input and find the largest and smallest of them. WORKSHEETS 1. Write pseudocode that reads two numbers and divide one by another and display the quotient. 2. Write pseudocode to print all multiples of 5 between 10 and 2. 3. Give an example of a loop that is to be executed a certain number of times. 4. Suppose you are collecting money for something. You need 200 in all. You ask your parents, uncles and aunts as well as grandparents. Different people may give either 10, 20 or even 50. You will collect till the total becomes 200. Write the algorithm. 5. Write the pseudocode to print the bill depending upon the price and quantity of an item. Also print Bill GST, which is the bill after adding 5% of tax in the total bill. 6. Write an algorithm that accepts four numbers as input and find the largest and smallest of them. 7. Write a pseudocode to calculate the factorial of a number. 8. Draw a flowchart to check whether a given number is an Armstrong number. An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 +7**3 + 1**3 = 371. ANSWER KEY: QUESTION 1 Input first number Input second number Calculate quotient = first number // second number Print quotient QUESTION 2 For i in range ( 10, 26, 5 ) Print i QUESTION 3 For i in range ( 10, 26, 5 ) It wil execute only 3 times QUESTION 4 Set sum = 0 While sum = 200 Input money obtained Sum += money Print thank you Algorithm :- 1- Start 2- Approach to parent, uncle, aunts and grandparents 3- Request for money 4- Collect given amount 5- Add amount received to make sure it is 200 6- If not reach to 200 7- Again, request from others 8- If received 200 goal achieved 9- Stop QUESTION 5 Input Price Input quantity Calculate total = price * quantity Calculate including_GST = total + total* 0.05 Print total bill is including_GST QUESTION 6 1. Input first number 2. Input second number 3. Input third number 4. Input fourth number 5. Set lst = [ first , second, third , forth ] 6. Sort the lst 7. lst.sort( ) 8. Print greatest number is lst [ -1 ] 9. Print smallest number is lst [ 0 ] QUESTION 7 Input number Set Factorial = 1 For i in range ( 1, number + 1) : Factorial *= I Print factorial QUESTION 8 GETTING STARTED WITH PYTHON CONTENT – REVIEW S.NO TOPICS 1. Introduction to Python 2. Python Keywords 3. Identifiers 4. Variables 5. Comments 6. Everything is an Object 7. Data Types 8. Operators 9. Expressions 10. Statement 11. Input and Output 12. Type Conversion 13. Debugging 5.1 INTRODUCTION TO PYTHON A program written in a high-level language is called source code. Python uses an interpreter to convert its instructions into machine language, so that it can be understood by the computer. An interpreter processes the program statements one by one, first translating and then executing. This process is continued until an error is encountered or the whole program is executed successfully 5.1.1 Features of Python • Python is a high level language. It is a free and open source language. • It is an interpreted language, as Python programs are executed by an interpreter. • Python programs are easy to understand as they have a clearly defined syntax and relatively simple structure. • Python is case-sensitive. For example, NUMBER and number are not same in Python. • Python is portable and platform independent, means it can run on various operating systems and hardware platforms. • Python has a rich library of predefined functions. • Python is also helpful in web development. Many popular web services and applications are built using python. • Python uses indentation for blocks and nested blocks. 5.1.2 Working with Python To write and run (execute) a Python program, we need to have a Python interpreter installed on our computer or we can use any online Python interpreter. 5.1.3 Execution Modes There are two ways to use the Python interpreter: a) Interactive mode b) Script mode Interactive Mode: Without passing python script file to the interpreter, directly execute code to Python (Command line). Example: >>>6+3 Output: 91. INTRODUCTION Computers are used for solving various day-to-day problems. It is pertinent to mention that computers themselves cannot solve a problem. Precise step-by-step instructions should be given by us to solve the problem. Thus, the success of a computer in solving a problem depends on how correctly and precisely we define the problem, design a solution (algorithm) and implement the solution (program) using a programming language. Thus, problem solving is the process of identifying a problem, developing an algorithm for the identified problem and finally implementing the algorithm to develop a computer program. 2. Steps for Problem Solving There are four steps in problem solving Analysing the problem Developing an Algorithm Coding Testing and Debugging 2.1 Analysing the problem It is important to clearly understand a problem before we begin to find the solution for it. If we are not clear as to what is to be solved, we may end up developing a program which may not solve our purpose. By analysing a problem, we would be able to figure out what are the inputs that our program should accept and the outputs that it should produce. 2.2 Developing an Algorithm The solution for a problem is represented in step by step procedure called an algorithm. For a given problem, more than one algorithm is possible and we have to select the most suitable solution. 2.3 Coding After finalising the algorithm, we need to convert the algorithm into the format which can be understood by the computer to generate the desired solution. 2.4 Testing and Debugging The program created should be tested on various parameters. The program should meet the requirements of the user. In the presence of syntactical errors, no output will be obtained. In case the output generated is incorrect, then the program should be checked for logical errors, if any. 3. Algorithm Algorithm is the step by step procedure for solving the problem. Suppose following are the steps required for an activity ‘riding a bicycle’: remove the bicycle from the stand, sit on the seat of the bicycle, start peddling, use breaks whenever needed and stop on reaching the destination. Example: Algorithm to find square of a number. Step 1: Input a number and store it to num Step 2: Compute num * num and store it in square Step 3: Print square 3.1 Why do we need an Algorithm Writing an algorithm is mostly considered as a first step to programming. Once we have an algorithm to solve a problem, we can write the computer program for giving instructions to the computer in high level language. If the algorithm is correct, computer will run the program correctly, every time. So, the purpose of using an algorithm is to increase the reliability, accuracy and efficiency of obtaining solutions. Characteristics of a good algorithm • Precision — the steps are precisely stated or defined. • Uniqueness — results of each step are uniquely defined and only depend on the input and the result of the preceding steps. • Finiteness — the algorithm always stops after a finite number of steps. • Input — the algorithm receives some input. • Output — the algorithm produces some output. While writing an algorithm, it is required to clearly identify the following: • The input to be taken from the user • Processing or computation to be performed to get the desired result • The output desired by the user 4. Representation of Algorithms There are two common methods of representing an algorithm —flowchart and pseudocode. Either of the methods can be used to represent an algorithm while keeping in mind the following: • it showcases the logic of the problem solution, excluding any implementational details • it clearly reveals the flow of control during execution of the program 4.1 Flowchart — Visual Representation of Algorithms A flowchart is a visual representation of an algorithm. A flowchart is a diagram made up of boxes, diamonds and other shapes, connected by arrows. Symbols / Functions / Descriptions / Start/End . Also called “Terminator” symbol. It indicates where the flow starts and ends. Process Also called “Action Symbol,” it represents a process, action, or a single step. Decision A decision or branching point, usually a yes/no or true/ false question is asked, and based on the answer, the path gets split into two branches. Input/Output Also called data symbol, this parallelogram shape is used to input or output data Arrow Connector to show order of flow between shapes. Flowchart to calculate square of a number  4.2 Pseudocode A pseudocode (pronounced Soo-doh-kohd) is another way of representing an algorithm. It is considered as a non-formal language that helps programmers to write algorithm. The word “pseudo” means “not real,” so “pseudocode” means “not real code”. Following are some of the frequently used keywords while writing pseudocode: • INPUT • COMPUTE • PRINT • INCREMENT • DECREMENT • IF/ELSE • WHILE • TRUE/FALSE Example: Pseudocode for the sum of two numbers will be: input num1 input num2 COMPUTE Result = num1 + num2 PRINT Result 4.5 Flow of Control The flow of control depicts the flow of events as represented in the flow chart. 4.5.1 Sequence Sometimes the algorithm to either does some routine tasks in a repeated manner or behave differently depending on the outcomes of previous steps. The statements are executed one after another is known as sequence. 4.5.2 Selection Let us look at some other examples where decision making is dependent on certain conditions. For example, (i) Checking eligibility for voting. Depending on their age, a person will either be allowed to vote or not allowed to vote: • If age is greater than or equal to 18, the person is eligible to vote • If age is less than 18, the person is not eligible to vote (ii) Let us consider another example If a student is 8 years old and the student likes Maths put the student in Group A Otherwise Put the student in Group B  Actions depending on true or false of a condition Conditionals are written in the algorithm as follows: If <condition> then steps to be taken when the condition is true/fulfilled There are situations where we also need to take action when the condition is not fulfilled (In above Figure). To represent that, we can write: If <condition> is true then steps to be taken when the condition is true/fulfilled otherwise steps to be taken when the condition is false/not fulfilled 4.6 Verifying Algorithms The software designer should make sure that the functioning of all the components are defined correctly, checked and verified in every possible way. When we were told that the formula for the sum of first N natural numbers is N(N+1) / 2 , how did we verify it? Well, we can check this for small numbers, for which we can manually calculate the sum. Let N = 6, then the sum is 1 + 2 + 3 + 4 + 5 + 6 = 21 Using formula we get sum = 6x(6+1) / 2 The method of taking an input and running through the steps of the algorithm is sometimes called dry run. Such a dry run will help us to: 1. Identify any incorrect steps in the algorithm 2. Figure out missing details or specifics in the algorithm Write an algorithm to calculate the time taken to go from place A to C (T_total) via B where time taken to go from A to B (T1) and B to C (T2) are given. That is, we want the algorithm to add time given in hours and minutes. One way to write the algorithm is: PRINT value for T1 INPUT hh1 INPUT mm1 PRINT value for T2 INPUT hh2 INPUT mm2 hh_total = hh1 + hh2 (Add hours) mm_total = mm1 + mm2 (Add mins) Print T_total as hh_total, mm_total Now let us verify. Suppose the first example we take is T1 = 5 hrs 20 mins and T2 = 7 hrs 30 mins. On dry run, we get the result 12 hrs and 50 mins. This looks fine. 4.7 Comparison of Algorithm There can be four different ways to write algorithms to check whether a given number is prime or not as shown below: (i) Starting with divisor 2, divide the given number (dividend) and check if there are any factors. Increase the divisor in each iteration and repeat the previous steps as long as divisor < dividend. If there is a factor, then the given number is not prime (ii) In (i), instead of testing all the numbers till the dividend, only test up to half of the given value (dividend) because the divisor can not be more than half of the dividend (iii) In method (i), only test up to the square root of the dividend (numbers) (iv) Given a prior list of prime number till 100, divide the given number by each number in the list. If not divisible by any number, then the number is a prime else it is not prime All these four methods can check if a given number is prime or not. Now the question is which of these methods is better or efficient? Algorithm (i) requires large number of calculations (means more processing time) as it checks for all the numbers as long as the divisor is less than the number. If the given number is large, this method will take more time to give the output. Algorithm (ii) is more efficient than (i) as it checks for divisibility till half the number, and thus it reduces the time for computation of the prime number. Algorithm (iii) is even more efficient as it checks for divisibility till square root of the number, thereby further reducing the time taken. As algorithm (iv) uses only the prime numbers smaller than the given number for divisibility, it further reduces the calculations. But in this method we require to store the list of prime numbers first. Thus it takes additional memory even though it requires lesser calculations. Hence, algorithms can be compared and analysed on the basis of the amount of processing time they need to run and the amount of memory that is needed to execute the algorithm. These are termed as time complexity and space complexity, respectively. The choice of an algorithm over another is done depending on how efficient they are in terms of processing time required (time complexity) and the memory they utilize (space complexity). 4.8 Coding Once an algorithm is finalised, it should be coded in a high-level programming language as selected by the programmer. The ordered set of instructions are written in that programming language by following its syntax. Syntax is the set of rules or grammar that governs the formulation of the statements in the language, such as spellings, order of words, punctuation, etc. 4.9 Decomposition The basic idea of solving a complex problem by decomposition is to 'decompose' or break down a complex problem into smaller sub problems Answer the Following Questions (Very Short Annswers) Define Algorithm What is decomposition? Why do we need Algorithm? What is meant by Debugging? Answer the Following Questions (Short Answers) Write an algorithm to find the greatest among two different numbers Write a pseudocode to calculate the factorial of a number Write an algorithm to fing greates among three numbers Answer the Following Questions (LongAnswers) Write pseudocode and draw flowchart to accept numbers till the user enters 0 and then find their average. Write a pseudocode and draw a flowchart where multiple conditions are checked to categorize a person as either child (<13), teenager (>=13 but <20) or adult (>=20),based on age specified: Write an algorithm that accepts four numbers as input and find the largest and smallest of them. REVISION NOTES CLASS XI GETTING STARTED WITH PYTHON 5.1 INTRODUCTION TO PYTHON A program written in a high-level language is called source code. Python uses an interpreter to convert its instructions into machine language, so that it can be understood by the computer. An interpreter processes the program statements one by one, first translating and then executing. This process is continued until an error is encountered or the whole program is executed successfully 5.1.1 Features of Python Python is a high level language. It is a free and open source language. • It is an interpreted language, as Python programs are executed by an interpreter. • Python programs are easy to understand as they have a clearly defined syntax and relatively simple structure. • Python is case-sensitive. For example, NUMBER and number are not same in Python. • Python is portable and platform independent, means it can run on various operating systems and hardware platforms. • Python has a rich library of predefined functions. • Python is also helpful in web development. Many popular web services and applications are built using python. • Python uses indentation for blocks and nested blocks. 5.1.2 Working with Python To write and run (execute) a Python program, we need to have a Python interpreter installed on our computer or we can use any online Python interpreter. Script Mode: In this mode source code is stored in a file with the .py extension and use the interpreter to execute the contents of the file. To execute the script by the interpreter, you have to tell the interpreter the name of the file. Example: If you have a file name Demo.py , to run the script you have to follow the following steps: Step-1: Open the text editor i.e. Notepad Step-2: Write the python code and save the file with .py file extension. (Default directory is C:\Python33/Demo.py) Step-3: Open IDLE ( Python GUI) python shell Step-4: Click on file menu and select the open option Step-5: Select the existing python file Step-6: Now a window of python file will be opened Step-7: Click on Run menu and the option Run Module. Step-8: Output will be displayed on python shell window 5.2 PYTHONKEYWORDS Reserved words in the library of a language. There are 33 keywords in python. All the keywords are in lowercase except 03 keywords (True, False, None) 5.3 IDENTIFIERS Identifier: The name given by the user to the entities like variable name, class-name, function-name etc. Rules for identifiers: • It can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore. • It cannot start with a digit. • Keywords cannot be used as an identifier. • We cannot use special symbols like !, @, #, $, %, + etc. in identifier. • _ (underscore) can be used in identifier. • Commas or blank spaces are not allowed within an identifier. 5.4 VARIABLES • A variable in a program is uniquely identified by a name (identifier). • Variable in Python refers to an object — an item or element that is stored in the memory. • Value of a variable can be a string (e.g., ‘b’, ‘Global Citizen’), numeric (e.g., 345) or any combination of alphanumeric characters (CD67). • In Python we can use an assignment statement to create new variables and assign specific values to them. gender = 'M' message = "Keep Smiling" price = 987.9 Program Write a program to display values of variables in Python. #To display values of variables message = "Keep Smiling" print(message) userNo = 101 print('User Number is', userNo) Output: Keep Smiling User Number is 101 5.5 COMMENTS • Comments are not executed. • Comments explain a program and make a program understandable and readable. • All characters after the # and up to the end of the physical line are part of the comment and the Python interpreter ignores them. Example #Variable amount is the total spending on grocery amount = 3400 #totalMarks is sum of marks in all the tests of Mathematics totalMarks = test1 + test2 + finalTest 5.6 EVERYTHING IS ANOBJECT Python treats every value or data item whether numeric, string, or other type (discussed in the next section) as an object in the sense that it can be assigned to some variable or can be passed to a function as an argument. Example >>> num1 = 20 >>> id(num1) 1433920576 #identity of num1 >>> num2 = 30 - 10 >>> id(num2) 1433920576 #identity of num2 and num1 #are same as both refers to #object 20 5.7 DATATYPES 5.7.1 Number Number data type stores numerical values only. It is further classified into three different types: int, float and complex. Table Numeric data types Boolean data type (bool) is a subtype of integer. It is a unique data type, consisting of two constants, True and False. Example >>> num1 = 10 >>> type(num1) <class 'int'> >>> float1 = -1921.9 >>> type(float1) <class 'float'> >>> float2 = -9.8*10**2 >>> print(float2, type(float2)) -980.0000000000001 <class 'float'> >>> var2 = -3+7.2j >>> print(var2, type(var2)) (-3+7.2j) <class 'complex 5.7.2 Sequence String String is a group of characters. These characters may be alphabets, digits or special characters including spaces. >>> str1 = 'Hello Friend' >>> str2 = "452" We cannot perform numerical operations on strings, even when the string contains a numeric value, as in str2. List List is a sequence of items separated by commas and the items are enclosed in square brackets [ ]. Example #To create a list >>> list1 = [5, 3.4, "New Delhi", "20C", 45] #print the elements of the list list1 >>> print(list1) [5, 3.4, 'New Delhi', '20C', 45] Tuple Tuple is a sequence of items separated by commas and items are enclosed in parenthesis ( ). This is unlike list, where values are enclosed in brackets [ ]. Once created, we cannot change the tuple. Example #create a tuple tuple1 >>> tuple1 = (10, 20, "Apple", 3.4, 'a') #print the elements of the tuple tuple1 >>> print(tuple1) (10, 20, "Apple", 3.4, 'a') Set Set is an unordered collection of items separated by commas and the items are enclosed in curly brackets { }. A set is similar to list, except that it cannot have duplicate entries. Once created, elements of a set cannot be changed. Example #create a set >>> set1 = {10,20,3.14,"New Delhi"} >>> print(type(set1)) <class 'set'> >>> print(set1) {10, 20, 3.14, "New Delhi"} #duplicate elements are not included in set >>> set2 = {1,2,1,3} >>> print(set2) {1, 2, 3} 5.7.4 None None is a special data type with a single value. Example >>> myVar = None >>> print(type(myVar)) <class 'NoneType'> >>> print(myVar) None 5.7.5 Mapping Mapping is an unordered data type in Python. Currently, there is only one standard mapping data type in Python called dictionary. Dictionary Dictionary in Python holds data items in key-value pairs.Items in a dictionary are enclosed in curly brackets { }. Example #create a dictionary >>> dict1 = {'Fruit':'Apple', 'Climate':'Cold', 'Price(kg)':120} >>> print(dict1) {'Fruit': 'Apple', 'Climate': 'Cold', 'Price(kg)': 120} >>> print(dict1['Price(kg)']) 120 5.7.6 Mutable and Immutable Data Types Mutable Immutable The objects can be modified after the Objects can not be modified after the creation as well. creation of the objects. Classes that are mutable are not considered Classes that are final. considered final. Thread unsafe. immutable are Thread-safe. Classes are not made final for the mutable Classes are made final for the immutable objects. objects. Example: Lists, Dicts, Sets, User-Defined Example: int, float, bool, Classes, Dictionaries, etc. Unicode, tuple, Numbers, etc. 5.8 OPERATORS 5.8.1 Arithmetic Operators string, 5.8.2 Relational Operators 5.8.3 Assignment Operators 5.8.4 Logical Operators 5.8.5 Identity Operators 5.8.6 Membership Operators 5.9 EXPRESSIONS An expression is defined as a combination of constants, variables, and operators. An expression always evaluates to a value. 1. 100 2. 3.0 + 3.14 3. num 4. 23/3 -5 * 7(14 -2) 5. num – 20.4 6. "Global" + "Citizen" 5.9.1 Precedence of Operators Example How will Python evaluate the following expression? (20 + 30) * 40 Solution: = (20 + 30) * 40 # Step 1 #using parenthesis(), we have forced precedence of + to be more than that of * = 50 * 40 # Step 2 = 2000 # Step 3 Example How will the following expression be evaluated in Python? 15.0 / 4 + (8 + 3.0) Solution: = 15.0 / 4 + (8.0 + 3.0) #Step 1 = 15.0 / 4.0 + 11.0 #Step 2 = 3.75 + 11.0 #Step 3 = 14.75 #Step 4 5.10 STATEMENT In Python, a statement is a unit of code that the Python interpreter can execute. Example >>> x = 4 #assignment statement >>> cube = x ** 3 #assignment statement >>> print (x, cube) #print statement 4 64 5.11 INPUT AND OUTPUT The input() function prompts the user to enter data. It accepts all user input as string. The user may enter a number or a string but the input() function treats them as strings only. The syntax for input() is: input ([Prompt]) Example 5.14 >>> fname = input("Enter your first name: ") Enter your first name: Arnab >>> age = input("Enter your age: ") Enter your age: 19 >>> type(age) Example 5.12 TYPE CONVERSION Consider the following program num1 = input("Enter a number and I'll double it: ") num1 = num1 * 2 print(num1) The program was expected to display double the value of the number received and store in variable num1. So if a user enters 2 and expects the program to display 4 as the output, the program displays the following result: Enter a number and I'll double it: 2 22 5.12.1 Explicit Conversion Program Program of explicit type conversion from int to float. #Explicit type conversion from int to float num1 = 10 num2 = 20 num3 = num1 + num2 print(num3) print(type(num3)) num4 = float(num1 + num2) print(num4) print(type(num4)) Output: 30 30.0 Program Program to show explicit type conversion. #Explicit type conversion icecream = '25' brownie = '45' #String concatenation price = icecream + brownie print("Total Price Rs." + price) #Explicit type conversion - string to integer price = int(icecream)+int(brownie) print("Total Price Rs." + str(price)) Output: Total Price Rs.2545 Total Price Rs.70 5.12.2 Implicit Conversion Implicit conversion, also known as coercion, happens when data type conversion is done automatically by Python and is not instructed by the programmer. Program 5-10 Program to show implicit conversion from int to float. #Program #Implicit type conversion from int to float num1 = 10 #num1 is an integer num2 = 20.0 #num2 is a float sum1 = num1 + num2 #sum1 is sum of a float and an integer print(sum1) print(type(sum1)) Output: 30.0 5.13 DEBUGGING A programmer can make mistakes while writing a program, and hence, the program may not execute or may generate wrong output. The process of identifying and removing such mistakes, also known as bugs or errors, from a program is called debugging. Errors occurring in programs can be categorised as: i) Syntax errors. ii) Logical errors iii) Runtime errors 5.13.1 Syntax Errors Like other programming languages, Python has its own rules that determine its syntax. The interpreter interprets the statements only if it is syntactically (as per the rules of Python) correct. If any syntax error is present, the interpreter shows error message(s) and stops the execution there. For example, parentheses must be in pairs, so the expression (10 + 12) is syntactically correct, whereas (7 + 11 is not due to absence of right parenthesis. Such errors need to be removed before the execution of the program 5.13.2 Logical Errors Logical errors are also called semantic errors as they occur when the meaning of the program (its semantics) is not correct. For example, if we wish to find the average of two numbers 10 and 12 and we write the code as 10 + 12/2, it would run successfully and produce the result 16. Surely, 16 is not the average of 10 and 12. The correct code to find the average should have been (10 + 12)/2 to give the correct output as 11. 5.13.3 Runtime Error A runtime error causes abnormal termination of program while it is executing. Runtime error is when the statement is correct syntactically, but the interpreter cannot execute it. Runtime errors do not appear until after the program starts running or executing. Program Example of a program which generates runtime error. #Runtime Errors Example num1 = 10.0 S.NO TOPIC Introduction , Steps for Problem Solving , Algorithm , , Representation of Algorithms Flow of Control , Verifying Algorithms , Comparison of Algorithm , Coding , Decomposition 1. INTRODUCTION Computers are used for solving various day-to-day problems. It is pertinent to mention that computers themselves cannot solve a problem. Precise step-by-step instructions should be given by us to solve the problem. Thus, the success of a computer in solving a problem depends on how correctly and precisely we define the problem, design a solution (algorithm) and implement the solution (program) using a programming language. Thus, problem solving is the process of identifying a problem, developing an algorithm for the identified problem and finally implementing the algorithm to develop a computer program. 2. Steps for Problem Solving There are four steps in problem solving Analysing the problem Developing an Algorithm Coding Testing and Debugging 2.1 Analysing the problem It is important to clearly understand a problem before we begin to find the solution for it. If we are not clear as to what is to be solved, we may end up developing a program which may not solve our purpose. By analysing a problem, we would be able to figure out what are the inputs that our program should accept and the outputs that it should produce. 2.2 Developing an Algorithm The solution for a problem is represented in step by step procedure called an algorithm. For a given problem, more than one algorithm is possible and we have to select the most suitable solution. 2.3 Coding After finalising the algorithm, we need to convert the algorithm into the format which can be understood by the computer to generate the desired solution. 2.4 Testing and Debugging The program created should be tested on various parameters. The program should meet the requirements of the user. In the presence of syntactical errors, no output will be obtained. In case the output generated is incorrect, then the program should be checked for logical errors, if any. 3. Algorithm Algorithm is the step by step procedure for solving the problem. Suppose following are the steps required for an activity ‘riding a bicycle’: remove the bicycle from the stand, sit on the seat of the bicycle, start peddling, use breaks whenever needed and stop on reaching the destination. Example: Algorithm to find square of a number. Step 1: Input a number and store it to num Step 2: Compute num * num and store it in square Step 3: Print square 3.1 Why do we need an Algorithm Writing an algorithm is mostly considered as a first step to programming. Once we have an algorithm to solve a problem, we can write the computer program for giving instructions to the computer in high level language. If the algorithm is correct, computer will run the program correctly, every time. So, the purpose of using an algorithm is to increase the reliability, accuracy and efficiency of obtaining solutions. Characteristics of a good algorithm • Precision — the steps are precisely stated or defined. • Uniqueness — results of each step are uniquely defined and only depend on the input and the result of the preceding steps. • Finiteness — the algorithm always stops after a finite number of steps. • Input — the algorithm receives some input. • Output — the algorithm produces some output. While writing an algorithm, it is required to clearly identify the following: • The input to be taken from the user • Processing or computation to be performed to get the desired result • The output desired by the user 4. Representation of Algorithms There are two common methods of representing an algorithm —flowchart and pseudocode. Either of the methods can be used to represent an algorithm while keeping in mind the following: • it showcases the logic of the problem solution, excluding any implementational details • it clearly reveals the flow of control during execution of the program 4.1 Flowchart — Visual Representation of Algorithms A flowchart is a visual representation of an algorithm. A flowchart is a diagram made up of boxes, diamonds and other shapes, connected by arrows. Symbols Functions Descriptions Start/End Also called “Terminator” symbol. It indicates where the flow starts and ends. Process Also called “Action Symbol,” it represents a process, action, or a single step. Decision A decision or branching point, usually a yes/no or true/ false question is asked, and based on the answer, the path gets split into two branches. Input/Output Also called data symbol, this parallelogram shape is used to input or output data Arrow Connector to show order of flow between shapes. Flowchart to calculate square of a number 4.2 Pseudocode A pseudocode (pronounced Soo-doh-kohd) is another way of representing an algorithm. It is considered as a non-formal language that helps programmers to write algorithm. The word “pseudo” means “not real,” so “pseudocode” means “not real code”. Following are some of the frequently used keywords while writing pseudocode: • INPUT / • COMPUTE / • PRINT / • INCREMENT / • DECREMENT / • IF/ELSE /• WHILE • TRUE/FALSE Example: Pseudocode for the sum of two numbers will be: input num1 input num2 COMPUTE Result = num1 + num2 PRINT Result 4.5 Flow of Control The flow of control depicts the flow of events as represented in the flow chart. 4.5.1 Sequence Sometimes the algorithm to either does some routine tasks in a repeated manner or behave differently depending on the outcomes of previous steps. The statements are executed one after another is known as sequence. 4.5.2 Selection Let us look at some other examples where decision making is dependent on certain conditions. For example, (i) Checking eligibility for voting. Depending on their age, a person will either be allowed to vote or not allowed to vote: • If age is greater than or equal to 18, the person is eligible to vote • If age is less than 18, the person is not eligible to vote (ii) Let us consider another example If a student is 8 years old and the student likes Maths put the student in Group A Otherwise Put the student in Group B Actions depending on true or false of a condition Conditionals are written in the algorithm as follows: If <condition> then steps to be taken when the condition is true/fulfilled There are situations where we also need to take action when the condition is not fulfilled (In above Figure). To represent that, we can write: If <condition> is true then steps to be taken when the condition is true/fulfilled otherwise steps to be taken when the condition is false/not fulfilled 4.6 Verifying Algorithms The software designer should make sure that the functioning of all the components are defined correctly, checked and verified in every possible way. When we were told that the formula for the sum of first N natural numbers is N(N+1) / 2 , how did we verify it? Well, we can check this for small numbers, for which we can manually calculate the sum. Let N = 6, then the sum is 1 + 2 + 3 + 4 + 5 + 6 = 21 Using formula we get sum = 6x(6+1) / 2 The method of taking an input and running through the steps of the algorithm is sometimes called dry run. Such a dry run will help us to: 1. Identify any incorrect steps in the algorithm 2. Figure out missing details or specifics in the algorithm Write an algorithm to calculate the time taken to go from place A to C (T_total) via B where time taken to go from A to B (T1) and B to C (T2) are given. That is, we want the algorithm to add time given in hours and minutes. One way to write the algorithm is: PRINT value for T1 INPUT hh1 INPUT mm1 PRINT value for T2 INPUT hh2 INPUT mm2 hh_total = hh1 + hh2 (Add hours) mm_total = mm1 + mm2 (Add mins) Print T_total as hh_total, mm_total Now let us verify. Suppose the first example we take is T1 = 5 hrs 20 mins and T2 = 7 hrs 30 mins. On dry run, we get the result 12 hrs and 50 mins. This looks fine. 4.7 Comparison of Algorithm There can be four different ways to write algorithms to check whether a given number is prime or not as shown below: (i) Starting with divisor 2, divide the given number (dividend) and check if there are any factors. Increase the divisor in each iteration and repeat the previous steps as long as divisor < dividend. If there is a factor, then the given number is not prime (ii) In (i), instead of testing all the numbers till the dividend, only test up to half of the given value (dividend) because the divisor can not be more than half of the dividend (iii) In method (i), only test up to the square root of the dividend (numbers) (iv) Given a prior list of prime number till 100, divide the given number by each number in the list. If not divisible by any number, then the number is a prime else it is not prime All these four methods can check if a given number is prime or not. Now the question is which of these methods is better or efficient? Algorithm (i) requires large number of calculations (means more processing time) as it checks for all the numbers as long as the divisor is less than the number. If the given number is large, this method will take more time to give the output. Algorithm (ii) is more efficient than (i) as it checks for divisibility till half the number, and thus it reduces the time for computation of the prime number. Algorithm (iii) is even more efficient as it checks for divisibility till square root of the number, thereby further reducing the time taken. As algorithm (iv) uses only the prime numbers smaller than the given number for divisibility, it further reduces the calculations. But in this method we require to store the list of prime numbers first. Thus it takes additional memory even though it requires lesser calculations. Hence, algorithms can be compared and analysed on the basis of the amount of processing time they need to run and the amount of memory that is needed to execute the algorithm. These are termed as time complexity and space complexity, respectively. The choice of an algorithm over another is done depending on how efficient they are in terms of processing time required (time complexity) and the memory they utilize (space complexity). 4.8 Coding Once an algorithm is finalised, it should be coded in a high-level programming language as selected by the programmer. The ordered set of instructions are written in that programming language by following its syntax. Syntax is the set of rules or grammar that governs the formulation of the statements in the language, such as spellings, order of words, punctuation, etc. 4.9 Decomposition The basic idea of solving a complex problem by decomposition is to 'decompose' or break down a complex problem into smaller sub problems Answer the Following Questions (Very Short Annswers) Define Algorithm What is decomposition? Why do we need Algorithm? What is meant by Debugging? Answer the Following Questions (Short Answers) Write an algorithm to find the greatest among two different numbers Write a pseudocode to calculate the factorial of a number Write an algorithm to fing greates among three numbers Answer the Following Questions (LongAnswers) Write pseudocode and draw flowchart to accept numbers till the user enters 0 and then find their average. Write a pseudocode and draw a flowchart where multiple conditions are checked to categorize a person as either child (<13), teenager (>=13 but <20) or adult (>=20),based on age specified: Write an algorithm that accepts four numbers as input and find the largest and smallest of them. WORKSHEETS 1. What is the difference between a keyword and an identifier? 2. How many ways are there in Python to represent an integer literal. 3. Which of the following identifier names are invalid and why? i Serial_no. v Total_Marks ii 1st_Room vi total-Marks iii Hundred$ vii _Percentage iv Total Marks viii True 4. Write logical expressions corresponding to the following statements in Python and evaluate the expressions (assuming variables num1, num2, num3, first, middle, last are already having meaningful values): a) The sum of 20 and –10 is less than 12. b) num3 is not more than 24 c) 6.75 is between the values of integers num1 and num2. d) The string ‘middle’ is larger than the string ‘first’ and smaller than the string ‘last’ e) List Stationery is empty 5. Add a pair of parentheses to each expression so that it evaluates to True. a) 0 == 1 == 2 b) 2 + 3 == 4 + 5 == 7 c) 1 < -1 == 3 > 4 6. Write the output of the following. a) num1 = 4 num2 = num1 + 1 num1 = 2 print (num1, num2) b) num1, num2 = 2, 6 num1, num2 = num2, num1 + 2 print (num1, num2) c) num1, num2 = 2, 3 num3, num2 = num1, num3 + 1 print (num1, num2, num3) 7. Give the output of the following when num1 = 4, num2 = 3, num3 = 2 a) num1 += num2 + num3 print (num1) b) num1 = num1 ** (num2 + num3) print (num1) c) num1 **= num2 + num3 d) num1 = '5' + '5' print(num1) e) print(4.00/(2.0+2.0)) f) num1 = 2+9*((3*12)-8)/10 print(num1) g) num1 = 24 // 4 // 2 print(num1) h) num1 = float(10) print (num1) i) num1 = int('3.14') print (num1) j) print('Bye' == 'BYE') k) print(10 != 9 and 20 >= 20) l) print(10 + 6 * 2 ** 2 != 9//4 -3 and 29>= 29/9) m) print(5 % 10 + 10 < 50 and 29 <= 29) n) print((0 < 6) or (not (10 == 6) and (10<0))) 8. Categorize the following as syntax error, logical error or runtime error: a) 25 / 0 b) num1 = 25; num2 = 0; num1 / num2 9. Write a Python program to convert temperature in degree Celsius to degree Fahrenheit. If water boils at 100 degree C and freezes as 0 degree C, use the program to find out what is the boiling point and freezing point of water on the Fahrenheit scale. (Hint: T(°F) = T(°C) × 9/5 + 32) 10. Write a Python program to calculate the amount payable if money has been lent on simple interest. Principal or money lent = P, Rate of interest = R% per annum and Time = T years. Then Simple Interest (SI) = (P x R x T)/ 100. Amount payable = Principal + SI. P, R and T are given as input to the program. 11. Write a program to enter two integers and perform all arithmetic operations on them. 12. Write a program to swap two numbers without using a third variable. ANSWER KEY QUESTION 1 Keyword is a special word that has a special meaning and purpose. Keywords are reserved and are few. For example : if, else, elif etc. Identifier is the user-defined name given to a part of a program like variable, object, functions etc. Identifiers are not reserverd. These are defined by the user but they can have letters, digits and a symbols underscore. They must begin with either a letter or underscore. For example : chess, _ch, etc. QUESTION 2 Python allows three types of integer literals : 1. Decimal (base 10) integer literals. 2. Octal (base 8) integer literals. 3. Hexadecimal (base 16) integer literals. For example, decimal 12 will be written as 14 as octal integer and as OXC as hexa decimal integer. (12)10 = (14)8 = (OXC)16. (as hexa decimal) QUESTION 3 i) Serial_no.: Invalid - Identifier in python cannot contain any special character except underscore(_). ii) 1st_Room: Invalid - Identifier in Python cannot start with a number. iii) Hundred$: Invalid - Identifier in Python cannot contain any special character except underscore(_). iv) Total Marks: Invalid - Identifier in Python cannot contain any special character except underscore(_). If more than one word is used as a variable then it can be separated using underscore ( _ ), instead of space. v) Total_Marks: Valid vi) total-Marks: Invalid - Identifier in Python cannot contain any special character except underscore(_). If more than one word is used as a variable then it can be separated using underscore ( _ ), instead of a hyphen ( - ). vii) _Percentage: Valid viii) True: Invalid - Identifier in Python should not be a reserved keyword. QUESTION 4 a) (20 + (-10)) < 12 b) num3 <= 24 or not(num3 > 24) c) (6.75 >= num1) and (6.75 <= num2) d) (middle > first) and (middle < last) e) len(Stationery) == 0 QUESTION 5 a) ( 0 == (1==2)) b) (2 + (3 == 4) + 5) == 7 c) (1 < -1) == (3 > 4 ) QUESTION 6 a) 2, 5 b) 6, 4 c) Error as num3 is used in RHS of line 2 (num3, num2 = num1, num3 + 1) before defining it earlier. QUESTION 7 a) num1 += 3 + 2 The above statement can be written as num1 = num1 + 3 + 2 = 4 + 3 + 2 = 9 Therefore, print(num1) will give the output 9. b) num1 = num1 ** (num2 + num3) The above statement will be executed as per the following steps. num1 = 4 ** (3 + 5) = 4 ** 5 = 1024 Therefore, print(num1) will give the output 1024. c) num1 **= num2 + num3 The above statement can be written as num1 **= 5 num1 = num1 ** 5 num1 = 4 ** 5 num1 = 1024 Therefore, the output will be 1024. d) num1 = '5' + '5' The RHS in the above statement is '5' + '5'. Please note that 5 is enclosed in quotes and hence will be treated as a string. Therefore, the first line is just a string concatenation which will give the output 55. The type of output will be a string, not an integer. e) print(4.00/(2.0 + 2.0)) The numbers written in the statement are in float data type therefore, the output will be also in float data type. print(4.00/(2.0 + 2.0)) print(4.0/4.0) 1.0 Therefore, the output will be 1.0. f) num1 = 2 + 9 * ((3 * 12) - 8) /10 # The expression within inner brackets will be evaluated first num1 = 2 + 9 * (36 - 8) /10 # The expression within outer brackets will be evaluated next num1 = 2 + 9 * 28/10 # * and / are of same precedence, hence, left to right order is followed num1 = 2 + 252/10 num1 = 2 + 25.2 num1 = 27.2 Therefore, the output will be 27.2. g) num1 = 24 // 4 // 2 #When the operators are same, left to right order will be followed for operation num1 = 6 // 2 #When floor division is used, return value will be int data type num1 = 3 Therefore, the output will be 3 h) num1 = float(10) float(10) will convert integer value to float value and therefore, the output will be 10.0. i) num1 = int('3.14') This will result in an error as we cannot pass string representation of float to an int function. j) print('Bye' == 'BYE') As Python compares string character to character and when different characters are found then their Unicode value is compared. The character with lower Unicode value is considered to be smaller. Here, 'y' has Unicode 121 and 'Y' has 89. Therefore, the output will be 'False'. k) print(10 != 9 and 20 >= 20) print(True and True) print(True) Therefore, the output will be 'True'. l) print(10 + 6 * 2 ** 2 != 9//4 -3 and 29>= 29/9) Taking the above statement in two separate parts LHS: 10 + 6 * 2 ** 2 != 9//4 - 3 10 + 6 * 4 != 2 - 3 10 + 24 != -1 34 != -1 True RHS: 29 >= 29/9 True Now the complete equation can be written as print(True and True) Therefore, the output will be 'True'. m) print(5 % 10 + 10 < 50 and 29 <= 29) Taking the above statement in two separate parts LHS : 5 % 10 + 10 < 50 5 + 10 < 50 15 < 50 True RHS: 29 <= 29 True Now, the complete equation can be written as print(True and True) Therefore, the output will be 'True'. n) print( (0 < 6) or (not (10 == 6) and (10<0) ) ) print(True or (not False and False)) print(True or (True and False)) # not will be evaluated before and/or. print(True or False) print(True) Therefore, the output will be 'True'. QUESTION 8 a) Runtime Error. The syntax for the division is correct. The error will arise only when 'interpreter' will run this line. b) Runtime Error. The syntax is correct. The error will arise only when 'interpreter' will run the line containing these statements. QUESTION 9 #defining the boiling and freezing temp in celcius boil = 100 freeze = 0 print('Water Boiling temperature in Fahrenheit::') #Calculating Boiling temperature in Fahrenheit tb = boil * (9/5) + 32 #Printing the temperature print(tb) print('Water Freezing temperature in Fahrenheit::') #Calculating Boiling temperature in Fahrenheit tf = freeze * (9/5) + 32 #Printing the temperature print(tf) OUTPUT: Water Boiling temperature in Fahrenheit:: 212.0 Water Freezing temperature in Fahrenheit:: 32.0 QUESTION 10 #Asking the user for Principal, rate of interest and time P = float(input('Enter the principal: ')) R = float(input('Enter the rate of interest per annum: ')) T = float(input('Enter the time in years: ')) #calculating simple interest SI = (P * R * T)/100 #caculating amount = Simple Interest + Principal amount = SI + P #Printing the total amount print('Total amount:',amount) OUTPUT:Enter the principal: 12500 Enter the rate of interest per annum: 4.5 Enter the time in years: 4 Total amount: 14750.0 QUESTION 11 #Program to input two numbers and performing all arithmetic operations #Input first number num1 = int(input("Enter first number: ")) #Input Second number num2 = int(input("Enter second number: ")) #Printing the result for all arithmetic operations print("Results:-") print("Addition: ",num1+num2) print("Subtraction: ",num1-num2) print("Multiplication: ",num1*num2) print("Division: ",num1/num2) print("Modulus: ", num1%num2) print("Floor Division: ",num1//num2) print("Exponentiation: ",num1 ** num2) OUTPUT: Enter first number: 8 Enter second number: 3 Results:Addition: 11 Subtraction: 5 Multiplication: 24 Division: 2.6666666666666665 Modulus: 2 Floor Division: 2 Exponentiation: 512 QUESTION 12 #defining two variables x=5 y=6 #printing the values before swapping print("The values of x and y are",x,"and",y,"respectively.") # Using 'multiple assignment' to swap the values x,y = y,x #printing the values after swapping print("The values of x and y after swapping are",x,"and",y,"respectively.") OUTPUT: The values of x and y are 5 and 6 respectively. The values of x and y after swapping are 6 and 5 respectively. SR NO QUESTIONS The physical and tangible electronic components of a computer system are known as _______. (Ans. Hardware) The programs which provide commands to work upon and govern the working on the computer is known as _______. (Ans. Software) Which of the following function(s) does not require the user’s involvement – Input, Process, Output, Storage (Ans. Process, Output, Storage) The ________ of CPU is responsible for supervising the requests received 1 from CPU. (Ans. CU) Which part of the CPU carries out the arithmetic instructions and logical comparison to complete the task? (Ans. ALU) The computer follows the IPO cycle that refers to Input-PerformanceOutput. (True/False) The small units of data storage hold the places of data in the CPU is _______. (Ans. Register) When the power is turned off, data will be lost. This is known as _________. (Ans. Volatility) The ______ is volatile memory where ________ non-volatile memory. (Ans. RAM, ROM) The PROM is call _______, which stands for One Time Programmable memory. (Ans. OTP) The EPROM can take _______ minutes for erasing contents written on them. (Ans. 20) SRAM is faster memory than DRAM. (True/Fast) The ________ memory is high-speed memory available inside CPU to speed up access to data and instructions stored in RAM. (Ans. Cache) The ________ is mobile system I/O unit. (Ans. Communications Process Unit) The Application Processing Unit (APU) is responsible for governing, and controlling all the common tasks on mobile systems. (True/False) The output carried out from the mobile system using _____________ systems. (Ans. Display) The mobile system doesn’t have RAM and ROM. (True/False) The external storage of mobile systems are known as ____________ storage. (Ans. Expandable) The battery in the mobile system is known as ________. (Ans. Power Management System) The software that controls the internal operations of a computer is known as _______ software. (Ans. System) The program code written by the user is known as _________. (Ans. Source Code) The converted code into machine-readable form is known as ________ code. (Ans. Object) Which language processor executes the program line-by-line? (Ans. Interpreter) Which language process executes the whole program in one go? (Ans. Compiler) The set of some basic applications are provided by _____ type for application software. (Ans. Packages) The software made to fulfill users need is known as ________ software. (Ans. Tailor-made) The pre-written code that can be used to develop applications are known as _______. (Ans. Libraries) The software provided in Operating Systems to assist the user is known as _______. (Ans. Utilities) Notepad is a very popular package for documentation. (True/False) The _______ software rearranges the files in the computers and cleans up the memory. (Ans. Disk defragmenter) Lalit is a game programmer and he is designing a game where he has to use different python functions as much as possible. Apart from other things, following functionalities are to be implemented in the game. (1) He is simulating a dice where random number generation is required. (2) Since the program becomes too lengthy, Lalit wants a separate section 2 where he can store all the functions used in the game program. Lalit is feeling difficulty in implementing the above functionalities. Help him by giving answers following questions: i) To implement functionality (1) which module can be used: a) random b) randomise c) randint d) math ii) In functionality (2), Lalit should use a) in-built functions b) He should write another Python program c) He should use a module with all the required functions d) He should make a separate section in the same Python program One student who is learning Python, is making a function-based program to find the roots of a quadratic equation. He wrote the program but he is getting some error. Help him to complete the task successfully: from ……… import sqrt LINE-1 Def quad(b,c,a=1): LINE-2 x = b*b-4*a*c 4 LINE-3 if x < 0: LINE-4 return “Sorry,complex root(s)” LINE-5 d = sqrt(x) LINE-6 r1 = (-b + d)/(2*a) LINE-7 r2 = (-b – d)/(2*a) LINE-8 3 return r1,r2 LINE-9 print(quad(1,1,2)) LINE-10 root = quad(3) LINE-11 rt = quad(2,1) LINE-12 i) Which python module should be used in line 1 a) random b) CMath c) math d) Either (b) or (c) ii) Which statement is correct with reference to above program? a) Two return statements are used and a function can use only one return statement b) Required module is not given c) Syntax error in line 4 d) Error in line 11 What gets printed with the following code ? x = True y = False z = False if not x or y : print 1 elif not x or not y and z: 4 print 2 elif not x or y or not y and x: print 3 else: print 4 Answer: 3 Which numbers are printed? for i in range(2): print i for i in range(4,6): 5 print i Answer: 0,1 4, 5 What gets printed? country_counter = {} def addone(country): if country in country_counter: country_counter[country] + = 1 else: 6 country_counter[country] = 1 addone(‘China’) addone(‘Japan’) addone(‘china’) print len(country_counter) Answer: 3 What gets printed? namesl = [‘Amir’, ‘Barry’, ‘Chales’, ‘Dao’] if ‘amir’ in namesl: 7 print 1 else: print 2 Answer: 2 Start with the list[8,9,10]. Do the following using list functions (a) Set the second entry (index 1) to 17 8 (b) Add 4, 5 and 6 to the end of the list. (c) Remove the first entry from the list. (d) Sort the list. (e) Double the list. (f) Insert 25 at index 3 answer (a) list[1]=17 (b) list.append(4) list.append(5) list.append(6) (c) list.pop(0) (d) list.sort() (e) list=list*2 (f) list.insert(3,25) Find out the output generated by following code fragments: (a) plane = (“Passengers”, ”Luggage”) plane [1] = “Snakes” (b) (a, b, c) = (1,2,3) (c) (a, b, c, d) = (1,2,3) (d) a, b, c, d = (1,2,3) (e) a, b, c, d, e = (p, q, r, s, t) = t1 9 answer: (a) TypeError: 'tuple' object does not support item assignment (b) This will assign 1 to a, 2 to b and 3 to c. (c) ValueError: not enough values to unpack (expected 4, got 3) (d) ValueError: not enough values to unpack (expected 4, got 3) (e) If tuple t1 has 5 values then this will assign first value of t1 in to a and p , next value to b and q and so on. What is Authentication and Authorization? Why are these two used together? 10 Difference between Authentication and Authorization. Both the terms are often used in conjunction with each other in terms of security, especially when it comes to gaining access to the system. Authentication means confirming your own identity, while authorization means granting access to the system. FLOW OF CONTROL CONTENT – REVIEW Flow control statements are used to control the flow of execution depending upon the specified condition/logic. Sequential Flow of control - Sequential execution is when statements are executed one after another in order. We don't need to do anything more for this to happen as python compiler itself do it. There are three types of control statements. 1. Selection Statements 2. Iteration Statements (Loop control statement) 3. Jump Statements (break, continue, pass) Selection statement These are used to selectively execute some statements and control the flow of execution of program depending upon condition. There are three types of decision making statement. 1. if statements 2. if-else statements 3. if elif statement Simple if: The statement inside the if block are executed only when condition is true, otherwise not. Syntax if <condition>: Statement(s) Example: if a < b : print(‘a is greater’) if-else statement The statements inside the if block are executed only when condition is true, otherwise the statements in the else block are executed. Syntax if <condition>: Statement(s) else: statements Example: if a < b : print(‘a is greater’) else: print(‘b is greater’) if elif statement The if...elif...else statement allows you to check for multiple test expressions and execute different codes for more than two conditions. print('****program to find greatest of 3 numbers****') num1,num2,num3=eval(input('enter 3 unique numbers: ')) if num1 > num2 and num1 > num3: print('The greatest of the three nos. is : ',num1) elif num2 > num3 and num2 > num1: print('The greatest of the three nos. is : ',num2) elif num3 > num1 and num3 > num2: print('The greatest of the three nos. is :',num3) else: print('any two nos are equal') Nested if-else Statements #Check leap year / divisibility year = int(input("Enter a year: ")) if (year % 4) == 0: if (year % 100) == 0: if (year % 400) == 0: print("{0} is a leap year".format(year)) else: print("{0} is not a leap year".format(year)) Iteration statements(loop) These are used to execute a block of statements as long as the condition is true. Loops statements are used when we need to run same code again and again. Python Iteration (Loops) statements are of two type :1. While Loop 2. For Loop While Loop It is used to execute a block of statement if a given condition is true. And when the condition become false, the control will come out of the loop. The condition is checked every time at the beginning of the loop. Syntax while (condition): [statements] Counter=0 #initiation stmt while Counter < 5: #test condition print(Counter) Counter += 2 #increment stmt OUTPUT: 0 2 4 Loop For It is used to iterate over items of any sequence, such as a list or a string. Syntax for val in sequence: #here val will take value of each element in the sequence statements Example: for I in [1,2,3,4,5]: print(I*5) OUTPUT: 5 10 15 20 25 range() Function This function generates a sequence of numbers based on the parameters passed. 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. Python use range() function in three ways: a. range(stop) b. range(start,stop) c. range(start,stop,step) Note: All parameters must be integers. All parameters can be positive or negative. a. range(stop): By default, It starts from 0 and increments by 1 and ends upto stop, but not including stop value. Example: for x in range(4): print(x) Output: 0 1 2 3 b. range(start,stop) : It starts from the start value and upto stop, but not including stop value. c. range(start, stop, step): Third parameter specifies to increment or decrement the value by adding or subtracting the value. Use with for loop: for i in range(1,5): for i in range(5,3,-1): print(i) print(i) OUTPUT: Output 1 5 2 4 3 4 Jump Statements Jump statements are used to transfer the program's control from one location to another. Means these are used to alter the flow of a loop like - to skip a part of a loop or terminate a loop There are three types of jump statements used in python. 1.break / 2.continue / 3.pass Break It is used to terminate the loop. e.g. for val in "string": if val == "i": break print(val) print("The end") Output str The end Continue • Used to skip the rest of the statements of the current loop block and to move to next iteration, of the loop. • Continue will return back the control to the beginning of the loop. • Can be used with both while & for. Eg: for letter in ‘Python’: if letter == ‘h’: continue print (letter) Output Pyton Pass Statement This statement does nothing. It can be used when a statement is required syntactically but the program requires no action. Use in loop : while True: pass # Busy-wait for keyboard interrupt (Ctrl+C) WORKSHEETS Sr no Q1 Question Can we write if/else into one line in python? a) Yes b) No c) if/else not used in python d) None of the above Q2 Which one of the following is a valid Python if statement. a) if a>=2 : b) if (a >= 2) c) if (a => 22) d) if a >= 22 Q3 What keyword would you use to add an alternative condition to an if statement? a) else if b) elseif c) elif d) None of the above Q4 What will be the data type of the var in the below code snippet? var = 10 print(type(var)) var = "Hello" print(type(var)) a) int and str b) int and int c) str and str d) float and str d)Q5 How is a code block indicated in Python? a) Brackets b) Indentation c) Key d) None of the above Q6 What will be the output of the following code snippet? a = [1, 2, 3] a = tuple(a) a[0] = 2 print(a) a) [1,2,3] b) (1,2,3) c) [2,2,3] d) error Q7 What will be the output of the following code snippet? print(type(5 / 2)) print(type(5 // 2)) a) int and int b) str and str c) int and float d) float and int Q8 What will be the output of the following Python code? x = [ 'ab' , 'cd' ] for I in x: i. upper() print ( x ) a) [ ‘ab’, ‘cd’ ] b) [‘AB’, ‘CD’] c) [None, None] d) none of the mentioned What will be the output of the following Python code? i=5 Q9 while True: if i%0O11 == 0: break print(i) i += 1 a) 5 6 7 8 9 10 b) 5678 c) 56 d) error Q10 What will be the output of the following Python code? i = 1 while True: if i%3 == 0: break print(i) i+=1 a) 1 2 b) 1 2 3 c) error d) none of the mentioned 1 Find the output of the following program segments: I. a = 10 while a > 2: print (a) a -= 2 II. for i in range (20, 30, 2): print (i) III. var = 7 while var > 0: print (“current variable value: ” , var) var = var – 1 if var == 3: break else: if var == 6: var = var – 1 continue print (“Good bye!”) 2 Write a Python program to find the factorial of a positive number Q6) What are the four elements of a while loop in Python? 3 What are endless loops ? Why do such loops occur? Give example. 4 Draw flowchart for displaying first 10 odd numbers. 5 What is a flowchart? How is it useful? 6 What is empty statement in Python? What is its need? 7 Write a program to check whether a years is leap year or not. 8 Write a program to check a character is vowel or not. COMPETENCY BASED SECTION A: MCQ 1.The first line of Python code can’t have an indentation. Say True or False Ans: True 2. Which of the following expression is not allowed in if statement a) arithmetic expression b) relational expression c) logical expression d) none Ans: a. 3. x=[ ‘P’ , ‘ y’ , ‘t’ , ‘h’ , ‘o’ , ‘n’ ] for i in x: print(i,end=’’) `a) P b) python c) P y t h o n d) PYTHON Ans: c 4. Function range(3) is equivalent to : a) range(1,3) b) range(0,3) c) range(0,3,1) d) range(1,3,0) Ans: b or c 5. The else block of a loop will not get executed if a ……….statement has terminated the loop. Ans: break 6. The range() function can only be used in ……… loops Ans: for 7. The in and not in operators are also called as …………. Ans: membership operators 8. For a while loop, an equivalent for loop can always be written. Say True or False. Ans: False 9. The range() function generates a sequence of …………type Ans: list 10. for is a ……. loop whereas while is a ……….loop Ans: counting, conditional SECTION B : 2 marks question: 1) Define pass statement. 2) What is the difference between elif and else construct of if statement? 3) Write the equivalent while loop for the following for loop n=20 for i in [1,10]: n+=i 4) What is the output for the following code? i=1 while(i<=7): i*=2 print(i) 5) What is the output of the following loop? for a in[1,4,7]: print(a) print(a*a) FUNCTION - MODULES CONTENT – REVIEW TOPIC: FUNCTIONS One of the main advantages of Python is the availability of a vast library of modules that can be used for different purposes. A module is a logical organization of Python code. Related code are grouped into a module which makes the code easier to understand and use. Any python module is an object with different attributes which can be bind and referenced. Python programs can get access to code from another python module by importing the file/function using import. The import statement is the most common way of invoking the import machinery There are three ways to access the code of other built-in/user defined modules using import • import module_name • from module_name import function_name/constant/object • from module_name import * import module_name EXAMPLE import math print(math.pi) # this searches for the module and links the module code to the module name in local scope. #The module objects need to be prefixed with the module name to ensure name resolution. from module_name import * EXAMPLE: from math import * print(pi) #this searches for the module and copies all the contents of the module into the global memory of the importing program. from module_name import function_name/constant/object from math import pi print(pi) #this searches for the module and copies only the specific objects/methods into memory of the importing program, thus reducing memory usage. math Module Python has a built-in module that you can use for mathematical tasks. The math module has a set of methods and constants. Some of the important ones are: Method Description math.ceil() Rounds a number up to the nearest integer math.cos() Returns the cosine of a number math.fabs() Returns the absolute value of a number math.factorial() Returns the factorial of a number math.floor() Rounds a number down to the nearest integer math.pow() Returns the value of x to the power of y math.prod() Returns the product of all the elements in an iterable Returns the closest value that can make numerator completely math.remainder() divisible by the denominator math.sin() Returns the sine of a number math.sqrt() Returns the square root of a number math.tan() Returns the tangent of a number math.trunc() Returns the truncated integer parts of a number Math Constants Constant Description Returns math.e Euler's number (2.7182...) Returns a floating-point positive math.inf infinity Returns a floating-point NaN math.nan (Not a Number) value math.pi Returns PI (3.1415...) math.tau Returns tau (6.2831...) Random Module Python has a built-in module that you can use to make random numbers. Some of the methods in the random module are: Method Description Returns a random number between the given randrange() range Returns a random number between the given randint() range Takes a sequence and returns the sequence in a shuffle() random order random() Returns a random float number between 0 and 1 Returns a random float number between two uniform() given parameters Statistics module Python has a built-in module that you can use to calculate mathematical statistics of numeric data. Method Description Calculates the harmonic mean (central location) of statistics.harmonic_mean() the given data statistics.mean() Calculates the mean (average) of the given data Calculates the median (middle value) of the given statistics.median() data statistics.median_grouped() Calculates the median of grouped continuous data statistics.median_high() Calculates the high median of the given data statistics.median_low() Calculates the low median of the given data Calculates the mode (central tendency) of the given statistics.mode() numeric or nominal data Calculates the standard deviation from an entire statistics.pstdev() population Calculates the standard deviation from a sample of statistics.stdev() data statistics.pvariance() Calculates the variance of an entire population statistics.variance() Calculates the variance from a sample of data WORKSHEETS SL NO 1 2 3 4 5 6 7 8 9 10 QUESTION Predict the output: from math import * x=10 y=pi * sqrt(pow(x,4)) Identify the errors and correct them: Import math Y=25 S=sqrt(Y) print(S) Predict the output: import math num=90.23 print(math.ceil(num)) print(math.floor(num)) Predict the output: (What are the possible values?) import random print(random.random(5)) Predict the output: li=[1,2,3,4,5,6,7,8,9,10] from statistics import * print(mean(li)) print(median(li)) Identify the errors and correct them: li=[1,2,3,4,5,6,7,8,9,10] from statistics import * print(li.mean()) print(statistics.median(li)) Predict the output: (What are the possible values?) import random print(random.randint(5,10)) Predict the output: (What are the possible values?) import random print(random.randrange(10,20,2)) Write program to find square root of a function using math module Predict the output: li=[1,2,3,4,4,4,4,4,4,5,5,5,5,5,6,7,8,8,8,8,9,10] from statistics import * print(mode(li)) STRINGS CONTENT – REVIEW WORKSHEETS CLASS: XI (LEVEL 1) 1. If first= “FIRE STOP” with string values then what will be the output of first[3] and first[6]. 2. Write the name of membership operators used for string data type. 3. What will be the result of following expression: a. len(“Papaya”) b. “Co” in “country c. “divya”>”Divya 4. Evaluate following expressions for given string : string1=”My work” a. string1[3:6] b. string1[: : 2] c. string1*2 5. Write differences between upper() and isupper() functions. 6. Asha is using Python idle and try to capitalize first character of each word and using following code: address= “ ram sita radha riya” address.upper() But all the characters changed in uppercase , so suggest her the built in function name which can fulfill her requirements. 7. Which of the following operator is used for concatenation of two strings? a. - b. * c. + d. / 8. Which function will remove leading space from the given string? 9. Find out the errors and write the correct code : a= “hello” b=a* ”2” c=a+b 10. Write a program which can check whether the given character is uppercase or lowercase letter CLASS: XI (LEVEL 2) 1. Which of the following function is used for checking whether the given value is number or not: a. isalpha() b. isdigit() c. isalnum() d. None of the above 2. How is capitalize() function different from upper() function? 3. What will be the output of following code: str= “Hello India” p=2 * str + 2* “wow” print(p) 4. Write down the output after performing given function: a. ”Very good”.title() b. “ Bye Bye”.rstrip() c. “favourite.index(‘u’) 5. What is the use of endswith() function? 6. Pooja is writing a program for entering mobile number of her friends and try to check whether the given input is number and writing following code: a= int(input(“enter phone no.”)) If a.isalnum()==True: print(“valid number”) else: print(“not valid”) So suggest her the correct function for getting her desired output and write correct code. 7. Find out the error in the given code and write the reason : name=”priyanshi” name[4]=a 8. Write the difference between endswith() and endswith() 9. Define slicing and explain with examples. 10.Write a program which replaces all vowels in the string with ’*’ . WORKSHEET FOR COMPUTER SCIENCE CLASS: XI (LEVEL 3) 1. What is the use of join () function and write one example? 2. Write the output of following code: first=” Programming Language Learning work” first.partition(“Language”) 3. What is the difference between join and partition? 4. Evaluate the following expression : a. “$$”.join(“My”, “Godness”) b. “No need “.rstrip() c. “Going For walk”.split(“ “) 5. Find the output of following statements: str1= “Interesting” print(str1[2:7]) print(str1[-1:-5:-1]) print(str1[: : 2]) print(str1[-5:0:1]) 6. Function………………… raises an exception if the substring is not found. 7. s= ‘ ‘ (single space).Then s.isalnum() will return . a. True b. False c. Error d. None 8. Ravi wanted to search the index of the word “work” in his program and wrote the following code in Python but it produced a value error. He did not understand what was wrong with the code . “My School work”.index(“ Work”) Suggest him the code(other function name) which will not produce errors. 9. Write a program to input a string and calculate the length of each word present in string and print length along with the word. 10.a Write a program to input a string and print the total number of uppercase and lowercase letters in a given string. COMPETENCY BASED CASE BASED QUESTIONS 1. Asha is using Python idle and try to capitalize first character of each word and using following code: address= “ ram sita radha riya” address.upper() But all the characters changed in uppercase , so suggest her the built in function name which can fulfill her requirements. 2. Pooja is writing a program for entering mobile number of her friends and try to check whether the given input is number and writing following code: a= int(input(“enter phone no.”)) If a.isalnum()==True: print(“valid number”) else: print(“not valid”) So suggest her the correct function for getting her desired output and write correct code. 3. Ravi wanted to search the index of the word “work” in his program and wrote the following code in Python but it produced a value error. He did not understand what was wrong with the code . “My School work”.index(“ Work”) Suggest him the code(other function name) which will not produce errors. COMPETENCY BASED QUESTION 1. Write a program to input a string and calculate the length of each word present in string and print length along with the word. 2. Write a program to input a string and print the total number of uppercase and lowercase letters in a given string. 3. A string is given of three or more words, now the task is to write a Python program to check whether a specific word is present in that given string. 4. program to read a string and display it in reverse order- display one character per line. FLASH CARDS LISTS MANIPULATION CONTENT – REVIEW WORKSHEETS CLASS: XI - List (LEVEL 1) 1. If L= [15, 25, 30, 5, 10, ‘python’, ‘program’] then what will be the output of L[5] and L[2]. 2. Why are lists called mutable types? 3. Write the name of the joining operator used for list data type. 4. Evaluate following expressions for given list: a = [5, 4, 3, 10, 6] i. a[0] ii. a[-2] iii. a[2:5] 5. What will be the result of following expression: L=[20, 3, 5, 11, 15] a. len(L) b. L + “abc” c. L * 3 6. What is the difference between pop( ) and remove( ) method. 7. Which of the following operator is used for replicating a list? a. - b. * c. + d. / 8. Which function will return the smallest element from a list? 9. Find out the errors and write the correct code : a=[5, 6, 3, 4, 1] b=a* ”3” c=a+b 10. Write a program to find the largest and smallest number in a list. CLASS: XI - List (LEVEL 2) 1. List can contain values of these types: a. integers b. float c. lists d. all of these 2. Which of the following function is used to add an element at the end of the list. a. extend() b. append() c. insert() d. None of the above 3. How to create a mixed data type list? 4. What will be the output of following code: L=[3, 5, 1, 10, 2] L.append(55) print(L) 5. Write down the output after performing given function: X = [5, 10, ‘python’, ‘XI’, 5.6] a. X[X[0]] b. X[-1 : -5] c. X.insert(3, 99) 6. What is the use of the clear( ) function? 7. What will be the output of the following statements? i) list1 = [12,32,65,26,80,10] list1.sort( ) print(list1) ii) list1 = [12,32,65,26,80,10] sorted(list1) print(list1) iii)list1 = [1,2,3,4,5,6,7,8,9,10] list1[::-2] list1[:3] + list1[3:] iv)list1 = [1,2,3,4,5] list1[len(list1)-1] 8. Find out the error in the given code and write the reason : sub=[‘eng’, ‘cs’, ‘ip’, ‘maths’, ‘che’] sub + ‘phy’ 9. Write the difference between sort( ) and sorted( ) functions. 10.Define slicing and explain with examples. 11.Write a program to input a list and an element, and remove all occurrences of the given element from the list. CLASS: XI - List (LEVEL 3) 1. What will be the output of following code: l="Welcome to Python".split() print(l) 2. What will be the output of following code: a=[[[1,2],[3,4],5],[6,7]] print(a[0][1][1] ) 3. What will be the output of following program: a=[2,1,3,5,2,4] a.remove(2) print(a) 4. Differentiate between append( ) and extend() function. 5. Write a Python Program to Find the Second Largest Number in a List . 6. What will be the output of following program: my_list = ['p', 'r', 'o', 'b', 'l', 'e', 'm'] print('p' in my_list) print('a' in my_list) print('c' not in my_list) 7. What will be the output of the following program: l=[6,12,18,24,30] for i in l: for j in range(1,i%4): print(j,'#',end='') print( ) 8. Write a Program to Print list having numbers less than 10. 9. What will be the output of the following program: 10.l=[10,20,30,40,50,60] for i in range(len(l)): if(i%2==0): print(l[i],end='#') else: print(l[i],end='@') 11.Take a list of 10 elements. Split it into middle and store the elements in two different lists. E.g.- INITIAL list : 5 10 6 12 After splitting : 5 10 6 12 3 44 1 90 25 66 3 12.What will be the output of following program: odd = [1, 9] odd.insert(1,3) print(odd) odd[2:2] = [5, 7] print(odd) 13.What will be the output of following program: list("a#b#c#d".split('#')) FLASH CARDS 25 66 44 1 90 TUPLES CONTENT – REVIEW WORKSHEETS Tuple – Worksheet L1 1. A tuple is declared as T = (12,5,6,9,8) What will be the value of sum(T)? 2. Which of the following is a Python tuple? 3. Suppose t = (1, 2, 4, 3), which of the following is incorrect? 4. State the output t=(1,2,3,4,5) print(t[1:4]) 5. What is the data type of (1)? COMPETENCY BASED 1. Write a program to input your friends name and their phone numbers, and store them as key value pair in Dictionary Perform the following operations a) Display name and phone number of all your friends b) Search for a friends name in your list , if found display their phone number c) Delete a particular friend d) Modify the phone number of an existing friend e) Display the dictionaries in sorted order of friends 2. Write a program to create a dictionary from a String which tracks down no of items a character is present in the string 3.Write a program to read email IDs of n number of students and store them in a tuple. Create two new tuples, one to store only the usernames from the email ids and second to store the domain names from the email ids. Print all three tuples at the end of the program.[Hint : you may use the function split()] 4. Write a program to print the frequency of a number accepted from the user in the given tuple. 5. Create a dictionary which contains dice combinations as( tuple) keys and the prizes awarded as values. Write a program to take lot or ask user to enter the dice combination, check in the dictionary and print appropriate message DICTIONARIES CONTENT – REVIEW Dictionary Unordered collection of items / elements. Each item has two parts - key : value A mapping between key and it’s value, separated by colon (:) Items are enclosed in {} and separated by comma. Are optimized to retrieve data using key. So key (values) should be unique. They can be integer, float, string or tuple. D[key] can be used for accessing element, also to add element in an existing dictionary. Creation- Using built - in function dict() assignment operator creates deep copy copy() creates shallow copy {} to create blank dictionary Shallow and Deep Copy Accessing Items Accessing Items… Adding an item Updating an Item Traversing Built – in Functions Built – in Functions A Sample code to find frequency of vowel letters A Sample code to draw lot WORKSHEETS I. Write Python statements to: 1. Create a dictionary which contains the name of airlines corresponding to the flight number. b. Concatenate following dictionaries to create a new one dic1={1:10, 2:20} dic2={3:30, 4:40} Expected Result : {1: 10, 2: 20, 3: 30, 4: 40} 3 Add a key to a dictionary. 4 sum all the items in a dictionary 5 Sort (ascending and descending) a dictionary by value. 6 check if a given key already exists in a dictionary 7. multiply all the items in a dictionary 8. get the maximum and minimum value in a dictionary 9 print all unique values in a dictionary 10. check a dictionary is empty or not 11. print a dictionary in table format II . What will be the output of the following code? 1. dictionary = {"Roll":9 , "Class":8, "Section":’A’, “Marks”:90} print("Roll" in dictionary) 2. b. a = {} a[1] = 6 a['1'] = 2 a[1]= a[1]+1 count = 0 for i in a: count += a[i] print(count) CYBER SAFETY / SECURITY / SOCIETY LAW AND ETHICS CONTENT – REVIEW Society, Law and Ethics Digital footprint • A digital footprint is an impact you create on the Web through your online activity, which incorporates browsing, interactions with others, and publication of content. • In other words, it can be considered as the data trail – intentional and unintentional you leave behind while you surf the Web or Internet. • Digital footprint or digital shadow refers to the trail of data left behind through the utilization of the Web or on digital devices. • The digital footprint of any person can have a positive as well as a negative impact on him. Find some of the examples of digital footprints: • Visiting Websites And Online Shopping • Online Searching • Posting on Social Media, blogs, etc. • Online Image and Video Upload • Communicating Online (Ex:- Chat, Email, etc.) • Any activity you perform Online etc. Digital Society and and Netizen • Anyone who uses digital technology along with Internet is a digital citizen or a netizen. Being a good netizen means practicing safe, ethical and legal use of digital technology. A responsible netizen must abide by net etiquettes, communication etiquettes and social media etiquettes. → Net Etiquettes: o Be Ethical o Be Respectful o Be Responsible → Communication Etiquettes : o Be Precise o Be Polite o Be Credible → Social Media Etiquettes: o Be Secure o Be Reliable Data Protection: Elements of data that can cause substantial harm, embarrassment, inconvenience and unfairness to an individual, if breached or compromised, is called sensitive data. Examples of sensitive data include biometric information, health information, financial information, or other personal documents, images or audios or videos. All over the world, each country has its own data protection policies (laws). These policies are legal documents that provide guidelines to the user on processing, storage and transmission of sensitive information. Intellectual Property Rights(IPR) Intellectuals Property refers to the inventions, literary and artistic expressions, designs and symbols, names and logos. The ownership of such concepts lies with the creator, or the holder of the intellectual property. This enables the creator or copyright owner to earn recognition or financial benefit by using their creation or invention. Intellectual Property is legally protected through copyrights, patents, trademarks,etc. Copyright: Copyright grants legal rights to creators for their original works like writing, photograph, audio recordings, video, sculptures, architectural works, computer software, and other creative works like literary and artistic work. Copyright law gives the copyright holder a set of rights that they alone can avail legally. It prevents others from copying, using or selling the work. Patent: A patent is usually granted for inventions. Unlike copyright, the inventor needs to apply (file) for patenting the invention. When a patent is granted, the owner gets an exclusive right to prevent others from using, selling, or distributing the protected invention. Trademark: Trademark includes any visual symbol, word, name, design, slogan, label, etc., that distinguishes the brand or commercial enterprise, from other brands or commercial enterprises. For example, no company other than Nike can use the Nike brand to sell shoes or clothes. Violation of IPR Violation of intellectual property right may happen in one of the following ways: Plagiarism: Presenting someone else’s idea or work as one’s own idea or work is called plagiarism. If we copy some contents from Internet, but do not mention the source or the original creator, then it is considered as an act of plagiarism. Copyright Infringement: Copyright infringement is when we use other person’s work without obtaining their permission to use or we have not paid for it, if it is being sold. Suppose we download an image from the Internet and use it in our project. But if the owner of the copyright of the image does not permit its free usage, then using such an image even after giving reference of the image in our project is a violation of copyright. Trademark Infringement: Trademark Infringement means unauthorised use of other’s trademark on products and services. An owner of a trademark may commence legal proceedings against someone who infringes its registered trademark. General Public License(GPL): GPL is primarily designed for providing public licence to a software. GNU GPL is another free software license, which provides end users the freedom to run, study, share and modify the software, besides getting regular updates. Creative Commons(CC): CC is used for all kind of creative works like websites, music, film, literature, etc. CC enables the free distribution of an otherwise copyrighted work. It is used when an author wants to give people the right to share, use and build upon a work that they have created. Apache: The Apache License is a permissive free software license written by the Apache Software Foundation (ASF). It allows users to use the software for any purpose, to distribute it, to modify it, and to distribute modified versions of the software under the terms of the license, without concern for royalties. Cyber crime: Cybercrime is a crime that involves a computer and a network. The computer may have been used to commit the crime and in many cases, it is also the target. Cybercrime may threaten a person or a nation’s security and financial health.. Hacking: An effort to attack a computer system or a private network inside a computer is known as hacking. Simply, it is unauthorized access to or control of computer network security systems with the intention of committing a crime. Hacking is the process of finding some security holes in a computer system or network in order to gain access to personal or corporate information. One example of computer hacking is the use of a password cracking technique to gain access to a computer system. The process of gaining illegal access to a computer system, or a group of computer systems, is known as hacking. This is accomplished by cracking the passwords and codes that grant access to systems. Cracking is the term used to describe the process of obtaining a password or code. The hacker is the individual who performs the hacking. Following are some of the things that can be hacked: • Single systems • Email account • A group of systems • LAN network • A website • Social media sites, etc Eavesdropping; It is the act of secretly listening to a private conversation of others without their consent. The main purpose of eavesdropping is to steal data. Phishing: • It is the way in which an authentic looking webpage or website is created to get sensitive information of users which may include their name, password, phone number, email address and bank details. • So you must look at address bar of web browser to verify the name of website where you are providing your information . Ransomware: • Ransom ware is a malware that hold data of persons at ransom. This data is encrypted and the user is unable to access his personal files or organizational files. The user has to pay a ransom price in order to get back his files and data. • Ransomware attacks can be detected using security parameters like software that can detect malicious files in the system. Most of these ransomwares are hidden files they get into the system when certain programs or software’s are being downloaded from the internet which are unsafe to the users. • Ransomwarecan be removed by using strong cyber security software system. However, certain files cannot be recovered after removing ransomwares , as these files are removed along with the ransomware. • Ransomware Attacks pose a big threat to sensitive information of a particular person ororganisation. As this information is at times sold at a very high price. It poses to be a major cybercrime and can lead to severe punishment. Preventing Cyber Crime Following points can be considered as safety measures to reduce the risk of cyber crime: ✓ Take regular backup of important data. ✓ Use an antivirus software and keep it updated always. ✓ Avoid installing pirated software. Always download software from known and secure (HTTPS) sites. ✓ Always update the system software which include the Internet browser and other application software. ✓ Do not visit or download anything from untrusted websites. ✓ Usually the browser alerts users about doubtful websites whose security certificate could not be verified; avoid visiting such sites. ✓ Use strong password for web login, and change it periodically. Do not use same password for all the websites. Use different combinations of alphanumeric characters including special characters. Ignore common words or names in password. ✓ While using someone else’s computer, don’t allow browser to save password or auto fill data, and try to browse in your private browser window. ✓ For an unknown site, do not agree to use cookies when asked for, through a Yes/No option. ✓ Perform online transaction like shopping, ticketing, and other such services only through well-known and secure sites. ✓ Always secure wireless network at home with strong password and regularly change it. Cyber Safety: The world is becoming more digital with each passing day. Along with development, comes the threat of cyber attacks. Through this blog, you will understand what is cyber safety and the various aspects of cyber safety. You will also understand how cyber safety and security are important. Cyber Safety Important: One of the prime reasons for implementing Cyber Safety is the protection of confidential data. Cyber Safety can protect these data to a great extent. These data protection go a long way, especially in cases of government-related data. Breach of such data of national importance can cause serious disturbance to the nation. Additionally, a breach of personal data would result in personal losses such as reputation damage, etc. There are high chances of an extortion threat. By giving in to the threat, there are chances of financial damages. Data privacy is important in this digital world. For example, breach of personally identifiable information (PII), intellectual property, and protected health information (PHI) would make people lose faith in the service and the possibility of recovering lost customers or building faith again is a herculean task. This is usually applicable in the sectors of hospitals and other healthcare institutions, financial service programs, and power plants. However, the most fearsome aspect of the data breach through any cyberattack is the mishandling of data.Through the following segment, you will understand the various types of cyber attacks. Based on the understanding of cyber-attacks and why cyber safety is important, you can implement cyber safety measures accordingly. Types of Cyber Attacks Malware: Malware, or malicious software, is any program or file that is harmful to a computer user. Malware includes computer viruses, worms, Trojan horses and spyware. These malicious programs can perform a variety of functions, including stealing, encrypting or deleting sensitive data, altering or hijacking core computing functions and monitoring users' computer activity without their permission. Programs officially supplied by companies can be considered malware if they secretly act against the interests of the computer user. For example, company ABC sold the rootkit, which contained a Trojan horse embedded into CDs that silently installed and concealed itself on purchasers' computers with the intention of preventing illicit copying. It also reported on users' listening habits, and unintentionally created vulnerabilities that were then exploited by unrelated malware. One strategy for protecting against malware is to prevent the malware software from gaining access to the target computer. For this reason, antivirus software, firewalls and other strategies are used to help protect against the introduction of malware, in addition to checking for the presence of malware and malicious activity and recovering from attacks. Virus: Computer virus is a type of malicious software, or malware, that spreads between computers and causes damage to data and software. Computer viruses aim to disrupt systems, cause major operational issues, and result in data loss and leakage. A key thing to know about computer viruses is that they are designed to spread across programs and systems. Computer viruses typically attach to an executable host file, which results in their viral codes executing when a file is opened. The code then spreads from the document or software it is attached to via networks, drives, file-sharing programs, or infected email attachments. Common Signs of Computer Viruses A computer virus will more than likely have an adverse effect on the device it resides on and may be discoverable through common signs of performance loss, including: Speed of System A computer system running slower than usual is one of the most common signs that the device has a virus. This includes the system itself running slowly, as well as applications and internet speed suffering. If a computer does not have powerful applications or programs installed and is running slowly, then it may be a sign it is infected with a virus. Pop-up Windows Unwanted pop-up windows appearing on a computer or in a web browser are a telltale sign of a computer virus. Unwanted pop-ups are a sign of malware, viruses, or spyware affecting a device. Programs Self-executing If computer programs unexpectedly close by themselves, then it is highly likely that the software has been infected with some form of virus or malware. Another indicator of a virus is when applications fail to load when selected from the Start menu or their desktop icon. Accounts Being Logged Out Some viruses are designed to affect specific applications, which will either cause them to crash or force the user to automatically log out of the service. Crashing of the Device System crashes and the computer itself unexpectedly closing down are common indicators of a virus. Computer viruses cause computers to act in a variety of strange ways, which may include opening files by themselves, displaying unusual error messages, or clicking keys at random. Mass Emails Being Sent from Your Email Account Computer viruses are commonly spread via email. Hackers can use other people's email accounts to spread malware and carry out wider cyberattacks. Therefore, if an email account has sent emails in the outbox that a user did not send, then this could be a sign of a computer virus. Changes to Your Homepage Any unexpected changes to a computer—such as your system’s homepage being amended or any browser settings being updated—are signs that a computer virus may be present on the device. Trojans: In computing, a Trojan horse is a program that appears harmless, but is, in fact, malicious. Unexpected changes to computer settings and unusual activity, even when the computer should be idle, are strong indications that a Trojan is residing on a computer. A Trojan horse may also be referred to as a Trojan horse virus, but that is technically incorrect. Unlike a computer virus, a Trojan horse is not able to replicate itself, nor can it propagate without an end user's assistance. This is why attackers must use social engineering tactics to trick the end user into executing the Trojan. Typically, the malware programming is hidden in an innocent-looking email attachment or free download. When the user clicks on the email attachment or downloads the free program, the malware that is hidden inside is transferred to the user's computing device. Once inside, the malicious code can execute whatever task the attacker designed it to carry out. Indian Information Technology Act(IT Act) The Government of India’s Information Technology Act, 2000 (also known as IT Act), amended in 2008, provides guidelines to the user on the processing, storage and transmission of sensitive information. In many Indian states, there are cyber cells in police stations where one can report any cyber crime. The act provides legal framework for electronic governance by giving recognition to electronic records and digital signatures. The act outlines cyber crimes and penalties for them. Safely Browsing the Web ➢ Install and use antivirus software. ➢ Use a Firewall. ➢ Use strong passwords. ➢ Update your security software. ➢ Be aware of clicking links in emails. ➢ Bookmark important sites. ➢ Use VPNs and Proxies. WORKSHEETS Level 1 1. What is cyber safety? 2. What is Cyber Stalking 3. What is identity theft? 4. What is Cyber Troll? 5. What is Cyber Bullying? 6. What is Malware? 7. What is adware? 8. What is Spyware? 9. What is Phishing? Worksheet Level 2 1. Passwords are used to improve the ______ of a network. a) Performance b) Reliability c) Security d) Longevity 2. The full form of Malware is a) Malfunctioned software b) Multipurpose software c) Malicious software d) Malfunctioning of security 3. The transformation of key business processes through the use of digital or Internet technologies is known as ____________ a) E-business b) E-Commerce c) Digital Business d) Both A and C 4. A _________ community is one where the interaction takes place over a computer network, mainly the Internet. a) Online b) Virtual c)Internet d) All of the above 5. _________ has specific objectives to increase profits when increasing its benefits to society. a) Digital Business b) Social Network c)Social Enterprise d) Virtual Community 6. Social networks are organized primarily around __________. a) Brands b) People c) Discussions d) interests 7. Which social network is considered the most popular for social media marketing? a) Twitter b) Facebook c) Linkdin d) Whats App 8. Which of the following is an important aspect of creating blogs and posting content? a) Using a witty user name b) Posting at least once a month to the blog c) Social Media Optimization d) All of the above 9. Which of the following is the correct depiction of Digital Marketing? a) E-mail Marketing b) Social Media Marketing c)Web Marketing d) All of the above 10. Which of the following is not specifically required by the search engines? a) Poor user experience b) Keyword stuffing c)Buying links d) All of the above COMPETENCY BASED 1. Smridh has recently changed his school so he is not aware of the people, but someone is posting negative ,demeaning comments on his social media profile. He is also getting repeated mails from unknown people. Everytime he goes online, he finds someone chasing him online. i) Smridh is a victim of …………. : a) Eavesdropping b) Stolen identity c) Phishing d) Cyber stalking Ans: d ii) The action that Smridh should take : a) He should ONLY share with his friends b) He should NOT share with anyone as it can cause serious problem c) He should immediately report to the police d) He should bring to the notice of his parents and school authorities. Ans: d iii) …………………….. is a set of moral principles that governs the behaviour of a group or individual and regulates the use of computers. a) Copyright b) Computer ethics c) Property rights d) Privacy law Ans: b 2. After practicals, Atharv left the computer laboratory but forgot to sign off from his email account. Later, his classmate Revaan started using the same computer. He is now logged in as Atharv. He sends inflammatory email messages to few of his classmates using Atharv’s email account. i) Revaan’s activity is an example of which of the following cyber crime? a) Hacking b) Identity theft c) Cyber bullying d) Plagiarism Ans: b ii) If you post something mean about someone, you can just delete it and everything will be Ok . a) True b) False Ans: b iii) Anonymous online posts/comments can _________ be traced back to the author. a) Always b) Never c) Sometimes d) Many Times Ans: a FLASH CARDS File Viruses infect executable files or BAT files. Macro virus Phlashing What are the three types of cyber security controls? Usually in VBA infects MS office template files (excel or word) Melissa was an example Hacking the software in flash memory firmware Physical, Hardware, Devices SAMPLE PAPERS - 2022 Class: XI Session: 2022-23 Computer Science (083) Sample Question Paper (Theory) Maximum Marks: 70 Time Allowed: 3 hours General Instructions: 1. This question paper contains five sections, Section A to E. 2. All questions are compulsory. 3. Section A have 18 questions carrying 01 mark each. 4. Section B has 07 Very Short Answer type questions carrying 02 marks each. 5. Section C has 05 Short Answer type questions carrying 03 marks each. 6. Section D has 03 Long Answer type questions carrying 05 marks each. 7. Section E has 02 questions carrying 04 marks each. 8. All programming questions are to be answered using Python Language only. SECTION A 1. Which of the following is not an operating systema. Windows 2. c. Oracle d. DOS Antivirus software is _______________ software. a. Application 3. b. Linux 1 b. Utility c. System 1 d. Chat Which of the following is not a valid identifier name in Python? 1 a. 5Total 4. b. _Radius b. id() b. 1 b. if 1 d. ! c. 6 b. == 1 d. 8 c. = b. int c. String 1 d. both b and c Which of the following is Membership operator: b. and c. or 1 d. % Which statement is used to terminate the loop? b. break 1 d. != Which out of the following is immutable data type? a. continue 13. d. while Which operator is used to check whether two variables are same? a. in 12. 1 c. % b. 3 a. List 11. d. 0 What is the value of this expression: 3**1**2 a. 10. c. 3 c. day b. // a. 9 9. 1 Which one of these is floor division operator? a. / 8. d. str() Which of the following is not a keyword? a. for 7. c. ord() What is the value of this expression: 17%3 a. 2 6. d. name Which function out of the following will return the data type of the 1 object: a. type() 5. c. pie c. for 1 d. pass Which statement can be used when a statement is required 1 syntactically but the program requires no action. a. break 14. b. for c. continue d. pass Function range(0, 5, 2) will yield on iterable sequence like a. [0, 2, 4] b. [1, 3, 5] c. [0, 1, 2, 5] 1 d. [0, 5, 2] 15. Write any two benefits of e-Waste Recycling. 1 16. Define Eavesdropping and give one example. 1 17. What do you understand by the term netizen? 1 18. What is Open Source Software? Give example. 1 SECTION B 19. Find the output of the following code: 2 sum = 0 for i in range(1,5): sum = sum + i print(sum) 20. What do you mean by a tuple in Python? Write a statement to create a 2 tuple named ‘T1’ with only one element i.e. 10. 21. D = {‘red’:10, ‘blue’:15} is a dictionary in python. 2 (i) Write a python statement to add a new element ‘black’:25 in the dictionary D. (ii) Write a python statement to change the value of red to 15 in the dictionary D. 22. Find the output of the following code: a, b, c=10, 20, 30 2 b=b+2 a+=2 c-=b print(a,b,c) 23. How to concatenate two lists? Give an example. 2 24. Write the differences between Plagiarism and Copyright infringement. 2 25. Vikas has to make an online transaction through net banking. He wants 2 to make sure that he is opening the genuine bank website and not some fake page. Write any two ways in which he can identify if his connection to the banking website is secure. SECTION C 26. Briefly answer the following: 3 a) What is the difference between a compiler and an interpreter? b)What is an Operating System? Write any two functions of operating system. c)State True/False: UTF-8 is a fixed length encoding scheme and UTF-32 is a variable length encoding scheme. 27. State output of the following 3 List = [12,13,14,15, ‘apple’, ‘mango’] 28. (i) print(List[2:6:2]) (ii) print(List+['a','b']) (iii) print(4 in List) Write a Python program to display the sum and mean/average of first 3 n natural numbers. 29. State two differences between lists and tuples with example. 3 30. What are the gender and disability issues while teaching and using 3 computers? What solutions do you suggest to handle such issues? SECTION D 31. a) Draw the equivalent logic circuit for the following Boolean 5 Expression: A’.(B+C’) b) Name the law shown below and verify it using a truth table: A+B.C=(A+B).(A+C) c) Convert the following: (i) (106)10 = ( ? )2 (ii) (111100111100)2 = ( ? )8 (iii) (B2F)16 = ( ? )8 32. a. Differentiate between clear(), pop() and popitem() functions in 5 Dictionary by giving example for each. b. Write the output of following Python code: dict = {1: 4, 2: 5, 3: 1} a=0 b=0 for i in dict.keys(): a=a+i print(a) for i in dict.values(): b=b+i print(b) 33. (i)Write the output of the following Python code- 5 t = (1,2,3,4,5,3,2,3,4,5,2,1) print(t.count(2)) print(t.index(2)) (ii)Explain fromkeys(), setdefault() and copy() functions in Dictionary by giving example for each. SECTION E 34. Write the output of the following: 4 L=[10, 20, 30] item = L.pop(1) print('ITEM:',item) list1=[3,2,1,0,1,2,3] list1.remove(3) print('SUM OF LIST:',sum(list1)) list1.insert(6,4) print('UPDATED LIST1:',list1) newList=L[:3]+list1[3:] print('NEW LIST:',newList) 35. (a) Match the following: 4 Column A Column B Hacking Crime, in which the attacker blackmails the victim to pay for getting access to the data Credit card fraud The trail that is created when a person uses the Internet Digital Foot Print Breaking into computers to read private emails and other files Ransomware Fakers, by offering special rewards or money prize asked for personal information, such as bank account information (b) In school, Navneet forgot to sign out from his email account while leaving the computer laboratory. Later, his classmate Ankit started using the same computer. He is now logged in as Navneet. He sends inflammatory email messages to few of his classmates using Navneet’s email account. Ankit’s activity is an example of which of the following cyber crime? Justify your answer. a) Hacking b) Identity theft c) Cyber bullying d) Plagiarism Class: XI Session: 2022-23 Computer Science (083) MARKING SCHEME Maximum Marks: 70 Time Allowed: 3 hours General Instructions: 1. This question paper contains five sections, Section A to E. 2. All questions are compulsory. 3. Section A have 18 questions carrying 01 mark each. 4. Section B has 07 Very Short Answer type questions carrying 02 marks each. 5. Section C has 05 Short Answer type questions carrying 03 marks each. 6. Section D has 03 Long Answer type questions carrying 05 marks each. 7. Section E has 02 questions carrying 04 marks each. 8. All programming questions are to be answered using Python Language only. SECTION A 1. Which of the following is not an operating systema. Windows b. Linux c. Oracle 1 d. DOS c. Oracle 2. Antivirus software is _______________ software. a. Application b. Utility c. System 1 d. Chat b. Utility 3. Which of the following is not a valid identifier name in Python? 1 a. 5Total b. _Radius c. pie d. name a. 5Total 4. Which function out of the following will return the data type of the 1 object: a. type() b. id() c. ord() d. str() a. type() 5. What is the value of this expression: 17%3 a. 2 b. 1 1 c. 3 d. 0 a. 2 6. Which of the following is not a keyword? a. for b. if c. day 1 d. while c. day 7. Which one of these is floor division operator? a. / b. // c. % 1 d. ! b. // 8. What is the value of this expression: 3**1**2 a. 9 b. 3 c. 6 1 d. 8 b. 3 9. Which operator is used to check whether two variables are same? a. b. == b. == c. = d. != 1 10. Which out of the following is immutable data type? a. List b. int c. String 1 d. both b and c d. both b and c 11. Which of the following is Membership operator: a. in b. and c. or 1 d. % a. in 12. Which statement is used to terminate the loop? a. continue b. break c. for 1 d. pass b. break 13. Which statement can be used when a statement is required 1 syntactically but the program requires no action. a. break b. for c. continue d. pass d. pass 14. Function range(0, 5, 2) will yield on iterable sequence like a. [0, 2, 4] b. [1, 3, 5] c. [0, 1, 2, 5] 1 d. [0, 5, 2] a. [0, 2, 4] 15. Write any two benefits of e-Waste Recycling. ½ mark for each benefit (any two) ● Save Landfill Space. Electronic waste is being thrown into landfills at an increasing rate each year ● Save Natural Resources. ● Increase in Employment. ● Saves the Environment. 1 16. Define Eavesdropping and give one example. 1 Definition- Eavesdropping is as an electronic attack where digital communications are intercepted by an individual whom they are not intended. For definition ½ mark, for any correct example ½ mark 17. What do you understand by the term netizen? 1 Anyone who uses digital technology along with Internet is a digital citizen or a netizen. For any correct definition 1 mark 18. What is Open Source Software? Give example. 1 Open source software is software with source code that anyone can inspect, modify, and enhance. Example- MySql, Linux For any correct definition ½ mark and example ½ mark SECTION B 19. Find the output of the following code: sum = 0 for i in range(1,5): 2 sum = sum + i print(sum) 10 20. What do you mean by a tuple in Python? Write a statement to create a 2 tuple named ‘T1’ with only one element i.e. 10. For tuple definition 1 mark T1=(10,) For correct statement 1 mark 21. D = {‘red’:10, ‘blue’:15} is a dictionary in python. 2 (i) Write a python statement to add a new element ‘black’:25 in the dictionary D. (ii) Write a python statement to change the value of red to 15 in the dictionary D. (i) D[‘black’]=25 (ii) D[‘red’]=15 1 mark -for each correct statement 22. Find the output of the following code: a, b, c=10, 20, 30 b=b+2 a+=2 c-=b print(a,b,c) 2 12 22 8 23. How to concatenate two lists? Give an example. 2 1 mark- for correct method 1 mark for example 24. Write the differences between Plagiarism and Copyright infringement. 2 2 marks for any 2 differences 25. Vikas has to make an online transaction through net banking. He wants 2 to make sure that he is opening the genuine bank website and not some fake page. Write any two ways in which he can identify if his connection to the banking website is secure. 1. Check if the URL is misspelled 2. Look for padlock sign 1 mark - for each correct way SECTION C 26. Briefly answer the following: 3 a) What is the difference between a compiler and an interpreter? b)What is an Operating System? Write any two functions of operating system. c)State True/False: UTF-8 is a fixed length encoding scheme and UTF-32 is a variable length encoding scheme. a) ½ mark for each difference (any 2 difference) b) For operating system definition 1 mark, for any 2 functions 1 mark (½ mark for each function) c) False 27. State output of the following 3 List = [12,13,14,15, ‘apple’, ‘mango’] (i) print(List[2:6:2]) (ii) print(List+['a','b']) (iii) print(4 in List) [14, 'apple'] [12, 13, 14, 15, 'apple', 'mango', 'a', 'b'] False 1 mark- for each correct output 28. Write a Python program to display the sum and mean/average of first 3 n natural numbers. n = int(input("Enter number")) sum = 0 # loop from 1 to n for num in range(1, n + 1): sum = sum + num print("Sum of first ", n, "numbers is: ", sum) average = sum / n print("Average of ", n, "numbers is: ", average) 29. State two differences between lists and tuples with example. 2 marks - any 2 differences (1 mark each) ½ mark - list example ½ mark - tuple example 3 30. What are the gender and disability issues while teaching and using 3 computers? What solutions do you suggest to handle such issues? 1 mark-any 2 gender issues 1 mark -any 2 disability issues 1 mark- any 2 solutions to handle such issues SECTION D 31. a) Draw the equivalent logic circuit for the following Boolean 5 Expression: A’.(B+C’) b) Name the law shown below and verify it using a truth table: A+B.C=(A+B).(A+C) c) Convert the following: (i) (106)10 = ( ? )2 (ii) (111100111100)2 = ( ? )8 (iii) (B2F)16 = ( ? )8 a) b)distributive law ½ mark for name of law, ½ mark for truth table c) (i) 1101010 (ii)7474 (iii) 5457 32. a. Differentiate between clear(), pop() and popitem() functions in 5 Dictionary by giving example for each. b. Write the output of following Python code: dict = {1: 4, 2: 5, 3: 1} a=0 b=0 for i in dict.keys(): a=a+i print(a) for i in dict.values(): b=b+i print(b) (a) 1 mark - for each correct explanation of function with example (b) 6 10 1 mark for each correct output 33. (i)Write the output of the following Python codet = (1,2,3,4,5,3,2,3,4,5,2,1) print(t.count(2)) print(t.index(2)) (ii)Explain fromkeys(), setdefault() and copy() functions in Dictionary by giving example for each. (i) 3 1 5 1 mark- for each correct output (ii)3 marks 1 mark - for each correct explanation of function with example SECTION E 34. Write the output of the following: L=[10, 20, 30] item = L.pop(1) print('ITEM:',item) list1=[3,2,1,0,1,2,3] list1.remove(3) print('SUM OF LIST:',sum(list1)) list1.insert(6,4) print('UPDATED LIST1:',list1) newList=L[:3]+list1[3:] print('NEW LIST:',newList) ITEM: 20 SUM OF LIST: 9 UPDATED LIST1: [2, 1, 0, 1, 2, 3, 4] NEW LIST: [10, 30, 1, 2, 3, 4] 4 1 mark for each correct output 35. (a) Match the following: Column A Column B Hacking Crime, in which the attacker blackmails the victim to pay for getting access to the data Credit card fraud The trail that is created when a person uses the Internet Digital Foot Print Breaking into computers to read private emails and other files Ransomware Fakers, by offering special rewards or money prize asked for personal information, such as bank account information (b) In school, Navneet forgot to sign out from his email account while leaving the computer laboratory. Later, his classmate Ankit started using the same computer. He is now logged in as Navneet. He sends inflammatory email messages to few of his classmates using Navneet’s email account. Ankit’s activity is an example of which of the following cyber crime? Justify your answer. a) Hacking b) Identity theft c) Cyber bullying d) Plagiarism a) 2 marks 4 Hacking Breaking into computers to read private emails and other files Credit card fraud Fakers, by offering special rewards or money prize asked for personal information, such as bank account information Digital Foot Print The trail that is created when a person uses the Internet Ransomware Crime, in which the attacker blackmails the victim to pay for getting access to the data b) 1 mark- for correct answer Identity theft 1 mark - for justification Class: XI Session: 2022-23 Computer Science (083) Sample Question Paper (Theory) Maximum Marks: 70 Time Allowed: 3 hours General Instructions: 1. This question paper contains five sections, Section A to E. 2. All questions are compulsory. 3. Section A have 18 questions carrying 01 mark each. 4. Section B has 07 Very Short Answer type questions carrying 02 marks each. 5. Section C has 05 Short Answer type questions carrying 03 marks each. 6. Section D has 03 Long Answer type questions carrying 05 marks each. 7. Section E has 02 questions carrying 04 marks each. 8. All programming questions are to be answered using Python Language only. SECTION A 1. Which of the following is not a language processor? a. Assembler b. Operating system c. Compiler d. Interpreter 1 2. Expand given terms: EEPROM , GPU 1 3. If t=”hello” then which of the following is not valid in Python? a. t*2 b. t+t c. t+2 d. t+”hi” 1 4. How can you know the datatype of a variable? 1 What is the value of this expression: (10 == 9)and (7 > 5) 5. 1 a. True b. False c. None d. Can not find 6. Which of the following is not a keyword? a. for b. if c. Else d. While 1 7. Which one of these returns remainder on division? a. / b. // c. % d. ! 1 8. Which logical gate is also called inverter. 9. Which operator is used to check whether two variables are same? a. b. == c. = d. != 1 1 10. Which out of the following is mutable data type? a. List b. int c. String d. both b and c 1 11. Which of the following is Membership operator: a. in b. and c. or d. % 1 12. Which of the following are not valid strings in Python? (a)”Hello”(b) “Hello‘ (c)’Hello‘ (d) ‘Hello” (e) {Hello} 1 13. Which statement can be used when a statement is required syntactically but the program requires no action. 1 a. break b. for c. continue d. Pass 14. Function range(8,1,-2) will yield on iterable sequence like 1 a. [8,7,6,5,4,3,2,1] b. [7,5,3] c. [8,7,6,5,4,3,2] d. [8,6,4,2] 15. Write any two benefits of e-Waste Recycling. 1 How do websites track you online? 16. 1 What is phishing? 17. 1 18. What is Open Source Software? Give example. 1 SECTION B What will be the output produced by following code fragment? x, y= 20, 60 19. y, x, y=x, y-10, x+10 print (x, y) 20. What is the difference between a keyword and an identifier? 2 2 L= [11,34,56,23,67,78] is a list in python. 21. (i) Write a python statement to remove 78 from the list. 2 (ii) Write a python statement to insert 89 after 23 in the given list. What will be the output of following Python code? 22. a=12 b=7.4 2 c=1 a-=b print (a, b) a*=2+c print(a) b+=a*c print( b ) What is the output produced by the following code? x=1 if x>3: if x>4: print(“A”,end=””) else: print(͞”B”,end=””) 23. 2 elif x<2: if (x!=0): print(“C”,end=””) print(“D”) 24. What is cyber bullying and cyber stalking? 2 Raman wanted to gift his brother a football or a wrist watch. So he 25. searched for many sports items and wrist watches online. But after 2 that every time he goes online, his webbrowser shows him advertisements about sports items and wrist watches. (a) Why is this happening? (b) How could have Raman avoided them? SECTION C Briefly answer the following: a) What is the difference between system software and application software? 26. b)What is an Operating System? Write any two functions of 3 operating system. c)Explain IPO Cycle. Name the function/method required to (i) Check if a string contains only alphabets 27. (ii) Converts the first character to upper case 3 (iii) Converts a string into lower case 28. WAP to find minimum and maximum element in the given tuple. 3 29. WAP to check whether entered string is palindrome or not. 3 What are the gender and disability issues while teaching and using 30. computers? What solutions do you suggest to handle such issues? 3 SECTION D 31. a) Write Boolean Expression for the given circuit. 5 b)Verify given expression using truth table: A+B.C=(A+B).(A+C) c) Convert the following: (2345)7 =(?)10 (11110.111)2=(?)10 (231)4=(?)2find x. (i)Write the output of the following Python code- 32. t = (1,2,3,4,5,3,2,3,4,5,2,1) print(t.count(2)) print(t.index(2)) 5 (ii)Explain fromkeys(), setdefault() and copy() functions in Dictionary by giving example for each. Python program to find number is armstrong or not , is given. Fill the given blanks. 33. number = int(_________("enter number")) num = number digit, sum = ____ , _____ length = len(str(num)) 5 for i in range(length): digit = int(num%10) num = num/10 sum += pow(digit,_________) if sum==number: print(_______________) else: print(_______________) SECTION E a) Write a Python script to generate and print a dictionary that contains a number (between 1 and n) in the form (x, x*x).. Sample Expected Output : {1: 1, 2: 4, 3: 9, 4: 16, 5: 25} Dictionary(n=5): 34. b)Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” 3+1 what command do we use? a)d.delete(“john”:40) b)d.delete(“john”) c)del d[“john”] d) del d(“john”:40) 35. 4 1. Match the following: Column A Credit card fraud Column B Crime, in which the attacker blackmails the victim to pay for getting access to the data Ransomware a type of malware whose primary function is to self-replicate and infect other computers Worm Breaking into computers to read private emails and other files Hacking Fakers, by offering special rewards or money prize asked for personal information, such as bank account information 2. What is private browsing? Why is it considered a better way of browsing the internet? SAMPLE QUESTION PAPER-2022-23 CLASS XI SUBJECT: COMPUTER SCIENCE Note: a) All questions are compulsory. b) Give examples wherever possible. 70 Q. No Question Time: 3 HOURS Max Marks: Ma rks SECTION A 1.a 25616 = _______2 ) b) Which of the following is/are the universal logic gates? 1 1 c) d) A. OR and NOR B. AND C. NAND and NOR NOT ______________ is the term for a program being run by the computer D. 1 When we work on any document on PC, it is stored temporarily in______ 1 memory e) A) RAM B) ROM State DeMorgan’s Theorem C) CPU D) CD-ROM f) What is utility software? Give example. 2 G) Draw the logic circuit for the Boolean expression: F=AB’ +(CD)’ 2 H) Give full form of: i) ISCII ii) MICR iii) OCR 3 1 SECTION B 2.a identify the valid identifiers from the following: ) i) myname1 ii) While iii) 1stname iv) for b) ‘All the Best!’.__________ will produce the list [‘All’,’the’,’Best!’] 1 c) evaluate the expression: 15+3*2-(9**0.5) 1 d) Value=(“abcd”,[1,2,3],10,”xyz’) Identify the data type of Value (i) list (ii) dictionary (iii) string 1 1 (iv) tuple e). import random 1 X=random.randint(1,4) In the above code, X will take minimum value______ and maximum value________ f) 2 Correct the errors in the given code and underline the corrections Num = input("Number:") Sum = 0 For i in range(10,Num) Sum+=i if i%5 print( i*2) Else: print ( Sum) 3.a Predict the output of the following code snippet if N is given the value 2: ) N=int(input(“enter a number”)) 3 b) c) d) e) f) g) C=1 while (C<8): if(C==3 or C==5): C+=1 continue print(C,’*’,N,’=’,C*N) C+=1 Write a program to get a list of numbers from the user and triple the value of all the elements at the even position. For example, if the list entered is [1,2,3,4,5,6] the resultant list should be [3,2,9,4,15,6] Write 2 mutable and 2 immutable datatypes Give the output of the following code T=(2,’abc’,39) X,Y,Z=T print(X,Y*2,Z//4) Write a program to check if a string given by the user is a palindrome or not and display the result Write any four safety measures that can reduce the risk of cyber crime Ms Sharmishtha has many electronic gadgets which are not usable due to outdated hardware and software. Help her to find three best ways to dispose the used electronic gadgets. 4.a A=100 ) print(a) What is the exception that will occur and why? b) Give the output: import statistics as M L=[1,2,3,4,5,6,7,8,9,10] print(M.mean(L)) c) If L =[10,14,18,22,’four numbers’], evaluate and write the output of the following I) L[1::3] II) L[4][0:4] 2 2 2 2 2 2 1 1 2 d) 3 e) What will the output for following code? S='Model Exams 2022. Computer Science' L=S.split() for I in L: if I[0]=='C': print('CS') elif I[0]=='E': print('Experiment') elif I.isdigit(): print('0000') else: print(I) Write the difference between list and dictionary with example f) Write program to find factorial of a given number 2 g) i) ______________ function in list is used to add multiple elements at end 2 of list 2 ii) Write the output: a=10 print(type(a)) SECTION C 5.a Identify the type of cyber crime for the following situations: ) 1. Sabhya quickly downloads a 2-minute clip from the internet explaining the concept of dictionary in Python. Using video editor, he adds the text “Prepared by Sabhya” in the downloaded video clip. He then emails the modified video clip to Ahaana. This act of Sabhya is an example of: (a) Fair use (b) Hacking (c) Copyright infringement (d) 5 Cybercrime 2. Ms. Kavita complains that her debit/credit card is safe with her still somebody has done shopping /ATM transaction on this card. 3. A person complains that somebody has created a fake profile of Facebook and defaming his/her character with abusive comments and pictures. 4. Ravi received an email from First Generic Bank (as shown below). On clicking the link, he was taken to a site designed to imitate an official looking website. He uploaded some important information on it. 5. After a fight with your friend, you created an embarrassing picture of your friend and uploaded on your account on a social networking site. b) c) Write a Python Program to find max among three input numbers using if - elif 5 statement Results is a dictionary containing Name and Score of students in key: value pair. Results= {“A”:240,”B”:340,”C”:350,”D”:280,”E”:370} Perform following operations on it. a) Print name of all the students having score >250 b) Change marks of student “C” to 450. c) Calculate average score in this class. d) Add one more student with name “G” with score 290. e) Delete entry of student “C” from it. OR s= “Welcome to python world” Write output for given statements: a) print (s.isalpha()) b) print (s.islower()) c) print(s.upper()) d) print(s.capitalize()) e) print(s.title()) SECTION D 5 e) Anitha is trying to create a program to get student marks and generate a simple report card. As a programmer, help him to complete the program for its successful execution. ##program to get student marks and display grade and average from ____________ import mean #LINE1 print('**Student Details**') while True: Rno=int(input('Enter student roll no(should be less than 40):')) if Rno >= 40: print('you entered wrong roll no. please re-enter details') ___________ #LINE2 Name=input('Enter student name:') Marks=eval(input('Enter list of marks in 5 subjects:')) avg=mean(Marks) if 90 < avg <= 100: Grade='A+' Msg='Excellent!!' elif 70 <= avg <=90: Grade='B' Msg="Great. Keep it up" elif 50 <= avg <70: Grade='C+' Msg='Good but you need to work harder' elif 30 <= avg <50: Grade='C' Msg='You can do better' elif 0 <= avg < 30: Grade='D' Msg='You can definitely do better. Please meet Class Teacher' _____: #LINE3 Grade='Error' print('Something wrong. reenter details correctly') continue print('**REPORT CARD**\nRollno:',Rno,'\tName:',Name) print(‘Average marks:',avg,'\tOverall Grade:',Grade,'\n',Msg) Choice=input('Do you wish to enter more data? enter y/n: ') 4 if Choice.________=='n': #LINE4 _________ #LINE5 print (‘END OF PROGRAM’) A. Which module should she import in LINE1 to be able to use mean function? [1] B. Which JUMP statement should she use in LINE2 to go back to beginning of the WHILE Loop? [1] C. Which keyword should she use in LINE3? [1] D. Which function should she call in LINE4 to convert Choice to lower case? [1] Which JUMP statement is to be included in LINE5 to come out of the WHILE LOOP? [1] f) Consider the following Algorithm and then answer any Four Questions from following: 1. Start 2. Set S = 0 3. Input N 4. If N > 0 then proceed to step 5 else proceed to step 10 5. Calculate Remainder of N ÷ 10 say R 6. S = S+ R 7. Calculate Integer Part of Quotient of N ÷ 10 say Q 8. Set N = Q 9. Proceed to Step 4 10. Print S 4 11. End. i) What is the above lines called as : a) Program b) Pseudocode c) Flowchart d) None of the Above ii) What is the purpose of the above Algorithm: a) It calculates sum of factors of a Number N b) It calculates sum of multiples of a Number N c) It calculates sum of digits of a Number N d) It calculates sum of all digits which are divisible by 10 in the Number N iii) What will be the Final value of N after completion of above algorithm : a) 0 b) 1 c) 2 D) 10 iv) What will happen to the result obtained by the algorithm if the positions of steps 6 and 7 are exchanged? a) Will effect on the result of the algorithm and it will change b) Will not effect on the result of the algorithm and it will be same c) Will stop as algorithm from earlier. working, at all. d) None of the above. v) Which type of Flow of Logic is shown in the above Algorithm: a) Sequential b) Conditional c) Iterative (Cyclic) d) Procedural KENDRIYA VIDYALAYA SANGATHAN, CHENNAI REGION SAMPLE QUESTION PAPER-2022-23 CLASS XI SUBJECT: COMPUTER SCIENCE Note: a) All questions are compulsory. Time: HOURS 3 b) Give examples wherever possible. Max Marks: 70 Q. No Question SECTION A 1.a 0010 0101 01102 ) b) C. NAND and NOR 1 c) process 1 d) A) RAM 1 e) (A+B)’ = A’ . B’ 1 (A.B)’= A’ + B’ Software used for maintenance and configuration of the computer system is 2 called system utility. Some system utilities are shipped with the operating system for example disk defragmentation tool, formatting utility, system restore utility, etc. Another set of utilities are those which are not shipped with the operating system but are required to improve the performance of the system, for example, anti-virus software, disk cleaner tool, disk compression software, etc. 2 f) G) H) Give full form of: iv) ISCII - Indian Script Code for Information Interchange v) MICR - Magnetic Ink Character Recognition vi) OCR - Optical Character Recognition. SECTION B 2.a ii) ) b) split() c) 18.0 d) 1 myname1 (iv) tuple ii) While 3 1 1 1 1 e). In the above code, X will take minimum value 1 and maximum value 4 1 Correct the errors in the given code and underline the corrections Num = int(input("Number:")) Sum = 0 for i in range(0,Num): Sum+=i if i%5: print( i*2) else: print ( Sum) 3.a Predict the output of the following code snippet if N is given the value 2: ) 1*2=2 2*2=4 4*2=8 6 * 2 = 12 7 * 2 = 14 b) N=eval(input('enter a list of numbers:')) for i in range(len(N)): if i%2 == 0: N[i] *= 3 c) mutable -- List , diuctionary immutable datatypes – int, string, tuple d) 2 abcabc 9 2 f) e) f) 3 2 2 2 String = input('Enter a string:') 2 if String == String[-1::-1]: print('its a palindrome') else: print('its not a palindrome') 1. Take regular backup of important data 2 2. Use an antivirus software and keep it updated always 3. Avoid installing pirated software. Always download software from known and secure (HTTPS) sites 4. Always update the system software which include the Internet browser and other application software 5. Do not visit or download anything from untrusted websites 6. Usually the browser alerts users about doubtful websites whose security certificate could not be verified; avoid visiting such sites 7. Use strong password for web login, and change it periodically. Do not use same password for all the websites. Use different combinations of alphanumeric characters including special characters. Ignore common words or names in password 8. While using someone else’s computer, don’t allow browser to save password or auto fill data, and try to browse in your private browser window 9. For an unknown site, do not agree to use cookies when asked for, through a Yes/No option. 10.Perform online transaction like shopping, ticketing, and other such services only through well-known and secure sites 11.Always secure wireless network at home with strong password and regularly change it. g) 1. Give Back to Your Electronic Companies and Drop Off Points 2 2. Visit Civic Institutions 3. Donating Your Outdated Technology 4. Sell Off Your Outdated Technology 4.a A=100 1 ) print(a) NameError: name 'a' is not defined b) 5.5 1 c) d) If L =[10,14,18,22,’four numbers’], evaluate and write the output of the 2 following III) [14, 'four numbers'] IV) 'four' What will the output for following code? 3 Model Experiment 2022. CS Science e) List is indexed sequence -- Dictionary is mapping List can be sliced. Dictionary cannot be sliced 2 f) print ("Program to generate factorial of a given number") no=int(input("enter the natural number: ")) if no < 0: 2 g) print('factorial not possible for negative number') else: fact=1 i=1 while i<=no: fact*=i i+=1 print("factorial of given number",fact) i) extend() function in list is used to add multiple elements at end of list ii) 2 <class 'int'> SECTION C 5.a Identify the type of cyber crime for the following situations: ) 1 (c) Copyright infringement 2. Card fraud 5 3. Trolling 4. Phishing b) 5. Cyber bullying print('****program to find greatest of 3 numbers****') num1,num2,num3=eval(input('enter 3 unique numbers: ')) if num1 > num2 and num1 > num3: print('The greatest of the three nos. is : ',num1) elif num2 > num3 and num2 > num1: print('The greatest of the three nos. is : ',num2) elif num3 > num1 and num3 > num2: print('The greatest of the three nos. is :',num3) else: print('any two nos are equal') 5 c) f) Print name of all the students having score >250 for name in results: if results[name]>250: 5 print (name) g) Results [‘C’] = 450 h) sum = 0;cnt =0 for name in Results: sum += Results[name] cnt+=1 avg = sum/cnt i) Results[‘G’]=290 j) del Results['C'] OR s= “Welcome to python world” Write output for given statements: f) print (s.isalpha()) -- False g) print (s.islower()) -- False h) print(s.upper()) -- 'WELCOME TO PYTHON WORLD' i) print(s.capitalize()) -- 'Welcome to python world' j) print(s.title()) -- 'Welcome To Python World' SECTION D e) E. statistics [1] F. continue [1] G. else H. lower() [1] I. break [1] f) [1] 4 vi) b) Pseudocode vii) c) It calculates sum of digits of a Number N viii) a) 0 ix) b) Will not effect on the result of the algorithm and it will be same as earlier. x) c) Iterative (Cyclic) 4 Class: XI Session: 2022-23 Computer Science (083) Sample Question Paper (Theory) Maximum Marks: 70 Time Allowed: 3 hours General Instructions: 1. This question paper contains five sections, Section A to E. 2. All questions are compulsory. 3. Section A have 18 questions carrying 01 mark each. 4. Section B has 07 Very Short Answer type questions carrying 02 marks each. 5. Section C has 05 Short Answer type questions carrying 03 marks each. 6. Section D has 03 Long Answer type questions carrying 05 marks each. 7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35 against part c only. 8. All programming questions are to be answered using Python Language only. SECTION A: 1. Define PROM 2.A box that can represent two different conditions is…….. 3. Which of the following is not a example of hexadecimal number? a) 1C2 b) 2A.1 c) 1ABCD d) 67GA 4. The operating system that uses two or more CPU’s within a single computer is called………. 5. What is the output for the following code x=12 x=5 x=x+x print(x) a) 10 b) 17 c) 5 d) none 6. write the full form of ASCII? 7. Convert (145)8 to decimal number 8. Python files are saved with the extension of …… 9. The smallest element in Python is ………… 10. for x in range (5): print(x) a) 1234 b) 01234 c) 12345 d) 012345 11. The loop that is best suited to handle iterations is………. 12. str=”togetherwithpython” str.count(“t”) output will be…… a) 3 b) 2 c) none d) zero 13. Tuples are……………datatypes 14. item=[‘a’,’b’,’c’,’d’] name=item.pop() print(name) predict the output.? 15. Which statement is used to create an empty dictionary? a) d1={ } b) d1=( ) c) d1= dict{ } d) d1=[ ] 16. Gaining someone else’s identity without his/her knowledge and misuse it a) cyber fraud b) identity theft c) data fraud d) cyber theft 17.A license allows the user to use coprright material. Say true or false 18. The main purpose of pseudocode is……. a) development b) design c) coding d) debugging. SECTION B: 19. Differentiate primary and secondary memory. 20.Write the different functions of Control unit? 21. Write the decimal equivalent of binary number? 101.0110 22.What do you meant by Python identifier? 23.What is the difference between selection and repetition? 24.Write the for loop to print the values from 1 to 10 in separate lines? 25. Lists and Tuples are ordered. Explain. SECTION C: 26 Write a python program to create a dictionary from a string? 27. Write any 2 ways to protect personal data on social media…..2 marks Name the most common technique of electronic fraud?........1 mark 28. What is dynamic typing.? Explain with an example. 29. Write any 3 methods used in list. 30.mylist=[10,20,30,40] mylist.append([50,60]) mylist.extend([80,90]) mylist.sort() SECTION D: 31.Write a python program to find the highest 2 values in a dictionary. 32.Find the output for the following segments. (i) a=110 while a >100: print(a) a-=2 (ii) for i in range (20,30,2): print(i) (iii) country=”INDIA” for i in country: print(i) (iv) i=0; sum=0 while i<9: if i%4==0: sum=sum+i i=i+2 print(sum) 33. Write a python program to print the mathematical tables from 1 to 10. SECTION E: 34. Write the different types of plagiarism. 35.Abi has written a following code. st=input(“enter a string”) print(st) ch=input(“enter the character to be searched; “) count=0 for character in st: if character== ch: count+=1 print(“number of times character”,ch,”occurs:”,count) a) Now she wants to show a copy of the string with uppercase characters converted into lowercase. Which of the following function will be used? (i) Count() (ii) partition() c) swapcase() d) strip() b) She does not know the syntax of doing so, help her in doing by choosing the correct option. (i) print(swapcase()) (ii) print(st.swapcase()) (iii) print(st.swapcase) (iv) print(swapcase.st) c) She wants to capitalize the first character of the string,then…..must be used (i) lower() (ii) upper() (iii) capitalize() (iv) find() d) Now she wants first character of every word in the string must be in uppercase. (i) st.istitle() b) st.isupper() c) st.islower() d) none e). She wants to check whether all the character of the string are alphabet or not (i) isdigit() b) istitle() c) isupper() d) isalpha() SOLUTION FOR SAMPLE PAPER CLASS 11 SECTION A: 1. Programmable Read Only Memory is a memory chip on which data can be written only once and remains forever 2. Parallelogram 3. Option d 4. Multi processing 5. Option a 6. American Standard Code for Information Interchange 7. (101)10 8. .py 9. Tokens 10.Option b 11. for loop 12.Option a 13.Immutable datatypes 14.Item=[‘a’, ’b’ , ‘c’] 15.Option a 16.Option b 17.True 18. Option b SECTION B 19.Primary memory is the computer's main memory and stores data temporarily. Secondary memory is external memory and saves data permanently. Data stored in primary memory can be directly accessed by the CPU, which cannot be accessed in secondary memory. 20.Functions of control unit: Fetching instructions one by one from primary memory and gather required data and operands to perform those instructions. Sending instructions to ALU to perform additions, multiplication etc. Receiving and sending results of operations of ALU to primary memory Fetching programs from input and secondary memory and bringing them to primary memory Sending results from ALU stored in primary memory to output 21. (5.375)10 22. Python Identifier is the name we give to identify a variable, function, class, module or other object. Basically, identifiers are the sequences of alphabet or digits 23. Selection: Algorithms can use selection to determine a different set of steps to execute based on a Boolean expression. Iteration: Algorithms often use repetition to execute steps a certain number of times or until a certain condition is met. 24. The for loop is as follows: for i in range(1,11): print(“%d” %i) 25.In Lists and Tuples, the items are retained in the order in which they are inserted. The elements can always be accessed based on their position. The element at the position or 'index' 0 will always be at index 0. Therefore, the Lists and Tuples are said to be ordered collections. SECTION C: 26. str= input(“Enter any string”) dict={ } for ch in str: if ch in dict: dict[ch]+=1 else: dict[ch]=1 print(dict) output: Enter any string: alphabet {‘a’:2, ‘l’=1, ‘p’=1, ‘h’=1, ‘b’=1, ‘e’=1, ‘t’=1} 27. o Create strong passwords. ... o Don't overshare on social media. ... o Use free Wi-Fi with caution. ... o Watch out for links and attachments. ... b) Identity theft 28. The term dynamic typing means that a compiler or an interpreter assigns a type to all the variables at run-time. The type of a variable is decided based on its value. 29.pop() clear() count() 30.mylist=[10,20,30,40,[50,60]] mylist=[10,20,30,40,[50,60],80,90] mylist=[10,20,30,40,[50,60],80,90] SECTION D 31.dict={‘p’:9, ‘y’=20, ‘t’=4, ‘h’=8, ‘o’=1, ‘n’=5} lst=list() for a in dict.values(): lst.append(a) lst.sort() print(“highest value:”,lst[-1]) print(“second highest value:”, lst[-2]) Output: Highest value: 20 Second highest value: 9 32.(i) 110 108 106 104 102 (ii) 20 22 24 26 28 (iii) I N D I A (iv) 12 33.for i in range(1,11): print(“table %d” %i) print(“…………”) for j in range(1,11): k=i*j print(“%d * %d=%4d” %(i,j,k)) 34.global plagiarism paraphrasing plagiarism verbatim plagiarism 35. a) c b)(ii) c) iii d) b e) d. Class: XI Session: 2022-23 Computer Science (083) Sample Question Paper (Theory) Maximum Marks: 70 Time Allowed: 3 hours General Instructions: 1. This question paper contains five sections, Section A to E. 2. All questions are compulsory. 3. Section A have 18 questions carrying 01 mark each. 4. Section B has 07 Very Short Answer type questions carrying 02 marks each. 5. Section C has 05 Short Answer type questions carrying 03 marks each. 6. Section D has 03 Long Answer type questions carrying 05 marks each. 7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35 against part c only. 8. All programming questions are to be answered using Python Language only. SECTION A 1. State True or False 1 “Antivirus software is type of system software” 2. Which of the following is a valid data type in Python? (a) For (b) None (c) for (d)while 3. Which character is used in Python to make a single line comment? 4. 1 1 (a) / (b) // (c) # (d) * Choose the name of the process in which someone's intellectual work is 1 stolen by someone and represented as its own. (a) Copying (b) Plagiarism (c) Copy and paste (d) Intellectual steal 5. Which statement is correct? 1 (a) List is immutable && Tuple is mutable (b) List is mutable && Tuple is immutable (c) Both are Mutable. (d) Both are Immutable 6. What is the output of this expression 2 * 3 ** 3 * 4 ? (a) 216 (b) 864 (c) 72 (d) 1 Error 7. What is the output of the following code: 1 x = 100 y = 50 print(x and y) (a) True (b) 100 8. (c) False (d) 50 Operating system is an example of which type of software? (a) Application software (b) System software (c) Utility Software (d) None of these 1 9. Which of the following statement(s) would give an error after executing the following code? str1="Hello" 1 # Statement 1 print(str1) # Statement 2 str2=10 # Statement 3 str3=str1+str2 S=str1*str3" # Statement 4 #Statement5 (a) Statement 3 (b) Statement 4 (c) Statement 5 (d) Statement 4 and 5 10. What is the most widely used method for e-waste disposal? 1 (a) Burning (b) Recycling (c) Landfilling (d) Disintegration 11. Find out the type of error in the following code: 1 x=x+10 y=x*x print(x,y) (a) Value error (b) Name error (c) Type error (d) none of above 12. Find out the output of given code: if 1 + 3 == 7: print("Hello") 1 else: print("Bye") (a) Bye (b) Hello (c) HelloBye (d) hello Bye 13. Fill in the blank: 1 Memory can not store the data permanently. (a) Flash Memory (b) Cache (c) RAM 14. Convert the following while loop into for loop: (d)Hard Disk 1 x=0 while(x <4): print(x) x = x+1 15. Choose the correct data type for given example. 1 a=[5,4,9,’a’,’b’] (a) List (b) Tuple (c) String (d) None of above 16. Python considers the character can be enclosed in triple quotes then 1 choose the option true\false. (a) True (b) False (c) can not say (d) none of above Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as (a) Both A and R are true and R is the correct explanation for A (b) Both A and R are true and R is not the correct explanation for A (c) A is True but R is False (d) A is false but R is True 17. Assertion: Recycling is the only solution for the treatment of e- 1 waste, provided it is carried out in an environment friendly manner. Reason: During the recycling process, metals like copper, iron, silicon, nickel and gold are recovered in developing countries. 18. Assertion (A): Items in dictionaries are unordered. 1 Reason (R): We may not get back the data in which order we had entered the data initially. SECTION B 19. What will be the output of the following Python program? i=0 while i < 5: print(i) i += 1 if i == 3: break else: print(0) 2 20. Draw the logic circuit for the following equation: 2 A’B’+(AB)’ OR Draw the logic symbol of any two basic gates. 21. What is the result of executing the following code? 1 number = 5 while number <= 5: if number < 5: number = number + 1 print(number) (a) The program will loop indefinitely (b) The value of number will be printed exactly 1 time (c) The while loop will never get executed (d) The value of number will be printed exactly 5 times 22. Define nested tuples and write one example to show operation of the 2 nested list. 23. Write any two possible solutions for special needs students. 2 or Define plagiarism and why it is a punishable offense? 24. Predict the output of the Python code given below: L=[2,3,4,6,9,3,8,9) 2 print(L.index(4)) print(L.count(3)) L.append(L.count(9)) print(L) OR Predict the output of the Python code given below: T1=(1,2,3,4,5,6,7,8) print(T1[0]) print(T1[-1]) print(T1[4-1]) print(T1[2:6:2]) 25. Evaluate any two from the following conversions: 2 (a) (421.5)10=(?)8 (b) (BAD)16=(?)10 (c) (1101100)2=(?)16 SECTION C 26. A tuple store marks of a student in 5 subjects .Write a program to 3 calculate the grade of the student as per following details: Average Grade >=80 A 80-70 B 70-55 C 55-33 D <33 E 27. Proof the Demorgan's Laws with the help of truth tables. 3 OR Explain Universal gates with the help of truth tables. 28. ASHA making a project on” Environment cleanliness” and downloading some pages from web browser ,she completed her work in three steps ,so give your justification for following steps if any ethics violates or not : 3 (a) She read a paragraph then she pasted it in her report with the same words. (b) She downloaded images and pasted them in her report in the form of collage. (c) She copied the logo of one organization related with cleanliness and pasted on front page of her report 29. Write a program that repeatedly asks the user to enter product names 3 and prices. Store all of them in a dictionary whose keys are product names and values are prices. And also write a code to search an item from the dictionary. For example: If D={‘eraser’: 10,’pen’:25,’pencil’:10} Enter the product you want search: ‘eraser’ output: “product found with price: 10” otherwise “ Not found” 30. Write a program for checking whether the given string is palindrome or not. 3 For Example: Entered string :” MoM” output: Entered string is palindrome string OR Write a program to find the average of the list of the numbers entered through keyboard. for Example: L=[2,6,7,8,9,10] Output: Average of the numbers is : 7 SECTION D 31. Write the output for the following statements on the given string: s= “ interesting facts” (a) print(s.upper()) (b) print((s.split(‘ ‘ )) (c) print(s.find(‘CTS’)) (d) print(s.index(‘e’)) (e) print(s.replace(‘sacts’, ‘idea’)) OR Write a program for checking whether the given character is uppercase ,lowercase, digit ,special symbol or white space. 5 32. Write the most appropriate list method to perform the following task: 5 (a) Add 4th element in the given list (b) Add element in the last position of the list (c) Delete 2nd element from the given list (d) Delete the given element from the given list (e) Add elements more than one at the end of given list. 33. Write a program to create a dictionary with the roll number,name and marks of n students in a class and displays the name of students whose marks are greater than 70. OR Write a program to print minimum, maximum,sum of keys of numbers dictionary as given below: numbers= {1:100,2:200,3:300,4:400} 5 SECTION E 34. Match the following: Column A Column B Plagiarism Fakers, by offering special rewards or money prize asked for personal information, such as bank account information Hacking Copy and paste information from the Internet into your report and then organise it Credit fraud 4 card The trail that is created when a person uses the Internet. Digital Foot Breaking into computers to read private emails Print and other files 35. Explain any 4 built in functions which can be performed over a given 4 tuple. OR Explain any 4 built in functions which can be performed over a given list. KENDRIYA VIDYALAYA SANGATHAN, CHENNAI REGION SAMPLE QUESTION PAPER-2022-23 CLASS XI SUBJECT: COMPUTER SCIENCE Note: a) All questions are compulsory. Time: 3 HOURS b) Give examples wherever possible. Max Marks: 70 Q. Question No SECTION A 1.a) 0010 0101 01102 1 b) C. NAND and NOR 1 c) process 1 d) A) RAM 1 e) (A+B)’ = A’ . B’ 1 (A.B)’= A’ + B’ Software used for maintenance and configuration of the computer system is 2 called system utility. Some system utilities are shipped with the operating system for example disk defragmentation tool, formatting utility, system restore utility, etc. Another set of utilities are those which are not shipped with the operating system but are required to improve the performance of the system, for example, anti-virus software, disk cleaner tool, disk compression software, etc. 2 f) G) H) Give full form of: vii) ISCII - Indian Script Code for Information Interchange viii) MICR - Magnetic Ink Character Recognition ix) OCR - Optical Character Recognition. 3 SECTION B 2.a) iii) b) c) split() 18.0 1 1 d) (iv) tuple 1 e). In the above code, X will take minimum value 1 and maximum value 4 1 f) Correct the errors in the given code and underline the corrections Num = int(input("Number:")) Sum = 0 for i in range(0,Num): Sum+=i if i%5: print( i*2) else: print ( Sum) Predict the output of the following code snippet if N is given the value 2: 1*2=2 2*2=4 4*2=8 6 * 2 = 12 7 * 2 = 14 N=eval(input('enter a list of numbers:')) for i in range(len(N)): if i%2 == 0: N[i] *= 3 mutable -- List , diuctionary immutable datatypes – int, string, tuple 2 abcabc 9 2 String = input('Enter a string:') if String == String[-1::-1]: print('its a palindrome') else: print('its not a palindrome') 12.Take regular backup of important data 13.Use an antivirus software and keep it updated always 2 3.a) b) c) d) e) f) myname1 ii) While 1 3 2 2 2 2 g) 4.a) b) c) 14.Avoid installing pirated software. Always download software from known and secure (HTTPS) sites 15.Always update the system software which include the Internet browser and other application software 16.Do not visit or download anything from untrusted websites 17.Usually the browser alerts users about doubtful websites whose security certificate could not be verified; avoid visiting such sites 18.Use strong password for web login, and change it periodically. Do not use same password for all the websites. Use different combinations of alphanumeric characters including special characters. Ignore common words or names in password 19.While using someone else’s computer, don’t allow browser to save password or auto fill data, and try to browse in your private browser window 20.For an unknown site, do not agree to use cookies when asked for, through a Yes/No option. 21.Perform online transaction like shopping, ticketing, and other such services only through well-known and secure sites 22.Always secure wireless network at home with strong password and regularly change it. 1. Give Back to Your Electronic Companies and Drop Off Points 2 2. Visit Civic Institutions 3. Donating Your Outdated Technology 4. Sell Off Your Outdated Technology A=100 1 print(a) NameError: name 'a' is not defined 5.5 1 If L =[10,14,18,22,’four numbers’], evaluate and following V) [14, 'four numbers'] VI) 'four' write the output of the 2 d) What will the output for following code? Model Experiment 2022. CS Science 3 e) List is indexed sequence -- Dictionary is mapping List can be sliced. Dictionary cannot be sliced 2 f) print ("Program to generate factorial of a given number") no=int(input("enter the natural number: ")) if no < 0: print('factorial not possible for negative number') else: fact=1 i=1 while i<=no: fact*=i i+=1 print("factorial of given number",fact) i) extend() function in list is used to add multiple elements at end of list 2 g) ii) 2 <class 'int'> SECTION C 5.a) Identify the type of cyber crime for the following situations: 1 (c) Copyright infringement 2. Card fraud 5 3. Trolling 4. Phishing 5. Cyber bullying b) print('****program to find greatest of 3 numbers****') num1,num2,num3=eval(input('enter 3 unique numbers: ')) if num1 > num2 and num1 > num3: print('The greatest of the three nos. is : ',num1) elif num2 > num3 and num2 > num1: print('The greatest of the three nos. is : ',num2) elif num3 > num1 and num3 > num2: print('The greatest of the three nos. is :',num3) else: print('any two nos are equal') 5 c) k) Print name of all the students having score >250 for name in results: if results[name]>250: print (name) l) Results [‘C’] = 450 m) sum = 0;cnt =0 for name in Results: sum += Results[name] cnt+=1 avg = sum/cnt n) Results[‘G’]=290 o) del Results['C'] OR 5 s= “Welcome to python world” Write output for given statements: k) print (s.isalpha()) -- False l) print (s.islower()) -- False m) print(s.upper()) -- 'WELCOME TO PYTHON WORLD' n) print(s.capitalize()) -- 'Welcome to python world' o) print(s.title()) -- 'Welcome To Python World' SECTION D e) J. K. statistics continue [1] [1] 4 L. else M. lower() [1] N. break [1] f) [1] xi) b) xii) c) Pseudocode It calculates sum of digits of a Number N xiii) a) 0 xiv) b) Will not effect on the result of the algorithm and it will be same as earlier. xv) c) Iterative (Cyclic) Class: XI Session: 2022-23 Computer Science (083) Marking Scheme (Theory) Maximum Marks: 70 Time Allowed: 3 hours General Instructions: 1. This question paper contains five sections, Section A to E. 4 2. All questions are compulsory. 3. Section A have 18 questions carrying 01 mark each. 4. Section B has 07 Very Short Answer type questions carrying 02 marks each. 5. Section C has 05 Short Answer type questions carrying 03 marks each. 6. Section D has 03 Long Answer type questions carrying 05 marks each. 7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35 against part c only. 8. All programming questions are to be answered using Python Language only. SECTION A 1. State True or False 1 “Antivirus software is type of system software” Ans:- False 2. Which of the following is a valid datatype in Python? (a) For (b) None (c) for 1 (d)while Ans: (a) For 3. Which character is used in Python to make a single line comment? 1 (a) / (b) // (c) # (d) * Ans: (c) # 4. Choose the name of the process in which someone's intellectual work is stolen by someone and represented as its own. (a) Copying (b) Plagiarism (c) Copy and paste (d) Intellectual steal 1 Ans: (b) Plagiarism 5. Which statement is correct? 1 (a) List is immutable && Tuple is mutable (b) List is mutable && Tuple is immutable (c) Both are Mutable. (d) Both are Immutable Ans : (b) List is mutable && Tuple is immutable 6. What is the output of this expression 2 * 3 ** 3 * 4 ? (a) 216 (b) 864 (c) 72 1 (d) Error Ans: 216 7. What is the output of the following code: x = 100 y = 50 print(x and y) (a) True (b)100 (c) False 1 (d)50 Ans: 50 8. Operating system is an example of which type of software? (a) Application software (b) System software (c) Utility Software (d) None of these Ans: (b) System software 1 9. Which of the following statement(s) would give an error after executing the following code? str1="Hello" print(str1) # Statement 1 # Statement 2 str2=10 # Statement 3 str3=str1+str2 S=str1*str3 1 # Statement 4 # Statement 5 (a) Statement 3 (b) Statement 4 (c) Statement 5 (d) Statement 4 and 5 Ans: (d) Statement 4 and 5 1 What is the most widely used method for e-waste disposal? 0. (a) Burning (b) Recycling (c) Landfilling 1 (d) Disintegration Ans: ( c ) Landfilling 1 Find out the type of error in the following code: 1. x=x+10 y=x*x print(x,y) (a) (b) Value error Name error 1 (c) (d) Type error none of above Ans: (b) Name error 1 Find out the output of given code: 2. if 1 + 3 == 7: 1 print("Hello") else: print("Bye") (a) (b) (c) (d) Bye Hello HelloBye hello Bye Ans: (a) Bye 1 Fill in the blank: 3. Memory can not store the data permanently. (a) Flash Memory Disk (b) Cache (c) RAM 1 (d)Hard Ans: (c) RAM 1 Convert the following while loop into for loop: 4. x=0 while(x <4): print(x) x = x+1 Ans: for i in range(x): print(x) 1 1 Choose the correct data type for given example. 5. a=[5,4,9,’a’,’b’] (a) (b) (c) (d) 1 List Tuple string None of above Ans: (a) List 1 Python considers the character can be enclosed in triple quotes 6. then choose the option true\false. 1 (a) (b) (c) (d) True False can not say none of above Ans: (a) True Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as (a) Both A and R are true and R is the correct explanation for A (b) Both A and R are true and R is not the correct explanation for A (c) A is True but R is False (d) A is false but R is True 17. Assertion: Recycling is the only solution for the treatment of e-waste, provided it is carried out in an environment friendly manner. Reason: During the recycling process, metals like copper, iron, silicon, nickel and gold are recovered in developing countries. Ans : (b) 1 18. Assertion (A): Items in dictionaries are unordered. 1 Reason (R): We may not get back the data in which order we had entered the data initially. Ans: (b) SECTION B 19. What will be the output of the following Python program? 2 i=0 while i < 5: print(i) i += 1 if i == 3: break else: print(0) Ans: 0 1 2 20. Draw the logic circuit for the following equation: A’B’+(AB)’ 2 mark for correct logic circuit OR Draw the logic symbol of any two basic gates . 1-1 mark for each correct symbol 2 21. What is the result of executing the following code? 1 number = 5 while number <= 5: if number < 5: number = number + 1 print(number) (a) The program will loop indefinitely (b) The value of number will be printed exactly 1 time (c) The while loop will never get executed (d) The value of number will be printed exactly 5 times Ans: (a) The program will loop indefinitely 22. Define nested tuples and write one example to show operation of the nested list. 2 Ans: 1 mark for definition and 1 mark for correct example 23. Write any two possible solutions for special needs students. Ans: 1-1 mark for any correct answer or Define plagiarism and why it is a punishable offense? Ans: Plagiarism is defined as stealing or presenting someone's ideas or words of another author as your own. ● Plagiarism is literally equal to theft and fraud since you are stealing someone's content and pretending that it is your own. ● That is why it is punishable in all universities and considered illegal by the copyright law of different countries. 1 mark for definition ,1 mark for offense 2 24. Predict the output of the Python code given below: L=[2,3,4,6,9,3,8,9) print(L.index(4)) print(L.count(3)) L.append(L.count(9)) print(L) Ans: 2 2 [2,3,4,6,9,3,8,9,2] ½ mark for each correct answer OR Predict the output of the Python code given below: T1=(1,2,3,4,5,6,7,8) print(T1[0]) print(T1[-1]) print(T1[4-1]) print(T1[2:6:2]) Ans: 1 8 4 [3,5] ½ mark for each correct answer 2 25. Evaluate any two from the following conversions: 2 (a) (421.5)10=(?)8 (b) (BAD)16=(?)10 (c) (1101100)2=(?)16 Ans: (a) 645.4 (b)2989 (c) 6C SECTION C 26. A tuple store marks of a student in 5 subjects .Write a program to calculate the grade of the student as per following details: Average Grade >=80 A 80-70 B 70-55 C 55-33 D <33 E 3 Partial marking can be given for correct code 27. Proof the Demorgan's Laws with the help of truth tables. Ans: 1 mark for defining laws and 2 mark for truth table OR Explain Universal gates with the help of truth tables. Ans : 1.5 mark for each correct gate 3 28. ASHA making a project on”Environment cleanliness” and downloading some pages from web browser ,she completed her work in three steps ,so give your justification for following steps if any ethics violates or not : 3 (a) She read a paragraph then she pasted it in her report with the same words. (b) She downloaded images and pasted them in her report in the form of collage. (c) She copied the logo of one organization related with cleanliness and pasted on front page of her report. Ans: (a) and (b) Plagiarism because she is copying someone data and showing as her work (b) copyright because some organization registered that logo. 1-1 mark for each correct answer j 29. Write a program that repeatedly asks the user to enter product names and prices. Store all of them in a dictionary whose keys are product names and values are prices. And also write a code to search an item from the dictionary. 3 For example: If D={‘eraser’: 10,’pen’:25,’pencil’:10} Enter the product you want search: ‘eraser’ output: “product found with price: 10” otherwise “ Not found” Ans: Partial marking can be given for correct code 30. Write a program for checking whether the given string is palindrome or not . For Example: Entered string :” MoM” output: Entered string is palindrome string. 3 Ans: Partial marking can be given for correct code x = "MoM" w = input(“Entered string:”) if (x == w): print("Entered string is palindrome string") else: print("Not palindrome") OR Write a program to find the average of the list of the numbers entered through keyboard. for Example: L=[2,6,7,8,9,10] Output: Average of the numbers is : 7 Ans: Partial marking can be given for correct code SECTION D 31 . Write the output for the following statements on the given string: s= “ interesting facts” (a) print(s.upper()) (b) print((s.split(‘ ‘ )) (c) print(s.find(‘CTS’)) (d) print(s.index(‘e’)) (e) print(s.replace(‘sacts’, ‘idea’)) Ans: (a) INTERESTING FACTS (b) ‘interesting’, ‘ facts’ (c) -1 5 (d) 3 (e) interesting idea 1-1 mark for each correct answer OR Write a program for checking whether the given character is uppercase ,lowercase,digit ,special symbol or white space. Ans: Partial marking can be given for correct code 32. Write the most appropriate list method to perform the following task: 5 (a) Add 4th element in the given list (b) Add element in the last position of the list (c) Delete 2nd element from the given list (d) Delete the given element from the given list (e) Add elements (more than one at the end of the given list. Ans: (a) insert() (b) append() (c ) pop() (d) remove() (e) extend() 33 . Write a program to create a dictionary with the roll number,name and marks of n students in a class and displays the name of students whose marks are greater than 70. Ans: ½ -½ mark for each correct statement OR Write a program to print minimum, maximum,sum of keys of numbers dictionary as given below: numbers= {1:100,2:200,3:300,4:400} Ans: ½ -½ mark for each correct statement 5 SECTION E 34 . Match the following: Column A 4 Column B Plagiarism (a) Fakers, by offering special rewards or money prize asked for personal information, such as bank account information Hacking (b) Copy and paste information from the Internet into your report and then organize it Credit fraud card (c ) The trail that is created when a person uses the Internet. Digital Print Foot (d) Breaking into computers to read private emails and other files Ans: Column A Column B 1. Plagiarism (b) 2. Hacking (d) 3. Credit card fraud (a) 4. Digital foot print (C) 1-1 mark for each correct answer 35. Explain any 4 built in functions which can be performed over a given 4 tuple. Ans: 1-1 mark for each correct function OR Explain any 4 built in functions which can be performed over a given list. Ans: 1-1 mark for each correct function Class: XI Session: 2022-23 Computer Science (083) Sample Question Paper (Theory) Maximum Marks: 70 Time Allowed: 3 hours General Instructions: 1. This question paper contains five sections, Section A to E. 2. All questions are compulsory. 3. Section A has 18 questions carrying 01 marks each. 4. Section B has 07 Very Short Answer type questions carrying 02 marks each. 5. Section C has 05 Short Answer type questions carrying 03 marks each. 6. Section D has 03 Long Answer type questions carrying 05 marks each. 7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35 against part c only. 8. All programming questions are to be answered using Python Language only. SECTION A 1. Antivirus software is _______________ software. a. Application d. Chat b. Operating System 1 c. System Ans: (a). Application 2. Which of the following data types is not indexed in Python? 1 (a) list (b) dictionary (c) string (d)tuple Ans: (b). Dictionary 3. Which character is used in Python to make a multi line comment? 1 (a) / (b) ‘’’ (c) # (d) * Ans: (b) ‘’’ 4. Things like these, e.g., online email account, social media 1 account or handle, online shopping account, online photo sharing account, trademarks, own registered domain name etc.. collectively called _______________. (a) Online Identity (b) Online estate (c) Digital identity (d) Digital property Ans: (d). Digital property 5. Which statement is correct? (a) List is immutable && Tuple is mutable (b) List is mutable && Tuple is immutable (c) Both are Mutable. (d) Both are Immutable Ans: (b) List is mutable && Tuple is immutable 1 6. What is the output of this expression 5//2 ? (a) 2 (b) 2.5 (c) 2.0 1 (d) 1 Ans: (a) 2 7. What is the output of the following code: x = 100 y = 50 print(x or y) (a) True (b)100 1 (c) False (d)50 Ans: (b).100 8. Which of the following is not an operating system: a. Windows b. Linux c. Oracle 1 d. DOS Ans: (c). Oracle 9 Which of the following statement(s) would give an error after executing the following code? str1="Hi" 1 print(str1) 2 # Statement # Statement str2=10 # Statement 3 str3=str1+str2 # Statement 4 1 S=str1*str3 (a) (b) (c) (d) # Statement 5 Statement 3 Statement 4 Statement 5 Statement 4 and 5 Ans: (d) Statement 4 and 5 10. Write any two benefits of e-Waste Recycling. 1 Ans: 1. Allows for recovery of valuable precious metals 2. Creates jobs 3. Toxic Waste Or any other related answers. 11. Find out the type of error in the following code: 1 x=x+10 y=x*x print(x,y) (a) (b) (c) (d) Value error Name error Type error none of above Ans: (b) Name error 12. Find out the output of given code: 1 a=5 b=True c=a+b print(c) (a) (b) (c) (d) error 6 0 None of these Ans:(b) 6 13 ASCII code is a 7 bit code for (a)letters (b) numbers 1 (c) other symbols (d)all of these Ans: (d). All of these 14 Consider the loop given below: 1 for i in range ( 10, 2, -3): break What will be the final value of i after this loop: a). 5 b). 10 c). 4 d).-3 Ans: (b) 10 15 Choose the correct data type for given example. a=(5,4,9,’a’,’b’) 1 (a) List (b) Tuple (c) string (d) None of above Ans: (b) Tuple 16 Flash memory is a type of ___________________ memory. a). Primary b). Secondary 1 c). cache d).RAM Ans: (b). Secondary 17. Assertion: Developed countries have specifically built facilities 1 for recycling of e-wastes. Reason: Recycling in developing countries often involves manual participation thus exposing workers to toxic substances present in e-wastes. A. Both assertion and reason are true and the reason is the correct explanation of the assertion B. Both assertion and reason are true but reason is not the correct explanation of the assertion C.Assertion is true but reason is false D. Both assertion and reason are false. Ans: (b). 18. The default separator character of print( ) is ___________. 1 a). Space b). tab c). newline d). Dot Ans: (a) Space SECTION - B 19. Following code contains an endless loop. Could you find out why? 2 Suggest a solution. n=10 result=1 while (n > 0): result = result + n**3 n=n+1 print(result) Ans: For a while loop to terminate, it is necessary that its condition becomes false at one point. But in the above code condition n>0 never false and n is always incrementing. Possible solution: 1) Instead of n=n+1 we can use n=n-1. 20. Draw the logic circuit for the following equation: y=ab+b’c+c’a’ 2 mark for correct logic circuit 2 O R State and verify distributive law. Ans: 1. X(Y+Z) = XY + XZ 2. X+YZ = (X+Y) (X+Z) 21. D= {‘apple’:15, ‘orange’:20} is a dictionary in python. 2 (i) Write a python statement to add a new element ‘banana’:20 in the dictionary D. (ii) Write a python statement to change the value of apple to 10 in the dictionary D. Ans: (i). D[‘banana’']=20 (ii). D[‘apple’]=10 22. Write the difference between append( ) and extend( ) functions. Ans: append( ) can append only a single element. extend( ) can append a list of elements. 2 23. Define plagiarism and why it is a punishable offense? 2 Ans: Plagiarism is defined as stealing or presenting someone's ideas or words of another author as your own. ● Plagiarism is literally equal to theft and fraud since you are stealing someone's content and pretending that it is your own. ● That is why it is punishable in all universities and considered illegal by the copyright law of different countries. 1 mark for definition ,1 mark for offense Or Vikas has to make an online transaction through net banking. He wants to make sure that he is opening the genuine bank website and not some fake page. Write any two ways in which he can identify if his connection to the banking website is secure. Ans: 2 marks for related answers. 24. Find the output of the following code: x, y, z =15, 20, 10 y=x+2 x+=5 z=y print(x,y,z) Ans: 20 17 17 or Predict the output of the Python code given below: L=[2,3,4,6,9,3,8,9] print(L.index(4)) 2 print(L.count(3)) L.append(L.count(9)) print(L) Ans: 2 2 [2, 3, 4, 6, 9, 3, 8, 9, 2] 25 Convert the following:( any two) 2 (a) (FA CE)16=(?)2 (b) (125)10=(?)8 (c) (1110101000.100100)2=(?)8 Ans: (a) F - 1111, A - 1010 , C- 1100 E- 1110 (b) 175 (c) 1650.44 SECTION - C 26. Write a program which replaces all vowels in the string with ’*’ 3 Ans: Partial marking can be given for correct code 27. Explain Universal gates with the help of truth tables. Ans : 1.5 mark for each correct gate OR State and verify the following: 3 1. Involution law 2. Associative law Ans: 1 mark for defining laws and 2 marks for truth tables. 28. Discuss in detail about operators with suitable examples. 3 Ans : 1 mark for definition of operator 2 marks for list outing all operators 29. Kavi making a project on”Environment cleanliness” and 3 downloading some pages from web browser ,she completed her work in three steps ,so give your justification for following steps if any ethics violates or not : (a) She read a paragraph then she pasted it in her report with the same words. (b) She downloaded images and pasted them in her report in the form of collage. (c) She copied the logo of one organization related to cleanliness and pasted it on the front page of her report. Ans: (a) and (b) Plagiarism because she is copying someone data and showing as her work (b) copyright because some organization registered that logo. 1-1 mark for each correct answer 30. What will be the output of the following statements? i) list1 = [12,32,65,26,80,10] list1.sort( ) 3 print(list1) ii) list1 = [12,32,65,26,80,10] sorted(list1) print(list1) iii)list1 = [1,2,3,4,5,6,7,8,9,10] list1[::-2] list1[:3] + list1[3:] Ans: i). [10, 12, 26, 32, 65, 80] ii). [12, 32, 65, 26, 80, 10] iii). [10, 8, 6, 4, 2] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] SECTION - D 31 Explain any 5 built in functions which can be performed over a 5 given tuple. Ans: Ans: 1-1 mark for each correct function 32. Write the output for the following statements on the given string: s= “PYTHON program” (a) print(s.lower()) (b) print((s.split(‘ ‘ ))) 5 (c) print(s.isalpha( )) (d) print(s.index(‘o’)) (e) print(len(s)) Ans: (a). python program (b). ['PYTHON', 'program'] (c). False (d). 9 (e). 14 OR Write a program for checking whether the given character is uppercase ,lowercase,digit ,special symbol or white space. Ans: Partial marking can be given for correct code 33. 1. Differentiate between clear( ), pop( ) and popitem( ) 5 functions in the Dictionary by giving examples for each. 2. What will be the output of following program: aList = [1,2,3,5,6,1,5,6,1] fDict = {} for i in aList: fDict[i] = aList.count(i) print (fDict) 3. What will be the output of following program: test = {1:'A', 2:'B', 3:'C'} del test[1] test[1] = 'D' del test[2] print(len(test) Ans: 1. 1 - mark for definition of clear( ) 1 - mark for definition of pop( ) 1 - mark for definition of popitem( ) 2. {1: 3, 2: 1, 3: 1, 5: 2, 6: 2} 1 mark 3. 2 (1 mark) SECTION - E 34. Match the following: 4 Column A Column B Ransomware Fakers, by offering special rewards or money prize asked for personal information, such as bank account information Hacking Crime, in which the attacker blackmails the victim to pay for getting access to the data Credit card fraud The trail that is created when a person uses the Internet. Digital Footprint Breaking into computers to read private emails and other files Ans: Column A Column B 1. Ransomware (b) 2. Hacking (d) 3. Credit card fraud (a) 4. Digital footprint (c) 1-1 mark for each correct answer 35 Write the most appropriate list method to perform the following 4 task: (a) Add 5th element in the given list (b) Add element in the last position of the list (c) Reverse the items of the list (d) Delete the given element from the given list Ans: 1-1 mark for each correct function or Discuss in detail the following: a). if - else statement b). Differentiate between break and continue statements c). for loop Ans: 1 mark for correct definition of if-else statement 1 mark for correct definition of break statement 1 mark for correct definition of continue statement 1 mark for correct definition of for loop statement