One of the many goals is to work with AI.
Hence this serves as a section that focuses on AI relating knowledge.
Phyton Resource: https://youtu.be/_uQrJ0TkZlc
Notes
int,float,bool
int() - convert strings to integer
float() - convert strings into float // float are numbers with decimals
bool() - convert string into boolean value // boolean are true.false
For writing long message with spaces in between best to use ''' '''
''' HELLO
GOOD EVENING GOOD NIGHT
BYE BYE '''
Square brackets, [ ], represent index
course = 'Phyton for Beginners'
print(course [1])
Result : h
Note that -1 , represent first character from right, -2 represent second character from right
also note that
print(course[ 0: 3])
Result : Phy
Note : t which is the 3rd character is excluded
print(course[ : ])
Result : Phyton for Beginners
Formatted strings - prefix with f
first = 'John'
last = 'Smith'
msg = f ' {first} [{last}] is a coder '
print(msg)
Result : John [Smith] is a coder
String methods
course = 'Phyton for Beginners'
print(len(course)) // len tells us the amount of characters and its a general purpose function
course. (a list of function comes out)// known as specific function
Note : "in" operators as boolean, which tell is if something exist or not in terms of true/false
Arithmatic Operations
+ addition
- subtraction
* multiplication
/ division
// division but value obtained will be integer
% remainder of division
** exponent
(any arithmatic operation) = integer // augmented assignment operator
x=10
x+=3
print(x)
Result = 13
Operator Precedence - BODMAS
Math Function
i. round // round off
x= 2.9
print(round(x))
Result : 3
ii. abs// absolute
x= 2.9
print(abs(-2.9))
Result = 2.9
iii. import math // imports all mathematical module
math. (all available math module appears)
Note : To learn more, google "Phyton 3 math module"
IF /ELSE /ELIF(otherwise) statements
Comments
Post a Comment