Strings

gedit first.py

  • Opens the file first.py in the Gedit text editor.

  • The terminal is locked (you can't type anything else) until Gedit is closed.

gedit first.py

gedit first.py&

  • Opens the same file in Gedit, but in the background.

  • The terminal stays free for other commands while Gedit is still open.

gedit first.py& 

line-by-line explanation of your Python code:

#!/bin/python3
  • This is called a shebang line.

  • It tells the system to run the script using the Python 3 interpreter located at /bin/python3.


#print string
  • This is a comment (starts with #) and is ignored by Python.

  • It's just for humans to understand the code. Here, it's explaining that strings will be printed.


print("Hello,World")
  • Prints the string Hello,World to the screen.


print('\n')
  • Prints a newline (empty line), because is the newline character.


print('Hello,World')
  • Again prints Hello,World, using single quotes (same result as double quotes).


print("""This string runs
multiple lines!""")
  • Prints a multi-line string using triple quotes.

  • Output will be:

    This string runs
    multiple lines!

print("This string is "+"awesome!")
  • Concatenates (joins) two strings and prints:

    This string is awesome!

#!/bin/python3  

#print string
print("Hello,World")
print('\n')
print('Hello,World')

print("""This string runs
multiple lines!""")

print("This string is "+"awesome!"
Output This Code

Last updated