May 2, 2019
# Comments tell a computer to ignore a part of the program. The code or comments will not run by the computer: these are called code comments. Python interprets anything after the # symbol as a comment.
# This is a python comment
Python print function lets you tell the computer what to say. Make sure that you message you want to display is surrounded by quotes, otherwise it will through a SyntaxError.
# In Python you can output a string of text by using double-quotes "" or '' single-quotes. Just remember that the quotes have to be the same for each string, if not it will throw a SyntaxError
#Bad - print("bad') - will throw SyntaxError because of mismatched statement quotes
#Good - print("good") or ('good')
# We are going to output something. In python this is done by using print
print ("Howdy Earthlings")
#Variables let you reuse code by storage data to be easily changed and reused.
#Assigning variables is done by using the equals sign =
#Python variables can't have spaces or symbols in their names, though you can use underscores _ . They also can't start with number, you can use numbers in the variables, but just not as the first character.
#Good - my_awesome_666varible
#Bad - 666_my_aweomsevariable
#message_string is our variable
message_string = "Howdy Earthlings"
# Prints "Howdy Earthlings"
print(message_string)
# Programming often calls a character text block as strings.
# In Python you can output a string of text by using double-quotes "" or '' single-quotes. Just remember that the quotes have to be the same for each string, if not it will throw a SyntaxError
# In the code below the string is Amie, because it is in the quotes block 'Amie'
print('Amie')
print("Amie")
Either will work.
View this profile on InstagramAmie DD (@amiedoubled) • Instagram photos and videos
August 11, 2024