Learn to Code via Tutorials on Repl.it!

← Back to all posts

# Hey guys, today I will be covering data types and math

### Few data types

• integers
• strings
• boolean
• lists

#### This is how you declare in int(integer)

``num = 2 # this num variable stores a number``

#### Strings

``word = "Python" # this is how you declare a string (add quotes. Can be single or double)``

#### Boolean

``is_male = True # capitalize the T``

#### lists

``````nums = [1, 2, 3, 4, 5] # a list can contain multiple values unlike a variable which can only contain one value

# a list can contain different data types, so you can do this

values = ["Python", 1, True, False, 2, "car"]``````

### Math in Python

``print(2 + 2) # this will output 4 to the console``

You can use these to do basic math

• +
• -
• *
• /
• %
``print(2 - 2) # outputs 0 to the console``
``print(2 * 2) # outputs 4 to the console``
``print(10 / 5) # outputs 2  to the console``
``print(2 % 2) # % (modulus) operator outputs the remainder, so in this case 0``
hotnewtop
Wumi4 (486)

There are also a `//` too, which do the same as `/` but return a integer instead of float ( as my brain said ).

@Wumi4 Yes, I know that. But I wanted to cover the basics, not advanced.

@Bookie0 oh, i thought they were a bit advanced. I wanted cover the most basic operators.

Bookie0 (5977)

@SUHASTADIPARTH1 almost every tutorial covers them

@Bookie0 well, ok. I will do that next time.

CodeLongAndPros (1591)

@SUHASTADIPARTH1 And modulo is basic? Anyways, you can emulate // by doing int(x /y) or int(str( x /y).split('.)[0)

@CodeLongAndPros That is true. I think I am going to make a tutorial on this. Using the advanced operators.

CodeLongAndPros (1591)

@SUHASTADIPARTH1 You gave a tutorial on creating variables and doing math, and you call that complete?

@CodeLongAndPros No, I have a tutorial series. And this is the second tutorial in the series. I have more tutorials coming up.

Kookiez (389)

@SUHASTADIPARTH1 but if it's a series then it would probably be called cycle squeezing

Kookiez (389)

@SUHASTADIPARTH1 well, at least most people would, if it's a really long part 1 and a long part 2, i wouldn't call that cycle squeezing. but this is really short, i would really recommend to make it one long tutorial or 2 long tutorials.

Bookie0 (5977)

btw think u messed up the markdown a bit here

you should also try to concatenate all your tutorials together instead of making a whole small series like these, and make them a bit longer too :)