Tuesday Python 18:30
Home > Tuesday Python 18:30 (Page 3)
Question:
Spamway Inc. maintains a network of zombie computers to solicit and collect orders for its various fine products. Each zombie computer is responsible for zero or more subordinate zombies that it coordinates in these activities.
Spamway uses a simple communication strategy among its zombies for transmitting...
Question:
The term “code monkey” is sometimes used to refer to a programmer who doesn’t know much about programming. This is unfair to monkeys, because contrary to popular belief, monkeys are quite smart. They have just been misunderstood. This may be because monkeys do not speak...
Question:
Alice is looking at a crystal through a microscope. Alice’s microscope has the interesting feature that it can superimpose grid lines over the image that she is looking at.
At level 1 of magnification, Alice sees the image as follows:
Notice that at level 1, there is...
Question 1:
The hailstone sequence starting at a positive integer n is generated by following two simple rules. If n is even, the next number in the sequence is n/2. If n is odd, the next number in the sequence is 3*n+1. Repeating this process, we generate the hailstone sequence. Write a recursive function hailstone(n) which prints the...
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 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,...
Question:
Every girl likes shopping, so does Jessica. Now she finds the shop is increasing the price every day because the Spring Festival is coming. Her favorite shop named “memory”. Now she wants to know the rank of this shop’s price after the change of everyday.
Input...
Question:
Being able to send encoded messages during World War II was very important to the Allies. The messages were always sent after being encoded with a known password. Having a fixed password was of course insecure, thus there was a need to change it frequently....
Question 1:
Winnie is feeling generous today, so she decided to adopt all the children in an orphanage. There are N orphanages, numbered from 1 to N, that she can choose from. Each orphanage has M children. Each children has a cuteness value ranging from 1...
Question:
Annie has two favourite baseball teams: the Eagle and the Warrior. She has followed them throughout the season, which is now over. The season lasted for N days. Both teams played exactly one game on each day.
For each day, Annie recorded the number of runs scored by...