[Go to site: main page, start]

0% found this document useful (0 votes)
3 views15 pages

Algorithm Code

The document introduces the basics of programming with Python, emphasizing the importance of algorithms and flowcharts in breaking down complex tasks into manageable steps. It explains how programming languages serve as a bridge between human instructions and machine code, highlighting Python's user-friendly syntax and versatility. Additionally, it provides guidance on installing Python and using its built-in IDLE environment to write and execute code.

Uploaded by

gdtdq74746
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)
3 views15 pages

Algorithm Code

The document introduces the basics of programming with Python, emphasizing the importance of algorithms and flowcharts in breaking down complex tasks into manageable steps. It explains how programming languages serve as a bridge between human instructions and machine code, highlighting Python's user-friendly syntax and versatility. Additionally, it provides guidance on installing Python and using its built-in IDLE environment to write and execute code.

Uploaded by

gdtdq74746
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
From Idea to Execution Your First Steps into the World of Python Every Complex Task is a a Series of Simple Steps. Before we write a single line of code, let’s consider how we accomplish tasks in real life, Whether it's following a recipe, planning a trip, or even getting ready for school, we follow a specific sequence of steps to achieve a goal. w | O® RECIPE TRIP ) SCHOOL The Plan for the Machine: The Algorithm When we want a computer to perform a task, we must provide it with a precise, step-by-step plan. In computer science, this plan is called an algorithm. It is a set of instructions written for the computer to follow. RECIPE _ Task: Make Instant Noodles Instructions: 1. Take pan 2 Boil water b eee 3. Add noodles , eoaoune 4 Cook 5 Servet cee, Visualizing the Plan: The Flowchart Q | Analgorithm lays out the steps in text, But how can we be sure the logicis correct, especially / for complex tasks? A flowchart is a graphical representation of an algorithm. It allows us to visualize the flow of instructions and confirm our plan makes sense from start to finish. Step1 Step2 ITS Step3 -}-—__} Step 4 VA Step5 input Data Process Step Output Result et The Language of Flowcharts c=) Start / End - Marks the beginning and end of the flowchart. Input / Output - Used for taking data in (e.g., user input) or displaying results out (e.g., printing to screen). Process - Represents a calculation or an action being performed (e.g., C=(F-32) * 5/9). <> Decision - Asks a yes/no question to determine the next step in the flow. Connector - Shows the direction of flow, connecting one symbol to the next. From Algorithm to Flowchart: An Example Convert Temperature from Fahrenheit to Celsius. Algorithm Flowchart 1. Start 2. Input temperature in Fahrenheit (F) 3. Calculate Celsius: C = (F-32) * 5/9 4. Display temperature in Celsius (C) [Link] The Translation Challenge Our algorithm and flowchart are clear to us, but there’s a problem. Computers don’t understand English or diagrams. They understand a fundamentally different language. Input temperature in Fahrenheit The Bridge: Programming Languages A program is an algorithm written in a language that a computer can ultimately understand These languages act as a bridge between human instructions and the machine's native binary code. onoroigo® AS Se FR 'n00 =e =) eo essa = Difficult for humans. symbolic, but still low-level. Closer to human language, easier to write and read. How Translation Works: Compilers vs. Interpreters High-level languages need a special program called a translator to convert our code into machine code. There are two main types: Compiler Interpreter (| { a aa Reads the entire program at once and Reads and executes the program line by line. translates it into a complete executable file. This makes testing and debugging faster. Used by languages he rt, 'Byhon uses an interpreter Introducing Python Developed Guido van Rossum fs 1991 Source Sans Pro 7 Source Sans Pro aN oO An Interesting Fact The name doesn't come from the snake, Van Rossum was a fan of the BBC comedy series ‘Monty Python's Flying Circus' and chose the name from the show's title. The Power of Python: Why It’s the Language of Choice Simple, clean syntax allows Avast collection of pre-written focus on problem-solving, code for everything from Data not complex code. Science and Al to web development. Interactive Mode Portable Test code one line at a ® Write code on Windows, time for rapid feedback ®) run it on Mac or Linux and debugging. without changes. ‘Extendable ‘Scalable: connects to any major Combine Python with code database, making itthe choice for from other languages like C++ massive applications like Google, for high-performance tasks. Instagram, and YouTube. es WV) WZ Navigate Open aweb browser and goto [Link]. Download Find the ‘Downloads’ section and click the button for the latest version compatible with your ‘operating system (Windows/Mac). 45 Run the downloaded installer. Pe @ Install in) &% Ee CRITICAL STEP On the first screen of the installer, you MUST check the box labeled ‘Add [Link] to PATH’, (Ervon sep > | custome isan Setting Up Your Workshop: Installing Python Your Workspace: An Introduction to IDLE Python comes with a simple, built-in program to write and run code called IDLE (Integrated Development and Learning Environment). To open it, search for “IDLE” in your computer’s Start Menu. ox) >>> fl The Two Modes of IDLE Shell Mode (Interactive) Script Mode (Program Files) [5] Identified by: The >>>" prompt. <2, How to access: Go to ‘File > New File’, < Purpose: For testing single commands. Purpose: For writing, saving, and Type a command, press Enter, and see running multi-line programs. Your work the result instantly, issavedina ‘py’ file. k Ma | / = \ (ose =oxy ° (Coe Samy} 33> 542 il LIF Lead k S| k S| You’ve Written Your First Program Tistproaampy Sar, print("Hello, World!) print ("My programming journey starts now.") By writing code in Script Mode and running it, you have executed your first Python program. Run (F5) (DLE Shela Son Hello, World! My programming journey starts now. >>> You now have the tools and understanding to begin exploring.

You might also like