Untitled document Upload one python file (ends in .py) by 10 PM on March 30th (Wednesday). Reminder: this is individual work. You may discuss concepts with other people, but you must turn in your own...

I need the assingment done



Untitled document Upload one python file (ends in .py) by 10 PM on March 30th (Wednesday). Reminder: this is individual work. You may discuss concepts with other people, but you must turn in your own code. You can not share your code or any part of your code with other people. You can not use code that you found online. You can not post your code online. Doing so will be considered plagiarism/cheating. Your final submission will be a Python .py program. You do not need to keep every version of your code. In this assignment you will write a dot-matrix "bitmap" display emulator, and a shape drawing program. The dot-matrix display is 80 wide by 24 tall, so it has 80*24=1920 bits. It only has two colors: off and on. Off will be represented by a space " ", while On will be represented by an asterisk, "*". A "bitmap" is just the idea that we can make a drawing by representing places where the drawing is dark with 1s and places where its light with 0s inside of a binary number. As long as we know how wide the bitmap should be (in this case 80 columns wide!) we can send the number to someone and they can see the same picture. When the program starts, it should ask the user for a bitmap number. Then it should display the bitmap followed by the bitmap number. For ever 1 bit in the bitmap number, the program should display an asterisk, for every 0 bit it should display a space. The bit in the 1s place (20) represents row 0, column 0. The bit in the 2s place (21) represents row 0, column 1. The bit in the 211 place represents row 0, column 11. The bit 280 place represents row 1, column 0. The bit in the 291 place represents row 1, column 11. Hint: 91 is 80*1 + 11. If you want to know whether the number in the 2nd row (row #1) and the 12th column (column #11) is a space or an asterisk, you can check the bit in the 291 place. That's the same as the 92nd to last 1 or 0, in binary representation of the number! Then it should ask the user if they want to add a line. If the user enters "yes", then it should ask them for a starting row and column, and an ending row and column. It should then ask them if it should turn the line on or off. If the user selects on, it draw the line in on bits ("*"s), if the user selects off it should draw the line in off bits (" "s) (it is actually erasing the line!). Then it should print the bitmap followed by the bitmap number. Then the program should ask the user if they want to add a line again. Part 1: ● Write a function to display the bitmap and the bitmap number. ● Get your program working so that it starts, asks for the bitmap number, and then displays the bitmap and the bitmap number. ● You are NOT ALLOWED to use bin() or bitarray or other similar tools in your answer. You can use them to check your work, but remove it or comment it out before you submit. ● You must use bitwise arithmetic. Hint: Print one line for each row. Hint: For some row and column, you should use the formula 80*row+column Hint: You will need to use bitwise arithmetic to determine if each bit is 1 (on, "*") or 0 (off, " "). For example, the number 7122835888563504393078426950438508108687603540800060375563159382381608017849428 1808506047209359972116695024842751192130414950963075764326977846521960803029255 9620232364444138510869265988531702403129239285808174732198201623400564690905187 5124584614189787030542607258086613042243453250128777959255952586440991554938311 5284471027437785044943195379684999266480795316529157302438078445392885391684582 5242896941142307013464243762256033292379841504928810853560616082138166279745513 4492394521123956372881099632019582831020267332351220026998697621915135181417774 9819120318220003990044675 should draw a giant star like it does below. The star is also in Example 1. It's a very large number because its 1920 bits long... or 1331 decimal digits long.Just make sure to copy and paste the whole thing! In fact, if we use the number above, and put it into bin, and we adjust the window so that its just the right width we can see the star! The only problems are that we can't use bin, we need to use asterisks and spaces instead of 1s and 0s and its upside down, backwards, and a little off centre: Hint: you'll need to call print() once for each row (so 24 times). Hint: each time you call print(), you'll have to print out 80 characters (one for each column) Hint: Each '*' or ' ' is a 1 or 0 in the binary representation of the number. For example if you used bin() and took off of the 0b, and put a new line every 80 bits, you'd have close to the right answer... except that it would be upside down and backwards, it would use 1s and 0s instead of spaces and asterisks, and you're not allowed to use bin(). The above example is a small 3x3 example, instead of 24x80. In decimal, its the number 175. Try taking one of the examples, like the Hi There! example below, putting into the bin function. Copy it into a file, take off the '0b' and hit enter on column 80, breaking it into lines of 80 digits. You get something like this: 10111111100000001011111110100000100001000000000000100100001000000000000000000000 10000000100000001000000010100000100001000000000000100100001000000000000000000000 00111111100000001011111110100000100001000000000000100100001000000000000000000000 10111111101111111011111110111111100001000000000000100100001000000000000000000000 10000000000000000000000000000000100001000000000000000100001000000000000000000000 10000000000000000000000000000000100001000000000000000100001000000000000000000000 10000000000000000000000000000000100001000000000000000111111000000000000000000000 10000000000000000000000000000000100001000000000000100100001000000000000000000000 10000000000000000000000000000000100001000000000000100100001000000000000000000000 10000000000000000000000000000000000001000000000000000100001000000000000000000000 10000000000000000000000000000000001111111000000000000100001000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000 Do you see the upside and backwards Hi there! Hint: remember that you can use 1 < 27="" to="" get="" a="" number="" that,="" when="" written="" in="" binary,="" has="" a="" 1="" bit="" in="" the="" 227s="" place,="" (the="" 28th="" bit="" from="" the="" end)="" and="" 0s="" everywhere="" else.="" if="" you="" use="" bitwise="" and="" with="" some="" number="" and="" a="" number="" with="" only="" one="" 1="" bit,="" then="" you="" can="" see="" if="" the="" original="" number="" had="" a="" 1="" there="" or="" not.="" part="" 2:="" write="" a="" function="" to="" ask="" the="" user="" if="" they="" want="" to="" add="" a="" line.="" use="" the="" function="" with="" a="" loop="" to="" repeat="" the="" line="" adding="" until="" the="" user="" says="" "no."="" write="" a="" function="" to="" turn="" bits="" on="" or="" off.="" you="" should="" use="" loops="" and="" rounding="" to="" determine="" the="" row/column="" locations.="" if="" the="" line="" has="" more="" rows="" than="" columns,="" you="" should="" set="" the="" same="" number="" of="" bits="" as="" there="" are="" rows="" for="" the="" line="" to="" cross.="" if="" the="" line="" has="" more="" columns="" than="" rows,="" you="" should="" set="" the="" same="" number="" of="" bits="" as="" there="" are="" columns="" for="" the="" line="" to="" cross.="" so,="" if="" you="" are="" drawing="" a="" line="" from="" 0,0="" to="" 23,79,="" you="" should="" set="" 80="" bits="" on="" or="" off.="" if="" you="" are="" drawing="" a="" line="" from="" 0,0,="" to="" 23,0,="" you="" should="" set="" 24="" bits="" on="" or="" of="" (one="" on="" each="" row).="" ●="" you="" are="" not="" allowed="" to="" use="" bin()="" or="" bitarray="" or="" other="" similar="" tools="" in="" your="" answer.="" you="" can="" use="" them="" to="" check="" your="" work,="" but="" remove="" it="" or="" comment="" it="" out="" before="" you="" submit.="" ●="" you="" must="" use="" bitwise="" arithmetic.="" hint:="" the="" round()="" function="" in="" python="" can="" round="" numbers.="" hint:="" you="" can="" either="" draw="" the="" line="" column-wise="" (by="" making="" a="" loop="" over="" the="" columns)="" or="" row-wise="" (by="" making="" a="" loop="" over="" the="" rows).="" when="" there="" are="" more="" rows="" than="" columns="" in="" the="" line,="" it's="" better="" to="" loop="" row-wise.="" when="" there's="" more="" columns="" than="" rows="" to="" cover,="" it's="" better="" to="" loop="" column-wise.="" for="" example,="" if="" you're="" drawing="" from="" 0,0="" to="" 23,79="" it's="" better="" to="" loop="" over="" the="" columns="" from="" 0="" to="" 79="" (including="" 79).="" hint:="" if="" you're="" looping="" column-wise,="" find="" a="" way="" to="" calculate="" what="" row="" you="" should="" be="" on.="" for="" example,="" if="" you're="" drawing="" from="" 0,0="" to="" 23,79,="" and="" you're="" currently="" on="" column="" 55="" you="" should="" be="" on="" row="" 16.="" this="" is="" because="" you're="" 55/79="0.6962" (~70%)="" of="" the="" way="" through="" the="" columns="" already.="" you="" need="" to="" draw="" rows="" 0="" to="" 23,="" so="" 23="" *="" 0.6962="" is="" 16.012...="" you="" can="" round="" that="" to="" 16.="" so,="" when="" you're="" on="" column="" 55="" you="" should="" be="" on="" row="" 16.="" note="" that="" the="" distance="" from="" row="" 0="" to="" row="" 23="" is="" 23,="" even="" though="" we'll="" be="" changing="" bits="" in="" 24="" rows.="" similarly,="" the="" distance="" between="" column="" 0="" and="" column="" 79="" is="" 79,="" even="" though="" we'll="" be="" changing="" bits="" in="" 80="" columns.="" this="" is="" because="" we're="" rounding.="" hint:="" it="" might="" be="" easier="" to="" get="" this="" working="" on="" lines="" that="" start="" at="" 0,0="" before="" trying="" to="" get="" it="" working="" for="" any="" line.="" hint:="" (taranjot's="" alternate="" explanation)="" equation="" of="" a="" line="" is="" :="" y="mx" +="" b.="" given="" the="" start="" and="" end="" points,="" we="" can="" find="" slope="" m="(y2" -="" y1)="" (x2="" -="" x1).="" then="" we="" can="" find="" intercept="" b="y1" -="" m="" x1.="" and="" once="" we="" calculate="" these="" two,="" for="" every="" x*="" between="" the="" start="" x1="" and="" end="" x2,="" we="" can="" calculate="" the="" corresponding="" y*="" by="" round(mx*+b)="" and="" plot="" the="" (x*,y*).="" that="" helped="" many="" people="" get="" to="" a="" solution="" they="" understood="" intuitively.="" for="" lines="" that="" have="" a="" greater="" length="" than="" width,="" the="" only="" thing="" that="" changes="" is="" that="" for="" every="" y*="" we="" need="" to="" calculate="" x*="" as="" round(="" (y-b)/m)="" and="" plot="" all="" the="" (x*,y*).="" part="" 3:="" ●="" fix="" your="" program="" so="" that="" if="" the="" user="" doesn't="" enter="" a="" valid="" answer="" for="" on/off="" or="" yes/no,="" the="" program="" simply="" asks="" again.="" ●="" fix="" your="" program="" so="" that="" if="" the="" user="" enters="" a="" number="" less="" than="" 0="" or="" greater="" than="" 23="" for="" rows="" or="" 80="" for="" columns,="" the="" program="" simply="" asks="" again.="" ●="" fix="" your="" program="" so="" that="" if="" the="" user="" enters="" a="" end="" column="" greater="" than="" the="" start="" column,="" the="" program="" still="" works="" correctly.="" ●="" fix="" your="" program="" so="" that="" if="" the="" user="" enters="" an="" end="" row="" greater="" than="" the="" start="" row,="" the="" program="" still="" works="" correctly.="" ●="" fix="" your="" program="" so="" that="" if="" the="" user="" enters="" the="" same="" start="" and="" end="" row="" and="" the="" same="" start="" and="" end="" column,="" it="" does="" not="" crash,="" it="" should="" set="" (or="" clear)="" a="" single="" bit.="" ●="" fix="" your="" program="" so="" that="" it="" does="" not="" crash="" due="" to="" dividing="" by="" zero.="" ●="" it="" is="" okay="" for="" the="" program="" to="" crash="" with="" "valueerror:="" invalid="" literal="" for="" int()"="" errors.="" to="" get="" full="" marks,="" these="" should="" be="" the="" only="" errors/crashes.="" hint:="" the="" abs()="" function="" in="" python="" gives="" you="" the="" absolute="" value.="" example="" 1:="">>> ================================== RESTART: /home/hazel/bitmap.py ================================= Enter bitmap number: 0 0 Add a line? yes Start row? 0 Start column? 0 End row? 23 End col? 79 On or off? on ** **** *** **** *** *** **** *** **** *** **** *** *** **** *** **** *** **** *** *** **** *** **** ** 71228358885591856054102416184012956908882844367712795158194601925632549870137887605278 54878705205827715967432708262649245429194814551034759635181068507496829749099591549846 01513585717349035636696547118090805484450742989249424114631153372067735412034650129140 75937010178208354372314022977865271264514442670156014964438802789638572458285755950682 11919757540473956464452428057354564781379052539066426885275745925926791578089329444588 16729165515104430323407337231664359189428382744986554417260166481206920165301050281571 52997914208645064713234763986628857250521561670503971340419075 Add a line? yes Start row? 0 Start column? 79 End row? 23 End col? 0 On or off? on **
Mar 29, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here