Today we are gonna learn about print, Operators and Datatypes.
Print:-
In layman's term, print is literally output that shows in your terminal.
you put something inside print, it will put that thing inside terminal, except if there is an error, usually in print you encounter syntax error.
EVERYONE GO AND TRY THIS CODE.
print("Hello World!")
NOTE:- TERMINAL IS THE THING THAT SHOWS YOUR OUTPUT AND ERROR.
NOW OPERATORS:-
there are several types of operators. so arthemetic operator is literally mathmathic's symbols example add, sub, divide, multiply and so on.
ARTHEMETIC OPERATOR:
+ means addition
- means substraction
* means multiplication
/ means division
% means modulus. (N, Modulus is basically fancy word of reminder)
Comparative Operator:
< means lower than
> means higher than
== means equals to
<= means lower or equal to
>= means higher or equal to
!= means is not equal to
LOGICAL OPERATOR: these are bit confusing but easy to understand
and (both value must be true) (a= 2+2 b= 3+3 if a=4 and b=6 then run code else don't)
or (one value must be true) (a=2 b=4 if a=2 or b=7 run code else don't) at least "a" is correct)
not (flips the value) (a=2, if not a==3 run code else don't) see a ==3 wrong but not makes false
into true.
Now lets start data types.
So, this is one of backbone of programming languages, almost all high level programming language has this.
INTEGAR= int
Integer is basically numbers, it represent numbers. but but, it doesn't deal with fractions, points what ever other thing is.
the key idea here is:-
we all know 3/2=1.5 right.
but in integar form. its 3/2=1
the .5 yeah it doesn't see the .5 it only sees whole number not .5 or .7 anything like that it only sees whole number.
to declare integar in python you use:- int function.
Float = float
This is basically Number again? yeah Numbers again but the difference is just every has point.
normally we see
2/2= 1 right
float will put points the back
meaning
in float
2/2=1.00
to declare float in python you use:- float function.
String= str
String is basically everything inside double(") quotation or single(') quotation.
yes, it includes number, floats, even emojis. all it has to do is exist inside the:- "" or ''
example:-
print("123") is a string
print('hello world') is also a string
but this
print(123) is not a string but an integar
for declaration of this string users may use:- str function
Boolean = bool
So, Boolean is literally the concept of true or false.
you can say bool is kinda like a checker, it checks in detail if logic is true or false.
(we will dive into deep later but for now this is how it works.)
a=2+2
we all know the answer is 4 easy right.
now lets say we do this
print(a)= 4
and if we did
print(bool(a)==4) it will say:- true
and similar we say
print (bool(a)==5 it will say :false
to use boolean one should use :- bool to declare or simple use true or false.
so for today this is it.
Oops! This image does not follow our content guidelines. To continue publishing, please remove it or upload a different image.
YOU ARE READING
PYTHON JOURNEY BY BEGINNER
FanfictionWELCOME TO DFOCMARU'S JOURNEY Where codes become madness, brains go senseless, nights turn restless, eyes grow shineless, spines go spineless, and hands... well, they're boneless. This is Python Journey by Beginner - a chaotic diary of bugs, coffee...
