we've already used built in functions such as print(), len(), int() ...however we can make our own funcitons too.
#Defining Functions
def my_function():
print("Bye") #do this
#Calling Functions
my_function()
tab over space
python recommend using space..!
for loop is definite repeatition with list, range
while loop continue repeating as long as a condition is true
-> can be dangerous as it can fall into infinite loop
while something_is_ture
do this
This mini robot reminds me of 2016 robot event parttime job. I had no idea that I would be into programming back then.
It took nearly an hour to solve this task.
Even though I approached it with logic flow chart.
Difference btw my code and angela's code is,
she wrote the while loop inside jump() so it can be repeated only when the code reaches jump().
It keeps the code much more readable and simple!!
#<mycode>
def turn_right():
turn_left()
turn_left()
turn_left()
def jump():
turn_right()
move()
turn_right()
move()
while not at_goal():
while wall_on_right() and wall_in_front:
if wall_in_front():
turn_left()
elif wall_on_right:
if at_goal():
done()
else:
move()
jump()
#<angela's code>
def turn_right():
turn_left()
turn_left()
turn_left()
def jump():
turn_left()
while wall_on_right():
move()
turn_right()
move()
turn_right()
while front_is_clear():
move()
turn_left()
while not at_goal():
if wall_in_front():
jump()
else:
move()
Algorithm: following the right edge of the wall.
def turn_right():
turn_left()
turn_left()
turn_left()
#<mycode>
while not at_goal():
if wall_on_right():
if wall_in_front():
turn_left()
elif front_is_clear():
move()
else:
turn_right()
move()
#<angela's code>
while not at_goal():
if right_is_clear():
turn_right()
move()
elif front_is_clear():
move()
else:
turn_left()
Ben had always enjoyed the occasional game of blackjack but never considered himself a high roller. His usual playstyle was cautious https://speedaupokies1.com/ and reserved, sticking to modest bets and steady gameplay. One evening, feeling a bit adventurous, he decided to explore a new blackjack site that boasted a high-stakes table with impressive jackpots. Despite his usual preference for low-risk play, Ben felt a sudden urge to test his luck on this new platform.