Übung zur Klausur

Klasse: 11 Fach: Informatik

     


Übung zur Klausur

Teil 1

Entscheide was die richtige Aussage zu den Code-Beispielen ist.


var x = 0;
x = 1;
	

(!x ist 0) (x ist 1) (!x ist 2)


var x = 0;
x = x + 1;
	

(!x ist 0) (x ist 1) (!x ist 2)


var x = 0;
x = x + 1;
x = 1;
	

(!x ist 0) (x ist 1) (!x ist 2)


var x = 0;
x = 1;
x = x + 1;
	

(!x ist 0) (!x ist 1) (x ist 2)


var x = 0;
x = 1;
if (x < 1) {
	x = x + 1;
}
	

(!x ist 0) (x ist 1) (!x ist 2)


var x = 0;
x = 1;
if (x >= 1) {
	x = x + 1;
}
			

(!x ist 0) (!x ist 1) (x ist 2)


var x = 0;
x = 1;
if (x == 1) {
	x = x + 1;
	if (x > 1) {
		x = x - 1;
	}
}
		

(!x ist 0) (x ist 1) (!x ist 2)

Teil 2

Entscheide welches Bild zu dem Code passt.


function setup() {
	createCanvas(200, 200);
}
	
function draw() {
	background(255);
	ellipse(width/2, height/2, 50, 50)
}
	
Bild 1) Bild 2)
Bild 3)

(Bild 1) (!Bild 2) (!Bild 3)


function setup() {
	createCanvas(200, 200);
}
	
function draw() {
	background(255);
	fill(0)
	ellipse(100,100, 50, 50)
	rect(75,75,50,50)
}
			
Bild 1) Bild 2)
Bild 3)

(Bild 1) (!Bild 2) (!Bild 3)

Teil 3


// Globale Variablen
var x=0;
var y;
var AL;
var AB;

// Programmstart
function setup() {
	createCanvas(600,400);
	AL=width/10;
	AB=height/10;
	y=height/2-AB/2;
}

// Endlose Schleife
function draw() {
	background(100);
	rect(x,y,AL,AB);
	x=x+1;

	if(x>width) {
		x=0;
	}
}

Teil 4

Korrigiere das Programm, so das es läuft. Das kannst du direkt im Code auf der Webseite machen.


function setup() {
	createCanvas(720, 400);
	background(white);
	stroke(153);
	strokeWeight(4);
	
	var a;
	var b = 120;
	var c = 180;
	
	line(a, b, a + c, b);
	line(a, b + 10, a + c, b + 10);
	line(a, b + 20, a + c, b + 20);
	line(a, b + 30, a + c, b + 30);
	
	a = a + c;
	b = height - b;
	
	line(a, b, a + c, b) line(a, b + 10, a + c, b + 10);
	line(a, b + 20, a + c, b + 20);
	line(a, b + 30, a + c, b + 30);
	
	a =< a + c;
	b = height - b;
	
	line(a, b, a + c, b);
	line(a, b + 10, a + c, b + 10);
	line(a, b + 20, a + c, b + 20);
	line(a, b + 30, a + c, b + 30);
}
	

Teil 5

Kommentiere den untenstehenden Code. Das kannst du direkt im Code auf der Webseite machen.


var x = 0;

function setup() {
	createCanvas(400, 400);
	
	noStroke();
	fill("beige");
	rect(5, height / 2, 10, height);
	rect(width - 5, height / 2, 10, height);
	fill("orange");
	stroke("brown");
}
	
function draw() {
	background(255)
	if (x < width /2) {
		ellipse(x, width / 2, 20, 20);
	}
	
	if (x >= width /2) {
		rect(x ,width / 2, 20, 20);
	}
	x = x + 1
}
	

Teil 6

Schreibe ein Programm, dass das Bild unten erzeugt. Die Leinwand ist 400x400 Pixel groß.

Teil 7

Schreibe ein Programm, dass einen Ball von der rechten oberen Ecke zu der linken unteren Ecke bewegt. Die Leinwand ist 400x400 Pixel groß. Der Ball soll einen Durchmesser von 50 Pixel haben.

Processing Online Editor - Javascript