Forum: Recent Posts
From categories:
page 1123...next »

From now on. Call me Moan.

by Moaning Myrtle Moaning Myrtle , 17 May 2019 01:37

Noah Rapetti, Monk way of the Drunken Fist up and ready for combat

Re: Python and Files by RapettiSpaghettiRapettiSpaghetti, 16 May 2019 21:26

You all have to make web pages. Hooray!

If you would like to use a funky new font you've found somewhere, you have to be careful. There's no guarantee that the other people have that font. There are a couple of solutions.

(1) Include the font with the HTML doc. A web page can use any font you like, whether it is installed on a computer or not, as long as it's accessible through the local file structure. Do this:

  • Put the font in the same folder as the HTML doc.
  • Add a style sheet line in the <head> of the HTML doc.
  • Refer to the font using a style reference.
  • Send the HTML doc and the font file together to the recipient.

For example, suppose I have a font file Cthulhu.ttf in the same folder as a web page with the following code:

<html>
<head>
<style type="text/css">
@font-face { font-family: myCrazyFont; src: url(Cthulhu.ttf); }
</style>
</head>
<body>
<h1 style="font-family: myCrazyFont;">Welcome To The Nightmare</h1>
</body>
</html>

These lines of code will link the web page to the font file Cthulhu.ttf. Note that the name of the font used within my document is no longer "Cthulhu", but "myCrazyFont". Normally you would name the font the same name as its font file, but you don't have to.

(2) Use a web font. There are lots of font collections available on the web, but many of them require you to download a font file. Some, like Google Fonts, let your web page access the fonts straight off their servers. For example, Google Fonts has a font called "Bree Serif". By adding either:

<link href="https://fonts.googleapis.com/css?family=Bree+Serif" rel="stylesheet">

or
<style>
@import url('https://fonts.googleapis.com/css?family=Bree+Serif');
</style>

into the <head> section of your HTML doc, the doc gains access to the Bree Serif font.

Use it through the style tag:

<p style="font-family: 'Bree Serif';">Hi there</p>
Fonts and Web Pages by Wes ProsserWes Prosser, 16 May 2019 12:14

This is the place for Geelong High's Unit 3&4 Systems Development class.

Hi There! by Wes ProsserWes Prosser, 16 May 2019 11:58

The following is a side-note to a problem flagged by Noah. If you install a funky new font, and want to use it in something that gets shared with other people, there's no guarantee that the other people have that font. There are a couple of solutions.

(1) Convert your doc to a PDF. PDFs can include font information in their files, so the doc appears exactly as you intended.

(2) Make a HTML doc (a web page). A web page can use any font you like, whether it is installed on a computer or not. Here's how:

  • Put the font in the same folder as the HTML doc.
  • Add a style sheet line in the <head> of the HTML doc.
  • Refer to the font using a style reference.
  • Send the HTML doc and the font file together to the recipient.

For example, suppose I have a font file Cthulhu.ttf in the same folder as a web page with the following code:

<html>
<head>
<style type="text/css">
@font-face { font-family: myCrazyFont; src: url(Cthulhu.ttf); }
</style>
</head>
<body>
<h1 style="font-family: myCrazyFont;">Welcome To The Nightmare</h1>
</body>
</html>

These lines of code will link the web page to the font file Cthulhu.ttf. Note that the name of the font used within my document is no longer "Cthulhu", but "myCrazyFont". Normally you would name the font the same name as its font file, but you don't have to.
Using Fonts With Web Pages by Wes ProsserWes Prosser, 16 May 2019 11:57

Somewhere or other there's a spot where you can become a member of Wikidot (for free), and then become a member of the site. Do it! It cuts down on ads you see.

by Wes ProsserWes Prosser, 16 May 2019 11:22
zac (guest) 16 May 2019 10:57
in discussion School-Specific Chat / Geelong High Y12 Computing 2019 » Python and Files

.

by zac (guest), 16 May 2019 10:57
Ben Malthouse (guest) 16 May 2019 01:56
in discussion School-Specific Chat / Geelong High Y12 Computing 2019 » Python and Files

Role call?

by Ben Malthouse (guest), 16 May 2019 01:56

Let's look at the HTML option.

By careful use of HTML and formatting you can:

  • make a .htm template page that looks like a document that you want to print;
  • copy the HTML code into a Python program that writes the document (possibly with customised content);
  • view the document on a browser and print it; and/or
  • view the document on a browser and save it as a .pdf (Chrome does this natively, Firefox does this with an add-on).

Examples of where this could be used:

  • Customer invoices;
  • Customer form letters;
  • Personalised information leaflets or brochures;
  • D&D character sheets;

… and many more.

One of the things you can do with Python is write files. Python can write text files and binary files. If you knew what to write, you could write any kind of file (a .gif, .jpg, .doc, .pdf, or whatever).

However, most of those are too difficult for most people. However however, there's one easy option, and a couple of middle-difficulty ones.

