
Task 2 :constants and variables
Hi all this is my second task constant and variables... 1.Create and Print a Variable Concept: A variable is used to store data that can be used later in a program. name = " Jaya Sri " print ( name ) Explanation: We create a variable called name and assign a string value to it. The print() function displays the stored value on the screen. 2.Reassign a Variable Concept: Variables in Python can be updated with new values. age = 18 print ( " Old age: " , age ) age = 19 print ( " New age: " , age ) Explanation: Initially, the variable age stores 18. Later, it is reassigned to 19, showing that variables are flexible and can change during execution. 3.Multiple Assignment in One Line Concept: Python allows assigning multiple variables in a single line. a , b , c = 5 , 10 , 15 print ( a , b , c ) Explanation: The values are assigned in order. This makes the code shorter and more readable. 4.Swap Two Variables Without Third Variable Concept: Python provides a simple way to swap values. x = 5 y
Continue reading on Dev.to Python
Opens in a new tab




