Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Local vs. Global Variables | Variable Scope, Nested Functions, and Closures
Functional Programming Concepts in Python
Osio 3. Luku 2
single

single

Local vs. Global Variables

Pyyhkäise näyttääksesi valikon

Tehtävä

Pyyhkäise aloittaaksesi koodauksen

Create a function that demonstrates the difference between local and global variables by modifying a global variable inside a function.

  • Use the global keyword to modify the global variable x inside the function;

  • Assign the value 20 to x within the function;

  • Create a local variable y inside the function and assign it the value 5.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 3. Luku 2
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

some-alt