Assign names of your five friends to five different variables. Write a program tp print your friends name in different lines
Answers
Printing the names of five friends - Python
We would take a user input string first, to enter the name of first friend. Same as first friend we will also take a user input string, to enter the name of second friend. We will continuously take user input string till fifth friend, to enter the names of friends.
We know that the input() function returns a string, string is one of the basis types in Python that store text.
We then display the names of five friends in different lines, by entering the names.
The Program
friend1=input("Enter your first friend name:")
friend2=input("Enter your second friend name:")
friend3=input("Enter your third friend name:")
friend4=input("Enter your fourth friend name:")
friend5=input("Enter your fifth friend name:")
print(friend1,friend2,friend3, friend4,friend5, sep="\n")
Sample run
Enter your first friend name: Keaton
Enter your second friend name: Noah
Enter your third friend name: Jacob
Enter your fourth friend name: Harry
Enter your fifth friend name: George
Keaton
Noah
Jacob
Harry
George
Printing the names:-
We would take a user input string first, to enter the name of favourite actor. After that same as favourite actor we will take a user input string, to enter the name of favourite actress.
We know that the input() function returns a string, string is one of the basis types in Python that store text.
We then display the names of favourite actor and actress, by entering the names.
The program
friend1=input("Enter your first friend name:")
friend2=input("Enter your second friend name:")
friend3=input("Enter your third friend name:")
friend4=input("Enter your fourth friend name:")
friend5=input("Enter your fifth friend name:")
print(friend1,friend2,friend3, friend4,friend5, sep="\n")
Sample run
Enter your first friend name: Keaton
Enter your second friend name: Noah
Enter your third friend name: Jacob
Enter your fourth friend name: Harry
Enter your fifth friend name: George
Keaton
Noah
Jacob
Harry
George
Hope it helps!!
Sorry for the inconvenience!!!! :(