EMT 1111 D318

CREATING A TURTLE GRAPHIC 

Instructions: Change the color of the window to “red” using wn.bgcolor property of the screen variable you create. Your turtle variable has to have a pen color “white”, you have to use the .pencolor property of your turtle variable. You have to make your turtle to change its heading to the right with an random angle between 0 and 45 degrees. Move your turtle forward a random distance between 0 and 150 pixels. Then move the turtle backward the same distance than above Repeat the last three steps 100 times

Instructions:
Change the color of the window to “red” using wn.bgcolor property of the screen variable you create.
Your turtle variable has to have a pen color “white”, you have to use the .pencolor property of your turtle variable.
You have to make your turtle to change its heading to the right with an random angle between 0 and 45 degrees.
Move your turtle forward a random distance between 0 and 150 pixels.
Then move the turtle backward the same distance than above
Repeat the last three steps 100 times

Creating this graph using python was a hard and confusing assignment at the beginning but after i got along with the code it was easier to keep on. its interesting how does an small error can stop the application from moving forward with the graph.

________________________________________________________________________________________________________

—————————————————————————————————————————–

PygLatin 
234567891011

Pig Latin translator.

Pig Latin is a language game, where you move the first letter of the word to the end and add “ay.” So “horse” becomes “orsehay.”

As it is shown in the picture its was a challenging program to create because everything to be in a place if something is place in the wrong string the game would not work, also it is very interesting to see how the program is develop and its getting to do the things that i wanted it to do

________________________________________________________________________________________________________

—————————————————————————————————————————–

Fruitful functions

raw

Fermat’s Last Theorem states that no three positive integers a, b, and c can satisfy the equation an + bn = cn for any integer value of n greater than two.

First problem.

1. Write a function named check_fermat that takes four parameters—a, b, c and n and that checks to see if Fermat’s theorem holds. If n is greater than 2 and it turns out to be true that an + bn = cn the program should print, “Fermat was right!” Otherwise the program should print, “No, that doesn’t work.”

2. 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.

Second problem.

In addition to the first problem, your code should let user make input and therefore to produce result.

Hint: use the built-in function <<raw_input>> and make the user input always be an integer.

its was hard to get the program to only accept integers but its is interesting simple it is. its not hard to create fruitful functions, and they are very useful to create this fruitful function i had to import math and plug in different type of strings to make the function better to make it more accurate. after that it was amazing to see how the function solve the equation and gave and answer.

________________________________________________________________________________________________________

—————————————————————————————————————————–

Code Academy- Date and Time

1 2 3 4 5 6

date and time with python

in this assignment i learned how to ask python for date and time

using date.time to import the actual time and date to python i just added now. at the beginning of date or time to get the answer. for example if i wanted to know the date in mm/day/year form i would type now.month/ now.day/ now.year and python would give me the answer.

it also print the actual time if its ask to do so.

________________________________________________________________________________________________________

Day at the supermarket

 
1234

 

5678

910111213

using dictionary to calculate and label prices, its interesting hoe we can use the dict function to do multiple thing, in this lab we use the dict function to calculate how much money would be spend if we buy thing from the supper market, we label the prices and hoe much product was in stock.

________________________________________________________________________________________________________

Advanced topics in Python – Review

review-1 review-2 review-3review-4

 

Review the dictionary function which helps to create a list of keys and add values to those keys, also using comprehension list to take different values from a range, comprehension list helps to get some values from a set of numbers in a range and we can decide which numbers we need by selecting characteristic of that number we can choose from numbers that dive it self by 2 and equal to 0 to get even numbers. filter function helps to clear a secret message or just getting what you want from a text,