Vai al contenuto

Challenge 2012-11

Text Challenge 1

Get the user to input a sentence and count how many times each letter in the alphabet is used.
Find the most common letter; often it is ‘e’.

Text Challenge 2

Write a TextWindow program to welcome a user and ask for their name.
Ask for more details like their age or where they live.
After each question, reply using some of the information already gained about the user to ask a new question.
For example if the user is under 18 you might ask if they are at school, otherwise you might ask if they work.

A conversation might go like this:

Computer: Welcome, what is your name?
User: John
Computer: Hello John, how old are you?
User: 15
Computer: Are you still at school John?
User: Yes
Computer: Where do you live John?
User: New York
Computer: Is New York near Seattle?

DiscussioneMath Challenge 1

  1. Find all the numbers less than 1000, where the sum of the digits is 15, for example 96 or 177.
    How many are there?
  2. If you fancy a further challenge, then calculate how many numbers less than 1000 there are that have a sum of digits equal to each of the possible values (not just 15, i.e. 1, 2, 3 … 25, 26, 27).

Math Challenge 2

Create a program that allows the user to create 3 points on the GraphicsWindow – perhaps use a mouse click to set a point.
Your program will join them up and calculate the area of the resulting triangle.

Graphical Challenge

Draw a scene with weather conditions, perhaps cloudy sky, or rain, wind or snow.

Events Challenge

Use the keyDown and keyUp events to display a simple keyboard on the GraphicsWindow showing which keys are currently pressed (perhaps red while the key is down).
It doesn’t have to be all possible keys, you could just do it for the arrow keys.

Physics Challenge

Running out of simple physics challenges – this one isn’t much harder, just takes more explaining.

An ideal gas has the following equation relating its pressure (P Bars), volume (V litres) and temperature (T degC).

(1)    P * V / (273 + T) = constantA (ideal gas equation)

This means that if we know the starting state (P, V & T) and any 2 quantities are changed then the 3rd can be calculated.

If we start at P = 2 Bar, V = 1 litre and T = 20 C and change the pressure, volume or temperature, then the others will change to keep the equation equal to constantA.

For example if we keep the temperature constant and double the volume, then the pressure will half (Boyle’s Law).

If there is no heat transfer (or technically no entropy change), then the following equation also holds for gases.

(2)    P * V^g = constantB (isentropic or adiabatic expansion)

g is a property of the gas (isentropic exponent), for air it is about 1.4.

V^g means V to the power of g; in SmallBasic this is Math.Power(V, g).  If you don’t know about powers then use P * V * V = constantB.

If we know the starting pressure and volume, then we can calculate the change in either P or V if the other is changed.

An example of gas compression heating a gas is the warming of a bicycle pump, and gas expansion cooling a gas might be ice that forms on the nozzle when a CO2 fire extinguisher is used, or even how a fridge works.

So if the volume changes, then the pressure will change according to (eqn 2) and the resulting pressure and volume change lead to a change in temperature (eqn 1).

Calculate and perhaps plot the change in temperature and pressure as we increase (expand) or decrease (compress) the gas volume.

Hint: Equations 1 and 2 can be written to show how the initial and new values of P,V,T are related:

(273 + T2) / (P2 * V2) = (273 + T1) / (P1 * V1)
P2 = P1 * (V1/V2)^g

where P1,V1,T1 are initial values and P2,V2,V2 are new values.

How much must we expand 1 litre of air to cool it from 20C to 0C?  What is the pressure change if we start at 2 Bar?

Not a programming question, but would it take more or less or similar effort pump up a cycle tire on a hot or cold day?

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.