Tutorial Specification COMP 1405 A/B/C (Fall 2021) − "Introduction to Computer Science I" Tutorial 04 of 10 Your submission for this tutorial must include your full name and you nine-digit student...

1 answer below »
All the instructions are provided in the attached file!!


Tutorial Specification COMP 1405 A/B/C (Fall 2021) − "Introduction to Computer Science I" Tutorial 04 of 10 Your submission for this tutorial must include your full name and you nine-digit student number as a comment at the top of every source file you submit. All source code files must be written using the Python 3 programming language and must run on the course's official virtual machine. Exercise A: "Number Triangles" For this exercise you will design and implement a program that will ask the user for an integer and then print out the corresponding "number triangle". Each row of the number triangle should be printed using a repeated sequence of digits that is the same length as the row number (starting from 1), and must use the digit that corresponds to that row (with one '1' on the first row, two '2's on the second row, three '3's on the third row, four '4's on the fourth row, etc.) In order to complete this task, you will need to: • decide whether to use a Boolean flag or a break statement for your postcondition loop Your submission for this exercise: • must be a source code file with filename1 'comp1405_f21_#########_tutorial_04_a.py' • must use a postcondition, event-controlled loop to ensure input is between 0 and 9 exclusive • must use nested counter-controlled loops to construct the number triangle from the input Exercise B: "Higher / Lower" For this exercise you will design and implement a program to play the "Higher / Lower" guessing game with the user. Your program will start by generating a pseudorandom integer that is between 1 and 100 (inclusive), and then the user will have no more than 10 guesses to determine what the selected number was. After each incorrect guess, your program must report whether the actual number is higher or lower than the last guess. In order to complete this task, you will need to: • ensure you know how to use the random library's "randint" function Your submission for this exercise: • must be a source code file with filename 'comp1405_f21_#########_tutorial_04_b.py' • must import random and use the "randint" function to get the pseudorandom integer • must use a postcondition, event-controlled loop, terminating if user wins or after 10 guesses • must report, after each incorrect guess, whether the actual value is higher or lower • must report whether the user has won or lost the game before ending 1 You must replace the number signs in the filename with your official nine-digit student identification number. 1 22 333 4444 55555 666666 7777777
Answered Same DayOct 22, 2021

Answer To: Tutorial Specification COMP 1405 A/B/C (Fall 2021) − "Introduction to Computer Science I" Tutorial...

Ketaki answered on Oct 23 2021
123 Votes
#10.A.
num = int(input("Enter a number: "))
if num < 0:
print("Enter a positive number")

else:
    for i in range(0,num+1):
        for j in range(0,i):
            print(i,end="")
        print()
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here