Syntax - Comments, Prints, Variables, Strings, Integers, String Concatenations, and Inputs.
- comments - For python, used with a '#' symbol or 3 quotes nesting your comment:
-
helps explain what the code is doing
-
great for jogging your memory if you are editing old code
-
helps keep code organized
- prints - A function Used to send data to the console/terminal/screen:
- Keep track of data in any part of your code
- Great for debugging code
- Needed for terminal/CLI based programs
print('ThisGuyCodez....*')
print(24)
- Strings, Integers , Floats , and Booleans - Data Types:
- 3a.) String{a sequence of characters within quotes} ...I will print this out below
# printing 2 exmaples of a String
print('This is a String' , "I'm a string 2")- 3b.) Integer{regular number} solid numbers only(NO COMMAS)...I will print this out below
# printing 2 exmaples of an Integer
print(24 or 2400)- 3c.) Float{decimals}...I will print this out below
# printing 2 exmaples of a Float
print(5.1 or 33.33)- 3d.) Boolean{One of the two values - True or False}...I will print this out below
# printing exmaples of a Boolean
print(True or False)
- Try writing the syntax yourself in the
test1.pyfile:
# Try it your self......
# Answer all the questions below, then move on to test2.py
# Try it your self......
# Answer all the questions below, then move on to test2.py
# 1.) print my youtube channel as a string...
'''
2.) print the names of your favorite
coding languages you know or the names
of the ones you want to learn in a string...
'''
# 3.) print a random number/integer...
# 4.) print a random decimal...
# 5.) print a bool...
# 6.) print a string, integer, decimal, and a bool...
- Variables - A place to store values for your code to manipulate, for the computer to process, etc.:
you_tube = 'ThisGuyCodez'
print('here is a variable ---->',you_tube)
- String concatenation - more than one strings added together[Using the 'Format method']:
name = 'Guy'
you_tube = 'ThisGuyCodez'
lang = 'Python'
concat = f"{name} talks about {lang} on his YT channel '{you_tube}'"
# -- OR --
concat = "{} talks about {} on his YT channel '{}'".format(name,lang,you_tube)
print(concat)
- Inputs - Function used to get data from the user:
"""
Prompt the user by typing in
the question the user should see
within the parentheses of the function as a string...
"""
input("Whats Your Name? ")
"""
-On the interacting side of things
(in this case the console/terminal)
you would be able to actually type in your name..
>>> Whats Your Name? Guy
Even so, since we did not save it to a "Variable", there is
nothing we can do with it. Try what we went over so far yourself below
and remember to save your inputs into variables.
"""# 1.)get the users name, favorite number, adv, and verb
# 2.) concat the inputs together in a sentence
# 3.) print your concat stringCONGRATS YOU JUST PROGRAMMED YOUR A MAD LIBS GAME IN PYTHON
SEE HOW FAR YOU CAN GO AN SHARE IN THE COMMENTS