Lab Activity 1: Implement the Weibull Distribution in Java
The Weibull functions are functions not only of wind speed x, but also of their parameters and . Given an input x, we need to calculate the probability density f,(x) and its integral F,(x). Each f
Wind Farm Investment Project
"Windy Profits Incorporated" is offering investors a chance to purchase shares of the output from several proposed wind turbine farms. Three turbines will be placed at one of three locations for a total of nine turbines. Locat
Jave Programming
Exercise 1
Lab 1
a. Open the following program in JCreator. The file Exercise1.java has been sent to you by email and is also posted on WebCT under Week1. Once it is open in JCreator, save it in the active workspace where you are allowed
Java Midterm for ECE 203
Part A: General Understanding
1. The Java Virtual Machine translates byte-code into: a. source code b. virtual code
First .
c. machine language code
Last .
d. ordinary English sentences.
2. The Java source code for a class should
Syllabus
ECE-203: Section 701 Fall 2007 Textbook: The textbook for the course is: Title: Big Java, 3rd edition Author: Cay S. Horstmann Publisher: Wiley ISBN: 978-0470-112090 In addition, you will also need to visit several online references Grading Schem
_author_ = 'robincarr'
print 'WORD SEARCH'
# Python module os provides utilities for displaying and modifying your current
working directory.
import os
print 'The currect working directory is: ', os.getcwd() # Current Work
Directory
# Read in all the word
_author_ = 'robincarr'
print "Educational Goal: Learn how to process python strings using 'string
slicing'."
print 'Slice up each compound word, into its component words.'
# Good references:
# http:/vocablog-plc.blogspot.com/p/compounds.html
# http:/www.e
_author_ = 'robincarr'
# Just run this example from the online reading.
# See: http:/www.python-course.eu/tkinter_message_widget.php
from Tkinter import *
master = Tk()
whatever_you_do = "Whatever you do will be insignificant, but it is very
important tha
_author_ = 'robincarr'
"
Calculate Fibonacci numbers using the formula of Binet.
See this reference for more information on the formula.
http:/www.cut-the-knot.org/proofs/BinetFormula.shtml
"
import math
# First define the Golden Ratio, often represented
_author_ = 'robincarr'
# Creates a table of numbers with N first in base 10, and then in base 2, and
16.
# Add base 8 (octal) to the table.
# Add another format flag for the octal numbers, and add a title for the octal
column.
print '%16s%20s%20s%20s' % (
# coding=utf-8
_author_ = 'robincarr'
import math
print 'SOLVING SSS TRIANGLES'
print 'Known: The sides a, b and c of the triangle are known.'
print 'Goal: Find the angles A, B and C of the triangle.'
print 'Side a is the side opposite angle A, side b is
import math
print
print
print
years
"Greetings Earthlings. We are visitors from the Andromeda galaxy."
"Your sun is about to expand and your planet is at risk of incineration."
"We will help you build a new Hollow Earth so you can live a few million
longe
_author_ = 'robincarr'
print 'COIN CHANGE MAKER'
print 'Computes your coin change (0-99 cents) in quarters, dimes, nickels and
pennies using the least number of coins.'
print 'Enter "change due" as an integer in the range 0-99.'
# A while loop can be used
_author_ = 'robincarr'
import time
# 1. New and improved memoized version.
known = cfw_0:0, 1:1
def fibonacci(n):
if n in known:
return known[n]
res = fibonacci(n-1) + fibonacci(n-2)
known[n] = res
return res
# 2. Here is the old recursive version of the
_author_ = 'robincarr'
# Method to invert a dictionary. (from page 105)
def invert_dict(d):
inverse = dict()
for key in d:
val = d[key]
if val not in inverse:
inverse[val] = [key] # Creates a list with one element. Note the [].
else:
inverse[val].append(k
print "Find the number of Platonic Solids."
print "Each Platonic Solid corresponds to a unique Schlafli Symbol cfw_p,q,"
print "where p and q are >= 3 and satisfy: 1/p + 1/q > 1/2\n"
platonic_dict = cfw_"tetrahedron": (3,3), "cube": (4,3),
"dodecahedron":
from Tkinter import *
# Now Modified TO HANDLE THREE RESISTORS
_author_ = "robincarr"
_date_ = "$Apr 24, 2015 12:47:13 PM$"
" GUI version of Resistor Calculator finds the equivalent resistance for two
resistors
connected either in series or parallel. Feat
_author_ = 'robincarr'
"
Adapted from this source: http:/www.python-course.eu/tkinter_labels.php
"
# See this reference for how the pack() command works:
# http:/effbot.org/tkinterbook/pack.htm
# Live! Use the Photo Image Library.
# 1. Import the Tkinter
_author_ = 'robincarr'
" Adapted from the "Saying Hello with Labels" example on this website:
http:/www.python-course.eu/tkinter_labels.php
Instead of printing "Hello" we'll display this poem. (First stanza of "The
Tyger" by William Blake.)
Tyger Tyger, b
_author_ = 'robincarr'
# explore Tkinter button as a toggle and as a control to cycle through a range
of values.
from Tkinter import *
root = Tk()
# root.title("Click the Button") # Change the title to "Colors of the Rainbow"
root.title("Colors of the Rai
_author_ = 'robincarr'
from Tkinter import *
from tkFileDialog
import askopenfilename
root = Tk()
root.title("Search a file for a given word")
word_list = []
# List of all the lines in the file. Empty for now.
# These methods or callbacks will perform the
"
Completed program to check if two phrases are anagrams, using dictionaries.
"
def histogram(s):
d = dict()
for c in s:
if c not in d:
d[c] = 1
else:
d[c] += 1
return d
def cleanup(s):
result = '
for c in s:
c = c.lower()
if c.isalpha():
result += c
retu
_author_ = 'robincarr'
#
#
#
#
Consider this recursive version of the Fibonacci number sequence.
Initialize count0 and count1 here.
Note: The solutions also implement count2 and count3. (Not asked for.)
The solutions also now show all calls, and count the
_author_ = 'robincarr'
def histogram(tally_this):
count = dict() # Empty dictionary of counts
for item in tally_this:
count[item] = count.get(item, 0) + 1
return count
print 'The following animals have been rescued from a ferocious forest fire.'
rescued_a
_author_ = 'robincarr'
# These further details were NOT part of the assigned homework, but should be
studied before the midterm.
# Uses a dictionary to count *ALL* calls made with the recursive Fibonacci
number method.
count_all_calls = dict() # Empty dic
import time
import math
# Demo code at the beginning is now commented out.
"
def procedure_to_sleep():
time.sleep(2.5) # Sleeps for 2.5 seconds and does nothing else.
# Measure process time
print '1. First we measure the PROCESS time for a procedure which
import math
print "Volume and Surface Area of a Pill Capsule with Hemispherical Ends"
print "\n1. Enter the length L (in cm) from one end to the other of the pill
capsule."
L = float( raw_input("Length: ") )
print "\n2. Enter the diameter D in centimeters
def histogram(tally_this):
count = dict() # Empty dictionary of counts
for item in tally_this:
count[item] = count.get(item, 0) + 1
return count
def invert_dict(d):
inverse = dict()
for key in d:
val = d[key]
if val not in inverse:
inverse[val] = [key]
el
Lecture 5
Midterm covers chapters 1, 2, 3 and 4 and parts of 5 in the text. Review all self-test questions in chapters 1, 2, 3 and 4 Review all of the lecture notes 1 though 5. Important Classes: Point, Complex, Math, String, Random, Scanner Method Invoca
Lecture 7: Introduction to Arrays
Review: Here again is our example from week 5 where a die was shaken multiple times. We shall redo this example at the end of this lecture using arrays. (See chapter 6 in Savitch).
Example 1: Use of the switch statement.
_author_ = 'robincarr'
print 'Simple Resistor Calculator'
print 'Finds the equivalent resistance of two resistors connected in series or
parallel.\n'
print 'Enter the value of resistor #1 in Ohms.'
# Convert to float to avoid a possible integer division e
# See also The Picnic Question in the first reading quiz.
# Wine, bread, cheese, grapes and a picnic basket are purchased for a weekend
picnic.
"
Item
Number Price Each
Tax in %
Wine bottle
2
$18.00
30 %
Loaf of French bread
3
$2.75
0 %
Cheese (cheddar, b
from Tkinter import *
_author_ = "robincarr"
" GUI version of Resistor Calculator finds the equivalent resistance for two
resistors
connected either in series or parallel. Features entry widgets and buttons."
def series_calculation():
r1 = float(e1.get()
import random # Import the random module
random.seed(2016)
winning_number = random.randint(1,256)
# This next line is for debugging only. It must be commented out before you play
the game!
print 'The winning number is 0' % winning_number
print "Apple Watc