Write a Python Program to Print 5 Lines About Yourself Using Print Function

Given the lines containing the words about yourself,  you have to print these words as an output of the program using the print function call.

Let's take the Name Study TV Hobbies and Native place as a variable and let's try to print it using the Python function.

 

Write a Python Program to Print 5 Lines About Yourself Using Print Function

 



Write a Python Program to Print 5 Lines About Yourself Using Print() Function

Let's take five variables:  name, study, tv, hobbies and native.  set the string variables by providing your details / description

For example name try to write your name, school, your hobbies etc

name = "My Name is : ABC"
study = "I study in : DEF School Class 1"
tv = "I watch Movies and Cartoon"
hobbies = "I love swimming, reading books"
native = "My native place is XYZ"




Use the print function to print the string variables that you have declared above using the string formatting inside the print function call as shown below.

print(f"{name} \n{study} \n{tv} \n{hobbies} \n{native} ")




Python code
=================

name = "My Name is : ABC"
study = "I study in : DEF School Class 1"
tv = "I watch Movies and Cartoon"
hobbies = "I love swimming, reading books"
native = "My native place is XYZ"

print(f"{name} \n{study} \n{tv} \n{hobbies} \n{native} ")






OUTPUT
===============


My Name is : ABC
I study in : DEF School Class 1
I watch Movies and Cartoon
I love swimming, reading books
My native place is XYZ




You can also modify the above program to  use the print function 5 times as shown below, It will produce the same output as shown in the output section.

name = "My Name is : ABC"
study = "I study in : DEF School Class 1"
tv = "I watch Movies and Cartoon"
hobbies = "I love swimming, reading books"
native = "My native place is XYZ"

print(name)
print(study)
print(tv)
print(hobbies)
print(native)





Conclusion
===================

Modify the above program by replacing the string values ABC, DEF and XYZ with your name, school name and native place and execute the above program.

Comment it down below if you have any suggestions to improve the above program.





Post a Comment

1 Comments