This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head><title>cashRegister</title></head> | |
<body> | |
<script type="text/javascript"> | |
function StaffMember(name,discountPercent){ | |
this.name = name; | |
this.discountPercent = discountPercent; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head><title>Blackjack</title></head> | |
<body> | |
<script type="text/javascript"> | |
document.write ("This is Balckjack game.</br>"); | |
document.write ("The points are as follow:</br>"); | |
document.write ("Ace(1) = 11.</br>"); | |
document.write ("King(12), Queen(11) and Prince(10) = 10.</br>"); | |
document.write ("The rest by their own number values.</br></br>"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head><title>Address Book</title></head> | |
<body> | |
<script type="text/javascript"> | |
var contacts = []; | |
function printPerson (person) { | |
document.write("First Name is: " + person.firstName) | |
document.write("</br>Last Name is: " + person.lastName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tml> | |
<head><title>Roll the Dice</title></head> | |
<body> | |
<script type="text/javascript"> | |
var die1 = Math.floor(Math.random()*6 + 1); | |
var die2 = Math.floor(Math.random()*6 + 1); | |
var score; | |
// This time if either die roll is 1 then score should be 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head><title>FizzBuzz</title></head> | |
<body> | |
<script type="text/javascript"> | |
document.write ("Counting 1 to 100, when ever number devide in 3 it is fuzz, when number devide in 5 it is buzz and both are fizzbuzz... "); | |
document.write (" "); | |
for (i=1; i<=100; i++) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head><title>simple page</title></head> | |
<body> | |
<h1 id="header">This is JavaScript</h1> | |
<script type="text/javascript"> | |
document.write('Hello World!'); | |
var h1 = document.getElementById("header"); // holds a reference to the <h1> tag | |
h1 = document.getElementsByTagName("h1")[0]; // accessing the same <h1> element | |
</script> | |
<noscript> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extract_names(filename): | |
""" | |
Given a file name for baby.html, returns a list starting with the year string | |
followed by the name-rank strings in alphabetical order. | |
['2006', 'Aaliyah 91', Aaron 57', 'Abagail 895', ' ...] | |
""" | |
# +++your code here+++ | |
# LAB(begin solution) | |
# The list [year, name_and_rank, name_and_rank, ...] we'll eventually return. | |
names = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_year (filename): | |
file1 = open (filename, 'rU') | |
match = re.findall (r'>Popularity in ([\d]+)<', file1.read()) | |
file1.close() | |
return match | |
def find_name_and_rank (filename): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def calculate_data (line_data): | |
# Got a sring and creates dictionary of (word : count) | |
dict = {} | |
for word in line_data: | |
if word in dict: | |
dict[word] += 1 | |
else: | |
dict[word] = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define print_words(filename) and print_top(filename) functions. | |
# You could write a helper utility function that reads a file | |
# and builds and returns a word/count dict for it. | |
# Then print_words() and print_top() can just call the utility function. | |
1. For the --count flag, implement a print_words(filename) function that counts | |
how often each word appears in the text and prints: | |
word1 count1 | |
word2 count2 | |
... |
NewerOlder