Posted by : at

Category : 30_Days_of_Code


This challenges asks you to print Hello, World. on the first line, and the contents of a user input inputString on the second line.

Sample Input:

Welcome to 30 Days of Code!

Sample Output:

Hello, World. 
Welcome to 30 Days of Code!

To print a string in python, you can use the print() function. All of the following output the same thing:

print("Hello, World.") #double quotes for a string
print('Hello, World.') #single quotes for a string
greeting = "Hello, World." #storing in a variable
print(greeting)
Hello World
Hello World
Hello World

Notice that the print function defaults to a new line after it runs. You can overwrite this using end = (e.g. print(“Hello”, end = “ “)) and whatever you’d like to seperate the strings with.

To take in user input, use input(). This will prompt the user to input something, and will return a string.

Sample Solution:

# Read a full line of input from stdin and save it to our dynamically typed variable, input_string.
input_string = input()

# Print a string literal saying "Hello, World." to stdout.
print('Hello, World.')

# TODO: Write a line of code here that prints the contents of input_string to stdout.
print(input_string)

Extra Notes:

Printing two strings automatically gives a space in between. The + is use to merge/concatenate strings.

print("Hello", "World")
print("Hello" + "World")
print("Hello " + "World")
Hello World
HelloWorld
Hello World
About

Data Scientist with B.S. Statistics (3.8 GPA, Cum Laude) from UCLA. Programming knowledge includes R, Python, SQL, Tableau, SAS and other data analysis tools.

Star