Write programs with iterators that computes:
• The sum of all even numbers between 2 and 100 (inclusive).
• The sum of all squares between 1 and 100 (inclusive).
• The product of all powers of 2 from 20 up to 220
• The product of all odd numbers between a and b (inclusive), where a and
b are inputs. (example, if a = 3, b = 7 then the product of odd numbers
between 3 and 7 is 3 * 5 * 7)
2. Write a program that allows you to play rock, paper, scissors against the computer.
Import the random module to select the computer’s choice.
3. A simple random generator is obtained by the formula rnew = (a×rold+b)%m and
then setting rold to rnew. Write a program that asks the user to enter an initial
value for rold. (Such a value is often called a seed). Then print the first 100 random
integers generated by this formula, using a = 32310901, b = 1729, and m = 224
4. In a predator-prey simulation, you compute the populations of predators and prey,
using the following equations:
preyn+1 = preyn × (1 + A – B × predn) (1)
predn+1 = predn × (1 – C + D × preyn) (2)
Here, A is the rate at which prey birth exceeds natural death, B is the rate of
predation, C is the rate at which predator deaths exceed births without food,
and D represents predator increase in the presence of food. Write a program
that prompts users for these rates, the initial population sizes, and the number of

"Get 15% discount on your first 3 orders with us"
Use the following coupon

Order Now