Parottasalna

AI, Backend Engineering & Architecture Guides

TASK 1: Python – Print exercises

  1. How do you print the string “Hello, world!” to the screen?
  2. How do you print the value of a variable name which is set to “Syed Jafer” or Your name?
  3. How do you print the variables name, age, and city with labels “Name:”, “Age:”, and “City:”?
  4. How do you use an f-string to print name, age, and city in the format “Name: …, Age: …, City: …”?
  5. How do you concatenate and print the strings greeting (“Hello”) and target (“world”) with a space between them?
  6. How do you print three lines of text with the strings “Line1”, “Line2”, and “Line3” on separate lines?
  7. How do you print the string He said, "Hello, world!" including the double quotes?
  8. How do you print the string C:\Users\Name without escaping the backslashes?
  9. How do you print the result of the expression 5 + 3?
  10. How do you print the strings “Hello” and “world” separated by a hyphen -?
  11. How do you print the string “Hello” followed by a space, and then print “world!” on the same line?
  12. How do you print the value of a boolean variable is_active which is set to True?
  13. How do you print the string “Hello ” three times in a row?
  14. How do you print the sentence The temperature is 22.5 degrees Celsius. using the variable temperature?
  15. How do you print name, age, and city using the .format() method in the format “Name: …, Age: …, City: …”?
  16. How do you print the value of pi (3.14159) rounded to two decimal places in the format The value of pi is approximately 3.14?
  17. How do you print the words “left” and “right” with “left” left-aligned and “right” right-aligned within a width of 10 characters each?

Solution:

Discover more from Parottasalna

Subscribe now to keep reading and get access to the full archive.

Continue reading