ࡱ> VXU5@ bjbj22 AXX>>>>>>>D<3& & & & & !!!*3,3,3,3,3,3,3$4R6P3>"!!""P3>>& & e3&&&">>& >& *3&"*3&,&&r0T>>1&  )sI%013 {303"1z71&^71>>>>7>1t!>?!,&k!$!4!!!P3P3VD & VComp 150 Exam 1 Overview. Resources During the Exam The exam will be closed book, no calculators or computers. You may bring notes on two sides of 8.5x11 inch paper (either both sides of one sheet, or two sheets written on single sides). Write this as you study! I test you on concepts, not memorized rote facts. Main topics that may be on exam 1 The flow of central ideas and technical achievements in the history of computers from the Abacus through todays computers (DH Chapter 1) Python: tutorial through 2.3.4 See the summary of chapter 1 + much of the Chapter 2 summary (no graphics or animation or fancy loops) How the Python topics get used: In the tutorial you were asked to predict and try. On an exam, you just get to predict final results or give a more complete explanation, playing computer. Follow fairly arbitrary code using the elements above, and show the results Write a line of code translating an idea into Python, or put a few steps together. Read the following before looking at either the problems or the solutions! 1. Study first and then look at the sample problems. The sample problems cannot give complete coverage, and if you look at them first, you are likely to study just these points first, and will not get an idea how well you are prepared in general. Look at the list at the top of the page and start by filling in any holes. 2. Do not look at the answers until you have fully studied and tried the problems and gotten help getting over rough spots in the problems if you need it! Looking at the answers before this time makes the problems be just a few more displayed examples, rather than an opportunity to actively learn by doing and check out where you are. The doing is likely to help you be able to do again on a test. New sample problems start on the next page. Review Problems for Exam 1 (Solutions follow the problems.) What is printed by the Python code? x = 5 y = x + 3 x = x - 1 z = 10 x = x + z print x: %s, y: %s, z: %s % (x, y, z) What is printed by the Python code? print 14/4, 14%4, 14.0/4 What is printed by the Python code? print 2*'No' + 3*'!' print 2 * ('No' + 3*'!') What is printed by the Python code? print '2' + '3' What is printed by the Python code? name = 'Stanley' print name[1], name[3:5] What is printed by the Python code? for z in [2, 4, 7, 9]: print z - 1 What is printed by the Python code? x = 2.5679 y = 9.0 print Answers %.3f and %.3f % (x, y) What is printed by the Python code? def func(): print 'Hi' print 'Lo' func() What is printed by the Python code? def func(x): print 2*x func(5) func(4) What is printed by the Python code? def func(x): return x - 1 print func(3) + func(5) What is printed by the Python code? n = 3 for x in [2, 5, 8]: n = n + x print n What is printed by the Python code? print range(3) What is printed by the Python code? for i in range(3): print 'Hello again!' What is printed by the Python code? for i in range(4): print i What is printed by the Python code? s = 'abcde' for i in range(3): print s[i] What is printed by the Python code? nums = list() for i in range(4): nums.append(2*i) print nums What is printed by the Python code? s = 'I ate it.' print s.upper() print s.count('t') w = s.split() print w print '/'.join(w) The data crunching needs of the 1890 US census were addressed by what development significant in the history of computers? In modern computers, numbers are stored electronically. Earlier mechanical devices used for numerical calculation had other ways of representing numbers. List two ways. Write a Python program that prompts the user for two numbers, reads them in, and prints out the product, labeled. Given a string s, write a short expression for a string that includes s repeated five times. Suppose you know x is an integer and ys is a string representing an integer. For instance, x is 3 and ys is '24'. Write code to print out the arithmetic sum of the two. In the example case, 27 would be printed. Suppose you are given a list of words, wordList. Write Python code that will write one line for each word, repeating that word twice. For example if wordList is ['Jose', 'Sue', 'Ivan'], then your code would print Jose Jose Sue Sue Ivan Ivan Write code to create a Python dictionary (the dict type). Add two entries to the dictionary: Associate the key name with the value Juan, and associate the key phone with 508-1234 Complete the code for the following function so it matches its documentation: def doubleList(numberList): ''' For each of the numbers in the list numberList, print a line containing twice the original number. For example, doubleList([3, 1, 5]) would print 6 2 10 ''' Answers on the next page Exam 1 Review Problem Answers 1. x: 14, y: 8, z: 10 2. 3 2 3.5 3. NoNo!!! No!!!No!!! 4. 23 5. t nl 6. 1 3 6 8 7. Answers 2.568 and 9.000 8. Lo Hi 9. 10 8 10. 6 11. 18 # 3+2+5+8 12 [0, 1, 2] 13. Hello again! Hello again! Hello again! 14. 0 1 2 3 15. a b c 16. [0, 2, 4, 6] 17. I ATE IT. 2 ['I', 'ate', 'it.'] I/ate/it. 18. A machine invented by Hollerith was used to tabulate the results, that added up data coded on punched cards. 19. Punched cards as above, the angle of gears or knobs (like in old odometers or the Difference Engine), and another choice mentioned briefly in the introduction is the position of beads in an abacus. 20. x = input(Enter a number: ) # or some such prompt y = input(Enter another number: ) # or some such prompt print The product is , x*y # or some such label 21. s*5 # or: s+s+s+s+s 22. print x + int(ys) 23. for word in wordlist: print word, word 24. d = dict() d['name'] = 'Juan' d['phone'] = '508-1234' 25. def doubleList(numberList): ''' For each of the numbers in the list numberList, print a line containing twice the original number. For example, doubleList([3, 1, 5]) would print 6 2 10 ''' for n in numberList: print 2*n @ b f n  + / H r s t 1 4  "%&cde¾º頙yuqh2h^Ehvh}5hvh^E5 h 5h} h}6] ho6]h6) h#a16]h}h#a1CJaJhfG h\Whp^)hjl h#a15\ hjl5 h~@5 h m5 hpV5h_h8|5h#a1h8| h_5\hl-h_'5? @ b s t  c $%degd}gd#a1 & F hh^hgd} & F hh^hgd#a1gd#a1 & F hh^hgd4dgd_gd_gd}gd}AFUV[]^mnopɼռɼռըռɤɉռ{w{hwhWihI7OJQJ^Jh1 OJQJ^Jh1 h_<hlFOJQJ^JhlFhqOJQJ^JhlFOJQJ^Jh_<h OJQJ^Jh hW\h2h OJQJ^Jh2OJQJ^Jhvc)OJQJ^Jh_<h2OJQJ^J+eop@ABF & Fgd5gd1  & Fgd1 gd!m & FgdwgdwL & Fgd!m & FgdlFgd  & Fgd gd2 & Fgd2:;?@ABEefjvx"#ùßììÛԗviieXvh1 h5OJQJ^Jh5h_<h1 OJQJ^Jh5OJQJ^Jh1 OJQJ^Jh1 h1 OJQJ^Jh1 h!mh_<h?TOJQJ^Jh_<hwOJQJ^Jh;hOJQJ^Jh_<hwLOJQJ^JhwhW\hwLh_<h!mOJQJ^Jh2OJQJ^Jh_<hWiOJQJ^J"#%EFktuw*+,Pz{5tuv5ؽ}plhhl-h!mh_<hW\OJQJ^JhW\OJQJ^JhW\h_<h mOJQJ^Jh mOJQJ^Jh mh_<h OJQJ^Jh OJQJ^Jh hhOJQJ^JhOJQJ^Jh5h_<h5OJQJ^Jh5OJQJ^Jh1 h5OJQJ^J(FG+,{|uvwst gdVgd!mgdW\ & FgdW\ & Fgd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000000 00`0 00 00 0 00 00`0 00`0 00 00 0  0 0 0 0 0 0 0 0 00 00`0 0@0 00 00 00 00 00 00 00 000p00000000p00000p0p000000p0p000000000 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 000 0 0 0 0 0 00 0 0p00p00p0p0p00000p0p5?@bstc$%deop@ A B F G + , { |   u v w s t  _d?0(0000 0 000 0 0(0000000 00`0 00 00 0 00 00`0 00`0 00 00 0 @ 0 0 0 0 0 0 0 0 00 00`0 00 00 00 0@0 0@0 0@0 0@0 0 0O9060O9060O9080@0O90E0 O90E0O90E0Oy00O900O900Oy00Oy00Oy080Oy060Oy00Oy0:0O90P0Oy00O90S0O90S0Oy00Oy00#5eF 88@0(  B S  ?&&4&{&    V*urn:schemas-microsoft-com:office:smarttagsplacehttp://www.5iantlavalamp.com/h*urn:schemas-microsoft-com:office:smarttagsCity0http://www.5iamas-microsoft-com:office:smarttagsB*urn:schemas-microsoft-com:office:smarttagscountry-region   ! 5 9 = A o s T U  5 9 G H Y d g h p t XZ_g!nx#57;D5>ORSUis%+AFV[P S X]34~jp&(EJit3333333333333333333333333 \ _fAndrew Harrington۰yg@HCk\!cnq\hh^h`o(. ^`hH. pLp^p`LhH. @ @ ^@ `hH. ^`hH. L^`LhH. ^`hH. ^`hH. PLP^P`LhH.h ^`hH.h ^`hH.h pLp^p`LhH.h @ @ ^@ `hH.h ^`hH.h L^`LhH.h ^`hH.h ^`hH.h PLP^P`LhH.h ^`hH.h ^`hH.h pLp^p`LhH.h @ @ ^@ `hH.h ^`hH.h L^`LhH.h ^`hH.h ^`hH.h PLP^P`LhH.h ^`hH.h ^`hH.h pLp^p`LhH.h @ @ ^@ `hH.h ^`hH.h L^`LhH.h ^`hH.h ^`hH.h PLP^P`LhH.Ck!cnqg@                            @WVu9%* y)lsIq5"_fG ;#6)p^)vc)|t,#a1I7<_<~@+uJ8LwL0jO?T\WtXW\_bboZeCf;hFiWi m!mq{:G1 ? ?Pb],V2s^K2 lF# l-1w]Ovj4}8|l^E-jlpVo k\FIp H~b@l!!@UnknownGz Times New Roman5Symbol3& z Arial?5 z Courier New"qhF,&3&rI +I +``24d 3QH)?bComp 150 Exam 1 OverviewAndrew HarringtonAndrew Harrington    Oh+'0 4@ \ h t Comp 150 Exam 1 Overview.ompAndrew Harringtonerndrndr Normal.dotiAndrew Harringtoner29rMicrosoft Word 10.0@,@%G+@ @bsII՜.+,0 hp  Loyola University Chicagov+ { Comp 150 Exam 1 Overview Title  "#$%&'(*+,-./0123456789:;<=>?@ABCDFGHIJKLNOPQRSTWRoot Entry FþsIYData !1Table)7WordDocumentASummaryInformation(EDocumentSummaryInformation8MCompObjj  FMicrosoft Word Document MSWordDocWord.Document.89q