Ask coding questions

← Back to all posts
hi im new at python
ThanhTungTung (1)

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

Commentshotnewtop
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
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
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

print(password%mathNumber)

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)...

print(myInt)

To print variables along strings you can do...

print("My Name is" + name)

Input
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")
else:
        print("Hello"+age+"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.
Conclusion
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.

https://www.youtube.com/watch?v=rfscVS0vtbw
https://www.python.org/about/gettingstarted/
https://www.udemy.com/course/python-for-absolute-beginners-u/?LSNPUBID=JVFxdTr9V80&ranEAID=JVFxdTr9V80&ranMID=39197&ranSiteID=JVFxdTr9V80-cEs2XQklSKCl1FR1tKA_eQ

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.

JonathanDavis3 (0)

YatinBayya, you missed the fact, that there is elif, that goes before else and after if

ThanhTungTung (1)

thank everyone again

ThanhTungTung (1)

thankkkkkkkkkkkkk so much for helping me

ChristopherLi5 (5)

Coding in Python? I suggest you either read a Python book or go to codecademy.com and take a Python course. After you know some Python, I suggest you could make some mini projects.

ThanhTungTung (1)

hi @ChristopherLi5 , thank for helping me, it very useful at codecademy.com

RyanRana (169)

Do you want to learn python? You can check out my programming youtube channel https://www.youtube.com/channel/UCIta8OqsKjfE1knTU2DJlSQ?disable_polymer=true. Python Intermediate, Beginner, and Advanced content. Please subscribe if you like it.

Or, do you need help with code, just copy and paste below if you need that.

ThanhTungTung (1)

@RyanRana , thank, your youtube channel was great, i sub it

RyanRana (169)

@ThanhTungTung Thanks, so much. Really appreciate it!

Masy (21)

Yeah, If you could post a code snippet, that would be helpful! :)

ThanhTungTung (1)

@Masy , thank very much, if have any problem, i will ask you guys

Zavexeon (303)

Can we get some context? ^w^

If you're struggling with code add a snippet of it, please. We'd be happy to help. :)

ThanhTungTung (1)

@Zavexeon , thank very much, if have any problem, i will ask you guys