In this Python Beginner Tutorial, we will begin learning about integers and floats. Integers and Floats allow us to work with numeric data in Python. We will be learning how to perform basic arithmetic, as well as how to compare numeric values. Let’s get started.
The code from this video can be found at:
Watch the full Python Beginner Series here:
✅ Support My Channel Through Patreon:
✅ Become a Channel Member:
✅ One-Time Contribution Through PayPal:
✅ Cryptocurrency Donations:
Bitcoin Wallet – 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet – 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet – MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
✅ Corey’s Public Amazon Wishlist
✅ Equipment I Use and Books I Recommend:
▶️ You Can Find Me On:
My Website –
My Second Channel –
Facebook –
Twitter –
Instagram –
#Python
Tag: convert string to int python 3, Python, Python Ints, Python Floats, Integers, Python Integers, Python math, Python arithmetic, Python for Beginners, Absolute Beginners, Python for Absolute Beginners, Python Basics, Getting Started with Python, Python 3.6, Python 36, Python 3, python tutorial, python, integers, floats
Xem thêm: https://icongnghe.org/category/pc
Nguồn: https://icongnghe.org
32 Bình luận. Leave new
Thx bro.
Great video thank you so much
You're a teaching GOD blessed hands
My teacher sent us this video so we can understand Python (because the school is closed and he can't really teach us now). But he can not speak english at all (we are hungarians), and Idk why does he expect us to know english if he can't even speak it. lol
But the video was good. It's really helpfull. <3
My friend has recommended you to look to your videos. Your teaching style is very good anyone can understand easily…
How to get instant RUN? In Atom I have to type 'python file.py' in the terminal window. I'd like that shortcut. I have script installed.
Goood job on the explaining easy for everyone.
was very helpful
thank you very much
10:38 I think it's a bug.
num1 = int('100')
num2 = int('200')
print('This is Sparta!')
Great tutorial and Merry Christmas, Corey!
hi! how can I add the positive whole numbers only if one or two input digits numbers are decimals numbers or negative numbers.
example
input: 2 -4 3.6 1
expected output: 3
Very good explanation of modulus, I’ve not had it put to me in this way before so I finally got it.
Some notes:
——-
Numbers
——-
Types :-
– int, normal integers like, -2,3,0 etc
– float, decimal/fractional values like, -0.4, 9.83 etc.
Arithmetic Operators :-
– 3 + 2 # Addition
– 3 – 2 # Subtraction
– 3 * 2 # Multiplication
– 3 / 2 # Division
– 3 // 2 # Floor Division (rounds float to int)
– 3 ** 2 # Exponent
– 3 % 2 # Modulus (remainder)
Comparisons :-
– return either true or false
– 3 == 2 # Equal
– 3 != 2 # Not Equal
– 3 > 2 # Greater Than
– 3 < 2 # Less Than
– 3 >= 2 # Greater or Equal
– 3 <= 2 # Less or Equal
Incrementing :-
num = 1
num += 1 # same as num = num + 1
# the "+" in += can be replaced by any other arthimetic Operators
# eg num *= 2, now num = num * 2 = 2. Similarly all other arthimetics.
Useful functions :-
1. Absolute value function – abs(value)
– gives the magnitude of integers.
– basically, removes the negative sign if there is one.
– abs(-3) # returns 3
2. round function – round(value) .
– Also accepts another argument to specify no. of digits
– after the decimal point to round the value off to.
– round(3.75) # returns 4
– round(3.75, 1) # returns 3.8, ie. 1 digit
Type conversion/casting :-
– int(value)
– num = "1"
int(num) # returns 1 as an integer
Miscellaneous :-
– Add parentheses () for enforcing precedence.
eg: 3 * (2+1) = 9
– you can use type(variable_or_value) to find the value's data type.
Codes from the video
num = 3
#num = 3.14
print(type(num))
#Arithmetic Operators:
#Addition: 3 + 2
#Subtraction: 3 – 2
#Multiplication: 3 * 2
#Division: 3 / 2
#Floor Division: 3 // 2 (drops decimal)
#Exponent: 3 ** 2
#Modulus: 3 % 2 (gives remainder)
print(3 / 2)
print(3 // 2)
print(3 % 2)
print(4 % 2)
#(any number) % 2
# -> gives remainder 1 , odd no.
# -> gives remainder 0 , even no.
print(3 * 2 + 1)
print(3 * (2 + 1))
num = 2
#num = num + 1
#num += 1
num *= 10
print(num)
# Some built in functions
print(dir(num))
print(abs(-3))
print(round(3.3))
print(round(3.5))
print(round(3.8))
print(round(3.75,1))
#Comparisons:
#Equal: 3 == 2
#Not Equal: 3 != 2
#Greater Than: 3 > 2
#Less Than: 3 < 2
#Greater or Equal: 3 >= 2
#Less or Equal: 3 <= 2
num_1 = 3
num_2 = 2
print(num_1 == num_2)
print(num_1 != num_2)
print(num_1 > num_2)
print(num_1 < num_2)
print(num_1 >= num_2)
print(num_1 <= num_2)
num_1 = '100'
num_2 = '200'
print(num_1 + num_2)
#casting to avoid concatenation
num_1 = int(num_1)
num_2 = int(num_2)
print(num_1 + num_2)
Thanks man
VIdeo 03/143 complete ty again.
Corey Schafer's Python educational videos are by far the best I have come accross. I have been learning, and now teaching python coding, for several years but Corey's teachings have been invaluable. I should really recommend my own video's but for all levels of Python Corey Schafer is THE first place I'd suggest for everyone. Thanks to Corey @coreyschafer for the excellent work.
Thank you so much. It helped me a lot.
thank you so much, very helpful
why cant we just remove the quotes??/
0:58 why no control + c?
Awesome!
hey Corey, is there a way we can loop through this?
try:
shapeSides = int(input("sides: "))
except:
print('please enter a number')
shapeSides = int(input("sides: "))
makes me think on a while loop, like while shapeSide != integer, but doesnt work like that, any idea?
One of the best Python tutorials I have seen! Thanks, Corey!
Hi Corey
I have been following your video tutorials for more than 1 yr. I wanna ask how do you keep your updated with the latest update in python and further please advise how to master this language. I am looking for your response. I love the way you teach.
Shut up and take my subscription!
8:48
Note to self : <= is slower than >=
Thank you <3
As usual, great video.
Comment: The video title is integers and float. I thought that few words on floats are required (e.g. decimal representation vs scientific representation, real/image values, casting). Just to have the video be complete
This tutorial, especially the round function was so useful for me!! Thanks a ton for putting up such a great effort
Directly to the point needs to learn not washing time I like it.
This was really thorough. I learned a lot.