CS 17700 Study Guide - Midterm Guide: Infinite Loop, Binary Number, Graded Ring

42 views6 pages

Document Summary

Note: correct answer is marked with a * Which numbers are printed by the following loop: sum = 0 x = 10 while x > 1 : sum = sum + x x = x - 3 print sum (a) 22 (b) *21 (c) 0 (d) 20. Consider of the following code snipet: def change(picture): width = getwidth(picture) height = getheight(picture) mid = height/2 for x in range(0,width): for y in range (0,height): if ( mid < y ): setcolor(getpixel(picture,x,y),blue) else: setcolor(getpixel(picture,x,y),red) return picture. Consider the following function: def func2(): string1 = "halley"s comet" string2 = "this is a picture of a house" print string2[:a]. capitalize() + string1[:b]. capitalize() What should be the values of a and b such that the output of the function is this is halley ? (a) * 8, 6 (b) 7, 5 (c) 9, 5 (d) 6, 6.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents

Related Questions