Proglan Midterms Set B Transition Term SY201415 Ronald L

advertisement
Proglan Midterms Set B
Transition Term SY201415 Ronald L. Ramos
Name: Perry E. Cabugao
Student Number: 11260564
Course: BS-IS
Answer the following questions as best as you can. Save the file as “Proglan Midterms Transition Term
SY201415 – yourfullname.doc”
When done upload the document to your wikifolder and update your wiki page.
The following will merit an automatic zero in the exam:
1. Plagiarizing answers
2. Copying from a classmate/seatmate
3. Opening facebook or any form of social media
4. Talking to a classmate/seatmate during the exam
Open notes. Open Internet. Closed Social Media sites.
Goodluck and Godspeed!
Python (60 points)
1. (30 points) Write a small Python program that has two functions that will convert temperatures
back and forth from the Celsius and Fahrenheit temperature scales. The formulas for making the
conversion are as follows:
Fahrenheit to Celsius: Cel s=(5/9)*(Fahr-32)
Celsius to Fahrenheit: Fahr =(9/5)*Cels+32
Sample output:
Temperature Conversion
Given: 20 C, 68 F
C to F: 20 deg Celsius = 68 deg Fahrenheit
F to C 68 deg Fahrenheit = 20 deg Celsius
Paste your code here:
_________________________________________________________________________
print "Temperature COnversion"
celsius = float(input('Enter degree Celsius: '))
fahrenheit = (celsius * 1.8) + 32
print("C to F: "'%0.1f degree Celsius = %0.1f degree Fahrenheit' %(celsius,fahrenheit))
print "Temperature Conversion"
fahrenheit = float(input('Enter degree fahrenheit: '))
celsius = (fahrenheit - 32) / 1.8
print("F to C: "'%0.1f degree Fahrenheit = %0.1f degree celsius ' %(fahrenheit, celsius))
_________________________________________________________________________
2. (5 points) Given a variable, f, what is the command to get python to print out the type of f?
Paste your code here:
print f
3. (5 points) What is an expression? Give 2 examples.
Expressions may be in any form such as string, number or an object which may also be stored
in a variable.
x = “Hello World!”
y =”I love Python”
4. (5 points) What is a statement? Give 2 examples.
Statements on the other hand are literal statements that does something or has an output.
Statements are usually composed of expressions(which is mentioned above).
-------------------------------------x=0, y=3
if x != y
print “Not Equal”
else
print “Equal”
x=0, y=3
z= x + y
print z
5. (5 points) What is the difference between a statement and an expression?
Expression are usually static and has a fixed value, where in an statement has no definite
value. For instance, the output of an statement always depends on the value of expressions.
6. (10 points) The following statement produces no screen output: 3.14 * 6 * 6. Modify it to
produce a screen output.
Paste your code here:
x = 3.14 * 6 * 6
print x
HTML5 (40 Points)
1. (10 points) Write the basic skeleton of an HTML 5 document.
<!doctype html>
<html lang=”en”>
<head>
<meta charset=”utf-8”>
<title>Python</title>
</head>
<body>
<p><h1> <strong>Hello World! </strong></h1></p>
<section></section>
</body>
</html>
2. (10 points) Write the basic skeleton of an HTML 4 document.
<html>
<head>
<title>Python</title>
</head>
<body>
<p><h1> Hello World!</h1></p>
</body>
</html>
3. (10 points) Create an HTML5 document with a canvas 300pixels wide by 300 pixels tall. Put a
black border around the canvas.
<!doctype html>
<html lang=”en”>
<head>
<meta charset=”utf-8”>
<title>Python</title>
</head>
<body>
<canvas id="canvas" width="300" height="300" style="border:2px solid
black;"></canvas>
</body>
</html>
4. (10 points) Create an HTML5 document with a canvas 400pixels wide by 300 pixels tall. Put a
black border around the canvas. Put a blue circle on the upper left corner of the canvas and a
red square on the lower right corner of the canvas.
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="400" height="300" style="border:1px solid Black;"></canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var grd = ctx.createLinearGradient(0,0,10000,0);
grd.addColorStop(0,"red");
grd.addColorStop(1,"red");
ctx.fillStyle = grd;
ctx.fillRect(305,10,80,80);
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
var centerX = canvas.width / 2;
var centerY = canvas.height / 2;
var radius = 40;
context.beginPath();
context.arc(50, 50, radius, 0, 2 * Math.PI, false);
context.fillStyle = 'blue';
context.fill();
context.lineWidth = .1;
context.strokeStyle = '#003300';
context.stroke();
</script>
</body>
</html>
Bonus (Optional – each answer must have a minimum of one paragraph with at least 3 sentences per
paragraph)
1. (10 points) What characteristics define a good programming language? Explain each
characteristic.
One is that the code/s have specific structure. This means the program must
comply with a certain standards. In this manner, maintenance of the codes will
be easier. It should be working or compatible on most machines regardless of
the hardware presented or the operating system you are working on.
2. (10 points) Cite an example of a good programming language to learn and explain why you
should learn it.
Reliability is a good point in criteria of a good programming language.
Intellisense is a part of it besides makes you work fast your trust you codes more.
Reliability consist of auto checking errors therefore, it promotes great effect in
minimizing error of your project.
/rlr2015 AMDG.
Download