Data Types, Evaluations, and Basic I/O Flashcards
section 2
assignment priorities
mdascnao
**, *, /, //, %, +, -, ==, !=, <= , >=, <, >, not, and, or
Bit wise operations
~, &, ^, |, «,»_space;
x~ - returrns complement of x
x & y - ‘bitwise and’
x^y - ‘bitwise exclusive or’
x|y - ‘bitwise or’
x «_space;y - moves x bit to the right by y places
x»_space; y - moves x bit to the left by y places
Accuracy of floating point numbers
floating point numbers have between 6 & 7 digits of precision
input()
recieves user input
sep=
used in print() function to disable softspace feature (‘’). You can use it to add characteres between outputs.
e.g
print(‘G’, ‘F’, ‘G’, sep=’’) => GFG
print(‘09’, ‘12’, ‘2023’, sep=’-‘) => 09-12-2023
end=
end the output with a space
e.g
print(“ How are”, end = “”)
print(“ you ?”, end = “”)
=> How are you?
Type castings
convert a python datatype to another type
String slicing
var = “DAMILOLA”
var[2:5] = “MILO”
var[:5] = “DAMILO”
var[5:] = “OLA”
how can i print out quoutes
The backslashes protect the quotes, but are not printed.