Uncategorized
Home > Uncategorized (Page 33)
Posted at 14:55h
in
Uncategorized
by admin
Question 1:Use recursion to write a function divides_all that consumes a list of positive integers seq and a positive integer factor. Your function should produce True if every item in seq is a multiple of factor and False otherwise. The helper function is_multiple has been provided for you.
Question 2:Use recursion to write a function reverse that consumes a list seq and produces a new...
Posted at 20:12h
in
Uncategorized
by admin
Reminder: Next Class will start from 5:15pm
Question 1:
A soccer team is looking for girls from ages 10 to 12 to play on their team. Write a program to ask the user’s age and if male or female (using “m” or “f”). Display a message indicating whether the person is...
Posted at 19:39h
in
Uncategorized
by admin
Question:
Continue modify the program we made in the class, so we can add '0' to the display correctly. (Hint, if the display is '0', do not add 0 after it)
Continue modify the program we made in the class, so we can add decimal point '.'...
Posted at 19:26h
in
Uncategorized
by admin
Question:
Today in gym class, your class decided to play dodgeball, and Jack is selected as one of the team captains! N students are lined up in a row, waiting to be put on teams. Jack is allowed to pick multiple students as long as they are adjacent...
Posted at 19:20h
in
Uncategorized
by admin
Question:
Since we have changed isKilled() method in the Enemy as following code:
def isKilled(self):
if self.hp <= 0:
return True
else:
return False
Modify the following program...
Posted at 19:02h
in
Uncategorized
by admin
Question 1:Use recursion to write a function has_digit that consumes a string and produces True if the string contains a digit (0 through 9) and False otherwise.
Hints:
Make sure that you have a base case.
Make sure to use the function on a shorter string.
Before calling the function,...
Posted at 05:01h
in
Uncategorized
by admin
Question 1:
A store is having a sale. They’re giving 10 percent off purchases of $10 or lower, and 20 percent off purchases of greater than $10. Write a program that asks the purchase price and displays the discount (10% or 20%) and the final price.
Sample Input...
Posted at 04:59h
in
Uncategorized
by admin
Question:You and your friend have come up with a way to send messages back and forth.
Your friend can encode a message to you by writing down a positive integer N and a symbol. You can decode that message by writing out that symbol N times in a row on...
Posted at 04:51h
in
Uncategorized
by admin
Question:
The Body Mass Index (BMI) is one of the calculations used by doctors to assess an adult’s health. The doctor measures the patient’s height (in meters) and weight (in kilograms), then calculates the BMI using the formula:
BMI = weight / (height * height)
Write a program...
Posted at 04:49h
in
Uncategorized
by admin
Question:
A charity is having a silent auction where people place bids on a prize without knowing anyone else’s bid. Each bid includes a person’s name and the amount of their bid. After the silent auction is over, the winner is the person who has placed...