Question

#define number of stars numStars = 6 #define function - takes a number of stars and...

#define number of stars

numStars = 6

#define function - takes a number of stars and prints an upside-down triangle

def printTriangle():

printTriangle(numStars)

Complete the function printTriangle(). the function is incomplete. print a triangle of stars. output is:

******

*****

****

***

**

*

__________________________

#define list of numbers

numbersList = [4, 12, 35, 13, 8, 13, 0, 2, 13, 13, 56]

def removeUnlucky():

print("Unlucky: ",numbersList

)removeUnlucky(numbersList

)print("Lucky: ", numbersList)

Complete the function removeUnlucky(). the program will not run because the function is incomplete. remove every instance of the number 13 from the list. output is:

Unlucky: [4, 12, 35, 13, 8, 13, 0, 2, 13, 13, 56]
Lucky: [4, 12, 35, 8, 0, 2, 56]

Homework Answers

Answer #1

Code:

#define number of stars
numStars = 6

#define function - takes a number of stars and prints an upside-down triangle

def printTriangle(n):
    for i in range(0, n):
        for j in range(i, n):
            print('*', end = '')
        print()

printTriangle(numStars)

Screenshots:

Know the answer?
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
Similar Questions
__#define list of numbers numbersList = [4, 12, 35, 13, 8, 13, 0, 2, 13, 13,...
__#define list of numbers numbersList = [4, 12, 35, 13, 8, 13, 0, 2, 13, 13, 56] def removeUnlucky(): print("Unlucky: ",numbersList )removeUnlucky(numbersList )print("Lucky: ", numbersList) Complete the function removeUnlucky(). the program will not run because the function is incomplete. remove every instance of the number 13 from the list. output is: Unlucky: [4, 12, 35, 13, 8, 13, 0, 2, 13, 13, 56] Lucky: [4, 12, 35, 8, 0, 2, 56]
Design a function called print_area that takes two floating-point numbers, representing the length and width of...
Design a function called print_area that takes two floating-point numbers, representing the length and width of a rectangle. The print_area function calculates and prints the area of the rectangle, rounded to two decimal places. Design a function called small_enough_word that takes a string for which the number of characters will be tested, and an integer representing the maximum allowable number of characters that the word can contain. Remember: the arguments MUST be in this order (the string of text before...
question: Complete the function remove number such that given a list of integers and an integer...
question: Complete the function remove number such that given a list of integers and an integer n, the function removes every instance of n from the list. Remember that this function needs to modify the list, not return a new list. please edit the Python form without errors def remove_number(lst: List[int], number: int) -> None:     """         Remove every instance of number in lst. Do this         *in-place*, i.e. *modify* the list. Do NOT         return a new list....
TO BE DONE IN PYTHON: Write a function `lowest_integer()` which takes 2 input arguments: 1)a function...
TO BE DONE IN PYTHON: Write a function `lowest_integer()` which takes 2 input arguments: 1)a function `g` representing an increasing function g(x) 2) a number `gmin`, and returns an integer `nmin` such that nmin>0 is the smallest integer that satisfies g(nmin)>gmin. test: def g(n): return 2*n print(lowest_integer(g, 10)) Output: 6
1. Design a function called sum that will take as arguments two floating-point numbers and will...
1. Design a function called sum that will take as arguments two floating-point numbers and will return the sum of those two numbers. 2. Design a function called get_longer that will take as arguments two phrases (strings) and will return the longer of the two strings. 3. Design a function called get_hypotenuse that will take as arguments the two lengths of the short sides (a and b in the formula below) of a right-angle triangle and returns the length of...
This code is in C++ Write a function named printMultTable that takes 2 integers, numValues and...
This code is in C++ Write a function named printMultTable that takes 2 integers, numValues and factor, and prints the first numValues greater than 0 that are multiples of  factor, separated by SPACE. It has no return value. printMultTable(5, 4) should print the first 5 multiples of 4, separated by a space, which is "4 8 12 16 20" printMultTable(3, 6) should print the first 3 multiples of 6, separated by a space, which is "6 12 18"   
IN C++ AS SIMPLE AS POSSIBLE ______ Re-write the given function, printSeriesSquareFifth,  to use a while loop...
IN C++ AS SIMPLE AS POSSIBLE ______ Re-write the given function, printSeriesSquareFifth,  to use a while loop (instead of for). • The function takes a single integer n as a parameter • The function prints a series between 1 and that parameter, and also prints its result • The result is calculated by summing the numbers between 1 and n (inclusive). If a number is divisible by 5, its square gets added to the result instead. • The function does not...
create a function that takes a dictionary and returns a list of int. The list should...
create a function that takes a dictionary and returns a list of int. The list should appear in decreasing order based on the sum of number in each dictionary. def total_num(dict1): #Code here input = {1: {'una': 5, 'dos': 7, 'tres': 9, 'quar' : 11}, 2: {'dos':2, 'quar':3}, 3:{'una': 3, 'tres': 5}, 4:{'cin': 6}, 5:{'tres': 7 , 'cin': 8}} output = [1,5,3,4,2] 1: 38 2: 5 3: 8 4: 6 5: 15 1>5>3>4>2
c) A function named tallied_data() that takes in a nested list (Use this on the data...
c) A function named tallied_data() that takes in a nested list (Use this on the data from part 1, but it should be able to be used to solve similar problems), indices for two columns and returns a tallied list. The inputs are: i) a nested list, ii) an index for the ‘reference column’/ ‘category’ (col_ref) iii) another index for the column to be tallied (col_tally) iv) this function returns a list of tuples where each element is a tuple...
1.Define a function value_to_key(d,value) that takes in a dictionary and a value as a parameter. The...
1.Define a function value_to_key(d,value) that takes in a dictionary and a value as a parameter. The function will return a list of all the keys that correspond with that value. If the value does not appear in the dictionary, it will return an empty list. ex.value_to_key({‘a’: 1, ‘b’: 4, ‘c’: 7}, 4) returns [‘b’] 2.Define a function input_tracker(number)that prompts the user to input values into the console a number of times.The function will return a dictionary where the keys are...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT