Posted at 01:49h
in
Uncategorized
by admin
Question:
Create a class called Food. The class should contain three class attributes, the name of the food(string), the sugar(int or float), and the fat(int or float) content.
The tastiness of a particular food is based on the amount of sugar + fat that food has. So...
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 01:32h
in
Uncategorized
by admin
Question:
write a program to ask user about the date(year, month and day), then pass these year month and day as arguments to a function calcDay that return the day of the year.
Sample input:
Year: 2016
Month: 6
Day: 23
Sample output:
Day of the year: 175
Hint:
You need consider leap...
Posted at 01:24h
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...
Question:In order to train Jason's sense of direction, Gordon built a big castle with N rooms (N<=10000) and M channels (M<=100000). Each channel is one-way, that is, if you say a certain channel connects from room A to room B. It only means that room...
Posted at 20:59h
in
Uncategorized
by admin
Question 1:
Write a program to print a multiplication table (a times table). At the start, it should ask the user which table to print. The output should look something like this:
Sample Input:
Which multiplication table would you like? 5
Sample Output:
Here’s your table:
5 x 1 = 5
5 x 2...