Programming basics 03: Expressions (simple maths)

Veröffentlicht am: 15 November 2023
auf dem Kanal: Codersaurs
16
1

Today we’re going to be showing you how to get our program to do some simple mathematics. And as an added bonus, you’ll learn how to tell our favourite dinousaur how to write things to the screen.

----------------------------------------------------------------------------
Here is today's code snippet:
----------------------------------------------------------------------------

cs()
home()
pu()

function write_and_step(value_to_write) {
const FONT_SIZE = 1.5
const STEP_SIZE = 15
write(value_to_write, FONT_SIZE)
fd(STEP_SIZE)
}

write_and_step("Dinosaurs are cool!")

write_and_step(42)

const SOME_CONSTANT = 1234
write_and_step("Constant is " + SOME_CONSTANT)

const EGGS_PER_BOX = 6
const GOOD_EGGS_PER_BOX = EGGS_PER_BOX - 2
write_and_step("Eggs: " + GOOD_EGGS_PER_BOX)

const BOXES_PER_CRATE = 120
const GOOD_EGGS_PER_CRATE = BOXES_PER_CRATE * GOOD_EGGS_PER_BOX
write_and_step("Crate: " + GOOD_EGGS_PER_CRATE)

const SCORE_MATHS = 84
const SCORE_SCIENCE = 90
const SCORE_ENGLISH = 50
const SCORE_AVERAGE = (SCORE_MATHS + SCORE_SCIENCE + SCORE_ENGLISH) / 3
write_and_step("Average: " + SCORE_AVERAGE)

const RADIUS = 3
const PI = 3.1415927
const AREA = PI * RADIUS * RADIUS
write_and_step("Area: " + AREA)

const TEMP_FARENHEIT = 60
const TEMP_CELCIUS = (TEMP_FARENHEIT - 32) * 5 / 9
write_and_step(TEMP_FARENHEIT + " farenheit is " + TEMP_CELCIUS + " celcius")


Auf dieser Seite können Sie das Online-Video Programming basics 03: Expressions (simple maths) mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Codersaurs 15 November 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 16 Mal angesehen und es wurde von 1 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!