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]
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
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...
* Create a function that takes in the length of two sides of a triangle and...
* Create a function that takes in the length of two sides of a triangle and returns an array of all integers that could be the length of the third side. * Note: The sum of two sides of a triangle is always greater than the third. */ exports.default = (firstSide, secondSide) => { // Your code goes here. }; const triangleSideRanges = require('./question').default; console.log(triangleSideRanges(3, 4)); // Expected Output:[ 2, 3, 4, 5, 6 ] console.log(triangleSideRanges(11, 7)); // Expected Output:[5,...
# Parts to be completed are marked with '<<<<< COMPLETE' import random N = 8 MAXSTEPS...
# Parts to be completed are marked with '<<<<< COMPLETE' import random N = 8 MAXSTEPS = 5000 # generates a random n-queens board # representation: a list of length n the value at index i is # row that contains the ith queen; # exampe for 4-queens: [0,2,0,3] means that the queen in column 0 is # sitting in row 0, the queen in colum 1 is in row, the queen in column 2 # is in row 0,...
python 3 For this exercise you are to implement the function poly_iter in the array-backed list...
python 3 For this exercise you are to implement the function poly_iter in the array-backed list class, which, when called with positive integer parameters a, b, c, returns an iterator over the values in the underlying list at indexes a*i2+b*i+c, for i=0, 1, 2, ... E.g., given an array-backed list lst containing the elements [0, 1, 2, 3, 4, ..., 98, 99], the following code: for x in lst.poly_iter(2, 3, 4): print(x) will produce the output: 4 9 18 31...