Thread: python homework

Results 1 to 5 of 5
  1. #1 python homework 
    Donator

    H1N1's Avatar
    Join Date
    Oct 2009
    Posts
    793
    Thanks given
    25
    Thanks received
    61
    Rep Power
    153
    This zyLab activity is the traditional programming assignment, typically requiring a few hours over a week. The previous section provides warm up exercises intended to help a student prepare for this programming assignment.



    This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width.

    (1) Modify the given program to use a loop to output an arrow base of height arrow_base_height. (1 pt)



    (2) Modify the given program to use a loop to output an arrow base of width arrow_base_width. (1 pt)



    (3) Modify the given program to use a loop to output an arrow head of width arrow_head_width. (2 pts)



    (4) Modify the given program to only accept an arrow head width that is larger than the arrow base width. Use a loop to continue prompting the user for an arrow head width until the value is larger than the arrow base width. (1 pt)

    while arrow_head_width <= arrow_base_width:
    print ('Enter arrow head width: ')
    arrow_head_width = int(input())


    Example output for arrow_base_height = 5, arrow_base_width = 2, and arrow_head_width = 4:

    Enter arrow base height: 5
    Enter arrow base width: 2
    Enter arrow head width: 4
    **
    **
    **
    **
    **
    ****
    ***
    **
    *

    my code that doesn't seem to work

    Code:
    print ('Enter arrow base height: ')
    arrow_base_height = int(input())
    
    print ('Enter arrow base width: ')
    arrow_base_width = int(input())
    
    print ('Enter arrow head width: ')
    arrow_head_width = int(input())
    
    
    # Draw arrow base (height = 3, width = 2)
    print ('**')
    print ('**')
    print ('**')
    
    # Draw arrow head (width = 4)
    print ('****')
    print ('***')
    print ('**')
    print ('*')
    
    arrow_base_height = int(input('Enter arrow base height:\n'))
    arrow_base_width = int(input('Enter arrow base width:\n'))
    arrow_head_width = int(input('Enter arrow head width:\n'))
    
    while arrow_head_width <= arrow_base_width:
    arrow_head_width = int(input('Enter arrow head width:\n'))
    print('')
    
    for i in range (arrow_base_height):
        i = ('*' * arrow_base_width)
        print(i)
    for j in range(arrow_head_width):
        j = '*' * arrow_head_width
        print (j)
        arrow_head_width -= 1
    Attached image
    Reply With Quote  
     

  2. #2  
    (Official) Thanksgiver

    Arham's Avatar
    Join Date
    Jan 2013
    Age
    23
    Posts
    3,415
    Thanks given
    7,254
    Thanks received
    1,938
    Rep Power
    3905
    Why are you printing out the i variable? Make another variable name for the printing out parts. I.e.:
    Code:
    for i in range(4):
        thing = ("*" * i)
        print thing
    You're not changing the index.
    Attached image
    Attached image
    Quote Originally Posted by MrClassic View Post
    Arham is the official thanker!
    List of my work here!
    Reply With Quote  
     

  3. #3  
    Donator

    H1N1's Avatar
    Join Date
    Oct 2009
    Posts
    793
    Thanks given
    25
    Thanks received
    61
    Rep Power
    153
    Quote Originally Posted by arham 4 View Post
    Why are you printing out the i variable? Make another variable name for the printing out parts. I.e.:
    Code:
    for i in range(4):
        thing = ("*" * i)
        print thing
    You're not changing the index.
    what would i replace?
    Attached image
    Reply With Quote  
     

  4. #4  
    (Official) Thanksgiver

    Arham's Avatar
    Join Date
    Jan 2013
    Age
    23
    Posts
    3,415
    Thanks given
    7,254
    Thanks received
    1,938
    Rep Power
    3905
    Quote Originally Posted by H1N1 View Post
    what would i replace?
    I told you already: the for loops. It's not spoon-feeding, it's homework.
    Attached image
    Attached image
    Quote Originally Posted by MrClassic View Post
    Arham is the official thanker!
    List of my work here!
    Reply With Quote  
     

  5. #5  
    Registered Member

    Join Date
    Oct 2011
    Posts
    2,084
    Thanks given
    0
    Thanks received
    1,043
    Rep Power
    3608
    do you have the actual assignment(s) in .pdf format? kinda hard to follow.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. python homework help
    By H1N1 in forum Homework
    Replies: 4
    Last Post: 02-07-2020, 05:46 PM
  2. Replies: 1
    Last Post: 03-26-2018, 07:38 AM
  3. Buying python homework help
    By CrimsonGFX in forum Buying
    Replies: 1
    Last Post: 11-14-2016, 05:03 AM
  4. Replies: 8
    Last Post: 03-15-2016, 03:28 AM
  5. python homework need help asap!!
    By abd1 in forum Homework
    Replies: 2
    Last Post: 04-30-2015, 11:48 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •