Question: python 3.x.x short answers: 1) Two non-negative integers x and y are equal if either: Both are 0, or x-1 and y-1 are equal Write
python 3.x.x short answers:
1) Two non-negative integers x and y are equal if either:
- Both are 0, or
- x-1 and y-1 are equal
Write a function named equals that recursively determines whether two parameters (both containing integer values) are equal and returns True or False.
2) Assume the availability of a function named printStars that can be passed one argument, an integer value n, which prints n asterisks. Write a function named printTriangle that receives an integer value as an argument and prints a triangle of asterisks as follows: first a line with 1 asterisk, then a line with 2 asterisks, then a line with 3 asterisks, and so on until it prints a line of n asterisks, at which point it stops. For example, if the function received 5, it would print: * ** *** **** ***** The function must not use a loop of any kind. The function should invoke printStarsto accomplish the task of printing a single line.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
