# Python Scripts

#Basic#Script

We have tried using Python in the interactive shell. In fact we can save our work in textual files and use editors to help developing Python codes.

# Assignment 1 explained

# Solution 1

Here's an example to solve Assignment 1

print("Hello, " + input("What is your name? "))
1

The operator + concatenates two strings together. We will talk more about operators in the next lesson. Good job if you use it to solve Assignment 1, since you have put common senses into programming!

# Solution 2

Here's another way to solve this problem.

print("Hello,", input("What is your name? "))
1

We don't need to use the operator + in this case. Python's print() (opens new window) function can display not only one but multiple objects (values), separated by space by default.

# Solution 3

We can even solve it in a verbose way.

name = input("What is your name? ")
print("Hello,", name)
1
2

# Save to file

A program file or script written in Python usually has the file extension .py. We can ask the Python interpreter to execute a .py file (Python script).

Now let's create a file named hello.py and put either solution from above in the file. Then open terminal and type the following command:

python hello.py
1

You should be able to type a name in command line and expect a greeting.

hello.py (opens new window)