Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
20 views
DocScanner 14-Dec-2024 2-23 pm
Cs chapter 8
Uploaded by
devadharshan27112008
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save DocScanner 14-Dec-2024 2-23 pm For Later
Download
Save
Save DocScanner 14-Dec-2024 2-23 pm For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
20 views
DocScanner 14-Dec-2024 2-23 pm
Cs chapter 8
Uploaded by
devadharshan27112008
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save DocScanner 14-Dec-2024 2-23 pm For Later
Carousel Previous
Carousel Next
Save
Save DocScanner 14-Dec-2024 2-23 pm For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 24
Search
Fullscreen
SEE" 94 COMPUTER SCIENCE yp » TPG, \ Now if you change the value of # so that itis not reFeFFINg 10 SAME intepe, Ojo ‘expression o is b will return Tre: eel, thy sebebes ' —— | [7 Now is also pointing to same in >ssaisb 1 2(235) thus 8 is bis giving True t | tre | >>> print(id(a), id(b), $6(c)) ‘ 492124008 492124802 492124000 The i not operator is opposite ofthe is operator. It returms Tre when both its operan, ih referring to same memory address. rey 7.4.34 Equolity ( and Identity (is) — Important Relation You have seen in above given examples that when two variables are referring to same Value is operator returns True. When the is operator returns True for two variables, it rae means that the equality operator wil ako return True, That is, expression ais bas True eH that a = b will also be True, always. See below : ans >>> print(a, b) 235 235 »aisd True | >>> gee | True t t 1 t i 1 i J But its not always true other way round, That means there are some cases where you will ind that the two objects are having just the same value i.e, — operator returns True for them butte is operator returns False. ‘See in the screenshots shown here. >>> S2-= input(“Enter a string:") Enter a string : abe >>> Sass? True >>> SL is 52 False >>» S3= ‘abc! >>> sliss3 Do not confuse Is with era! equality of the valuf stored, vil Test Tor Ue eam Tntapxeter re to the same location In memory), 7 PeObjects Fand jstorat ge But operaorretums Fateefor fie) behaviour is ‘The reason behind this that there are a few cases where Python creates two different objects even though both store the same value. These are : © input of strings from the console ; © writing integers literals with many digits (very big integers) ; © writing floating-point and complex literals. Following figure illustrates one of the above given screenshots . nput("Enter a string: Enter a string : abc H | \ \ i 1 >>> sL==s2 | True i | >>> stiss2 i 1 | False ' | 1 | >>> 35 ‘abe! 1 | 1 | isleiss \ a | True 4 OTE L if the Is operator returns True for Most of the times we just need to check whether the Wo UOC Di hen the = operator objects refer to the same value or not ~in this case the equality vet return Tue for the same operator (=) is sufficient for this test. However, in advanced cafes be two elerences Programs or in your projects, you may need to check whether ser e ie sara es ov they refer to same memory address or not ~ in this case, you ress, always same, can use the is operator. —COMPUTER SCIENCE wy Woy Ni An earlier section discussed about relational operators that orn relationships at values. This section talks about logical operators, hae conte ne (or, ana me re + to the ways these relationships (among values) ¢ ‘thon prov) th, isp eee to combine existing expressions. These are or, and, and not, Vides Before we proceed tothe discussion of logical operators itis mMPoriant fF YOU to know apo, Value Testing, because in some cases logical operators base their results on truth Value teat eh s Ks 7.4.44 Truth Valve Testing / Python associates with every value type, some truth value (the truthin ). 4, Python it categorizes them as true or false. Any object can be tested for truth value. Python conn following values false, (i.c., with truth-value as false) and true : ide, Values with truth value as false Values with truth value gy we None | False Goolean value Fates) ctype. for example. 0, 00, 0} Alll other values are considered true, [Please note, is empty string is empty tuple; and {] is empty ist] ‘The enuf eatonal expression canbe Tru or False depending upon the values of ts operands and ip ‘comparison taking place. Do not confuse between Boolean values True, False and truth values (truthiness values) tru, fg Simply put truth-value tests for zero-ness or emptiness ofa value. Boolean values belong to jus one data type, i, Boolean type, whereas we can test truthiness for every value object in Python, But to avoid any contusion, we shall be giving truth values rue and fein smal letters and with a subsp foal, i. now on in this chapter true, and false ,., willbe referring to truth-valuies of an object. ‘The utility of Truth Value testing will be clear to you as we are discussing the functioning o logical operators. 7.4.48 The or Operator The or operator combines two expressions, which make its operands, The or operator works in these ways : (i) relational expressions as. ‘operands (ii) numbers or strings or lists as operands (i) Relotional expressions as operands When or operator has its operands as relational expressions (e, operator pertorms as per following principle : The or operator evaluctes to True if either of its (relational) operands evaluates to True ; False if both operands evaluate to False. That is : p> 4q,j =k, etc.) then the or x yx _ Kory Falseto? — False (©) False Falseco) True es) True Trueca) False) Tre Treqey Tue") True{A HANDLING on gre some examples of this oy results into True because first (5-78) expression (4 ==4)is True, results into False because 2 578 5¢ both expressions 5 > 8 and 5 <2 are False. ors / stings / iss 08 operands? Nur fl operator has its operands as whe? ctrings or lists (¢.g., “a or”, 30r0, 50! sumer he oF operator performs a5 per 1c) iple: followin principle: Me pesion X OT Y. FHS operand, (i, 110 mg) hs false then return second od 08 result, otherwise return x, operané is: nats y xory false ject false nat false rat EU oat y true est false rat ee Ue x ingeneral, True and False represent the Boolean values ‘and true and false represent truth values. Bomples operation Results Reason Tor 0 Ist expression (0) as false, thus | | and expression 0 is retumed. (or 8 | 8 | Istexpression (0) has false, thus | | and expression 8 is retumed. Ser00 5 st expression (5) has true, thus | | 1st expression 5 is returned. “hello or” ‘hello’ | 1st expression (‘hello’) has trie. thus Ist expression ‘hello'is retumed Ist expression (") has false,y thus 2nd expression ‘a’ is retumed. | 1st expression (") has filse jt thus [2nd expression ” is returned. nel tory | rae Pry" | fa" |Ast expression (a") has trem thus Ist expression ‘a’ is retumed. How the truth value is determined ? — refer 10 “lion 74.44 above, - i %F Operator will test the second operand feat the first operand is false, otherwise iorore it; even if the second operand is logically wrong eg, Wo iors 4194 will give you result as true Without checking the second operand of or .e-, “a +1>4, which is syntactically wrong - ou Cannot add an integer to a string. 2 PES RE aT ENTIE The or operator wil tet the second operand only the {first operand is false, otherwise ignore tt T4A4C The ond Operator ‘The and operator combines two expressions, Which make its operands. The and operator works in these ways : (i) relational expressions as operands (ii) numbers or strings or lists as operands {i) Relational expressions es operands When and operator has its operands as relational expressions (e.g., p > 9, j != k, etc.) then the and operator performs as per following principle : The and operator evaluates to True if both of its (relational) operands evaluate to True ; False if either or both operands eveluate to False. That is: x y xandy False False False False Te False ‘True False False True True True Following are some examples of the and operation = "(@=4) and (5-8) results into False because first expression G==4)is ‘True but second expression (5 == 8) evaluates to False, Both operands have to result into True in order to have the final results as True Hea of or functioning applies to any value whichis nota relational expression bt whose truthness can be determined n,08 £8 Ge Sed rent: fate. Fader ecatae iret expression | 5S 8 ates Fal ase 2es srouiths fnhy Thhte Kronise both apeninids BR > Sand 2¢ 5 shunts The lists os operandsé When on number or-ttings or lists (eg. ‘a’ or”, 80r0, ete) then the anc operator performs as per tollowing principle operator has its operands as ar exoression x andy. if first operand, (i.e. folse,,... then retu rm first ‘operand » as result, otherwise return y That is x y xand y false i true 2 false pe y true gy v Reason Ist expression (0) has false thas frst expression 0 s returned Ist expression (0) has fel py thas Ist expression 0 is retuned. Ist expression (5) has rut thus 2nd expression 00 is retumed Ist expression (hello’ has fru, thus 2nd expression “is retumed Ist expression (") has false, thus Ist expression "is retumed, Jst expression (") has false gy, thus Ist expression” is returned Ast expression (a!) has true | thus 2nd expression is | returned. ser ee How the truth value is determined 2 ~ refer to section 744A. This typeof or functioning applies to by Python, ” 289 value which note relational expression but whose tyuthness canbe ds Important ‘The ana ope" wi Ae the the frst operand is tru, ‘and Wor He 10> 20 anda ya ce Moy vill ive you result as False ignoring the second pera com ‘rong You cannot add an integer ip nn rity OString in pth hoy mo Nore The and operator a ttt pean ey 7.4.4D The nc! Operator The Boolean/logic al Rot operator, single expression of operand jv. operator. The logical reve Works 1 itisa not oper, " ator S the truth value of the cos , © following iti. if the expression Pi trea Mhen not expressions Fag and iy versa. Unlike ‘and’ and ‘or retum number ora string or the ‘not’ operator returns value True or False. OPCFALOFS that alist ct. as su always a Books, Consider some examples below : not § results into False because 5 4 MON-7EFO (Ley, Erte gai) not @ results into True because 0 is zem (ey false gi) not -4 results into False because ~ 4s non 010 thus Ite py not(S > 2) results into False because the expression 5 >2 is True. not(S > 9) results into True because the expression 5 >9 is False. OTE Operator not has a lower priority than non soy operators, so not a == b is interpreted as not [2 and a == not bis a syntaxeror, perijoing. table summarizes the logical operator roll Logical Operators the Mo Result La lon pe ree j Gp ci Fatse yar then return y | (8) only evatunes he ce can else | Jatse. second argument ifthe first one is | s false, then x as | It (and) only evalanee ap ——4 werd vo only eval a tae trnar) Only evaluates the second argument the First one fo 5 5 16 falseyaie then return | not has a lower prone 2 aa [ret True as result, else False Prleity than nor- Boolean operators - 5 ———_____ ag Comparison Operators in While discussing Logical operators, Python has something interesting to offer. You can chain juluiple comparisons which are like shortened version of larger Boolean expressions. Let as see wv. Rather than writing 1 <2 and 2<3, you can even write 1 <2<3, which the chained version + Boolean expression, cho ho of earlie The above statement will check if 1 was less than 2 and if2 was less than 3. Let’s look at a few examples of using chains : yoo e263 isequivalentto —>»>1<2and2<3 True True As per the property of and, the expression 1<3 will be first evaluated and if only it fs True, then only the next chained expression 2 < 3 will be evaluated. similarly consider some more examples : yop an. ¢ 13912 True The above expression checks if 13 is larger than both the other numbers; itis the shortened version of 11 < 13 and 13 > 12. 74.5 Bitwise Operators Python also provides another category of operators - bitwise operators, which are similar to the logical operators, except that they work on a smaller scale ~ on binary representations of data. Bitwise operators are used to change individual bits in an operand. Python provides following Bitwise operators. Table 7.5 Bitwise Operators Operator | Operation | Use Description & TV itivise and |opa & op2 | The AND operator compares two bits and generates a result of Vif both bits are 1; otherwise, it retums 0. bitwise or [opr | op2 | The OR operator compares two bits and generates result of tif the bits ace complementary; otherwise, it returns 0. bitwise xor [opt * op2 | The EXCLUSIVE-OR (XOR) operator compares two bits and returns. Lit either of the bits are {andl it gives 0 if both bits are 0 or 1. bitwise opt ‘The COMPLEMENT operator is used to invert all of the bits af the operand.wi SSE" : » 200 COMPUTE Sc MH py Ahoy P if Let us examine them one by ane ; 7.4.54 The AND operator & : When its operands are numbers, the & operation performs the bitwise a ie parallel par of Bite in exch operand, The AND function sets the resulting pth oy, Corresponding bitin oth operands 61, as shown inthe following Tae 7.6 Pi ty 8H) Table 7.6 The Bitwise AND (&) Operation Ea op | Result 0 0 0 For AND operations, 1 AND 1 py o ja 0 | Any other combination Produces 9 mesa 1 | 0 0 1 | 4 1 lp >>> bin(a3) “@b11e1° 3812 1101 ‘Suppose that you were to AND the values 13 and 12. like this : 13 & 12, The result of this >>> bin(a2y operation is 12 because the binary si “eb11¢0° representation of 13 is 1101. You can use bin() >>> 43.843 R to get binary representation of a number. If both operand bits are 1, the AND function sets the resulting bit to 1 ; otherwise, the resulting bit is 0. So, when you line up the two operands ané perform the AND function, you can see that the two high-order bits (the tivo big farthest to the lett ofeach number) f each operand are 1. Thus, the resulting bitin the rent also 1. The low-order bits evaluate to 0 because either one or both bits in the operands are, >>> bin(13 &2) eb11e0" | r 1 1 | representation of 12 is 1100, and the binary i | | | L 7.4.58 The inclusive OR operator | When both of its operands are numbers, the | operator performs the inclusive OR operation Inclusive OR means that if either of the two bits is 1, the result is 1. The following Table 77 shows the results of inclusive OR operations. Table 7.7, The inclusive OR (|) Operation >>> bin(13) 33 [12 90001101 7 a fesult 000 1100 *@b1101' i 0 0 0 r 0 7 5 Gooo aon | 222 bin(32) 1 0 1 *@b1100 | 1 1 1 “ebisen" "For OR operations, 0 OR 0 produces 0, ob: ‘Any other combination produces 1. >>> a3 | 12 t ! I | | >>> bin(a3 | 12) | | | 7.4.5C. The eXclusive OR (YOR) operator ~ t Exclusive OR means that if the two operand bits are different, the result is 1 ; otherwis j result is 0. The following Table 7.8 shows the results of an eXclusive OR operation.pr HANOUNG 7 pats exclusive OR (*) Operation rhe - = 718 t we Re 3344; [55> bin(a3) fe Loe ___ op result 2 een iter | veutton” i > 0 0 e000 1109 | | a 1 1 {yor bin(az) | o 1 209 0001 | ‘abiiea" ‘ 1 { i 0 por ABA AZ | - 1 ! sqtions, 4 KORO mraauces tp does 0 XOR 1, (Ail these gor operator tative.) Any other combination produces 0, >>> bin(13* 12) | >>> bin(~12) i @b1161" 1 When an expression or statement involves multiple operators, Python resolves the order of execution through Operator Precedence. The chart of operator precedence from highest to Towest for the operators covered in this chapter is given below. 14.6 Operator Precedence it are. 2 ! sp the Complement Operator ~ 14 ator inverts the val it secomplement OPT value of each bit of the operand : if the operand bit is 1 the “i vm and if the operand bit is 0 the result i 1 7 — / Mistry eee -15i0 | i yt complement (-) Operation Zeconpleen fom” | i se 1 4 Fi a 12 e008 i i 0 a aue011 ° 3 1111 6011 | >>> bin(13) =~ (9080 1161) | “ebi2e2" ! ' L Operator z Description | 0 Parentheses (grouping) Highest ” Exponentiation | = Bitwise nor | | Positive, negative (unary +, -) Multiplication, division, floor division, remainder Addition, subtraction | Bitwise and | * Bitwise XOR ' Bitwise OR | slag te 1S Comparisons (Relational operators), identity operators is, is nol not x Boolean NOT | and Boolean AND —or__ Boolean OR _ | ei raat ne otal the number whose 2's complement is given, you can calculate its 2s complement again by following this rate - i pan right to left, copy all the bits asi is UNTIL you find first 1, then invert all other bits. As per this rule, an calculate 2's complement of 11110034 as 00001101, which is 13, -COMPINER Sct 02 i NH py Mig o AG, Operator Associotivity Python allows multiple operators ina single expression as You have learnt Above + ete, I the operators used in an expression have Wo "04 rent nw Seeder 4 dence 2“ fits. h In that ease, associativity helps determine the order of operations, ache 2cc or peg een there is not any problem as Python will evaluate the operator with higher what ifthe expression contains two operators that have the same proce differ Associativity is the order in which an expression (having multiple operators of is evaluated, Almost all the operators have left-to-right associativity exeg That means, in case of multiple precedence. other than", in same expression - the operator on the f samy Ne Prog PL expen ey Ponen Ta fRetAlors yi ay eH is evaluated inte a , which has right-to left associativi then the operator on its right and so on. For example, multiplication operator (), division operator (/) and floor divi have the same precedence. So, if we have an expression having these operator then the same-precedence-operators will be evaluated in left-to-right order, Sion opera, : 0 S SFmtneouy For example, | o00788/5//2 ise | ™ Ths fst exgresion sealed in ef to righ onder of operator. as evidet forge 2nd expresion's exaluation that elearly marks this order of evalwation ‘An expression having multiple * operators is evaluated from right to left, ie, 2" 34 will be evaluated as 2"* (3**4) and NOT AS (234 ‘Consider following example : — = = ‘See the default order of evaluation (first expression) wae 1 MATCHES withthe second expression whe a | a ‘Parentheses are added as per right-to-left associativity onder 19683 4nd NOT LIKE third expression that has parentheses from ‘eho order, because exponentiation (*) has 299394 (382) Veh lgiasecavy [ | | | { 1 | 19683 t tye H t 1 1 L >>> (3443) "2 729 ich 20 ivity is the order In which expression having multiple coe same precedence, is evaluated: All operators are left associat ‘ ‘exponentiation (right assotat®) extUNG. pra want 20: _ a will be te output produced GaMPLE WD ig ste pings gogo? a wit ell be He OPIN P by €xe0NeLE REND vite ting cade ging errr? f print (1143) print (‘11 +3) SOLUTION yer Th 4 - o 1 problem is with line 2 of given code rete ytyyy tty 2) because an integer cannot be added to a prane 2% string value, thus Python will give : Typeteron: can only concatenate str (not “int”) to str EXAMPLE BOY Which of the following expressions \ sna til r ld at \ rit Taha ill be the output produced by wl yd an integer type value a its output ? te? eins 5°2 i 32 print (14/14, 144, 24/4) (ig +2 (io) 592 (0) 5/2 (of) 52 saLutiOn (oi 5% 2 (ei) 3+20 3238 (a) 50°20 (3-2 se Bet wil be the output proce by SOLUTION pep code? Expressions (, (i), (vi), (if) will yield integer type result. print(2*'No' +3*"!") print(2* (*No' + 3*'1")) EXAMPLE RY Considering the expressions given in SOLUTION the previous example, wich expressions ‘will yield a ovo!!! {floating point result? ol INO! SOLUTION BAMPLE E] What will be the output produced by Suara (oi, (ex) will yield a floating thefillowing code ? print (type(1+3)) EXAMPLE BLY Considering the expressions given in print(type(1 +3.0)) the previous example 12, which expressions will yield a SOLUTION String result ?
SOLUTION
Expressions (iii), (iv) will yield a String result. EXAMPLE What will be the output produced by EXAMPLE TE Considering the expressions given in tie following code ? the previous example 10, which expressions will result into an Error and why ? Hy (22+3) SOLUTION nt (*24 4 +3" SOLUTIO Care's) Expression (x) will result into error because the 7 minus operator is not a valid operator for a string and integer values. a», COMPUTER ScENeE Win H Py, Ho, “y OPERATORS IN PYTHON p ——. Progress In Pri ‘on 7 2 ant strengthening operators’ concepts. It involves both This practical session aims : interactiy, nt node. For better understanding of the concepts, it would be better if you. gt toy Jnternctice mode practice questions followed by script mode practice questions, St peafgn® Oy he Please check the practical component-book ~ P oaress in Computer © Science with Python ond fil it there in PriP 7.2 under Chapter 7 afte, ) practically doing it on the computer. 4. What is the function of logical Immutable Types in Python mean that os cannot, < operators ? Write an expression in place. be cheng involving 2 logical operator to test if Mutable Types Python mean that their values can be changed eer a the 7% Poton has only 3 mutable type : lists, dictionaries and a, . 2 What is the order of evaluation nthe Gy erator are the symbols (or keywords sometime. following expressions: ; 5) that aa ee ycas specific operations. "pre : a 4 Arithmetic operators carryout arithmetic for Python, The | aa Ae +,unary=,+,-,*,4, % and **, “are ay (ii) a>bec>e 3. What ie the rentt of folowing * Una0’+ alves the value of ts operand, unary ~ changes the sin efiy expression :@ >= band (a+b)>aif —_9perond’s value Fcn'bco(miaat,ba7? 4 Addition operator + gives sum of is operand’s value, ~ subtract ty 4. What is the renlt of following Yue of second operand from the value of first operand, gis ie Soak it roduc of ts operands value. The operator /dlivides theft opeany ' ‘ilies second and returns afloat result // performs the floor division, % gies the remainder afer dividing first operand by second and + i te i ¢ ‘exponentiation operator, i, it gives base raised to power. ' (it) check ="", mate ="€ 4 etaional operators compare the values oftheir operand. These (tv) check = ‘meer’, mate >< >= and !=ie,, less than, greater than, equal fo, ss | (a) check or mate (b) mate or check than or equal £0, greater than or equal to and not equal i (@) check and not mate respectively. aed (@) check and mate (¢) mate and check + Bitwise operators are like logical operators but they work ot ' | Bvaluate ezch of the above expressions individual bits, : (ii) check = ~— for all four sets of values. % Identify operators (is, is not) compare the memory two object a __ 5. Identity the order of evaluation in the referencing, te 1 etloning expeston i 4 Logical operators perform comparisons on the basis of ruins i SeS4702-8%344 and {an expression or value. These are ‘or’, ‘anid? and ‘not’ | ST Y/ 2-14 bornat2—sand 4 Oe depends on i Le ies lean or relational expressions? truth value depends 0” 1 “6 a 185,b= 155 then why ivais big, Daman result True or False, vents 'Tpatce while a ee bis Trve 7 % Volues’ truth value depends on their emptiness oF nea Ae : ¢ i Empty numbers (such os 0, 0.0 jet.) and empty eat ir ! Bal pee “",11,()) and None have truth-value as false and © ne eis. (non-empty ones) have truth-value as true. ee0 205 xpress ~ ston in id combination of operators, ‘ATOM ness cariables. An expression is composed of one or An tom i something that has 3 juts ins, with operators, literals, and variables as the Ye. erties ers, gs more! rents of expressions. lists, tuples, sets, dictionaries etc. wt “ae astoms. ts it in this way :a valid combination of atoms and a forms a Python expression. In simplest words, an — to mething that has 2 value. So al ofthese ae toms ia identifiers, literals and values-in-enclosures such as “An in Py, parentheses, brackets, ete. i, strings, tuples, lists, uses (7) Pa aris 38 expressions 9 Python can Be of any type : athe 1 or siring expressions, relational expressions, logical expres arin compound expressions ee expr ip Tretypes of operators and operands used in an expression determine the expression type. « Anexpression can be compound expression to fit involves multiple types of operators, eg at b> ce*d or a*b
Z, KeRYOR 3. Logical Expressions ‘An expression having literals and/or variables of any valid type and logical operators is a logical expression. For example, these are valid logical expressions : aorb, bandc, aandnotb, not cornotb 4. String expressions Python also provides two string operators +and *, when combined with string operands and integers, form string expressions. © With operator +, the concatenation operator, the operands should be of string type only. © With * operator, he replication operator, the operands should be one string and one integer. For instance, following are some legal string expressions : “and” + "then" # would result into ‘andthen' - concatenation “and * 2 #would result into 'andand’ - replication String manipulation is being covered in a separate chapter ~ chapter 9.LN 206 TH py TH My a 7.5.1 Evaluating Expressions In this section, we shall be discussing how Python evaluates different 'ypes of arithmetic, relational and logical expressions. String, expressions, as Mentioned Pig, discussed in a separate chapter ~ chapter 9, tle it * 7.5.14 Evalvoting Arithmetic Expressions You all are familiar with arithmetic expressions and their basic evaluation » ‘i Seubeimary and middleschool years. Likewise, Python also hes SerAIN SCL OF rule BM og evaluate an expression. Let's see how Python evaluates them, ar, ‘hathapa Evoluoting Arithmetic Expressions Toevaluate an arithmetic ex resion with operator and operant), Python follows © Determines the order of evaluation in an expression considering the Operator yes: © As per the evaluation order, for each of the ‘sub-expression (generally in the fo, ratty
e.,13% 3) OF Vales Evaluate each of its operands of arguments, x nei » Promoting int to float or bool to int oft, les of Python, read the text gino after ther’ © ed on the operator, = Tession), soas ’ Python converts all oy pean Perands up to the type of the largest oe (ty ). In simplest form, 2M expression is like pI operator op2 (eg. hy applied dard numeric typos, the following coercions are © Meither argum, 5 fest * the other is converted to complex ; Point number, the other is co ‘ted to floating point; ® No con) Operands are integers, eee To nderstand this, Consider the dlear ne ample which will make it ches # integer : mally coerce # integer # integer # Floating point nunber # Floating point nunber # expression 1 # expression 2pata HANDLING owt . 20 1s per operator precedence, expressi Pression 1 will be internally evaluated as : n= ((ch + 4)/dd) int int Step 1 (n int floating pt (no conversion here) tel Step 2 (4 i floating pt P 2 (int to floating-pt conversion) eral, final datatype for expression 1 will ing-pol go overall, final datatype for expression 1 will be floating-point 4 ‘pill be evaluated as : ig Point number and the expression ((ch + )/ db) (G+ 2/50 (5 + 2))/5.0 =()/5.0 s pecrereay * ch)/2) [int to floating point conversion] Float float =7.0/5.0 F=--}-4---- no conversion A=14 float int =F=--}----integer to floating As per operator precedence, expression float pt conversion 2 will be internally evaluated as : integer to floating So, final datatype for expression 2 will float pt conversion be floating point number. The expression, expression 2 will be evaluated as : (((fd / db) ch) / 2) = (((36.0/5.0)* 5L/ 2) [no conversion required) = ((7.2*5)/2) [int to floating point conversion] = ((7.2* 5.0) /2) = (36.0 /2) [integer to floating point conversion] =36.0/2.0 B=180 Th aw IMPORTANT Ie out i 3 In Python, if the operator is the division pavwalbe 38,0 oe: (7), the result will always be a The f floating point number, even if both the \ final datatype of expression 1 will be floating operands are of integer types (an exception to a pression 1 wil : afeae point Tumber and of expression 2, it will be the rule). Cowsider folowing example that oat es ating-point number, pe(© In expression bia ar £7643 by Teeted operations, C= I | int” int Wand %, both —.,, ames ar iteges, i esd willbe integer. ease int int yo int You yourself can un these expressinsin Python shell and then check the type Of Cusing (Q fnction. be el essions (Comparisons) All comparison operations in Python have the same priority, arithmetic operations. All relational expressions (comparisoy True or False. Further, chzined expressions like a< mathematics Le, comparisons in Python are chained arbitrarily, e.g,, a
q) and (qe (i) (a<=N) and (N<=b) b
c4d>e+F ornot gh) tis ty i pe conversion (coercion) ? om does Python perform 7 : ~SOLUTION In oy ev evaluation, Py retums the resull of first argument i) x d 0, for the given expression, the secon AT ALL. “that ie why, Python reported no error, and simply retumed True, the real argument. Type Co You have leamt in earlier section that in expression with mixed types, Python internally changes the data type of “operands so that all operands have same data type. This type ‘of conversion is automatic, ic, implicit\nd!hence known as implicit type conversion. Python, however, also supports explicit type conversion. Ss: “1. Are the following expressions equal ? ‘Why/why not ? | -xory and not z | (kor y) and (not z) ) (xor (y and (not z) )) 2 State when would only frst argument be evaluated and when both first and ‘second arguments are evaluated in | following expressions if a=5,b=10, r-5.d=0 ()b>cander>d ( Wacborceed | ii (+e)
() functions appropriate data type, in the following manner :
(expression) where
is the data type to which you want io type-cast your expression. For example, if we have (a =3 and b = 5.0), then int(b) will cast the data-type of the expression as int. Similarly, d= float(a) will assign value 3.0 to d because float(a) cast tt expression’s value to float type and then assigned itto# Python offers some conversion functions that you cif I to type cast a value in Python. These are being listed'* following Table 7.10. 4 Progress In Prt This is an important practical session to reinforce the cones expression evaluation in Python. pooweeceable ing digits numbers 4, | number Booleans 5. | any type floating point number complex number string Boolean int( ) float( ) complex( ) akc) bool() Crd ete, or int(7.8) will give 7 (ating point number t umber to integer conversion) {nt(349" will give 34 (string to integer conversion) float(7) will give 7.0 (integer to floating point number conversion) float(34) will give 34.0 | (string to floating point number conversion) complex(7) will give 7+0j (ONE ARGUMENT: integer to complex number | conversion) complex(3, 2) will give 3 +2) (TWO ARGUMENTS - integer to complex number conversion) | str(3) will give ‘(integer to string conversion) str(5.78) will give '3.78° (floating-point number to string conversion) str(Q017) will give "15° (octal number to string conversion ; string converts the equivalent decimal number to string : 0017 = 15) str(1 + 2)) will give ‘(1+ 2 (complex number to string conversion) ste(True) will give ‘True’ (Boolean to string conversion) ool(0) will give False ; bool(0.0) will give False bool(t) will give True ; bool(3) will give True ool”) will give False ; bool(‘a’) will give True bool’hello’) will give True With bool( ), non-zero, non-empty values of any type will give True and rest (zero, empty values) will give False an : ona : ita number (in string form) is given in any other base i and tnt() asi (
COMPUTER SciENee iy Toy N Type Costing Issues Assigning a value to a type with a greater range (6. from shor! to longy 56 however, assigning a value of larger data type to a smaller data type (e.g fnteger) may result in losing some precision. 8) Poses i, + From gi Floating-point type to integer type conversion results in loss of fractional ya may be out of range for target type, in which case result is undefined, 2 S arget ty hy EXAMPLE Which ofthe following expressions will yield a Boolean type value as ie output p (@10>2 (24 (iti) (245, 6+6) (iv) 55 ©) 124,13, 411 4-22 (vid) 4, 202 (ix) ‘Cat’ < ‘dog’ (x) 5> 2and 10> 11 and (2 ea «oye "> &)5>2or195 SOLUTION Expressions (i, (i), (to), (0, (oi) to (xi) will yield a Boolean result, EXAMPLE Write Boolean expressions in Python for these conditions : (8) xis a factor of y (that is, x divides evenly into ¥) (ti) age is at least 18 and state equals ‘Goa’ (i) the string name is not ‘Nimra’ SOLUTION (x %y—=0 (if) age >= 18 and state = ‘Goa’ (iii) name t= “Nimra’ 7.6 Debugging Debugging in simple English means to remove ‘bugs’ from a Tesuccinc Program. An error causing disruption in program's running (Debugging refers ‘t or in producing right output, isa ‘program bug’. Debugging _of locating the, ete, involves rectifying the code so that the reason behind the bug Suen pny gets resolved and thus bug is also removed, - 24 In this section, ‘we hall tak about general debugging techniques and how you can debug code in Python, Before we tak about debugging techniques, itis important for you to know the errors, ere ‘yPes, what causes them etc So, let us fret tak about errors and exceptions. 7.6.) Errors in 0 Program An error, sometimes called ‘a bug, j compiling and running correctly. Some Program bugs are catastrophic in their effects, while others are comparatively less harmful and still others are 6o unclear that you will ever disco! ti ‘There are broadly three types of errors: Compile-tine errs, run-time errors and logical errors: 7.6.14 Compile-Time Errors Errors thal occur during compile-time, are compile-time errors, When a program compiles Is source code is checked for whether it follows the programming language's rules or nol: Two types of errors fall into category of compile-time errors,path HANDLING ewors vy errors occur when rules of a , synles ical rule of Python is violated, Trem language are misused) ie, when a ee ee VOL * Observe the following two statements : i= ON) ese to statements will result in syntax errors ag hes tes i isnot an assignment : 1g the assignment operator, nota relational ignment operator in Python ang jires colon (:) at the end of i, which is missing abana,” if 8 Block statement, i iB above. revere the correct statements will be as follows « K-VIZ bi Lf K == (KTV): ‘one should always try to get the syntax right the first time, as fyntax error wastes computing time and money, as well as 2ogrammers time and is preventable » Semantics Errors semantics Errors occur when statements are not meaningful. For instance, rr e the statement ‘Sita plays Guitar’ is syntactically and semantically correct asit has some meaning but the statement ‘Guitar plays Sita’ is syntactically correct (as the grammar is correct) but semantically incorrect, similarly, there are semantics rules of a programming language, violation of which results in semantical errors. For instance, the statement os [semanriecs KtYaZ : (Semantics refers to the set of will result in a semantical error as an expression cannot come fates which hve ine meoning ofa on the left side of an assignment statement. emer, 16.18 Logical Errors Sometimes,(even if you don’t encounter any error during compile-time and run-time, your program does not provide the correct result. This is because of the programmer's mistaken analysis of the problem he or she is trying to solvé) Such errors are logical errors(For instance, an incorrectly implemented algorithm, or use of a variable before its initialization, or unmarked end for a loop, or wrong parameters passed are often the hardest to prevent and to locate.) These must be handled carefully. Sometimes logical errors are treated as a subcategory of run-time errors, 1610 Run-Time Errors (Errors that occur during the execution of a program are run-time errors. These are harder to detect errors. Some run-time errors stop the execution of the program which is then called program “crashed” or “abnormally terminated”, Most run-time errors are easy to identify because program halts when it encounters them e.¢., an infinite loop or wrong value (of different data type other than required) is input. Normally, programming languages incorporate checks for run-time errors, so does Python. However, Python usually takes care of such errors by terminating the progcam, but a program {hat crashes whenever it detects an error condition is not desirable. Therefore, a program Shoulel be robust so as to recover and continue following, an error.Wek \ COMPUTER SCIENCE Winn Py r Exceptions salar but dtferent terms. While eFF0r represents, 4 _ ee program causes POET OUIPULAN Ty re ing executfondvantimee, which you Tay tion Errors and eve disrupts running of tion occurti 1 Ception Bin in cate that . we VE NO gop, any irregular § corrections in the code, fixiny nt any we fixed by making, €O B xcopy Ol Errors in a program can be fi “Phong ‘1 te i " that simple . or and exception with ifference between an erro pt ith the Let us try to understand the differen ep of Teal example - ‘or instance, if you operate an ATM then ; aencienle per or wrong pin number is an ERROR, «© ‘not that much amount in account’ is an EXCEPTION. also an EXCEPTION. © entering wrong account num © ‘ATM machine struck’ is So you can think of Exceptfons in a program asqsituation Lt N ay Ther cecam during rantime and yéu have no control of it IV - oc er Jc that opens a Gate fle and displays its We Er I 9 bug ithe vn. This program’s code is syntactically uses irregular output eg ct contents on screen. This progt vi run this 2082 from executing, ngs See logealy comet foo. Bat wehen you run thls CS Teague seein thy sromnam th ile that you are opeing, doesnot exist OM oeering ring oxea eee this wl couse an EXCEPTION. So the program has _prograrnmer has no cont,” no errors but an exception occurred. Table 7.11 Some Built-in Exceptions Exception Name Description EOFError Raised when one of the built-in functions (input( )) hits an end-of-file condition (FOR, without reading any data 1OError Kased when an UO operation (such as print( ), the built-in open( ) function or method of a file object) fails for an 1/O-related reason, e,g., “file not found” or “disk full”. ‘Name rror Raised when an identifier name is not found, | IndexError Raised when a sequence subscript or index is out of range, e.g., from a string of length if | you try to read a value of index like 4 or more ie,, string[4], string[5], string{-B] etc. will raise exception as legal indexes for a string of length 4 are 0, 1, 2, 3 and -1, -2, -3, ~4only._ ImportError j Raised when an import statement fails to find the module definition or when a from ~ import fails to find a name that is to be imported. : ‘TypeError | Raised when an operation or function is applied to an object of inappropriate type, if you try to compute a square-root of a string value. ValueError Raised when @ built-in operation or function receives an argument with # , inappropriate value eg, int("Z10") will raise ValueError. ZeroDicsiont v7) Raised when the second argument ofa division or modulo operation 16 780 Orerpiowtsver : | Raised when the resull of an arithmetic operation is too large to be represented Keyl S — fr _| fae whe mapping tay key wt found inthe st of ei I fder pata HANDUNG 7 215 ont ale, following, screensh is ror example, flloWlE Sereey ots are showing two different exceptions. >>> int iia’) Traceback (most re File “
", Line 1, in
division by zero Debugging using Code Tracing Most common technique to debug an error is to find Morten done by printing the values of every int urpose, code (racing is one most commonly use P the point of error and origin of error. This fermediate result and of all values. For this ed technique. Common useful technique for debugging is code tracing. Code tracing means executing code Jine at a time and watching its impact on variables. One way of code tracing is using Dry ‘ode tracing can also be done by one ; fan, which you have already learnt in an earlier chapter. C Tebugging, tools or debugg available in software form. fier Us REVISE i ‘san expression is composed of one or more operations. It is a valid combination of operators, literals and variables. ‘s In Python terms, an expression is a legal combination of atoms and operators. « anatom in Python is something that has a value. Examples of atoms are variables, literals, strings, lists, tuples, sets etc. «4 Expressions can be arithmetic, relational or logical, compound etc. 44 Types of operators used in an expression determine its type. For instance, use of arithmetic mahal arithmetic expression. i 4+ Arithmetic expressions can either be integer expressions or real expressions or complex number ions mixed-mode expressions. operations. + An arithmetic expression always results in a number (integer or floating-point number or a complex number) ; a relational expression always results in a Boolean value i.e., either True or False ; and a logical expression results into a number or a string or a Boolean value, depending upon its operands. + Ina mixed-mode expression, different types of variables/constants are converted to one same type. This process is called ‘ype conversion, Type conversion can take place in two forms : implicit (that is performed by compiler without programmer's intervention) and explicit (that is defined by the user). * In implicit conversion, all operands are converted up to the type of the largest operand, which is called type promotion or coercion, * The explicit conversion of an operand to a specific type is called type casting and it is done using type conversion functions that is used as
(
) £494, t0 convert to float, one may write float (
) * Debugging refers to the process of locating the place of error, cause of error, and correcting the code accordingly. ¥ Compitestime errors (syntax error and semantics errors) refer to the errors that violate the grammatical rules and regulations of a programming language. ‘Runtime errors occur during the execution of a program. Logical errors occur due to mistaken analysis of the problem. i‘ Irregular unexpected situations occurring during runtime are called Exceptions. Exceptions may occur even if the program is free from all types of errors.CE Wing 4 hy inoue OT,» MULTIPLE CHOICE QUESTIONS ee 1. Which of the following are valid Python data / (a) True iyper? (© Only in Functions (@) Numeric None” @ Mappings | 11, In Python, a variable ig a ‘a Scouence (Veet | ype, and then later ag ertuple — (y dctonay ‘ different type. This will yieiq | ® val 2 Which ofthe following are datatypes considered | (@) Warning ©) Ero : as Numbers in Python + |. , None No Ei © integer (b) Boolean (ocomplex "$12. In Python, a rs ONCE. assign i | one type, can be ) floating poin list.) Ne pred a (a) floating point list. (f) None | type later. This concept is phe 4 3. Consider the folowing sequence of statements: | ‘Own ay (@) mutability ® ”) Static typin a (9 dynamic typing (@) immute ing 7 - . (13. Isitsafe to directly use the == ope tlty Following the execution of these statements, |" mine whether objects of type fhe rode Python has created How many objects and How) Gy Yee ayo oe Hosta 7 Many references ? {a) Two integer objects, two references (8) One integer object, two references (©) One integer object, one reference (d) Two integer objects, one reference a, b=8.6,2 + 4. Which Python built-in function returns the print (a//b ) unique number assigned to an object ? i (43 (©) 40 (4 (@) compitation exe, (6) Yes, if the values are
109 | 14, What will the following code Produce? (0) identty( ) .id() | 15. In the Python statement x= 045-b: and hee (©) refnum( ) (4) ref) 5. The operator is used to check ifboth the, Operands (b) Expression ‘operands reference the same object memory. (6 operators (@) Equation (in Pris (id — (d= __ 16. In the Python statement x=045—b: a45-bis 6. For two Objects x and y, the expression x is y will yield True, if and only if | (@) Operands (b) Expression dey id(x) = id(y) + (b) Jen(x) = len (c) operators (d) Equation (xmy @all i these ©) | 17, What willbe the value of y after following code 7. Which of the fallowing is not an immutable fragments on type in Python ? x= 16. (a) String (b) Tuples (gSet (ff diction y= (x < 100.8) and x >= 10 8, What is the value of the expression 100 / msi (a) 110 (b) True (¢) False (d) Brvor. tay 4 40 | 18. Which of these are equivalent to True ? (25 (d) none of these | (a) 0.000001 (b) ‘None’ © Ri 9. What is the value of the expression 100 // 25 ? a uy % ne ( None i AY ws 25 ta ‘ eof these 19. Which of the following operators has the lowest : precedence ? 10. In Python, a variable must be declared before i } is assigned a value, eer oe @ not » % ~~ (cand + e)*pata HANDLING she value of the expression 1043 + 399 f is (o'r * de ‘ ws 739 (829) OL | 27 The result of paae Me and” case the value of x five times using an} ("isan empty stringy ? 10 fed assignment OPEFAOE, the comect| ge yan ay 4 0 sp will De loon open (by x5 The result of the expression ‘x’ and ‘a’ ? v5 (d) none of these | a Me Ww" jx Wt the fesult of the expression 10 or? | - ie result ofthe expression ‘a’ and ‘<7 2 wt “© ~ |10 at w ox 1 1-30. The result of frontal tecnpreson Sor? | TE Saat he tin nd Nome gt wm. 10 wo. ae ws , 31. The resu ‘ and ‘a’? nest of the expression 5 and 102 a oe OG a - “ The b) 1 wo or exit 7 ant a ba. ‘The result of the expression ‘false’ and False ? 5. The result of the expt 4 | (a) false (b) False (c) “faise” (d) ‘False’ @s © © (jo she result of the expression ‘a! oF" ("is an 3 npty string) ? 33. The result of the expression ‘false’ or False ? (@) false (6) False (¢) ‘talse’_(d) ‘False’ FLULIN THE Buawis 1.Boolean data type is internally treated as| 6. The division of two integers yields a result of “data types | : type a Two forms of floating-point numbers are =| 7. The sequence type cannot store form and notation. duplicate values. 4, Python's floating point numbers have precision | 8.Tke ___ datatype is like lists but is not of digits. [ mutable. A Three mutable types of Python are ,| 9.The ____ of an object gives the memory and : | location of the object 5, The floor division of two integers yields a result | 10. To check if two objects reference the same of type. | memory address, operator is used. ‘TRUE/FALSE QUESTIONS an immutable data type. 12. None has the truth value as False. 2 Set is a mutable data type. 13. ‘None’ has the truth value as False. 3. A set can contain duplicate values in it 14. The result of bool(0) is False. 4A Boolean value is internally treated as an| 15, The result of bool(‘None’) is False. integer value, 16. Dividing two integers results in an integer. 17. Floor division of two integers results in an integer. 18. Two floating point numbers should not be 5." (an empty string) has truth value as False. ©.""(@ space) has truth value as False. 7. Value false a legal literal value in Python. ‘compared for equality using = . 5. Value False is a legal literal value in Python, | 19. In implicit conversion, all operands’ data types are ». Value “False” is a legal literal value in Python. converted to the datatype of the largest operand. 10. Value * false’ isa legal literal value in Python. | 20: Explicit type conversion involves the use of a \ on to convert dat fa value. '-None and ‘None’ are the same. function to convert datatype of a value.
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6386)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (634)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brené Brown
4/5 (1160)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (982)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8302)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (633)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1254)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (933)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (10337)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (887)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (1007)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (3237)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (581)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (297)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (5058)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (943)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4346)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (458)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Tóibín
3.5/5 (2091)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1993)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1077)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2780)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (2032)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (2838)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (141)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4086)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (76)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (906)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2544)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (813)
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4.5/5 (2369)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carre
4/5 (277)