0% found this document useful (0 votes)
112 views20 pages

9th Class Computer Science CH 2 English Medium

Computer Science grade 9 chapter 2

Uploaded by

almasnasir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
112 views20 pages

9th Class Computer Science CH 2 English Medium

Computer Science grade 9 chapter 2

Uploaded by

almasnasir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 20
a (2) Team Clit) Se stay | ey ee at oe a eee = and Oss called binary number system. The usage of a ree} area feo ° | ee ott Students’ Learning Outcomes 11. Introduction of number systems © Describe following number systems with Examples = Binary = Decimal = Hexadecimal 2, Number System Conversion © Convert binary to decimal and decimal to binary number system © Convert decimal to hexadecimal and hexadecimal to decimal number system © Convert binary to hexadecimal and hexadecimal to binary number system 3. Memory and data storage © What is memory? © Understand how data is represented in @ computer memory (with reference of bits and bytes) © Storage device © Difference between memory and storage devices. 4, Measurement of size of computer memory. © Define following Terms = Bit = aye = Kilobyte mt Megabyte © Gigabyte m Terabyte Petabyte 5. Boolean algebra Explain © ABoolean proposition © Truth values © Logical operators (AND, OR, NOT) © Truth tables © Lams of Boolean algebra = Commutative Associative = Distributive Identity © Logical expressions 2.1 Introduction to Number Systems ‘A number system is the system for representation of numeric data. We all are familiar with decimal number system where each number consists of digits from 0 to 9. In a computer system, other number systems are also used. We discuss few number systems in the following sections. 2.1.1 Decimal Decimal Number The number system we use in our daily life is the decimal number system. The decimal number system has base 10 as it uses ten digits [0-9]. Each position represents a specific power of base 10 as shown in Figure 2-1. Figure 2-1 Examples: = 892 = 8x 10?+9x 10! +2x 10° . 1247 = 1x 109 +2 10? +4x 10° +7 x 10° = 53=5x10'+3x 10° Pepe Decimal number system is also called Hindu-Arabic, or Arabic, number system, in mathematics 2.1.2 Binary Binary number system has base 2 as all the numbers in this system consist of only two digits ie. 0 and 1. Digital computers use this system to store data. Your name is in the form of alphabets, but for a computer each alphabet has some binary value. Example: The binary value of the letter ‘A’ is 01000001 and its decimal value is 65. 2.1.3 Hexadecimal Hexadecimal system has total 16 numbers, ie, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A,B, C, D, E, F, where A=10, B=11, C=12, D=13, E=14 and F=15 (as shown in Figure 2-2). Example: 3F28 Deno 2.2. Number System Conversion We can convert a number from one number system to another and vice versa. In the following, we discuss conversions among different number systems. 2.2.1 Decimal to Binary and Binary to Decimal ‘+ Decimal to Binary To convert a decimal number to binary, we divide the number by 2 and take quotient and remainder. We continue dividing the quotient by 2 until we get quotient 0. We write out all the remainders in reverse order to obtain the value in binary. 2 |:isenea Example: 30 Convert 15619 (156 in decimal) to binary 2fas =a Table 2-1 shows the method to solve this 3} problem. Remainders are taken from bottom to “2[2 0 top to present the binary number. So, 3)-5—=0 15619 = 100111005. ——> Table 2-1 ce Ee! in the final examination of 8th clas ith your class fellows. Convert that © Binary to Decimal The conversion of a number from binary number system to decimal number system is explained below with the help of an example. Example: Convert (1000001), to decimal =1x2°+0% 240% 2440%2340% 2? +0x2' 412° 4+ 04040404041 65);0 The above conversion is done by the following steps Step 1. Write down the binary number which is (1000001), in this example. Step 2. List the powers of two from right to left starting with 0. In this example, the power of 2 starts from 0 and ends at 6. eed Step 3. Multiply 2's corresponding powers to each binary value. In the above example there are 7 binary values. Step 4. Compute each value. Step 5. Add all the values. Step 6. Write the answer along with its base subscript. Exchange your marks in binary form with your friends and convert them in decimal to know about their expectations in the board examination of 9th class. Double check with your class fellows that how much your calculations are accurate. Pere ‘According to Table 2-2, write in decimal, binary, and hexadecimal the time of your: © arrival at schoo! @ tunch = playing ial Binary 0 1 10 rT Table 2-2 pene Many online convertors for number systems are available. Try to find and use them. You can ask your class teacher to help in searching, 2.2.2 Decimal to Hexadecimal and Hexadecimal to Decimal * Decimal to Hexadecimal ‘As we have studied that hexadecimal number system has base 16, so for cr enc conversion of a number from decimal to hexadecimal, we divide the number by 16 and take both quotient and remainder. We continue dividing the quotient by 16 until the quotient becomes 0. Example: Convert (69610)i0 to Hexadecimal Table 2-3 shows the method to solve this problem. We 16] 69610 can observe from the table that remainder A is 26{ 4350 271 representation of 10, remainder E is representation of 14, and remainder F is representation of 15. Remainders are taken from bottom to top to present the hexadecimal number. So, (696100 = (LOFEA)is Teble23 ‘+ Hexadecimal to Decimal The method for this conversion is same as converting from binary to decimal except the base value. Since hexadecimal has base 16, the “place values" correspond to the powers of 16. To convert to decimal, multiply each place value by the corresponding power of 16. Start this process by writing the powers of sixteen next to the digits of a hexadecimal number. Example: Convert (C921): to decimal = CX 16° +9 x 16? +2x 16! + 1x 16° 12 x 165 +9 x 16? +2 16! +1x 16° = 12 x 4096 + 9.x 256+2x16+1%1 49152 +2304 +32 +1 = (51489)19 ce Ea Try to calculate that the binary of C9216 which is 11001001001000012. 2.2.3 Hexadecimal to Binary and Binary to Hexadecimal «Hexadecimal to Binary To convert a hexadecimal number to binary, simply convert each hexadecimal digit to four digits binary value. To find the four digits binary value, see the Table 2-4. Example: Convert (423); (A23 in hexadecimal) to binary. In this number, there are three hexadecimal digits. Binary of each digit is given as: i. For A, the binary value is 1010 For 2, the binary value is 0010 ili, For 3, the binary value is 0011 By combining all the binary values, we get 1010 0010 0011. 0 1 2 3 4 5 6 7 3 9 A 8 c © E F So, (A23);5 = (101000100011), aaa Example: Convert (70C558),, (70C558 in hexadecimal) to binary. In this number, there are six hexadecimal digits and binary of each is given in different colours as: i. For 7, the binary value is 0111 For 0, the binary value is 0000 |. For C, the binary value is 1100 iv. For 5, the binary value is 0101 v. For 5, the binary value is 0101 vi. For 8, the binary value is 1000 By combining all the binary values, we get 0111 0000 1100 0101 0101 1000. So, (70€558)1 = (011100001100010101011000),, + Binary to Hexadecimal This conversion is also very easy with the help of Table 2-4. In the given binary number, we start making groups of four digits from right to left and replace every group with a hexadecimal digit Example: Convert (11000001), to hexadecimal: The four digit binary groups in this binary number are given below where each group has four binary digits 1100 0001 i, For 1100, the hexadecimal is C For 0001 the hexadecimal is 1 So, (11000001), = (C1)s6 While making groups from right to left, if the left group has less than 4 binary digits then we simply add Os on the left. For example, 1010011 has groups 101 0011 and by adding one 0 on the left, it becomes 0101 0011. Example: Convert (110101111), to hexadecimal The groups in this binary number are given below where each group has maximum four binary digits. 1.1010 1111 The left most group in blue colour has only 1 binary digit and by adding Os, we get: 0001 1010 1111 We replace each group with the respective hexadecimal and get: AF, So, (110101111), = (1AF) 16 2.3 Memory and Data Storage 2.3.1 Memory Computer memory is any physical device capable of storing data, Primarily there are following two types of memory. 1+ Volatile Memory 2- Non-Volatile Memory Both types of computer memories are shown i we discuss these two types in detail. Figure 2-4. In the following, + Volatile Memory (Primary Storage) A device which holds data as long as it has power supply connected to it, is called Volatile Memory. Its best example is Random Access Memory (RAM), which holds memory only as long as it is connected to power source. As soon as the power supply is disconnected, all the data in RAM is cleared, + Non-Volatile Memory (Secondary Storage) A device which can hold data even if it is not connected to any power source, is called Non Volatile Memory. The typical examples for Non Volatile Memory are hard drives, flash drives and memory cards installed in cell phones. Even if you turn off your PC, the data in your hard drive or flash drive stays intact. lL —— Figure 2.3 volatile vs non-volatile memory 2.3.2 Data Representation in Computer Memory Digital computers store data in binary form. It means that whether it is a text, picture, movie or some application, it is stored in computer's memory in the form of Os and 1s, All the characters on your keyboard has an associated code in binary. This code is called ASCII code of the character. ASCII stands for American Standard Code for Information Interchange. It is a de-facto standard for representation of data inside computer's memory. Table 2-5 presents the ‘ASCII table which shows the code against each character on your keyboard. The codes are given in decimal form, but inside computer's memory they are represented after conversion to binary form, ieee eS ea 32 SP space 62 > greater than 33 ! ‘eclamationmark | 63 ? question mark 34 double quote 64 e "at symbol 35 ‘ number sign 6 a 36 s dollar sign 66 8 37 % percent 67 c 38 a ampersand a > 38 : single quote 6 E 0 G lettiopening parenthesis | 70 F a1 ) fight/closing parenthesis | 72 6 2 : asterisk R 4 8 + plus B 1 “4 i comma m4 2 45 : minus or dash 1 K 4 : dot 76 L a7 L forward slash 7 ™ 48 ° % N a a 7 ° 50 2 80 P 51 3 al Q 52 4 82 R 33 5 83 s 54 6 4 T 35 7 85 u 56 8 86 v 37 9 87 w 58 : «colon 88 x 38 : semi-colon 89 Y 60 < less than 90 z ot = ‘equal sign 91 c left/opening bracket eed 2 \ back slash 0 , 98 1 ‘ighticosing bracket | 111 ° 94 * caret/cicumfex nz P 95 z underscore 13 4 96 : na r 97 a ns 5 98 b 116 t 99 € 17 u 100 d 18 v 101 e ng w 102 t 120 x 103 9 121 y 104 h 12 2 105 H 13 i leftiopening brace 106 i 18 1 vertical bar 107 k 125 ) fight/dlosing brace 108 1 126 ~ tide 108 m a7 | Det delete Table 2-5 ASCII Table Example: To store name of our country ‘Pakistan’, in computer's memory, we need to store code of #0 ome each letter in one byte. As the word 107 1101011, “Pakistan” contains 8 letters, so 8 bytes 205_1101001 - : 15 | 1110011 are required for storage. It is 36 [1110100 demonstrated in Table 2-6. 97 1100001, n10| L010 Table 2-6 Activity 2.6 Write your complete name and give its presentation in binary format. ire eS ec 2.3.3 Storage Device ‘Any computing hardware that is used for storing, porting and extracting data, is called a storage device. It can hold or store information both temporarily and permanently. It can also be internal or external to a computer. An external storage device is a plug and play device, ie, we just plug it to some port and start using it without turning off a computer. To attach an internal storage device (Hard disk or RAM) we need to turn off the computer. Internal storage devices are connected to some fixed slots. Examples: RAM, Hard disk, CD, USB Flash Drive, etc. Difference between memory and storage Table 2-7 shows the difference between memory and storage. es Eee Place where an application loads its data during | Usually the place where data is stored for long processing or short term. Temporary storage device Permanent storage device Lesser in size Greater in size High accessing speed Low accessing speed Itis called primary memory Its called secondary memory Table 2-7 Difference between Memory and Storage 2.4 Measurement of Size of Computer Memory The smallest amount of data to be stored in computer's memory is @ 0 or 1. It is called a bit. A collection of eight bits is called a byte. At | gy, | Soup of eight its enough space ae to store single ASCII character, least one byte is required to store : ‘Klobyte | 1KB = 1,024 bytes any piece of information in a | megabyte] 1MB= (1024) KB or (L024) bytes computer's storage. On both [Gigabyte | 168= 1,024 MB oF (1,024) bytes primary and secondary storage | Tesbyte | XTB= 102468 or 024) byes devices, data is stored in the form Petebyte | IPB 1.024 TB or (024) pyres ei Table 2-8 of bytes. In Table 2-8 different ushecrast units of data are given. ui ‘Smallest unit of data, can hold only a fone value: Dor 2.5 Boolean Algebra 2.5.1 Boolean Proposition A proposition is a sentence that can either be true or false. For example, the following sentences are propositions. 1. “Someone from our school can join Pakistani Cricket Team” 2. “Iwill get A+ grade in board exam" 3. “Iwant to excel in mathematics” 4, “This year Pakistan Super League (PSL) final match will be played in Lahore” 5. “Tplay chess” But the following sentences are not propositions 1, Howare you? 2. Close the door. 3, Isithot outside? We can also assign some letter to a proposition, as shown in the following 1+ P= "Iplay chess’. 2+ Q= "Iwant to excel in mathematics” Now, when we say P, it means that we are referring to proposition “I play chess", and when we say Q it means that we are referring to proposition ‘I want to excel in mathematics”. Do you know? True and False are called Boolean values, The idea was given by George Boole (2 November 1815-8 December 1864) in his book "The Laws of Thought’. 2.5.2 Truth Values Every proposition takes one of two values true or false, and these values are called the truth values. Truth value is given on the basis of truthfulness or falsity of a proposition. Example: Assume P = “Islamabad is the capital of Pakistan”. You can assign the truth Easel value true to this proposition. Now assume another proposition Q = “The sun rises in the west’. The truth value for this proposition is false. If we have proposition R = “I have completed my homework’, then the truth value depends on the person who is assigning it. If a person has completed his homework then he can assign truth value true, otherwise false. 2.5.3 Logical Operators (AND, OR, NOT) ‘Sometimes we assemble more than one propositions to make one proposition called a compound proposition. For example if we have the following two propositions: 1. Today is Monday 2. Lamin school Then “Today is Monday AND I am in school” is a compound proposition. Truth value of the compound proposition depends upon the truth values of the individual propositions and the logical operator used to connect the propositions. In this example “AND* is a logical operator. In the following, we discuss three most commonly used logical operators AND, OR and NOT. AND Operator (.): If we use "AND" operator to connect two or more propositions, then the compound proposition is true only if all the connected propositions are true. AND operator can also be denoted by a dot *.” symbol It means that P AND Q may also be written as P.Q OR Operator (+): We can also use “OR” operator to connect two or more propositions eg. “Today is Monday OR I am in School". In case of OR operator, the compound proposition is true if at least one proposition is true. In other words, the compound proposition is false only if all the propositions are false. OR operator can also be denoted by a plus “+” symbol. It means that P OR Q may also be written as P + Q NOT Operator: The logical operator “NOT” is not a connector but it is used to negate a proposition. For example, if P = “Today is Monday” then NOT(P) means “Today is not Monday’. So, with NOT operator a True value becomes false and vice versa. Not operator can also be denoted by a "+" symbol. It means that NOT(P) may also be written as +P. 2.5.4 Truth Table A truth table is used to check whether a proposition is True or False. Usually it is used to check the truth value of a proposition where some logical operator is used. In the following, we discuss the truth tables for AND, OR and NOT operators, Truth Table for AND operator: The truth table for P AND Q is given in Table 2-9. The first two columns are showing all the possible combinations of truth values of propositions P and Q, the third column is showing the resultant truth value of P AND Q Assume: P = Itis raining Q= Today is Sunday P AND Q = Itis raining and today is Sunday If both P and Q are True then the P AND Q is also True, it means “It is raining on Sunday". This situation is shown on [TT] T Row 1 of Table 2-9. Suppose it is raining but not on fr }+}—t Sunday. Then P is True and Q is False due to which PAND [FF] Qis also False (row 2 of Table 2-9). In row 3 of Table 2-9,P Table 2-9 is False and Q is True, It means “It is not raining on Sunday” which results in False value of P AND Q. In the last row both P and Q are False, which means “Itis neither raining nor Sunday’. So, the proposition "It is raining and today is Sunday’ is false (row 4 of Table 2-9). ‘or the same propositions P Truth Table for OR operato Q and Q, let's see the truth table for the expression PORQ.P [TiT| T OR Q = “It is raining or it is Sunday". This compound |+}+}+—+ proposition is False if it is not raining and today is not LelFL F Sunday otherwise it is True as shown in Table 2-10. eee ft enc Truth Table for NOT operator: we can also make truth oe where NOT operator is used. Negation (also called NOT) is an Pre operator that reverses the nature of a value, ie, a value True LE] 1 becomes False and vice versa. The truth table for NOT T#ble2-42 operator is shown in Table 2-11. Truth Table for complex Boolean express : We can make truth table for any combination of these operators. For example, if we need to make a truth table i of “It is not raining and today is Sunday’. It means the proposition NOT(P) AND Q. F The truth table for this compound Table 2-12 proposition is shown Table 2-12. T T F F F F F T T T F 2.5.5 Laws of Boolean Algebra The laws of Boolean Algebra help us to simplify complex Boolean expressions. ‘Some laws are discussed in the following. ‘+ Commutative Law Commutative Law states that the order of application of two separate propositions is not important. So, a) A.B=B.A (The order in which two variables are AND'ed makes no difference.) b) A+B=B+A (The order in which two variables are OR'ed makes no difference.) We can use truth tables (Table 2-13a, Table 2-13b) to verify this law for AND and OR operations respectively. i i F F F F F F F T F F F T F F T i F F T F F F r F r r fr T i i Table 2-138 Table 2-13b aes We can observe from Table 2-13a that both the columns A - B and B - A contain same values in each row. Thus it verifies the commutative law for AND operation. Similarly we can verify for OR operation from Table 213b. + Associative Law This law is for several variables. According to this law there is no change in results if a grouping of expressions is changed. This law is quite same in case of AND and OR operators. a) (A+B)+C=A+B+O0 b) A.B).C=A.6.0) In order to verify the associative law for OR operation, we can observe the Truth Table presented in Table 2-14. Both columns (A+B)+C and A+(B+C) contain same values in each row. It verifies the associative law for OR operation. 7 Table 2-14 Similarly, we can observe Truth Table presented in Table 2-15 for verification of Associative Law for AND oper Table 2-15 res * Distributive Law This law is discussed in two ways, ie, “AND over OR" and “OR over AND". a)A. (B+ 0) =(A.B)+(A.C) (AND over OR) b)A+ (B.C) =(A+B).A+C) (OR over AND) We can verify the distributive law for (AND over OR) operation by using Table 2-16. Table 2-16 «Identity Law Ifa variable is OR’ed with a False, the result is always equal to that variable And if a variable is AND’ed with a True, the result is always equal to that variable. a) AOR False = A, A variable OR’ed with False is always equal to that variable b) AAND True = A, A variable AND‘ed with True is always equal to that variable 2.5.6 Logical Expressions We get a logical expression when some logical operator is applied to the Boolean proposition(s). For example, P AND Q, =(P OR Q), P OR Q.etc, In the tables, Table 2-14, 2-15 and 2-16 the truth tables are according to some logical expressions. eed By negating a negative proposition, we geta positive proposition. For example, + P=itissunny today ‘+ aPsItisnotsunny today © s9P=Itissunny today Similarly, . isnotFriday today EU Binary language consists of Os and 1s. Computer understands only binary language. ‘+ Decimal number system has base 10 as it uses ten digits from 0 to 9. ‘+ Hexadecimal system has total 16 numbers, ie. 0, 1, 2,3, 4,5, 6,7, 8,9, A,B, C.D, EF + Computer memory is a physical device capable of storing information temporarily ‘or permanently, + Adevice which holds the data as long as it has power supply connected to it and loses the memory when there is no power supply connected to itis called Volatile Memory or temporary memory. + Acdevice which can hold data even if itis not connected to any power source is called Non Volatile Memory or permanent memory. + A storage device is a hardware that is used for storing, porting and extracting data, + Boolean states either can be True or False. ‘+ A truth table is used to show whether the statement is true or false. «Laws of Boolean algebra: Associative lav (A+8)+C=A+ +0 + Commutative iaw A+B=B+A + Distributive law A+ (BQ =(A+ BUA +C) Identity law A+O=A 2.1 Multiple Choice Questions 1. Expression (A + B)-(A + C) is equal to : ) A+8OQ (i) AB+AC (i) ABO (v) A+8+0 2. The order of application of two separate terms is not important in (i) Associative Law (i) Commutative Law (iii) Distributive Law (iv) Identity Law 3. “Is it cold outside” is (Boolean Proposition (ii) Categorical proposition (iii) Moral propositions (iv) None of above 4, Number "17" is equal to in binary system. () 10000 (i) 10110 (ii) 10001 (iv) 10100 5. 1 Petabyte is equal to (i) 2,024)* bytes (i) 2,024)® bytes (iil) 2,024)° bytes (iv) (1,024)’ bytes 6. Hexadecimal system has total numbers. O: a7 ji) 16 (ii) 18 (iv) 15 2.2. Answer the following questions. Convert (69610)j0 to Hexadecimal. Differentiate between volatile and non-volatile memory. 3. Store the word “Phone” in computer memory starting from address 7003 where each letter needs one byte to store in the memory. Differentiate between temporary and permanent storage 5. Write the truth table for X AND Y where aes X= Itis sunny Y = Today is Monday 2.3 Fillin the Blanks 1. Temporary memory is__ and permanent memory is . Data toa processor is provided through ___. 3. At least byte is required to store any piece of information in a computer's memory. 4, is used to assemble more than one propositions into one proposition 5. In primary and secondary storages, data is stored in the form of 6 According to law there is no change in results if priority of expressions is changed. 2.4 Perform the following conversions 1. (ABCD):« to binary (0010110010001101001), to hexadecimal pene) Teacher will display a chart where alphabets and their codes are written. Class is divided into ‘two groups and each group writes at least 5 names in binary format. The famous names are selected from Pakistan Independence movement e.g, “Molana Muhammad Ali Johar”. Both groups exchange their data and produces original names. The group which deciphers the code to actual names less time will win,

You might also like