+1(316)4441378

+44-141-628-6690

Archive for the ‘PYTHON’ Category

rigid body, cylinder

A spool of thread has rolled under the bed! Fortunately, you get the free end of the thread. The inner part of the reel where the thread is wound is a homogeneous, full cylinder of mass 3M and radius 2R. At each end there is a homogeneous cylindrical disc with mass M and radius 3R. The total mass of reels m = 5M. The moment of inertia of a homogeneous, full cylinder about its axis of symmetry is: I = 1 / 2mr ^ 2. The free end of the thread comes out from the underside of the inner cylinder, in the middle between the two outer discs. There is friction between the reel and the floor, with a static coefficient of friction = 0.25 and a dynamic coefficient of friction = 0.2.

1. Show that the maximum force at which the reel rolls without slipping is:
F <F_max = 5 / 3Mg

2. In which direction does the reel move as you pull with the force F = F_max? Do you get out of bed? Explain.

The next thing you do is to give the thread a strong bounce in the horizontal direction,

Python Grade Assignment

Your math teacher has asked you to write a program that grades the multiple-choice questions in a Math exam. The exam has 10 multiple-choice questions. Here are the correct answers:

1. A        6. B       

2.D          7.A       

3. B          8. B     

4.B          9.C       

5.C          10.D     

Your program should store the correct answers shown above in a list. It should ask the student to enter her answers for each of the 10 questions, and the answers should be stored in another list. After the students answers have been entered, the program should display a message indicating whether the student passed or failed the exam. (A student must correctly at least answer 7 of the 10 questions to pass the exam.) It should then

Beginner’s Python

Part 1:

Write code that writes the names of three of your favorite movies to a file named movies.txt.

Each movie should be on a separate line in the text file.

Use file explorer to manually open the text file in a text editor (like Notepad, Notepad++, etc.) to verify your Python code wrote three movie names, one per line.
Sample output to a file:

The Matrix
Gladiator
Top Gun

Part 2:

Write a program that asks the user for the name of a file.

The program should display only the first five lines of the files contents if the file contains five or more lines.

If the file contains less than five lines, it should display the files entire contents.

Sample input/output (5 or more lines in the file):
Enter the name of the file: pokemon.txt

Bulbasaur
Ivysaur
Venusaur
Charmander
Charmeleon

Sample input/output (less than 5 lines in the file):
Enter the name of the file: pokemon.txt

Bulbas

NY Taxi Notebook Assignment

Download and unzip the NYC taxi dataset from Cyrille Rossant on GitHub: https://github.com/ipython-books/minibook-2nd-data (Links to an external site.)
Open the notebook file attached below.  You will be adding your code (make sure you add headers and comments) to the existing code, and make sure your code is well organized.
Please upload the data and display data columns, number of rows, variable types, and numeric statistics + categorical variable frequencies.
Display a scatter plot of pick up locations.  For which vendor is it easiest to find a cab?
Display a histogram of trip distances. What is the most common trip distance?
Display a histogram of the fare total amounts. What can you say about the data?
How many unusually long trips (of greater than 100 miles) do you see?

Beginner’s Python

Part 1:
Write a program that asks the user for a secret number between one and ten. This will become the number that the player tries to "guess".

Ask the user player to guess a number between 1 and 10.

If the user's guess is higher than the secret number, the program should display "Too high. Try again."

If the user's guess is lower than the random number, the program should display "Too low. Try again."

The program should use a loop that repeats until the user correctly guesses the secret number.

Then the program should display "You Win!"

TIP: Use a while loop

Sample input/output:
Enter the secret number: 7

Guess a number between 1 and 10: 3
Too low. Try again.

Guess a number between 1 and 10: 9
Too high. Try again.

Guess a number between 1 and 10: 7
You Win!

Part 2:
Write a program that converts the common measurements below. Use functions to logically organize each conversion task below.

Python Assignment for Physics

Python code using Physics and mathematical concepts.
Need seperate answer for each question in Python code. Please also make some note throughout the code using the # to keep track of what is being coded.
Please submit answer in a way where the code can be copy pasted.
When the question states Markdown, please use markdown cells. The first question 1a for example, only asks to use Markdown and Latex to display an matrix equation, no codes are required for this specific question.

Python

Create a class called Tour.  An instance of this class is to be instantiated with two US cities, and is used to fetch information from the web.  Specifically, the class must define:

1.    __init__  The constructor takes two strings as arguments, each giving a city name and state abbreviation, indicating the origin and destination.  For example: Tour(New York, NY, Los Angeles, CA)represents a tour that starts in New York city and ends in Los Angeles.
2.    distance  This method takes a single (optional) argument indicating a mode one of the strings driving (default), biking, or walking.  It returns the total distance (in meters) covered by the tour for the indicated mode.  This method is where you will use urllib functions to get data from the web to find the distances between two locations in the tour and calculate the total distance.  If a response does not contain a distance value, the method should rais

Create the game Columns using Python

This project is focused on implementing the mechanics of Columns, along with a program that you can run in the Python shell with a very spartan user interface that you'll use to test it.
There are features that must be completed.

Assignment Instructions found here:
https://www.ics.uci.edu/~thornton/ics32/ProjectGuide/Project4/

Foreign Exchange Option

We will use the Garman-Kohlhagan model (Links to an external site.) to price our options in this assignment. We will write a function that takes the option contract parameters (type--call or put, strike price, and expiration date) as well as market observations (spot exchange rate, volatility, and interest rates in both the domestic and foreign currencies) and returns the fair market value of the option contract.

The work will be decomposed into several functions and the pricing function will use these lower-level functions to calculate its result. The functions you will write are:

fx_option_price(call, strike, expiration, spot_date, spot, volatility, domestic_rate, foreign_rate)
fx_option_d2(term, volatility, d1)
fx_option_d1(strike, term, spot, volatility, domestic_rate, foreign_rate)
discount(rate, term)
years_apart(date1, date2)

python programming

The included Excel file lists HIV estimated prevalence of people ages from 15 to 49 in the world from 1979 to 2011. Use the dataset to complete following tasks:

Add one column as continent in the dataset and label each country/regionin the dataset to an appropriate continent such as Europe, Asia, Africa, North America, South America, Australia, or Antarctica. Explain how do you validate the correctness of your labelling. Output the updated dataset as a new CSV file. (1 point). (Note: You must write a Python program to complete the labelling, manully labelling wont get any credit).
Write a Python program to find the country/region in each continent thathas the highest average HIV estimated prevalence of people ages from 15 to 49 of from year 2000 to 2011. Find the country/region in each continent that has the lowest average HIV estimated prevalence of people ages from 15 to 49 of from year 2000 to 2011. Create a bar chart to show the highest average HIV estimated prevalence of