0% found this document useful (0 votes)
7 views12 pages

Python Essentials

Python_Essentials

Uploaded by

fwdk6fxvfm
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
7 views12 pages

Python Essentials

Python_Essentials

Uploaded by

fwdk6fxvfm
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
Python Fundamentals Talking to a Computer for the First Time. é print("Hello!" Module 1 Rules of the Road The Baseline The Pace ¢ No Engineering Background Start Small. We move from hb) Required. If you can use the zero in tiny, manageable internet, you belong here. steps. Read one short lesson ata time. The Method The Goal Break Things on Purpose. copy-paste. Type every Change numbers and words code example yourself to in the code to see what build muscle memory. breaks—that's how you learn. % recipe: Delius Mes! 1p et sateen cock What is a Program? fo et mie neat 1oad_ingretiens0) ({— tnservcttons = prcess datat) (Data [nso Syntax 101 - Your First Conversation The Text: | The Command: Tels the i - i. Quotes tell Python tis is computer to show print()"Hello, AI world!") a specific message, not a something on the screen i system command. The Delivery Box: Holds the exact information you are sending to the ‘command, Try itnow: Open your Python ‘ ) D editor, type this ine, change the message, and hit run Storage - Variables & Data Types A variable is a named box in memory holding a value. Numbers Text Strings Booleans Used for counting and adding. Used for words and messages. True of False values used for Always in quotes. making decisions. age = 30 name = "Alex" is_active = True print(name) Working Together print(age + 5) Decision Making - If/Else Logic © The Golden Rule Indentation matters! Python uses spaces to know hich lines of code belong to hich decision path, Wrong indentation = errors. if age >= 18: | prine(radute>) Repetition - The Power of Loops Common Uses Do something many times without copy-pasting, al for i in range(5): print(i) Go through a list of names. Count items that meet a 3 2 condition. Organizing Data — Lists vs. Dictionaries Lists Dictionaries ‘An ordered group of Items. Key > Value pairs. Keys are the questions, Uses square brackets | ] and commas. Values are the answers. Uses curly braces {). fruits = ["apple", "banana", “orange"] {"name": "Alex", "age": 30} st Zz fruits [0] gets the first fruit. (Indexes start at 0!) Instead of numbers, you look items up by their exact Key. Automation — Understanding Functions Inputs (Parameters): What you give. ‘Amini-program with a name. Call it whenever you need this specific job done. Outputs (Return Values): What you get back. def add(a, b): return a + b "Hello, Alex" SYNTHESIS - The Python Blueprint Functions You now know alll the core building blocks required to build almost any software in the world, Project Architecture: Pure Python Habit Tracker Step 1: Input Step 3: Decision Loop Sk Step 4: Output ao Variables/Inputs Loops & IfEise Functions/Print Output Step 1 Panel (Left) Step 2 Panel (Middle Left) Step 3 Panel (Middle Right) Step 4 Panel (Right) Ask the user to type a Save the habit into an Ask if they want to add When done, print a simple habit completed today. ongoing list record, another. If Yes, go back to summary of today's wins. Step 1 Next Steps & Stretch Goals Open your Python editor and write the basic Habit Tracker from scratch using what you just learned. ‘Add logic to your tracker! If habits > 3,print ‘Great job!'. If habits < 2,print ‘You can do one more tomorrow!" Try saving the list to a file. Practice making custom functions like add_two_numbers(a, b) add_two_numbers(a, 6) to prepare for Module 2.

You might also like