CBSE BOARD XII, asked by ramsmedicine, 1 month ago

Assign names of your five friends to five different variables. Write a program tp print your friends name in different lines

Answers

Answered by allysia
0

Language:

Python

There are a few ways to do that:

Method 1:

You can make a variable per line and print the output with one print statement per line making a 10 lines of program.

name1="Ram"

name2="Anindy"

name3="Swetank"

name4="Oreki"

name5="Pulvesh"

print(name1)

print(name2)

print(name3)

print(name4)

print(name5)

Method 2:

Use the same functions as above in 2 lines,

name1,name2,name3,name4,name5="Ram","Anindy","Swerank","Oreki","Pulvesh")

print(name1,name2,name3,name4,name5, sep="\n")

Note: sep is the separator between names \n is an escape character that gives new lines to each.

Similar questions