@AnthonyLosurdo/

ZanySnarlingCache

Python

A introduction to key python elements. Print(), and input() functions. Variables, \n, documentation, the shell.

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#A very python project

#If I place a # sign before typing, whatever follows it will be silenced. 
#This is a way to document your code, and leave notes about what is going on. 

"""I can also surround large bodies of text with these three quotation marks. 
I would use this if I had large amounts of text I wanted to write, or wanted to silence code temporarily. 

Let us discuss some basic functions. 
Functions are followed by () in python. 

I call a function by typing it. I can type it into the shell below, or in the main.py file you are currently reading.  
This is like drawing with turtle (if you remember).
Here are some sample functions you should play with that will help us design out text adventure. 
"""
print("Hello world") #prints text to the console.  
input() #pauses the program to give an opportunity for user input. 

print ("") #Type something in between the "" to see it printed below.

"""I can also have text printed when calling the input function. See whats going on below. FYI \n placed in the print function causes a line break."""

input("Why do they always type hello world?\n") 

"""
A variable is a box I can store something in. When I call the box by its variable name, later. I can use what was inside. Check it out below by unsilencing the following (delete the leading and trailing ") lines of code, and clicking run up top. If you are getting sick of the intro, silence the code above.
"""

"""
cat = "dog" #Notice the quotation marks. This means it is a "string", or text basically.  
print (cat) #Notice the lack of quotation marks. I am calling the variable cat in the print function.
print ("cat") #Again notice the quotation marks. I am calling the string cat in the print function. 
"""



"""
user = input("Type your name here.\n") 
print("")
input("Press enter to see what prints. \nI stored your input in the variable user.")
print(user) #notice the missing quotes. I am asking the computer to print a variable. The variable user. 
print("user")
print("Hello {}, how are you today?" .format(user))
"""