Omniadisce

Posts tagged Python

153 posts match

Type
Subject
Difficulty
Tags
Show all 247 tags
Lesson
Scientific Computing Beginner Lesson

Computational physics 19.5: The Metropolis rule

A shortcut to a system at temperature T: try random changes, and make one that needs extra energy ฮ”W only with chance e^(โˆ’ฮ”W/kT). In one line of NumPy, for 4000 molecules with two energy levelsโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 20.6: Leaking into the walls

Add up |ฯˆ|ยฒ in the walls and in the well: the share in the walls is the chance of finding the particle where a ball could never be. Higher levels leak more. Check that the walls were followed farโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 1.1: Your first program

A program is a list of instructions the computer carries out, one line at a time, from the top. Write and run your first lines of Python: print a number, do a sum, and fix a mistake. A calculatorโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 1.4: Comments and labels

Write notes for people in a program with #, switch a line off and on, and print a label and a number together: print("speed in m/s:", speed). Python stores numbers, not units. To Python, 12.5 isโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 1.5: Powers and brackets

Python works out * before +, as in maths, and brackets first. Write powers with and use them for the distance a stone falls, s = ยฝgtยฒ. Two stopwatches time the same fall: 12 s and 14 s. Their meanโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 1.6: Converting units

Convert km/h to m/s, minutes to seconds and millimetres to metres in a program, write powers of ten in e notation, and convert before you calculate. A car's speedometer says km/h; a physics formulaโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 1.7: Reading errors

Meet the errors every beginner meets: SyntaxError (a missing bracket), TypeError (text and a number added), and the worst bug of all, the one that gives a wrong number and no message. Everyโ€ฆ

0 views by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 2.1: True or false?

A program decides by asking questions with a yes-or-no answer. Compare numbers with <, >, <=, >=, == and !=, and read Python's two answers: True and False. A speed camera doesn't need to know yourโ€ฆ

1 view by Weten 8 days ago
× Enlarged view