Day Four lesson : Variables in Python
Variables are used to store data that can be used later in a program.
Example:
X= "Musa"
Y= 20
print(X)
print(Y)
Explanation
- X = "Musa" stores the name Musa in variable X.
- Y = 20 stores the number 20 in variable Y.
- print(X) displays the value of X.
- print(Y) displays the value of Y. Output:
Musa
20
String Variable in Python
A string variable stores text or words. Text must be written inside quotation marks (" ").
Example:
name = "Musa"
print(name)
Explanation:
- name is the variable.
- "Musa" is the text stored in the variable.
- print(name) displays the stored text. Output:
Musa
Integer Variable in Python
An integer variable stores whole numbers (numbers without decimal points).
Example:
birthday= 2025
print(birthday)
Explanation:
- birthday is the variable name.
- 2025 is a whole number (integer).
- print(birthday) displays the value stored in the variable. Output:
2025
Variables are the building blocks of programming. By learning how to store and use data, you are taking an important step toward creating real applications. Keep practicing and trust the learning process! 💻🐍
Top comments (0)