aqui puedo poner apuntes o cualquier texto
In [27]:
1//2
Out[27]:
In [28]:
#should equal 33.33
100//3
Out[28]:
In [6]:
#should not equal 0, but it does
59//60
Out[6]:
In [9]:
1/2
Out[9]:
In [10]:
100/3
Out[10]:
In [11]:
59/60
Out[11]:
In [29]:
25 % 5
Out[29]:
In [22]:
23 % 5
Out[22]:
In [38]:
nums = [x for x in range(0,100)]
for entry in nums:
if not entry % 5 :
print(entry)
In [23]:
5 ** 2 # or 5 squared
Out[23]:
In [26]:
nums = [0,1,2,3,4,5]
nums_squared = [element ** 2 for element in nums] # list comprehension
nums_squared
Out[26]:
ints are whole number integers like, 1, 93874, -4
In [44]:
this_is_an_int = 9
nums = [2,2,2,2,2,2,2]
type(nums)
Out[44]:
In [12]:
x = 1
if x < 100:
print('X is less than 100')
In [14]:
x = 1000
if x > 100:
print('X is greater than 100')
In [17]:
x = int(input('Please enter a number'))
if x < 0:
print('X is a negative number')
elif x == 0:
print('x is 0')
else:
print('x is a positive number')
There can be no elif and the final else is optional. Note for people with a different language background, Python doesn't have a switch or case statement
In [18]:
words = ['cat', 'dog', 'alligator', 'pirate']
for w in words:
print(w, len(w))
In [51]:
var1 = "this is sstring"
for char in var1:
print(hex(ord(char)))
In [49]:
help(ord)
In [ ]:
while True:
In [ ]: