![]() ![]() |
| |||||||||
| This page removed for FERPA compliance | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
We will be reading your answers. Here are the ground rules for the interaction.
- If you don't post, neither will we. We will not be posting official solutions to these problems at all! If one of you gets it right, terrific!
- We will try to always point out if an answer is wrong and confirm it when its right.
- We are glad to work with you toward the right answer. We can give hints, and we're glad to respond to partial guesses.
- 80% of the TA's are not robots so it may take a while to get a response. Please be patient. Especially if you post in the wee hours of the morning.
1. What does HTML stand for?
2. What is HTML validation and why is it necessary?
3. Match the following HTML tags to its function:
1. <html> | a) Enables you to write Javascripts |
2. <a href> | b) Puts an image on your page |
3. <img> | c) Used to specify a title for your webpage |
4. <head> | d) Makes a table on your webpage |
5. <title> | e) Specifies a link to another page |
6. <p> | f) The heading is enclosed within these tags |
7. <script> | g) Makes a row for your table |
8. <table> | h) The entire document is enclosed within these tags |
9. <tr> | i) Identifies a paragraph of text |
Write out what each of these programs will return.
def change1():
source = "Georgia Institute of Technology"
vowels = "aeiou"
source = source.lower()
for i in vowels:
loc = source.find(i)
if loc <> -1:
source = source[:loc] + source[loc + 1:]
return source
def change2():
source = "Georgia Institute of Technology"
vowels = "aeiou"
source=source.lower()
for i in vowels:
loc = source.find(i)
while loc <> -1:
source = source[:loc] + source[loc + 1:]
loc = source.find(i)
return source
If you don't know what a while loop is, it basically works the same way as an if statement. If the logical statement after the word while is true, then the code below it will run. The only difference is once it's done with the indented code, it'll go back to the while statement and check to see if it's true again. If it is, then it'll do it again. So whenever you see a while statement, think "while this statement is true, do this...". While Loops will not be on the midterm, but you may find other concepts from this question beneficial to your review. For REMOVED information about the wonderful word of while loops, see page 240 in the book.
For each of the below, see if you can figure out the representation in terms of bits and bytes.
(a) Internet addresses are four numbers, each between 0 and 255. How many bits are in an Internet address?
(b) In networking, computer port numbers range from 1 to 65,536. How many bits are needed to represent a port number?
(c) Each pixel's color has three components: red, green, and blue, each of which can be between 0 and 255. How many bits are needed to represent a pixel's color?
(d) A string in some systems can only be up to 1023 characters. How many bits are needed to represent the length of a string in such a system?
1. Write a function called double() that takes in an integer number. The function multiplies the given number by 2. The result is written to a file called "number.txt". Assume the file does not exist on your computer. You must create it and it can be in any folder on your computer.
2. Assume there is a file "string.txt" on your computer which has some text in it. Write a function called lastOne() which reads the contents of your file and returns the last character of the text. When you open the file, do not worry about the path, just put string.txt.
1. Write a function called media() that has a directory as a parameter. The function should find out all the media files in the directory i.e. it should find the number of files that have the extension .jpg and .wav. Note: There is a difference between .jpg and .JPG, .wav and .WAV, Your function should take care of all possibilities.
1. What is the difference between frequency and amplitude?
2. Explain the Nyquist theorem briefly.
3. How many bits are used to represent a sound? What is the range of sample values that a sound can have?
4. What is clipping?
1. Write a function called upDown() that has one parameter - a sound. The function should increase the volume of the first half of the sound and decrease the volume of the second half of the sound. Note: It doesn't matter how much the sound is increased or decreased.
2. Write a program that takes a sourceSound and a targetSound as input, then copy the sourceSound starting at 1 second and ending at 1.5 second into the targetSound starting 2 seconds into the targetSound.
3. Write a program where you move one second of an input sound from the 4th second of the sound to the start of the 2nd second.
Remember the string method replace()?
>>> letter = "Mr. Mark Guzdial requests the pleasure of your company at..."
>>> print letter.replace('a','!')
Mr. M!rk Guzdi!l requests the ple!sure of your comp!ny !t...
>>> print letter.replace('a','!').replace("e","#")
Mr. M!rk Guzdi!l r#qu#sts th# pl#!sur# of your comp!ny !t...
| FROM | TO |
| r | - |
| s | = |
| t | : |
a)
def func1(sound):
for s in getSample(sound):
if s > 10000:
s = 10000
else:
s = p
p = 15000
print p
b)
def func2():
f = open("C:\\world.txt", wt)
f.write("Go Jackets!")
f.write(13)
f.close
1. Represent the following colors in the rgb encoding:
>>> import os
>>> folder = pickAFolder()
>>> files = os.listdir(folder)
>>> file = files[0]
>>> foo = file.rfind('.')
>>> bar = file[foo:]
>>> print bar
1. Write a function called addItems() that takes in a list of numbers. The function should return the sum of all the elements in the list.
2. Write a function called rmMid() that takes in a list. The function should remove the middle element in a list. Note: If the list has 5(odd) elements, remove the 3rd element. If the list has 4(even) elements, remove the 2nd one.
1. Write a function called countAs() that takes in a string. The function should return the number of occurrences of the letter 'a' in the string.
2. Write a function called countVowels() that takes in a string. The function should count the number of times a vowel occurs and return the answer. Note: Vowels are a, e, i, o, u - just in case anyone forgot.
Charlie Brown:1919 Peanuts Lane:Atlanta, GA:404-992-9292 Peppermint Patty:2020 Cashew Street:Atlanta, GA:404-299-2929 Calvin:101 Tiger Lane:Decatur, GA:770-899-8989
| Don't sweat this one at this late stage. It is a good exercise for your critical thinking and approach to programming, but it is REMOVED complex than anything that will appear on this midterm. Bobby has posted a solution on the questions page. Colin Potts |
def listIt():
list = []
for i in range(1, 11, 2):
list.append(i)
string = "cHEcK"
for index in range(len(string)):
if string[index].isupper():
list[index] = string[index]
print "The string is", string
print "The list is", list