HTML is a text-only format. All the formatting that appears in a web page is text "instructions". Because it is text-only, it can be created pretty easily with Python text files. Try this:

doc = open("test.htm","w")
doc.write('<!doctype html>')
doc.write('<html>')
doc.write('<head>')
doc.write('</head>')
doc.write('<body style="background: #FEA;">')
doc.write('<h1 style="color:#F00;">Amazing!</h1>')
doc.write('<p>Does this actually work?!?</p>')
doc.write('<p style="color: #080;"><i>Sure does, buddy!</i></p>')
doc.write('</body>')
doc.write('</html>')
doc.close()

Notice the file is a .htm file. Double-click the created file - it should work in the browser of your choice.

RTF is a similar text-only format, created by Microsoft as a "back up" for Word Docs. It used to be really useful in the days of Macs and PCs, because each had their own character set, and sometimes docs written on one wouldn't come out 100% correct on the other. Like HTML, it uses commands written in to the text to show formatting and stuff.

Open Document Format uses XML-type mark-up, but has the disadvantage of using zip compression. This means the file starts life as a "text-only" file, but when complete is converted into a binary file.

See http://advtue.wikidot.com/birthday-2012 for details.
Also, send me a txt on 043 778 2744 so I have your mobile number.

Re: Thank you! by Wes ProsserWes Prosser, 30 Mar 2012 20:28

Speaking of which…

What are you doing Sat 14 Apr? Want to come down for a surf safari party?

Re: Thank you! by Wes ProsserWes Prosser, 30 Mar 2012 11:00
Thank you!
Da ManDa Man 29 Mar 2012 03:52
in discussion Targeted Chat / For Da Man! » Thank you!

Hey Wes!
Just wanted to say a big thanks for your help! I did the test on saturday just gone and it went pretty well! So i am hopeful that this year will be the year :D Thanks for helping me grasp topics i have been struggling with! Next time i am down we will have to catch up so i can say thanks in person :D

Thank you! by Da ManDa Man, 29 Mar 2012 03:52

Q 8.75 A container filled with 2.46kg H2O changes its temperature from 25.24°C to 27.31°C. How much heat (in kJ) did the H2O absorb?


C(H2O) = 4.18 J/g/°C
m(H2O) = 2.46 kg = 2460 g
ΔT = 27.31°C - 25.24°C = 2.07°C
Q = C × ΔT × m = 4.18 J/g/°C × 2.07°C × 2460 g = 21285 J = 21.3 kJ

Q 8.75 by Wes ProsserWes Prosser, 03 Mar 2012 04:04

Q 8.70 If 250J of heat is added to 30.0g Cu initially at 22.0°C, what is its final temperature?


C(Cu) = 0.385 J/g/°C
m(Cu) = 30.0 g
ΔT = Q ÷ C ÷ m = 250J ÷ 0.385J/g/°C ÷ 30.0g = 21.6°C
Final temperature = 22.0°C + 21.6°C = 43.6°C

Q 8.70 by Wes ProsserWes Prosser, 03 Mar 2012 04:03

Q 8.67 How much heat (in kilojoules) must be removed from 175g H2O to lower its temperature from 25°C to 15°C?


ΔT = 25°C - 15°C = 10°C
C(H2O) = 4.18 J/g/°C
m(H2O) = 175 g
Q = C × ΔT × m = 4.18J/g/°C × 10°C × 175g = 7320 J = 7.32 kJ

Q 8.67 by Wes ProsserWes Prosser, 03 Mar 2012 04:03

Q 8.65 A system absorbs 300 J heat and has 700 J of work done on it. What is ΔU? Is this overall endothermic or exothermic?


ΔU = +300 J + +700J = +1000 J
System is endothermic as it has absorbed heat.

Q 8.65 by Wes ProsserWes Prosser, 03 Mar 2012 04:02
Re: Sorry!
Wes ProsserWes Prosser 02 Mar 2012 11:01
in discussion Targeted Chat / For Da Man! » Mass Ratio

52 days lag! Piss poor!

Re: Sorry! by Wes ProsserWes Prosser, 02 Mar 2012 11:01

Q 3.44 Calculate the mass in g of
(a) 1.25 mol of Ca3(PO4)2


M(Ca) = 40.08 g/mol
M(P) = 30.97 g/mol
M(O) = 16.00 g/mol
M(Ca3(PO4)2) = 3 × 40.08 + 2 × 30.97 + 8 × 16.00 = 310.18 g/mol

Q 3.44 by Wes ProsserWes Prosser, 02 Mar 2012 10:56

Q 3.43 Calculate the molar mass of:
(a) NaHCO3


M(Na) = 22.99 g/mol
M(H) = 1.01 g/mol
M(C) = 12.01 g/mol
M(O) = 16.00 g/mol
M(NaHCO3) = 22.99 + 1.01 + 12.01 + 3 × 16.00 = 84.01 g/mol

Q 3.43 by Wes ProsserWes Prosser, 02 Mar 2012 10:55
page 1123...next »
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License