Dear all of my followers
Thank you for viewing my blog absence,
also Sahil sucks
Sincerely
Jacob
Monday, 25 August 2014
Monday, 5 May 2014
Lists
Multiple variables can be initialized with a common value in a single statement. a=b=c=10
Multiple variables can be initialized with differing values in a single statement. a,b,c = 1,2,3
A python list is a variable that can store multiple items of data that are indexed starting at zero.
Nums = [0,1,2,3,4,5]
Lists can have multiple dimensions
[0] [1] [2]
[0] 1 2 3
[1] 4 5 6
Example 1
quarter = ['January', 'February', 'March']
print("The first month is", quarter[0])
Example 2
coords = [[1,2,3],[4,5,6]]
print("Top left is".....
print("Bottom right is".....
Multiple variables can be initialized with a common value in a single statement. a=b=c=10
Multiple variables can be initialized with differing values in a single statement. a,b,c = 1,2,3
A python list is a variable that can store multiple items of data that are indexed starting at zero.
Nums = [0,1,2,3,4,5]
Lists can have multiple dimensions
[0] [1] [2]
[0] 1 2 3
[1] 4 5 6
Example 1
quarter = ['January', 'February', 'March']
print("The first month is", quarter[0])
Example 2
coords = [[1,2,3],[4,5,6]]
print("Top left is".....
print("Bottom right is".....
Friday, 21 March 2014
Sahil's question finished
def main():
tip=0
tipcount=0
price=int(input("How much was your meal?"))
if price > 200:
tip = 0.11 * price
elif price > 99 and price < 199:
tip = 0.10 * price
elif price > 49 and price < 100:
tip = 0.08 * price
elif price < 50:
tip = 0.065 * price
tipprice = tip * price
print("Your tip is", tip)
print("Pay up!!")
tip=0
tipcount=0
price=int(input("How much was your meal?"))
if price > 200:
tip = 0.11 * price
elif price > 99 and price < 199:
tip = 0.10 * price
elif price > 49 and price < 100:
tip = 0.08 * price
elif price < 50:
tip = 0.065 * price
tipprice = tip * price
print("Your tip is", tip)
print("Pay up!!")
Thursday, 20 March 2014
Abi's code finished
def main():
best=0
worst=100
total=0
count=1
while count<4:
swimtime=int(input("How fast is your swim time?"))
if swimtime>best:
best=swimtime
elif swimtime<worst:
worst=swimtime
total=total+swimtime
print(best, worst)
count=count+1
print(best, worst)
print("The average is ",total/count)
best=0
worst=100
total=0
count=1
while count<4:
swimtime=int(input("How fast is your swim time?"))
if swimtime>best:
best=swimtime
elif swimtime<worst:
worst=swimtime
total=total+swimtime
print(best, worst)
count=count+1
print(best, worst)
print("The average is ",total/count)
My question
Write an algorithm in
the form of a flowchart that:
·
Inputs the top speeds of a number of cars
·
Outputs the fastest top speed and the slowest
top speed of the cars entered
·
Outputs the average speed of all the top speeds
entered
Program
it in python
Monday, 3 March 2014
Logic Gates in Python
def AndGate():
print("Welcome to the And gate simulator")
a = int(input("Please enter 1 or 0"))
b = int(input("Please enter 1 or 0"))
if a==1 and b==1:
c=1
elif a==1 and b==0:
c=0
elif a==0 and b==1:
c=0
elif a==0 and b==0:
c=0
print(c)
def OrGate():
print("Welcome to the Or gate simulator")
a = int(input("Please enter 1 or 0"))
b = int(input("Please enter 1 or 0"))
if a==1 and b==1:
c=1
if a==1 and b==0:
c=1
if a==0 and b==1:
c=1
if a==0 and b==0:
c=0
print(c)
def NotGate():
print("Welcome to the Not gate simulator")
a = int(input("Please enter 1 or 0"))
if a==1:
c=0
if a==0:
c=1
print(c)
def NandGate():
print("Welcome to the Nand gate simulator")
a = int(input("Please enter 1 or 0"))
b = int(input("Please enter 1 or 0"))
if a==1 and b==1:
c=0
elif a==1 and b==0:
c=1
elif a==0 and b==1:
c=1
elif a==0 and b==0:
c=1
print(c)
def NorGate():
print("Welcome to Nor gate simulator")
a = int(input("Please enter 1 or 0"))
b = int(input("Please enter 1 or 0"))
if a==1 and b==1:
c=0
if a==1 and b==0:
c=0
if a==0 and b==1:
c=0
if a==0 and b==0:
c=1
print(c)
def XorGate():
print("Welcome to Xor gate simulator")
a = int(input("Please enter 1 or 0"))
b = int(input("Please enter 1 or 0"))
if a==1 and b==1:
c=0
elif a==1 and b==0:
c=1
elif a==0 and b==1:
c=1
elif a==0 and b==0:
c=0
print(c)
print("Welcome to the And gate simulator")
a = int(input("Please enter 1 or 0"))
b = int(input("Please enter 1 or 0"))
if a==1 and b==1:
c=1
elif a==1 and b==0:
c=0
elif a==0 and b==1:
c=0
elif a==0 and b==0:
c=0
print(c)
def OrGate():
print("Welcome to the Or gate simulator")
a = int(input("Please enter 1 or 0"))
b = int(input("Please enter 1 or 0"))
if a==1 and b==1:
c=1
if a==1 and b==0:
c=1
if a==0 and b==1:
c=1
if a==0 and b==0:
c=0
print(c)
def NotGate():
print("Welcome to the Not gate simulator")
a = int(input("Please enter 1 or 0"))
if a==1:
c=0
if a==0:
c=1
print(c)
def NandGate():
print("Welcome to the Nand gate simulator")
a = int(input("Please enter 1 or 0"))
b = int(input("Please enter 1 or 0"))
if a==1 and b==1:
c=0
elif a==1 and b==0:
c=1
elif a==0 and b==1:
c=1
elif a==0 and b==0:
c=1
print(c)
def NorGate():
print("Welcome to Nor gate simulator")
a = int(input("Please enter 1 or 0"))
b = int(input("Please enter 1 or 0"))
if a==1 and b==1:
c=0
if a==1 and b==0:
c=0
if a==0 and b==1:
c=0
if a==0 and b==0:
c=1
print(c)
def XorGate():
print("Welcome to Xor gate simulator")
a = int(input("Please enter 1 or 0"))
b = int(input("Please enter 1 or 0"))
if a==1 and b==1:
c=0
elif a==1 and b==0:
c=1
elif a==0 and b==1:
c=1
elif a==0 and b==0:
c=0
print(c)
Friday, 21 February 2014
Interrupts
What can interrupt a program?
A power failure can interrupt a program. A hardware malfunction can interrupt a program. A software interrupt can interrupt a program. A timer interrupt can interrupt a program.
A power failure can interrupt a program. A hardware malfunction can interrupt a program. A software interrupt can interrupt a program. A timer interrupt can interrupt a program.
Power failure is the highest priority and most serious of the interrupts. The hardware malfunction is also a serious interrupt. Software interrupts can be caused by any of the following: Division by zero, under or overflow detection and incorrect program calls. The system clock can interrupt operations at regular intervals. The last interrupt can be activated by pressing "Control, Alt and Delete" All at the same time, and the priority level for this interrupt is very low.
Subscribe to:
Posts (Atom)