LABS


LAB 1: TIP CALCULATOR

TIP CALCULATOR PT 1
IN this section we were asked to present a variable and set it equal to the amount of 44.50

 

TIP CALCULATOR PT 4
Here we were asked to perform some operations within the values presented

 

TIP CALCULATOR PT 5
Lastly we were asked to assign a total amount of the meal, tip and taxes for the overall cost of the meal

 

LAB 2: PLANNING A VACATION

TAKING VACATION PT 1
Here i was asked to review the previous work by setting a function and defining it as 42
TAKING VACATION PT 2
Here we were asked to define a function with a specific return
TAKING VACATION PT 3
here were were asked to set a function along with sub statements as cities and its price
TAKING VACATION PT 4
Here i was asked to set a ticket price for a set of days given along with price
TAKING VACATION PT 5
In this section i inputed the statement to calculated the sum of all of the trips cost
TAKING VACATION PT 6
Here i added spending cost as an argument to the function also adding it in the sum totaling.
TAKING VACATION PT 7
finally i added 600 to to 5 days as a precaution to the vacation total

 

LAB # 3 TURTLE GRAPHICS

Today we were introduced how to draw pictures using Turtle Graphics. We learned some basic turtle control functions and how to import them into our Python programs.We created a program that moves an arrow different directions but all based on the commands and angles  given it. The turtle is imaginative in much ways imagine holding a pencil over a blank paper and having someone telling you what to draw. Its the same concept except the directions are in code imported from the turtle module.

Here is the code for the turtle blast:

code

Results of the code once i ran it:

results of code

LAB # 5: Fruitful functions Fermat’s Last Theorem 

The objective of this lab was to test a famous mathematicians formula in python. The formula is named Fermat’s Last Theorem . It states that no three positive integers ab, and c can satisfy the equation an + bn = cn for any integer value of n greater than two. The cases n = 1 and n = 2 were known to have infinitely many solutions. If

The objective was to give the user of the interface an option to choose the values of A, B,C, and N. The program would than return a statement based on the users input. If N is chosen to be any number other than 1 the user will get a return of “No, that doesn’t work” if 1 is chosen it will display “Fermat was Wrong”.

fermat code

Here is the code and once ran will execute with no errors in python 3.4.

LAB # 6: DATE and TIME

Date and time is an exercise in code academy. The point of the project is to be able to tell python to return values of the date and time of the day or any specific value in specific formats. for example, python can be directed to return the date in the form of mm/dd/yy or in form of  dd/mm/yy which ever is desired. The equivalent can also be done with the time in hr/min/sec or vice versa. The str() and %s were used also merging them together.

 

Date and time 1

 

Date and time 3

Date and time 4

Date and time 5

Date and time 6

LAB # 7: BATTLESHIP

Description:

Battleship is a classic digital game. The purpose/goal is a one-player version of the classic board game Battleship! In this version of the game, there will be a single ship hidden in a random location on a 5×5 grid. The player will have 10 guesses to try to sink the ship. To build this game we will use our knowledge of lists, conditionals and functions in Python. When you’re ready to get started, click run to continue.

These are the pictures of the final code of the entire game completed.

battleship 1

battleship 2

battleship 3

LAB # 8: A DAY IN THE SUPERMARKET

The purpose of this lab is  to integrate all that we’ve learned thus far into a program for going to the supermarket. This code will consist of for, while, if elif and more functions as such. It also enforces strings and the slicing and addition. Further more its teaches about using the function dict to define words in a list, add new words to that list, remove words without editing the original list. from the. append, .remove and such we can add and edit the original list.

here are the images of the 13 steps into making the full code.

A day in the supermarket1A day in the supermarket2A day in the supermarket3A day in the supermarket4A day in the supermarket5A day in the supermarket6A day in the supermarket7A day in the supermarket8A day in the supermarket9A day in the supermarket10A day in the supermarket11A day in the supermarket12A day in the supermarket13

 

LAB # 9: REVIEW OF ADVANCED TOPICS IN PYTHON:

This week we focused on a new method of creating lists many called lambda, a built in python function which makes it easier to create lists without a return value. lambdas are useful when you need a quick function to do some work for you.If you plan on creating a function you’ll use over and over, you’re better off using def and giving that function a name. In addition we also learned further on list slicing, omitting indices lists and  reverse a list with the (-) function.

***HERE ARE THE IMAGES OF THE REVIEW SUMMARY

review pt 1

review pt 2 review pt 3 review pt 4

review pt 2

review pt 3

review pt 4

LAB # 10: PYGLATN

In this lab we took over what we learned from the previous exercise  in CONDITIONALS & CONTROL FLOW which includes string manipulation and branching and applied it to making Pig Latin translator for programmers.

FOLLOWING ARE THE SCRENSHOOTS OF THE CODE FROM 1-11.

Pyg1

Pyg2

Pyg3

Pyg4

Pyg5

Pyg6

Pyg7

Pyg8

Pyg9

Pyg10

Pyg11

Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning. -Albert Einstein