hi im new at python
ThanhTungTung (1)

can anyone help me? if you guys help me that good!

You are viewing a single comment. View All
YatinBayya (18)

The Basics
This is an overview of the basics to help you boost your start with python. I won't go through everything of course but enough for you to start your first application. Make sure you selected Python 3 instead of Python 2.
Variables in python are just like the ones in math but you have to define them. You can store different types of data like the ones below...
Booleans - True/False
Strings- Text
Int/Integer - Numbers with no decimal
Double - Decimals
Long - Big Number
Short - Small Number
Byte- 0-8
This is how we define each one

var myBoolean = True
var myString = "A String"
var myInt= -34
var myDouble= 43.143
var myShort = 10
var myLong =34123
var myByte = 2

The variable names are in the middle which you will need to call it... and you can name the variables anything without any special characters(!, +, #, etc)
Note: True/False in booleans MUST be capitalized
Operators is math. Done! Ok, here are the different types...
Addition - +(It adds stuff)
Subtraction- - (It subtracts stuff)
Multiplication- is the star above the 8 key (It multiplies stuff)
Division- / (It divides stuff)
*Modulus- % (It finds the remainder of an equation)
Here is the syntax

var mathNumber = 42
var password = 1234

var addition = mathNumber+password


As you can see my very AP math skills
Print Statements
The print statement is a very simple concept, all it does is display text in the terminal/console. In replit, you should see your program running on the side. Below is the syntax of the code for printing.

print("Hello World")

Whatever is in the quotes is printed so you can change it to "Creeper Aww Man" and it would work. We can also print variables like this (only if we have it defined)...


To print variables along strings you can do...

print("My Name is" + name)

Say you want to print What is your Name? and then print the user's name. To do this you would need to tell the computer you are getting there input.

name = input("What is your name?")

The code here makes a variable which you can use later to print or do something.
Note: the thing before the = sign is your variable name for pulling the data later.
If/Else Statements
What do we do when we want to check if data is equal to something... well if statements. This is the syntax to make if statements are...

if(age > 60):
        print("Sign Up for our senior program)
else if(age == 9):
        print("Greetings 9-year-old")

Note: Indentations (press tab key, NO SPACES) are REALLY important for the syntax. If it is wrong you program will crash. This is only when the line before has ":" which means it continues to the next line so you need to indent the things you want to execute when that statement is true.
This is a very small part of the programming world but I found some tutorials I think would help you out with your python coding.


ThanhTungTung (1)

hi @YatinBayya ,wow, you know lot about code, thank you

YatinBayya (18)

@ThanhTungTung Your welcome. I am glad it helped it took me an hour to write it

YatinBayya (18)

@ThanhTungTung My bad there is no else if there is only elif.