Write a program that uses two input statements to get two words as input. Then, print the words on one line separated by a space. on edhesive.com
Answers
Answer:
Following is the python code.
word1=str(input("Enter first word\n"))#taking input of word 1..
word2=str(input("Enter second word\n"))#taking input of word 2..
print(word1+" "+word2)#printing both words with space in between.
Explanation:
I have taken two variables word1 and word2 to store the first word and the second word.Taking input in string format that's why I have used str.Then printing both the words in one line with space in between using the print command of python.To print both the word in one line I have used +.
Program:
To read two input statements to get two words as input. Then printed them by using spaces.
X = input (“Enter word1: “)
Y = input (“Enter word2: “)
Print (“{} {}. Format(X, Y))
Explanation:
Here, Python language has been used for programming. Below are the following steps:
- Step 1: Define input value X, and by using input() method, get the value of word 1.
- Step 2: Define input value Y, and by using the input() method, get the value of word 2.
- Step 3: The values are outputted as {} {} (using space in between), by formatting space using Format() method.
- Step 4: The formatted values are printed using the Print() method.