1.Taking a Vacation Lab
First I define a function called hotel_cost. nights is it’s 1 argument. then i return 140 * nights to hotel_cost.
In this part i have print
out the trip_cost(
to "Los Angeles"
for 5
days with an extra 600
dollars of spending money.
2.TURTLE LAB
This lab was a turtle lab. You have to make the turtle move multiple places. The turtle is white and the background is red.
import turtle
import random
window = turtle.Screen()
window.bgcolor(“Red”)
Hall = turtle.Turtle()
Hall.pencolor(“white”)
for x in range (100):
Hall.right(random.randint(0,45))
distance = random.randint(0,150)
Hall.forward(distance)
Hall.backward(distance)
3.Pig Latin
In this part, i use the raw_input("Enter aword:")
to ask the user to enter a word.
In this part i add the if staement to check that len(original) > 0.Then i put an else statement and print empty.
i use and to add a second condition and use .isalpha()
- I created variable
s
and give it the string"Charlie"
- Next I access the first letter of
"Charlie"
usings[0]
. - Then I access a slice of
"Charlie"
usings[1:4]
. This returns everything from the letter at position 1 up till position 4.
4.Fermat’s Last Theorem
Write a function that prompts the user to input values for a, b, c and n, converts them to integers, and uses check_fermat to check whether they violate Fermat’s theorem.
5.Date & Time
In this lab I’m adjusting the time
In this part I get the current date and time.
In this part I use a new variable called print
out now
Then, print
out now month and print
out now day.
In this part i put the / between the & placeholders
6. Battle-Ship Lab
In this lab, I learned how to battle another battleship
For this lab I have to set up 1 variable (board) , use multiple list, lf statements and more
I first set up a variable called board. Then I set the range so I can loop .append() times to the board.
Then I defined print_board(board)
Then i play the real game and start with
def random_row(board):
return randint(0, len(board) – 1)
def random_col(board):
return randint(0, len(board[0]) – 1)
7. LAB: ADVANCED TOPICS IN PYTHON
In this part, I Call the appropriate method on movies
such that it will print
out all the items (hint, hint) in the dictionary—that is, each key and each value.
In this part I