Sale!

CMPE150 Homework 2 Drinking Straw Solved

$35.00

Category:

Description

5/5 - (1 vote)

Drinking Straw

Description

You will write a Python program to implement the ASCII cocktail glasses below using two parameters glass_size as the
size of the cocktail glass and straw_pos as the position of the straw. Your code will draw a cocktail that decreases as you
drink it through a straw. One example run is given at the bottom of this page.

You can find other example runs in the
example_runs.txt file. Please make sure you follow these rules in your implementation::
We provided two lines of code to take input from the user: first glass_size and then straw_pos. Don’t change it and
also you shouldn’t write any extra input taking part in your code.

 

You are not allowed to generate the entire picture or any single line using printing statements such as print(). For
example, you cannot have a statement that says: print(‘\\*****/’). You need to generate it using loops.
Assume that straw_pos will not be greater than glass_size*2 (straw_pos <= glass_size*2).
straw_pos and glass_size will be strictly greater than zero (straw_pos > 0 and glass_size > 0).

 

Warning:

You are not allowed to use imports and topics that haven’t been covered yet. Warning: Do not print any additional/unnecessary things as output. Your outputs should exactly match with the test
case outputs.
Example:
Input:
3
4
Output:
o
o
o
o

 

\******/
\****/
\**/

||
||
||
o
o
o
o

 

\ o /
\****/
\**/

||
||
||

 

o
o
o
o
\ o /
\ o/
\**/

||
||
||

Drinking Straw