My EMT 1111 Labs

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.

TV1

In this part i have print out the trip_cost( to "Los Angeles" for days with an extra 600 dollars of spending money.

TV2 TV3

 

 

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.

Capture

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.

A1

A2

In this part i add the if staement to check that len(original) > 0.Then i put an else statement and print empty.

PL4

i use and to add a second condition and use .isalpha()

PL5 PL6 PL8

  1. I created variable s and give it the string "Charlie"
  2. Next I access the first letter of "Charlie" using s[0].
  3. Then I access a slice of"Charlie" using s[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.

Capture33

5.Date & Time

In this lab I’m adjusting the time

B

In this part I get the current date and time.

B1

In this part I use a new variable called print out now

Then, print out now month and print out now day.

B1

In this part i put the / between the & placeholders

B1


6. Battle-Ship Lab

Capture14 Capture15

 

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

C1

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

Capture40

Capture41

Capture42