Question

This an intro class, we can't use 'i'f statements, yet

No loops, it has to be very simple, something somebody with little coding experience can do. We've learned about print, and basic math function in Python

Eiffel Tower In this program, you will print out ascii art of the eiffel tower. Name your progam eiffel tower.py. Your progra

Below are serveral examples of this program running with different input values provided. Enter Eiffel tower size: IZI IZ IZICoding, this is

0 0
Add a comment Improve this question Transcribed image text
Answer #1

## Please run with Python3

import math
import sys

def buildTowerTop(n, cen):
    skip = cen -1
    height = math.floor(n * 1.5)
    print(skip * ' ', end = '')
    print('$')
    line_str = (skip-1) * ' ' + "|Z|\n"
    print(height * line_str, end = '')

def buildTowerMid(n, cen):
    skip = cen - int((2 * n + 2)/2) - 1
    width = 2 * n + 1
    height = math.floor(n/2 + 3)

    ## code for the first line of Middle of tower
    print(skip * ' ', end = '')
    print('/', end = '')
    print(width * 'Z', end = '')
    print('/')

    ## code for the rest of Middle part
    line_str = skip * ' ' + 'H' + width * ' ' + 'H' + "\n"
    print(height * line_str, end = '')  

def buildTowerLow(n, cen):
    skip = 2
    width = 4 * n + 1
    height = math.floor(n/1.5)

    ## code for the First line of Bottom of the Tower
    print(skip * ' ', end = '')
    print('/', end = '')
    print(width * '%', end = '')
    print('/')

    ##code for the rest of the Bottom part
    line_str = ' ' + '##' + width * ' ' + '##' + "\n"
    print(height * line_str, end = '')
    line_str = '##' + (width+2) * ' ' + '##' + "\n"
    print(height * line_str)

if __name__ == '__main__':
    n = int(input('Enter Tower Size (btw 2-20) : '))
    if n < 2 or n > 20:
        print('Sorry!, out of my limit ')
        sys.exit(1)
    ## Center is calculated from base width
    cen_of_tower = int((4*n+2)/2+3)

    buildTowerTop(n, cen_of_tower)
    buildTowerMid(n, cen_of_tower)
    buildTowerLow(n, cen_of_tower)

    print('Wow!!, you did it :)')


##########################################
## Code can be improved by using Right Shift (>>) operator for divison

## Formula can be adjusted as per your requirment
#########################################

Add a comment
Know the answer?
Add Answer to:
This an intro class, we can't use 'i'f statements, yet No loops, it has to be...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT