HomeTurtlegraficsGPanelRobotics WebTigerPython
 Python - Online
Deutsch   English   

17. Arbeitsblätter

 

 

WORKSSHEET 1: PYTHON CITY

 

The worksheet depicts a realistic scenario in the IT industry: You are employed as a programmer in a company and are supposed to continue a project of your predecessor. You are given a complex, executable programme as a template. Your task is to understand the programme and make certain adjustments.

The programme draws a picture of a city. As the programme code contains random elements, the city will look different every time you run the programme.


1.

Copy the programme to WebTigerPython or WebTigerJython by clicking on the following button and run it several times.

Program:   

 

2.

 

Study the programme. The comments will help you to understand the programme structure.

3.

 

Change the number of houses. Initially only 30, then 70 and finally 45 houses should be drawn.

4.

The windows should be red, not yellow.

5.

 

You like the yellow windows better, but not all the windows should be illuminated. 30% of the windows should be black, the rest yellow. To do this, insert the following code in the right place
if random() < 0.4: meineFarbe = [0, 0, 0]

6.

 

The houses do not all have to be grey either. Half of the houses should have a reddish colour (e.g. [170, 100, 100]).

7.

 

A small star should be visible next to the moon. You draw the star round with the fillCircle() function.

8.

Draw 100 random stars in the night sky.

9.

The stars are not the same size. 30% have a diameter of 3, the rest 2.

10.

 

Add your own ideas to the picture (shooting stars, ships on the water, houses reflected in the water...)