Python Programming - Session 1
Python Programming - Session 1
• What is a program?
• Precise set of instructions to solve a problems
• Some are machine like languages such as assembly or low level languages
• Others are human readable or high level languages such as FORTRAN, COBOL, C, C++, Python
• Compilation vs Interpretation
• Example: Need to cook meat to eat – compiling, Salad vegetables can be eaten as is - interpreting
• Click "Download"
• Verify the installation by opening a command prompt and typing python -V (or py -V)
• Run the installer and click Next until you reach Finish.
• Using the Python CLI when needed (will be used in operators module etc.)
Programming Basics
•To design a program properly
• r=2cm
The program
• Find area of larger circle:
• A1 = 3.14 * 5 * 5
• Find area of smaller circle:
• A2 = 3.14 * 2 * 2
• Find area of metal sheet to make the ring
• A3 = A1 – A2
• Find the weight of the ring:
• W = A3 * 10
• Answer W is in gms
Writing this program in Python
(screen rec.)
# Find area of larger circle:
A1 = 3.14 * 5 * 5
# Find area of smaller circle:
A2 = 3.14 * 2 * 2
# Find area of metal sheet to make the ring
A3 = A1 - A2
# Find the weight of the ring:
W = A3 * 10
# Answer W is in gms
print(“The weight of the metal ring is: “, W, “ grams.”)