3.1-3.2 notes
value1 = 5
value2 = value1 / 10 #step 1
value3 = value2 * 2 #step 2
value4 = value3 - 4 #step 3
print(value4)
numlist = ["3","4","9","76","891"]
for x in numlist:
if int(x) % 3 == 0:
print(str(x) + " is divisible by 3 :) ")
continue
else:
print(str(x) + " is not divisible by 3 :(")
continue
def convert(number):
binary = ""
i = 7
while i >= 0:
if number % (2**i) == number:
binary = binary + "0"
i -= 1
else:
binary = binary + "1"
number -= 2**i
i -= 1
print(binary)
print("Here is your number in binary!")
convert(47)
Psuedocode
Pseudocode is writing out a program in plain language with keywords that are used to refer to common coding concepts.
Can be thought of with ordinary things you do: Brushing your teeth:
- Pick up your toothbrush
- Rinse toothbrush
- Pick up toothpaste
- Place toothpaste on the toothbrush
- Rinse toothbrush again
- Brush teeth in a circular motion
- Spit
- Wash mouth
- Rinse toothbrush
- You have brushed your teeth!
#the substring will have the characters including the index "start" to the character BEFORE the index "end"
#len(string) will print the length of string
(string) = "hellobye"
print(string[0:5])
print(string[5:8])
print(string[0:8])
len(string)
string1 = "butter"
string2 = "fly"
string3 = string1 + string2
print(string3)
names = ["cat","dog","racoon","rabbit"]
def length(names):
for x in names:
print(x, len(str(x)))
length(names)