Mary PW Chin
PhD (Wales), MSc (Surrey)
random numbers and the
assignment vs comparison;
variable names: rules and conventions;
output to screen (standard output) vs output to file;
Linux commands: ls, wc, head, tail;
initialisation and counters.
For the program on slide #20 mark out the:
Repeat Exercise 1 for the program on slide #24.
Repeat Exercise 1 for the program on slide #36.
Refer to the program on slide #36. What difference would you expect if we change
for n = 1 : so_many_times
for n = -99 : so_many_times-100
for n = so_many_times+1000 : -1 : 1001
for n = 1 : 1000 : so_many_times*1000
Refer the program on slide #40. What happens if we change
? Draw the revised flowchart.
Write a program to generate two random numbers between 0 and 100. Print the larger number, and the sum, difference and product of the two numbers.
Write a program to generate a random number between 0 and 10. Take the number as the radius of a circle. Print the diameter, circumference and area of this circle.
Write a program to generate a random number 1930 ≤ y ≤ 2017, take this as somebody's year of birth. Generate another random number 1 ≤ m ≤ 12, let this be his month of birth. We need to know his age in the coming years until he reaches 90. Print your output in three columns:
__ years __ months
90 years 0 month
Write a program simulating the draw of Magnum 4D first prize.
Write a program simulating your favourite chance-based game.
you might like to search for wonder, goodness, delight, surprise, voila… and more