This document discusses flow control in Python, including selection (branching) and repetition (looping). It covers basic concepts of loops like initialization, testing, the loop body, and updating. It explains counter-controlled and sentinel-controlled loops. It provides examples of using while and for loops in Python, including using range() to generate sequences. It also discusses nested loops, and control statements like break, continue, and pass.
This document provides an introduction to file management in Python. It discusses what files are and the two main types: text files and binary files. It explains how files are read into a file object or stream for interaction with a program. Key file operations covered include opening and closing files, reading and writing file contents line by line or all at once, and seeking to different positions within a file. The document also touches on file formats, encoding, and using the pickle module to serialize complex Python objects to files.
This document provides an overview of numbers and built-in functions in Python. It discusses integer and floating point number representations, built-in math functions like sqrt and log, techniques for comparing floating point numbers, and a case study on implementing square root calculation. It also covers optional topics like bitwise operators and their applications to encryption and pseudo-random number generation.
Lecture 7 program development issues (supplementary)alvin567
The document discusses key topics for writing good programs including thinking before programming, writing readable code through naming conventions, comments and formatting, strategies for problem solving like simplifying problems and relaxing, and the importance of testing, debugging, documenting programs to address errors and allow for maintenance. It provides examples and emphasizes practicing programming as the best way to improve problem solving and development skills.
This document summarizes key points from a lecture on Play with Python. It discusses revising lists and dictionaries in Python, introduces object-oriented programming concepts like classes and objects, and provides examples of using classes to represent animals and computer devices. It also demonstrates creating a graphical user interface (GUI) using PyQt4 by building a simple dialog box with buttons and an image label.
The document outlines a Python training course that will cover topics such as the Python shell, data types, built-in functions, operators, flow control, syntax, data structures, file input/output, regular expressions, and Python library modules. Exercises will be done after each topic is taught to allow students to practice writing Python scripts.
The document discusses various specializations available in MBA programs, including traditional fields like finance and marketing as well as emerging areas focused on corporate social responsibility, digital media, big data analytics, and telecommunications management. It provides details on the course content, career prospects, and average salaries for each specialization. The document also examines the scope and future trends of MBA education in India.
This document discusses strings and characters in Python. It defines strings as sequences of characters and describes how to define, access elements of, slice, and perform operations on strings. It also discusses string methods like upper(), lower(), find(), and chaining methods. Functions for working with strings like len() are also covered. The document provides examples and exercises to help understand strings and characters in Python.
This document provides an introduction to the Python programming language. It discusses what Python is, how to download and install it, how to run Python programs, and the differences between an interpreter and compiler. Key points covered include that Python is an open source, interpreted programming language suitable for tasks like web development, AI, and graphics. The document also demonstrates simple Python programs and explains how Python's interpreter works by translating code line-by-line rather than compiling all at once like other languages.
This document provides an introduction to file management in Python. It discusses what files are and the two main types: text files and binary files. It explains how files are read into a file object or stream for interaction with a program. Key file operations covered include opening and closing files, reading and writing file contents line by line or all at once, and seeking to different positions within a file. The document also touches on file formats, encoding, and using the pickle module to serialize complex Python objects to files.
This document provides an overview of numbers and built-in functions in Python. It discusses integer and floating point number representations, built-in math functions like sqrt and log, techniques for comparing floating point numbers, and a case study on implementing square root calculation. It also covers optional topics like bitwise operators and their applications to encryption and pseudo-random number generation.
Lecture 7 program development issues (supplementary)alvin567
The document discusses key topics for writing good programs including thinking before programming, writing readable code through naming conventions, comments and formatting, strategies for problem solving like simplifying problems and relaxing, and the importance of testing, debugging, documenting programs to address errors and allow for maintenance. It provides examples and emphasizes practicing programming as the best way to improve problem solving and development skills.
This document summarizes key points from a lecture on Play with Python. It discusses revising lists and dictionaries in Python, introduces object-oriented programming concepts like classes and objects, and provides examples of using classes to represent animals and computer devices. It also demonstrates creating a graphical user interface (GUI) using PyQt4 by building a simple dialog box with buttons and an image label.
The document outlines a Python training course that will cover topics such as the Python shell, data types, built-in functions, operators, flow control, syntax, data structures, file input/output, regular expressions, and Python library modules. Exercises will be done after each topic is taught to allow students to practice writing Python scripts.
The document discusses various specializations available in MBA programs, including traditional fields like finance and marketing as well as emerging areas focused on corporate social responsibility, digital media, big data analytics, and telecommunications management. It provides details on the course content, career prospects, and average salaries for each specialization. The document also examines the scope and future trends of MBA education in India.
This document discusses strings and characters in Python. It defines strings as sequences of characters and describes how to define, access elements of, slice, and perform operations on strings. It also discusses string methods like upper(), lower(), find(), and chaining methods. Functions for working with strings like len() are also covered. The document provides examples and exercises to help understand strings and characters in Python.
This document provides an introduction to the Python programming language. It discusses what Python is, how to download and install it, how to run Python programs, and the differences between an interpreter and compiler. Key points covered include that Python is an open source, interpreted programming language suitable for tasks like web development, AI, and graphics. The document also demonstrates simple Python programs and explains how Python's interpreter works by translating code line-by-line rather than compiling all at once like other languages.
The document provides an overview of the Python programming language. It discusses that Python is an interpreted, interactive, object-oriented language created by Guido van Rossum in the late 1980s. It describes Python as high-level, portable, and has an extensive standard library. The document then covers Python variables and data types, basic operators, and provides examples of Python code, including defining variables, strings, lists, tuples, and dictionaries.
This document provides an introduction and overview for a course on computational thinking using Python. It outlines the course structure including lectures, tutorials, and labs over 13 weeks. It introduces the teaching staff and covers topics like learning outcomes, assessments, academic honesty, and tips for studying. The goal is to teach computational thinking and problem solving using Python as a tool rather than just teaching programming.
Lecture 10 user defined functions and modulesalvin567
This document provides an introduction to user defined functions and modules in Python. It begins with an overview of function basics, including what a function is, why functions are useful, and how functions are defined, called, and return values in Python. It then discusses more advanced topics like functions that call other functions, scope and namespaces, and how the LEGB rule determines which namespace to use when looking up a variable name. The document uses examples and exercises to illustrate key concepts related to defining, using, and understanding the scope of functions in Python.
Lecture 4 variables data types and operatorsalvin567
The document discusses variables, data types, and operators in Python. It covers key topics like variable naming conventions, data types including integers, floats, booleans and strings, operators for different data types, and data conversion between types. Examples are provided to illustrate concepts like variable assignment, data type checking, and arithmetic operations.
This document discusses flow control in programming. It introduces selection (branching) and repetition (looping) as important concepts beyond basic sequential program execution. Selection allows a program to choose which instructions to execute based on conditions, while repetition allows instructions to be executed multiple times. Common flow control structures like if/else, while loops, and for loops are explained. A game of paper-scissors-rock is used as a case study to demonstrate nested if statements for modeling different outcomes.
The document provides an introduction to HTML and CSS for a WWW course. It discusses various HTML tags such as headings, paragraphs, lists, tables, and forms. It also covers CSS topics like the syntax, selectors, and properties for width and height. Students are assigned to improve their flower shop website by adding more pages that introduce the shop, showcases, and about page using images and various HTML elements and tags.
This document provides an overview of Google products that can be used to support collaboration, including Google Drive, Docs, Slides, Sheets, Forms, and Hangouts. It highlights key features of each tool and provides tips for using them, such as having students collaboratively edit documents in Docs, create and share presentations in Slides, and track data in Sheets. Video conferencing options through Hangouts are also demonstrated.
This document outlines the modules covered in an introductory Python course, including an introduction to Python programming, working with files, loops, functions and user inputs, object-oriented programming with classes and exceptions, building graphical user interfaces with Tkinter and wxPython, common Tkinter widgets like labels and buttons, customizing widgets, and building applications like Tic-Tac-Toe and a calculator.
The document discusses computational thinking and algorithms. It defines computational thinking as a problem solving process involving analysis, modeling, understanding how computers work, logic, and procedure design. An algorithm is described as a detailed set of instructions to solve a problem, while a program is an implementation of an algorithm in a specific programming language. Common ways to express algorithms are through flowcharts, Nassi-Schneiderman diagrams, and pseudo-code. These allow visualizing an algorithm's sequential steps, branches, and loops.
This document provides an introduction to Python basics including:
- Python is simple to use, powerful due to extensive libraries, free and open source, and portable across operating systems.
- Python supports literal constants like strings ("Hello") and numbers (2.5), as well as variables to store values. Variables must start with a letter or underscore and can include letters, numbers and underscores.
- Python uses hash marks (#) for comments and whitespace is ignored. Multiple statements can be written on one line separated by semicolons.
This document discusses exceptions in Python. It explains what exceptions are, how to handle them using try/except blocks, and the different philosophies of exception handling - LBYL (Look Before You Leap) vs EAFP (Easier to Ask Forgiveness than Permission). The key aspects covered are:
1. Exceptions represent errors or unexpected events
2. try/except blocks allow capturing exceptions and handling them gracefully
3. else and finally blocks provide additional control flow options when using exceptions
4. Python follows the EAFP philosophy of running code and handling errors that occur instead of preemptively checking for errors
Building the Internet of Things with Raspberry PiNeil Broers
With the advent of the low cost Raspberry Pi computer, anyone with a soldering iron and some basic Python skills can take everyday objects and transform them into fully networked, smart devices.
In this talk, I will show you how I hacked a Raspberry Pi into my home alarm system, turning my network of IP cameras into motion triggered sensors. I will show you how to build basic input and output circuits and introduce you to the RPi.GPIO Python module. We’ll talk about how you can build a RESTful server on your Raspberry Pi to enable remote access. And finally, more ideas for hacking everyday objects around the home!
No prior electronics knowledge required.
Basic concepts for python web developmentNexSoftsys
The programmers or coders still need to allow the look, feel and work of the python web development thoroughly to raise its popularity and profitability.
Python is a popular, general purpose, high-level programming language that is easy to interface with other languages. It has a clear, readable syntax and large standard library. It can be used for a wide range of applications including web development, desktop GUIs, games, science, and more. Major organizations like Google, Yahoo, NASA, and CERN use Python for applications like YouTube, Gmail, mapping tools, and scientific calculations due to its simplicity and flexibility.
This document introduces composite data types in Python, including lists, tuples, dictionaries, and sets. It discusses what composite types are, why data structures are important, and four common Python data structures. It focuses on lists and tuples, explaining how to create, access, modify, and iterate over them. Lists are mutable while tuples are immutable. Choosing the appropriate data structure can help simplify programming tasks.
This document provides an overview and introduction to the 16.30/31 Feedback Control Systems course. It discusses the motivation for control systems including stabilizing unstable systems and improving performance. The document outlines the typical feedback control approach of establishing control objectives, selecting sensors and actuators, obtaining models, and designing controllers. It also introduces state-space models as the representation that will be used in the course, noting their advantages over transfer functions. Key topics to be covered are also listed such as nonlinearities, robustness, and implementation issues.
This document provides an overview of an advanced training course for ITSP PAL Method developers. The course covers topics like using Cycle Composer software to create and edit macros and methods, converting macros to cycles, important ITSP concepts, and reviewing control levels, sample lists, methods, macros, atoms, and firmware. It includes examples of macro code and discusses best practices for developing macros, variables, synchronization, and exercises for attendees to practice these skills. The intended audience is experienced ITSP lab personnel looking to develop new methods and macros for the ITSP PAL system.
This document provides notes for an introduction to simulation course. It defines key terms like system, entities, events, and different types of models. It explains that simulation is useful for evaluating systems that would be too complex, expensive or dangerous to experiment on directly. The document outlines the goals of the course as understanding simulation concepts, mathematics, programming and implementing simulation projects. It also discusses different approaches to representing time in a simulation, like next-event time advance and fixed-increment time advance.
introduction to modeling, Types of Models, Classification of mathematical mod...Waqas Afzal
Types of Systems
Ways to study system
Model
Types of Models
Why Mathematical Model
Classification of mathematical models
Black box, white box, Gray box
Lumped systems
Dynamic Systems
Simulation
The document provides an overview of the Python programming language. It discusses that Python is an interpreted, interactive, object-oriented language created by Guido van Rossum in the late 1980s. It describes Python as high-level, portable, and has an extensive standard library. The document then covers Python variables and data types, basic operators, and provides examples of Python code, including defining variables, strings, lists, tuples, and dictionaries.
This document provides an introduction and overview for a course on computational thinking using Python. It outlines the course structure including lectures, tutorials, and labs over 13 weeks. It introduces the teaching staff and covers topics like learning outcomes, assessments, academic honesty, and tips for studying. The goal is to teach computational thinking and problem solving using Python as a tool rather than just teaching programming.
Lecture 10 user defined functions and modulesalvin567
This document provides an introduction to user defined functions and modules in Python. It begins with an overview of function basics, including what a function is, why functions are useful, and how functions are defined, called, and return values in Python. It then discusses more advanced topics like functions that call other functions, scope and namespaces, and how the LEGB rule determines which namespace to use when looking up a variable name. The document uses examples and exercises to illustrate key concepts related to defining, using, and understanding the scope of functions in Python.
Lecture 4 variables data types and operatorsalvin567
The document discusses variables, data types, and operators in Python. It covers key topics like variable naming conventions, data types including integers, floats, booleans and strings, operators for different data types, and data conversion between types. Examples are provided to illustrate concepts like variable assignment, data type checking, and arithmetic operations.
This document discusses flow control in programming. It introduces selection (branching) and repetition (looping) as important concepts beyond basic sequential program execution. Selection allows a program to choose which instructions to execute based on conditions, while repetition allows instructions to be executed multiple times. Common flow control structures like if/else, while loops, and for loops are explained. A game of paper-scissors-rock is used as a case study to demonstrate nested if statements for modeling different outcomes.
The document provides an introduction to HTML and CSS for a WWW course. It discusses various HTML tags such as headings, paragraphs, lists, tables, and forms. It also covers CSS topics like the syntax, selectors, and properties for width and height. Students are assigned to improve their flower shop website by adding more pages that introduce the shop, showcases, and about page using images and various HTML elements and tags.
This document provides an overview of Google products that can be used to support collaboration, including Google Drive, Docs, Slides, Sheets, Forms, and Hangouts. It highlights key features of each tool and provides tips for using them, such as having students collaboratively edit documents in Docs, create and share presentations in Slides, and track data in Sheets. Video conferencing options through Hangouts are also demonstrated.
This document outlines the modules covered in an introductory Python course, including an introduction to Python programming, working with files, loops, functions and user inputs, object-oriented programming with classes and exceptions, building graphical user interfaces with Tkinter and wxPython, common Tkinter widgets like labels and buttons, customizing widgets, and building applications like Tic-Tac-Toe and a calculator.
The document discusses computational thinking and algorithms. It defines computational thinking as a problem solving process involving analysis, modeling, understanding how computers work, logic, and procedure design. An algorithm is described as a detailed set of instructions to solve a problem, while a program is an implementation of an algorithm in a specific programming language. Common ways to express algorithms are through flowcharts, Nassi-Schneiderman diagrams, and pseudo-code. These allow visualizing an algorithm's sequential steps, branches, and loops.
This document provides an introduction to Python basics including:
- Python is simple to use, powerful due to extensive libraries, free and open source, and portable across operating systems.
- Python supports literal constants like strings ("Hello") and numbers (2.5), as well as variables to store values. Variables must start with a letter or underscore and can include letters, numbers and underscores.
- Python uses hash marks (#) for comments and whitespace is ignored. Multiple statements can be written on one line separated by semicolons.
This document discusses exceptions in Python. It explains what exceptions are, how to handle them using try/except blocks, and the different philosophies of exception handling - LBYL (Look Before You Leap) vs EAFP (Easier to Ask Forgiveness than Permission). The key aspects covered are:
1. Exceptions represent errors or unexpected events
2. try/except blocks allow capturing exceptions and handling them gracefully
3. else and finally blocks provide additional control flow options when using exceptions
4. Python follows the EAFP philosophy of running code and handling errors that occur instead of preemptively checking for errors
Building the Internet of Things with Raspberry PiNeil Broers
With the advent of the low cost Raspberry Pi computer, anyone with a soldering iron and some basic Python skills can take everyday objects and transform them into fully networked, smart devices.
In this talk, I will show you how I hacked a Raspberry Pi into my home alarm system, turning my network of IP cameras into motion triggered sensors. I will show you how to build basic input and output circuits and introduce you to the RPi.GPIO Python module. We’ll talk about how you can build a RESTful server on your Raspberry Pi to enable remote access. And finally, more ideas for hacking everyday objects around the home!
No prior electronics knowledge required.
Basic concepts for python web developmentNexSoftsys
The programmers or coders still need to allow the look, feel and work of the python web development thoroughly to raise its popularity and profitability.
Python is a popular, general purpose, high-level programming language that is easy to interface with other languages. It has a clear, readable syntax and large standard library. It can be used for a wide range of applications including web development, desktop GUIs, games, science, and more. Major organizations like Google, Yahoo, NASA, and CERN use Python for applications like YouTube, Gmail, mapping tools, and scientific calculations due to its simplicity and flexibility.
This document introduces composite data types in Python, including lists, tuples, dictionaries, and sets. It discusses what composite types are, why data structures are important, and four common Python data structures. It focuses on lists and tuples, explaining how to create, access, modify, and iterate over them. Lists are mutable while tuples are immutable. Choosing the appropriate data structure can help simplify programming tasks.
This document provides an overview and introduction to the 16.30/31 Feedback Control Systems course. It discusses the motivation for control systems including stabilizing unstable systems and improving performance. The document outlines the typical feedback control approach of establishing control objectives, selecting sensors and actuators, obtaining models, and designing controllers. It also introduces state-space models as the representation that will be used in the course, noting their advantages over transfer functions. Key topics to be covered are also listed such as nonlinearities, robustness, and implementation issues.
This document provides an overview of an advanced training course for ITSP PAL Method developers. The course covers topics like using Cycle Composer software to create and edit macros and methods, converting macros to cycles, important ITSP concepts, and reviewing control levels, sample lists, methods, macros, atoms, and firmware. It includes examples of macro code and discusses best practices for developing macros, variables, synchronization, and exercises for attendees to practice these skills. The intended audience is experienced ITSP lab personnel looking to develop new methods and macros for the ITSP PAL system.
This document provides notes for an introduction to simulation course. It defines key terms like system, entities, events, and different types of models. It explains that simulation is useful for evaluating systems that would be too complex, expensive or dangerous to experiment on directly. The document outlines the goals of the course as understanding simulation concepts, mathematics, programming and implementing simulation projects. It also discusses different approaches to representing time in a simulation, like next-event time advance and fixed-increment time advance.
introduction to modeling, Types of Models, Classification of mathematical mod...Waqas Afzal
Types of Systems
Ways to study system
Model
Types of Models
Why Mathematical Model
Classification of mathematical models
Black box, white box, Gray box
Lumped systems
Dynamic Systems
Simulation
https://github.com/telecombcn-dl/dlmm-2017-dcu
Deep learning technologies are at the core of the current revolution in artificial intelligence for multimedia data analysis. The convergence of big annotated data and affordable GPU hardware has allowed the training of neural networks for data analysis tasks which had been addressed until now with hand-crafted features. Architectures such as convolutional neural networks, recurrent neural networks and Q-nets for reinforcement learning have shaped a brand new scenario in signal processing. This course will cover the basic principles and applications of deep learning to computer vision problems, such as image classification, object detection or text captioning.
This document provides an overview of simulation modeling. It defines a system as any set of interrelated components acting together to achieve a common objective. A model represents the structure of a real system through simplification, abstraction, and assumptions. Simulation is the process of running a computer model of a real system to study or experiment with it. There are different types of simulations depending on whether changes are continuous or discrete over time and whether aspects are deterministic or stochastic. Monte Carlo simulation uses random sampling to approximate expectations while discrete event simulation models systems as sequences of discrete events over time. Examples provided include using Monte Carlo to estimate pi and modeling a single machine system in discrete event simulation software.
The document discusses templates in C++. It explains that templates allow functions and classes to work with different data types using a single code definition. Template functions are called function templates, and template classes are called class templates. The document provides examples of defining class and function templates, and overloading template functions. It demonstrates how templates can be used to create generic functions that operate on multiple types of data.
This document discusses Python loops and string manipulation. It covers while loops, using a loop counter to repeat code a specified number of times. It also discusses slicing strings to access characters or substrings, checking if a string contains a character, and calling string methods like lower(), upper(), and replace() to manipulate strings.
The document discusses algorithm analysis. It describes that the purpose of analysis is to determine an algorithm's performance in terms of time and space efficiency. Time efficiency, also called time complexity, measures how fast an algorithm solves a problem by determining the running time as a function of input size. Space efficiency measures an algorithm's storage requirements. Algorithm analysis approaches include empirical testing, analytical examination, and visualization techniques.
Chapter1.1 Introduction to design and analysis of algorithm.pptTekle12
This document discusses the design and analysis of algorithms. It begins with defining what an algorithm is - a well-defined computational procedure that takes inputs and produces outputs. It describes analyzing algorithms to determine their efficiency and comparing different algorithms that solve the same problem. The document outlines steps for designing algorithms, including understanding the problem, deciding a solution approach, designing the algorithm, proving correctness, and analyzing and coding it. It discusses using mathematical techniques like asymptotic analysis and Big O notation to analyze algorithms independently of implementations or inputs. The importance of analysis is also covered.
This document discusses the design and analysis of algorithms. It begins with defining what an algorithm is - a well-defined computational procedure that takes inputs and produces outputs. It describes analyzing algorithms to determine their efficiency and comparing different algorithms that solve the same problem. The document outlines steps for designing algorithms, including understanding the problem, deciding a solution approach, designing the algorithm, proving correctness, and analyzing and coding it. It discusses using mathematical techniques like asymptotic analysis and Big O notation to analyze algorithms independently of implementations or data. The importance of analyzing algorithms and techniques like divide-and-conquer are also covered.
This document outlines a simulation study conducted by Nora ALHarbi and Enaam ALOtaibi on blood donation drives. It includes an introduction to simulation, definitions, types of simulation, and the simulation process. It then discusses how the Red Cross used simulation to analyze their blood donation process and identify policies to reduce donor wait times. Alternative arrival patterns and policy options like increasing beds were tested. The simulation analysis improved performance and donor satisfaction at Red Cross blood drives.
Code Review Checklist: How far is a code review going? "Metrics measure the design of code after it has been written, a Review proofs it and Refactoring improves code."
In this paper a document structure is shown and tips for a code review.
Some checks fits with your existing tools and simply raises a hand when the quality or security of your codebase is impaired.
This document introduces repetition structures using sentinel values in loops. It discusses sentinel-controlled loops, where the loop continues executing until a sentinel value is entered to indicate the end. It provides an example of a loop that displays "Hello" until the user enters 99. The document also covers nested loops, with an example of a nested loop to display a multiplication table. It includes exercises on nested loops and arrays to calculate totals from input data.
Spark Summit EU talk by Ram Sriharsha and Vlad FeinbergSpark Summit
This document summarizes an online machine learning framework called Structured Streaming that is being developed for Apache Spark. Some key points:
- It allows machine learning algorithms to be applied continuously to streaming data and update models incrementally in an online fashion.
- Models are updated every time interval (e.g. every second) based on new data within that interval. This provides an approximation of processing all data to date.
- It uses a stateful aggregation approach to allow models to be updated and merged across distributed partitions in a way that is deterministic but not necessarily commutative.
- APIs are provided for common online learning algorithms like online logistic regression and gradient descent to interface with streaming data sources and sinks.
This document discusses stacks and queues as data structures. It begins by introducing stacks and their LIFO (last-in, first-out) operation. Common applications of stacks are then described, such as function calls, calculators, mazes, and undo functions. Static and dynamic stack implementations using arrays and linked lists are covered. The document then introduces queues and their FIFO (first-in, first-out) operation. Example applications of queues like print jobs and round robin scheduling are provided. Finally, the operations and implementations of queues are discussed at a high level.
Time Series Forecasting Using Recurrent Neural Network and Vector Autoregress...Databricks
Given the resurgence of neural network-based techniques in recent years, it is important for data science practitioner to understand how to apply these techniques and the tradeoffs between neural network-based and traditional statistical methods.
This lecture discusses two specific techniques: Vector Autoregressive (VAR) Models and Recurrent Neural Network (RNN). The former is one of the most important class of multivariate time series statistical models applied in finance while the latter is a neural network architecture that is suitable for time series forecasting. I’ll demonstrate how they are implemented in practice and compares their advantages and disadvantages. Real-world applications, demonstrated using python and Spark, are used to illustrate these techniques. While not the focus in this lecture, exploratory time series data analysis using time-series plot, plots of autocorrelation (i.e. correlogram), plots of partial autocorrelation, plots of cross-correlations, histogram, and kernel density plot, will also be included in the demo.
The attendees will learn – the formulation of a time series forecasting problem statement in context of VAR and RNN – the application of Recurrent Neural Network-based techniques in time series forecasting – the application of Vector Autoregressive Models in multivariate time series forecasting – the pros and cons of using VAR and RNN-based techniques in the context of financial time series forecasting – When to use VAR and when to use RNN-based techniques
Similar to Lecture 6.2 flow control repetition (20)
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIVladimir Iglovikov, Ph.D.
Presented by Vladimir Iglovikov:
- https://www.linkedin.com/in/iglovikov/
- https://x.com/viglovikov
- https://www.instagram.com/ternaus/
This presentation delves into the journey of Albumentations.ai, a highly successful open-source library for data augmentation.
Created out of a necessity for superior performance in Kaggle competitions, Albumentations has grown to become a widely used tool among data scientists and machine learning practitioners.
This case study covers various aspects, including:
People: The contributors and community that have supported Albumentations.
Metrics: The success indicators such as downloads, daily active users, GitHub stars, and financial contributions.
Challenges: The hurdles in monetizing open-source projects and measuring user engagement.
Development Practices: Best practices for creating, maintaining, and scaling open-source libraries, including code hygiene, CI/CD, and fast iteration.
Community Building: Strategies for making adoption easy, iterating quickly, and fostering a vibrant, engaged community.
Marketing: Both online and offline marketing tactics, focusing on real, impactful interactions and collaborations.
Mental Health: Maintaining balance and not feeling pressured by user demands.
Key insights include the importance of automation, making the adoption process seamless, and leveraging offline interactions for marketing. The presentation also emphasizes the need for continuous small improvements and building a friendly, inclusive community that contributes to the project's growth.
Vladimir Iglovikov brings his extensive experience as a Kaggle Grandmaster, ex-Staff ML Engineer at Lyft, sharing valuable lessons and practical advice for anyone looking to enhance the adoption of their open-source projects.
Explore more about Albumentations and join the community at:
GitHub: https://github.com/albumentations-team/albumentations
Website: https://albumentations.ai/
LinkedIn: https://www.linkedin.com/company/100504475
Twitter: https://x.com/albumentations
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Building RAG with self-deployed Milvus vector database and Snowpark Container...Zilliz
This talk will give hands-on advice on building RAG applications with an open-source Milvus database deployed as a docker container. We will also introduce the integration of Milvus with Snowpark Container Services.
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Speck&Tech
ABSTRACT: A prima vista, un mattoncino Lego e la backdoor XZ potrebbero avere in comune il fatto di essere entrambi blocchi di costruzione, o dipendenze di progetti creativi e software. La realtà è che un mattoncino Lego e il caso della backdoor XZ hanno molto di più di tutto ciò in comune.
Partecipate alla presentazione per immergervi in una storia di interoperabilità, standard e formati aperti, per poi discutere del ruolo importante che i contributori hanno in una comunità open source sostenibile.
BIO: Sostenitrice del software libero e dei formati standard e aperti. È stata un membro attivo dei progetti Fedora e openSUSE e ha co-fondato l'Associazione LibreItalia dove è stata coinvolta in diversi eventi, migrazioni e formazione relativi a LibreOffice. In precedenza ha lavorato a migrazioni e corsi di formazione su LibreOffice per diverse amministrazioni pubbliche e privati. Da gennaio 2020 lavora in SUSE come Software Release Engineer per Uyuni e SUSE Manager e quando non segue la sua passione per i computer e per Geeko coltiva la sua curiosità per l'astronomia (da cui deriva il suo nickname deneb_alpha).
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
20 Comprehensive Checklist of Designing and Developing a WebsitePixlogix Infotech
Dive into the world of Website Designing and Developing with Pixlogix! Looking to create a stunning online presence? Look no further! Our comprehensive checklist covers everything you need to know to craft a website that stands out. From user-friendly design to seamless functionality, we've got you covered. Don't miss out on this invaluable resource! Check out our checklist now at Pixlogix and start your journey towards a captivating online presence today.
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc
How does your privacy program stack up against your peers? What challenges are privacy teams tackling and prioritizing in 2024?
In the fifth annual Global Privacy Benchmarks Survey, we asked over 1,800 global privacy professionals and business executives to share their perspectives on the current state of privacy inside and outside of their organizations. This year’s report focused on emerging areas of importance for privacy and compliance professionals, including considerations and implications of Artificial Intelligence (AI) technologies, building brand trust, and different approaches for achieving higher privacy competence scores.
See how organizational priorities and strategic approaches to data security and privacy are evolving around the globe.
This webinar will review:
- The top 10 privacy insights from the fifth annual Global Privacy Benchmarks Survey
- The top challenges for privacy leaders, practitioners, and organizations in 2024
- Key themes to consider in developing and maintaining your privacy program
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Full-RAG: A modern architecture for hyper-personalizationZilliz
Mike Del Balso, CEO & Co-Founder at Tecton, presents "Full RAG," a novel approach to AI recommendation systems, aiming to push beyond the limitations of traditional models through a deep integration of contextual insights and real-time data, leveraging the Retrieval-Augmented Generation architecture. This talk will outline Full RAG's potential to significantly enhance personalization, address engineering challenges such as data management and model training, and introduce data enrichment with reranking as a key solution. Attendees will gain crucial insights into the importance of hyperpersonalization in AI, the capabilities of Full RAG for advanced personalization, and strategies for managing complex data integrations for deploying cutting-edge AI solutions.
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
2. 2 of 81Module 6 : Flow control
Topics
• Basic Concepts: Why Selection and Repetition
• Selection (Branching)
• Basic concepts
• Case study: Paper Scissor Rock
• Syntax
• Examples in Python
• Repetition (Looping)
• Basic concepts: for and while
• Syntax: while
• The range function
• Syntax: for
• Nested loops
• break, continue, and pass
• Case Study: Visual Example - Path of a projectile
5. 5 of 81Module 6 : Flow control
General structure of a loop
Generally, four steps:
1. Initialize: loop control variable
2. Test: continue the loop or not?
3. Loop body: main computation being repeated
4. Update: modify the value of loop control variable so
that next time when we test, we MAY exit the loop
Sometimes a loop may not have all of them,
e.g., infinite loop (test is always true)
6. 6 of 81Module 6 : Flow control
General structure of a loop
Visualize them by a flow chart!!!
1. Initialize
2. Test
3. Loop body
4. Update
Initialize
Statement
Update
Test
true
false
4
3
2
1
Loop
7. 7 of 81Module 6 : Flow control
main:
SET sum TO 0 // Initialize
SET counter TO 0
WHILE counter < N // Test
READ height // Loop body
ADD height TO sum
INCREMENT counter BY 1 // Update
ENDWHILE
COMPUTE average = sum/counter
PRINT average
General structure of a loop
Example: Compute average height of N students
1
2
3
4
8. 8 of 81Module 6 : Flow control
Two kinds of loop
1. Counter-controlled loop – the number of
repetitions is known before the loop starts
execution; just repeat the loop on each
element in a preset sequence
2. Sentinel-controlled loop – the number of
repetitions is NOT known before the loop
starts. For example, a sentinel value (e.g., –1,
different from the regular data) is used to
determine whether to execute the loop body
10. 10 of 81Module 6 : Flow control
Examples:
• Sentinel-controlled loops
Compute average height of people entering
Canteen A in a day…
sum = count = 0
time = get current time
WHILE time < Canteen A closing time
height = get height of next guy
sum += height
count += 1
time = get current time
END WHILE
Cannot know ahead how many people entering
canteen A before we start the loop body
11. 11 of 81Module 6 : Flow control
Examples:
• A Sentinel-controlled loop
usually contains all four loop elements
Initialize
Test
Loop Body
Update
Note: time is the loop control variable
12. 12 of 81Module 6 : Flow control
In Python
We can implement loops by:
• for – usually for counter-controlled loops
• while – usually for sentinel-controlled
loop, but may also be used to implement
counter-controlled loops
13. 13 of 81Module 6 : Flow control
Topics
• Basic Concepts: Why Selection and Repetition
• Selection (Branching)
• Basic concepts
• Case study: Paper Scissor Rock
• Syntax
• Examples in Python
• Repetition (Looping)
• Basic concepts: for and while
• Syntax: while
• The range function
• Syntax: for
• Nested loops
• break, continue, and pass
• Case Study: Visual Example - Path of a projectile
14. 14 of 81Module 6 : Flow control
Python Syntax: while
• Similar to an IF statement but repeat the
block till the condition becomes false
Syntax:
while <boolean expression> :
suite (one or more
indented statements)
Example:
while a > b:
print(a," > ",b)
a = a - 10
MUST use colon followed
by proper indentation
the whole
while structure
Test
true
Statement
false
17. 17 of 81Module 6 : Flow control
Print message
Read tempLimit
Start
fahren = 32.0
fahren<=tempLimit ?
true
fahren += 10
Print fahren, celsius
false
End
Initialize
while (Test)
Statement
Update
Loop Body
Test
celsius = (fahren
– 32.0) * 5.0 / 9.0
18. 18 of 81Module 6 : Flow control
Implementation
• Who is the loop control variable?
• Counter-controlled or sentinel-controlled?
Note: You will learn how to format the output as below for
print() by using % in module 8 on Strings
t - a tab space (nicer formatting)
20. 20 of 81Module 6 : Flow control
Any issue?
• Any potential issue in this program?
How if the user enters a value smaller than 32? Or? Then?
What will happen? So… Any idea to fix it?
21. 21 of 81Module 6 : Flow control
Example #1.2
• Maybe… we can force the user to input
again? But how?
• Idea:
• Keep asking until he/she enters a number that is
at least 32 and at most a certain reasonable limit
• Now… we can add a while loop
25. 25 of 81Module 6 : Flow control
Implementation
• Again, we can use while loop to
continue asking for user input…
• Who is the loop control variable?
• Counter-controlled or sentinel-controlled?
• Any issue to ensure for this design?
[Make sure: sentinel value will not appear in normal cases]
while
structure
26. 26 of 81Module 6 : Flow control
Python Syntax: while with else
• while loop, oddly, can have an associated
else statement
• else statement is executed when the loop
finishes under normal conditions
• The last thing the loop does as it exits
• Syntax:
while booleanExpression:
suite1
else:
suite2
rest of the program
the whole
while
structure
28. 28 of 81Module 6 : Flow control
Topics
• Basic Concepts: Why Selection and Repetition
• Selection (Branching)
• Basic concepts
• Case study: Paper Scissor Rock
• Syntax
• Examples in Python
• Repetition (Looping)
• Basic concepts: for and while
• Syntax: while
• The range function
• Syntax: for
• Nested loops
• break, continue, and pass
• Case Study: Visual Example - Path of a projectile
30. 30 of 81Module 6 : Flow control
What is range?
• Generates a list of integers from start up to
end (but excluding end) with stepsize step
• Syntax: it has three forms:
range( end )
range( start , end )
range( start , end , step )
i.e., we can use/call it in three different ways…
31. 31 of 81Module 6 : Flow control
Meaning
• range( end )
- Python puts start to 0 and step to 1 (default values)
- range(11) gives [ 0 , 1 , 2 , … , 10 ]
• range( start , end )
- Python puts step to 1 (default value)
- range(1,11) gives [ 1 , 2 , 3 , … , 10 ]
• range( start , end , step )
- Python returns a list (sequence) of integers from
start to end-1 with stepsize step
- range(1,11,2) gives [ 1 , 3 , 5 , …, 9 ]
However, range() returns a memory efficient object implicitly rather
than an explicit list; we can use list to see its contents, see next page
33. 33 of 81Module 6 : Flow control
Exercises for you
• How can you create a list containing
[ 0, 3, 6, 9, 12, 15 ] ?
• How can you create a list containing
[ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 ] ?
• How can you create a list containing
[ 4, 2, 0, -2, -4 ] ?
34. 34 of 81Module 6 : Flow control
What is memory efficient object?
• range() returns a “range object” (memory
efficient object) that pretends to be the sequence
• It is an opaque sequence which yields the same
values as "list(range())”,but NOT storing every
single value explicitly; it generates values for you
only when you use its contents (on demand)
• Any advantage? Think about…
Try range(1,1000000)and list(range(1,1000000))
Which one consumes more memory?
35. 35 of 81Module 6 : Flow control
Topics
• Basic Concepts: Why Selection and Repetition
• Selection (Branching)
• Basic concepts
• Case study: Paper Scissor Rock
• Syntax
• Examples in Python
• Repetition (Looping)
• Basic concepts: for and while
• Syntax: while
• The range function
• Syntax: for
• Nested loops
• break, continue, and pass
• Case Study: Visual Example - Path of a projectile
36. 36 of 81Module 6 : Flow control
Python Syntax: for
• Control flow: loop through the objects
according to their order in the sequence
Syntax:
for <element> in <sequence> :
suite (one or more indented statements)
Example:
for each element in it
two for
structures
can be a list also…
37. 37 of 81Module 6 : Flow control
Note:
Main issue:
• Variable x (or y) in the example “for” loops will take
different values in different loop iterations
Other issues:
• First, remember the colon!!!
• Second, why it is always counter-controlled?
• Lastly, remember range in Python!!
Excluding the ending element
i.e., not symmetric!!!
range(1,5,1) != range(5,1,-1)
40. 40 of 81Module 6 : Flow control
Example #2.1 – Implementation
• In Python, just a few lines…
Use comma to separate
different elements for printEnd with 11 instead
of 10 if we want the
last value to be 10
41. 41 of 81Module 6 : Flow control
Case Study: Example #2.2
• Summing a series of data using for loop
!10
x
!4
x
!3
x
!2
x
1!
x
1
10432
+−+−+− LL
Basic idea to implement it:
Sum the terms one by one by using a for loop,
i.e., one term per iteration
42. 42 of 81Module 6 : Flow control
Case Study: Example #2.2
• Let’s analyze the term
Observation:
• First, check the terms…
• 1st term is 1; 2nd term is
• Multiply 1st term with x, divide by 1 and flip the sign
• Third term is
• Multiply 2nd term with x, divide by 2 and flip the sign
……
!10
x
!4
x
!3
x
!2
x
1!
x
1
10432
+−+−+− LL
43. 43 of 81Module 6 : Flow control
Case Study: Example #2.2
• More detailed idea to implement it
So...
• We may have one variable to keep track of the term,
say term
• One more variable to keep track of what to be
divided next, say divisor
• Another variable to accumulate the sum, say total
!10
x
!4
x
!3
x
!2
x
1!
x
1
10432
+−+−+− LL
44. 44 of 81Module 6 : Flow control
Case Study: Example #2.2
• Hence, we have:
Note:
- Make sure use float for
x and term
- The negative sign before
term can flip the sign of
the term in each iteration
- I put in this “print(term)”
for testing purpose;
note: testing is important
to verify your code!!!
(after that, can just
comment it)
45. 45 of 81Module 6 : Flow control
Inputs/initialization:
x = 0.9, total= 1.0, term = 1.0
Case Study: Example #2.2
• We can trace each iteration to verify also:
Outputs:
Result = 0.406569
…
+1
-1
sign
0.4065699.609e-0810
…
0.5050.4052
0.0999-0.91
totaltermdivisor
… …
46. 46 of 81Module 6 : Flow control
Topics
• Basic Concepts: Why Selection and Repetition
• Selection (Branching)
• Basic concepts
• Case study: Paper Scissor Rock
• Syntax
• Examples in Python
• Repetition (Looping)
• Basic concepts: for and while
• Syntax: while
• The range function
• Syntax: for
• Nested loops
• break, continue, and pass
• Case Study: Visual Example - Path of a projectile
47. 47 of 81Module 6 : Flow control
Nested Loops
• Sometimes… one level of loop is not sufficient
for the algorithmic need; an outer loop may
enclose an inner loop (or even more), e.g.,
Two levels of loops!!!
48. 48 of 81Module 6 : Flow control
Example #2.3
• Note:
This additional argument is used in
Python 3 to avoid the default ending n
This is the entire
suite/block inside
the outer for loop
Only one statement
inside the inner for loop
Question:
How many times each print is executed?
What is the control flow?
49. 49 of 81Module 6 : Flow control
Case study: Example #2.4
• Printing the full Multiplication Table
Print out from
the program:
How many times each
of these print statements
is executed?
50. 50 of 81Module 6 : Flow control
Case study: Example #2.5
• Print a pattern, e.g., triangular pattern:
First… observe and
analyze the pattern…
How many stars on each level?
How many leading white spaces?
54. 54 of 81Module 6 : Flow control
Topics
• Basic Concepts: Why Selection and Repetition
• Selection (Branching)
• Basic concepts
• Case study: Paper Scissor Rock
• Syntax
• Examples in Python
• Repetition (Looping)
• Basic concepts: for and while
• Syntax: while
• The range function
• Syntax: for
• Nested loops
• break, continue, and pass
• Case Study: Visual Example - Path of a projectile
55. 55 of 81Module 6 : Flow control
What are break and continue?
• Python keywords that can alter control flow
in a loop
• Let’s start with the following simple loop:
- What will be printed if we
run this program?
- How many times the loop
is iterated?
- Note the else: statement
for while
57. 57 of 81Module 6 : Flow control
break
• Meaning: Executing break exits the immediate
loop that contains it
Compared to prev. page:
We add if and break
Control flow knowledge:
Go after the whole
enclosing loop
59. 59 of 81Module 6 : Flow control
break
• How if we include everything in a for loop?
This time, we add the outer for
Basically a for statement
The print-out doubled!!
Note: break affects only the
inner loop that contains it
61. 61 of 81Module 6 : Flow control
continue
• Skips the rest of the loop body and goes back to
the test in the loop that contains it
Compare to prev. page:
We add if and continue
Control flow knowledge:
Go immediately to test
in the enclosing loop
62. 62 of 81Module 6 : Flow control
continue
• If we run the program, print “here2” will only
be reached two times… why?
For continue, make sure
loop control variable can be
updated. Else infinite loop!
here3’s
back!
64. 64 of 81Module 6 : Flow control
Topics
• Basic Concepts: Why Selection and Repetition
• Selection (Branching)
• Basic concepts
• Case study: Paper Scissor Rock
• Syntax
• Examples in Python
• Repetition (Looping)
• Basic concepts: for and while
• Syntax: while
• The range function
• Syntax: for
• Nested loops
• break, continue, and pass
• Case Study: Visual Example - Path of a projectile
65. 65 of 81Module 6 : Flow control
Case Study: Path of a projectile
• In many computer games, we can see parabolas,
which are the trajectories of throwing objects
But how to compute a parabola?
From http://www.youtube.com/watch?v=bNNzRyd1xz0
You are advised to try and go through this
example yourself with Python and Excel
66. 66 of 81Module 6 : Flow control
Input and coordinate system
• First, what is our input?
• Let’s say:
u – initial velocity
a – angle
• 2D Coordinate System:
x – along horizon
y – height
0
y
x
u
horizon
a
x
y u
a
67. 67 of 81Module 6 : Flow control
Initial velocity along x and y
• In Physics, we know that we can decompose
u into two components (vector decomposition):
ux – initial velocity along x, which is u cos(a)
uy – initial velocity along y, which is u sin(a)
u sin(a) u
a
u cos(a)
68. 68 of 81Module 6 : Flow control
The Physics
• First, let’s look at the Physics…
• We can use the following formula:
s = u t + ½ a t2
where
• s = distance travelled (in m)
• u = initial velocity (in ms-1)
• t = time (in s)
• a = acceleration (in ms-2)
(unit: m – meter, s – second)
69. 69 of 81Module 6 : Flow control
The Physics
• Along x, we assume no external forces, i.e.,
a = 0
Thus, traveled distance along x at time t is:
x = ux t
• Along y, we have gravity, and so, we put a = g,
which is the gravitational field constant:
a = g = -9.8ms-2
Thus, traveled distance along x at time t is:
y = uy t – 4.9 t2
70. 70 of 81Module 6 : Flow control
To compute the parabola…
• To compute the parabola, we need looping to
incrementally compute the x and y locations of
the object over time
More important things…
• Loop control variable: time t and t starts from 0
• When to stop?
Ans: object reaches the ground again or y < 0
(of course, you may have more complicated
stopping criteria, say hitting an object)
71. 71 of 81Module 6 : Flow control
Implementation #1: Initialization
(note: implementation continues on in next page)
How detail we compute
the parabola path; change
this value yourself and try
Need radian for
cos and sin
Need math module
73. 73 of 81Module 6 : Flow control
Results
• A long list of coordinates, output in IDLE shell
How can we know
that the computed
parabola is correct?
Perhaps error here?
How to verify?
74. 74 of 81Module 6 : Flow control
Verify… Plot it with Excel #1
• We can first select the coordinate outputs (with
mouse) in IDLE and click copy in IDLE
• Then, we can open a text editor, and paste the
coordinates into a brand-new text file as follows:
75. 75 of 81Module 6 : Flow control
Verify… Plot it with Excel #2
• After that, we may load the text file into Excel
as a space-delimited text file:
Open the text file by Excel
check delimited, and next
Then check space, next
and finish
76. 76 of 81Module 6 : Flow control
Verify… Plot it with Excel #3
• Then, we can use the graph plotting function in
Excel to plot the two lists of coordinates:
y
x
I just use XY scatter plot
77. 77 of 81Module 6 : Flow control
More to try…
• You can change the initial velocity and plot more
series in the same plot: u = 100,80,60
When you verify, you have to ask
yourselves “Does it make sense?”
78. 78 of 81Module 6 : Flow control
Or… to try…
• You can change the initial angle and plot more
series in the same plot: a = 45,60,75
What is the angle for the optimal distance along X?
You can try the code (or try implement yourself) on Edventure
79. 79 of 81Module 6 : Flow control
Take Home Messages
• General structure of a loop:
– Initialize; Test; Loop body; Update
• Concepts: loop control variable, counter-controlled and
sentinel-controlled loops, nested loops
• Syntax: while, for, and range
• Reminders:
– Dry run and check the number of iterations!!!
One more or one less iteration can kill the program… bug!!!
– Understand how and when to stop!!!
– Use break and continue very carefully!!!
– Read (trace code and logic) and try (work it out) more examples...
– Always test and verify your code
Think and try test data that causes different consequences!!!
Practice! Practice!! Practice!!!
80. 80 of 81Module 6 : Flow control
More…
• Again the four levels of skills
like module 6.1
– #1 Understand: trace and
understand code: control flow
– #2 Analysis: Given a problem,
think and analyze carefully the
logic
– #3 Apply: Transform the logic
appropriately into for or while loops
– #4 Test: test data to evaluate with
different consequences
• Practice!
Practice!!
Practice!!!
What is/are to be printed out?
81. 81 of 81Module 6 : Flow control
Reading Assignment
• Textbook
Chapter 2: Control
2.1 to 2.4
Note: Though some material (2.3 and 2.4) in
textbook is not directly related to the lecture
material, you can learn more from them. Note:
other than using Excel, Python has module
pylab for graph plotting (see 2.4)