Coding for Beginners(readable edition) 2

Review

So last time we learned about programming languages(Python), the print statement, and data types. Just to test you guys, I’m gonna give you some examples and you have to guess which type it is.

 

  1. (“Me: Python is great and nice…:P:P:P:P:P Python: Can’t tell if that’s sarcastic.”)
  2. True
  3. 12321232122321
  4. 1.0000000000000000
  5. (“False”)

 

You can type them in the Console below to check your answers.

Console:

Input

Great job! I hope I’m being motivational. Really though. Now we are going to learn about input. Let’s say that you are talking to your friend(the computer) and you ask them if it is ok to call an accidental meeting and not say anything in among us(it is currently 2020)? (obviously it is. jk). To do that, in the Editor you can write input in front of the string, as in, to the left of it. In the console, it will ask the user(you) to type in an answer. (in a string you always have to put quotation marks and parentheses):

Editor: input(“Is it ok to call an accidental meeting and not say anything in among us(the game)?”) 

Console: Is it ok to call an accidental meeting and not say anything in among us? 

 

Another example(you can write all your life’s problems and then answer them yourself. Great technique) 🙂

Editor: input(“I told Casey that Alexa and her friend Charlie were not coming over today and that reminded her to ask Charlie about what went down at her birthday. Charlie told Casey to ask Alexa and Alexa is bad at keeping secrets so she told Casey that Em bribed the DJ to run away and told everyone that the party was over through text without Casey knowing. Everybody got sad. Is it my fault?”)

 

Console: I told Casey that Alexa and her friend Charlie were not coming over today and that reminded her to ask Charlie about what went down at her birthday. Charlie told Casey to ask Alexa and Alexa is bad at keeping secrets so she told Casey that Em bribed the DJ to run away and told everyone that the party was over through text without Casey knowing. Everybody got sad. Is it my fault?

Input is the information that the user types in the console and output is the code that you write. When you say input(“Question?”) you are asking the user for some input.

You should always comment your code to show the user what you are trying to do. You can do that by adding a hashtag # in front. 

Ex: #This is a comment

 

Variables

Now we’ll learn about variables. A variable in python is a symbol that gets assigned to a value. For example a == 3. a is the variable and 3 is the value.

 

Operators

Just like in math, when you want to add, subtract, etc there is a symbol.

In python:

 

ArithmeticOperators

(name)

Operator
Addition +(shift and =)
Subtraction
Multiplication *(shift and 8)
Division /
Modulus(the remainder after you divide)Ex: 8/5 mod=3 %(shift and 5)
Exponents **(shift and 8 twice)
Floor division //

 

Comparison Operators

(name)

Operator
equal ==
Not equal !=
Greater than >
Less than <
Greater than or equal to >=
Less than or equal to <=

 

You can apply operators on data types:

String + String

String * Integer

String * Bool

String
Integer + Integer

Integer * Integer

Integer
Integer/Integer (even if there is no remainder)

Integer + Float

Integer * Float

Float
String + Integer

String + Float

String+ Bool

String * Float

String/Float

Error
Bool + Integer 

Bool + Float

Integer

Float

 

That’s it for now, Thanks so much for reading guyyyyyssss. 

Stay stoked.

 

 

 

🤸

Saanvi out.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to Top