
TASK 1- Python – Print exercises
How do you print the string " Hello, world!" to the screen? CODE: print("Hello, world!") OUTPUT: Hello, world! EXPLANATION: print() is a built-in function in Python It is used to display output on the screen The text inside quotes (" ") is called a string Python prints exactly what is inside the quotes 2.How do you print the value of a variable name which is set to “Syed Jafer” or Your name? CODE: name = "Haripriya" print(name) OUTPUT: Haripriya EXPLANATION: name is a variable that stores a string value "Haripriya" is the value assigned to the variable print(name) displays the value stored in the variable Python prints the content of the variable, not the word name 3.How do you print the variables name, age, and city with labels “Name:”, “Age:”, and “City:”? CODE: `name = "Haripriya" age = 18 city = "Namakkal" print("Name:", name) print("Age:", age) print("City:", city)` OUTPUT: Name: Haripriya Age: 18 City: Namakkal EXPLANATION: Three variables are created: name, age, and city print()
Continue reading on Dev.to Tutorial
Opens in a new tab




