## Za tiste, ki jih domača naloga dolgočasi...

Due: среда, 12 октомври 2022, 15:15

... in bi se zato utegnili pritoževati, se lahko pozabavajo s stvarmi, ki se jih sicer še nismo naučili.

Že znate programirati, vendar ne v Pythonu? Potem veste, da obstajajo if in while in take reči. Napišite program, ki pove, kako daleč je potrebno ustreliti. Uporabnik mora vpisovati različne kote in hitrosti, dokler ne zadane cilja na podani razdalji. Cilj je zadet, če je razlika med pravo in dejansko dolžino strela manjša od toliko in toliko.

Že znati programirati, in to v Pythonu? Nekje med topom in ciljem je drevo (lahko je tudi zelo visoko; morda fižol, ki gre v nebo). Na veji tega drevesa (ali fižola) sedi prašič. Z isto kroglo bi radi zadeli prašiča in cilj. Napišite torej program, ki prebere oddaljenost do cilja ter oddaljenost in višino prašiča. Program naj izpiše kot in hitrost, s katero je potrebno ustreliti kroglo.

Drugo nalogo lahko rešite na dva načina. Napišete lahko program, ki s takšnim ali drugačnim poskušanjem odkrije rešitev. Lahko pa uporabite svoje znanje fizike ali matematike. Ali, še boljše, povadite oboje.

Those who would otherwise complain that they are bored by the slow pace of the course, can play with a few things we haven't learned yet.

You know how to program, just not in Python? Then you know about things like if and while and so forth. Write a game-like program that will pick a random distance and the user's task is to find the parameters (velocity and angle) to hit a target at that distance. The program should continue asking for parameters until the target is hit (within a certain sensible tolerance).

You already know Python? There is a tall tree between the cannon and the target. In the tree, there's a (angry bird) pig. Write a program that asks for the distance to the target, the distance to the tree and the height of the pig. The program must compute the angle and the velocity with which we hit the pig and the target with the same shot.

The second task can be solved in two ways. You can either write a program that tries different velocities and angles until it suceeds. (Even this might require quite some math.) A better solution is to use some math to solve the task analytically: derive the formula for angle and velocity, so that your program just computes the answer directly.