Introduction to Programming with Python

Slides:



Advertisements
Similar presentations
Branch Admin Panel Queue Pro: Queue Management System.
Advertisements

Nested Loops. Nesting Control Structures One if statement inside another one An if statement inside a loop A loop inside an if statement Control structures.
COMPUTER SCIENCE FEBRUARY 2011 Lists in Python. Introduction to Lists Lists (aka arrays): an ordered set of elements  A compound data type, like strings.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
A revision guide for programming with python. 1.A program is a set of instructions that tells a computer what to do. 2.The role of a programmer is to.
AE1205 Programming Python Quiz: so how do we generate Numbers 1 to 10? range( ) Numbers 5,10,15,20,25 to 100? range( ) Numbers 20,18,16, to 0? range( )
OCR Computing GCSE © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 12: A few other things.
2016 N5 Prelim Revision. HTML Absolute/Relative addressing in HTML.
Visual Basic.NET BASICS Lesson 11 List Boxes, For Next Loops, and Label Settings.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
PYTHON WHILE LOOPS. What you know While something is true, repeat your action(s) Example: While you are not facing a wall, walk forward While you are.
For Loop GCSE Computer Science – Python. For Loop The for loop iterates over the items in a sequence, which can be a string or a list (we will discuss.
Python - Iteration A FOR loop is ideal if we know how many times we want to repeat. Try this code: for loopCounter in range(10): print(loopCounter) There.
Controlling Program Structures. Big Picture We are learning how to use structures to control the flow of our programs Last week we looked at If statements.
PYTHON PROGRAMMING LANGUAGE.
Python - Iteration A FOR loop is ideal if we know how many times we want to repeat. Try this code: for loopCounter in range(10): print(loopCounter) There.
Introduction to Python
Python Loops and Iteration
Learning Intention Learning Intention: To develop understanding of variables, data types, and comments in text based programming languages Context: Sequencing.
Warm-up Program Use the same method as your first fortune cookie project and write a program that reads in a string from the user and, at random, will.
Lesson 3 - Repetition.
And now for something completely different . . .
Chapter 5 Repetition.
පාඨමාලා මාතෘකා Microsoft SQL Server Databases සැකසීම
Introduction to System Programming
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Mobile Development Workshop
Introduction to Programming with Python
Microsoft Azure Fundamentals Microsoft Azure මූලික දැනුම
Introduction to pseudocode
Introduction to Programming with Python
Introduction to Programming with Python
Introduction to Programming with Python
Introduction to Programming with Python
Introduction to Programming with Python
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Customizing Views Views Customize කර ගැනීම
Introduction to Programming using Python
ETI Base Code ETI මුලධර්මයන් හදුනාගනිමු
Microsoft Azure Fundamentals Microsoft Azure මූලික දැනුම
මුහම්මද් සල්ලල්ලාහු අලෙයිහි වසල්ලම්
Basics of MVC MVC වල මුලික කොටස්
Loops CIS 40 – Introduction to Programming in Python
Microsoft Azure Fundamentals Microsoft Azure මූලික දැනුම
Creating and Configuring Models Models create කිරීම සහ config කර ගැනීම
වී පොහොර සහනාධාර මුදල් ප්‍රදාන වැඩසටහන 2017/18 මහ කන්නය
Customizing Controllers Controllers Customizing කර ගැනීම
Three Special Structures – Case, Do While, and Do Until
Python 21 Mr. Husch.
A look at Python Programming Language 2018.
Topics Augmented Assignment Operators Sentinels Input Validation Loops
‘Shifters’ in bilingual education : Problems and challenges of learning through a second language Marie Perera 1Department of Humanities Education, University.
Introduction to Programming with Python
Electoral system in Sri lanka
CS 1111 Introduction to Programming Spring 2019
Introduction to Programming with Python
CHAPTER 6: Control Flow Tools (for and while loops)
Introduction to Programming with Python
Microsoft Azure Fundamentals Microsoft Azure මූලික දැනුම
Introduction to Programming with Python
මොඩියුල විශ්ලේෂණය Stored Procedure හඳුන්වා දීම.
Introduction to Programming with Python
Introduction to Computer Science
Print the following triangle, using nested loops
Python While Loops.
Introduction to Python
Iteration – While Loops
LOOP Basics.
Introduction to Computer Science
Flow Control I Branching and Looping.
Presentation transcript:

Introduction to Programming with Python නොදන්නා වාර ගණනක් පුනරාවර්තනය කිරීම Dileepa S. Rajapaksa | http://www.windowsgeek.lk @dsrajapaksa Microsoft Virtual Academy

කලින් Video එකෙන් … Loops භාවිතය Turtle library එක මඟින් නිර්මාණ ඇදීම Loop එක ඇතුලත variable එකක් භාවිතය Nested loops භාවිතා කිරීම Loop එක තුල ඔබේම අගයන් ලබාදීම Microsoft Virtual Academy

Demo කලින් Video එකේ අභියෝගයට පිළිතුරු Microsoft Virtual Academy

නොදන්නා වාර ගණනක් නැවත නැවත කිරීම While Loops Last part Practice your language Microsoft Virtual Academy

For Loop එකෙන් අපිට අවස්ථාව ලැබෙන්නේ ස්ථීර වාර ගණනක් සඳහා Loop කිරීමටයි අපි දන්නවානම් අමුත්තන් 20ක් ඉන්නවා කියලා අපිට නම් සඳහන් කාඩ්පත් 20ක් print කරන්න පුළුවන්. for steps in range(20):      Microsoft Virtual Academy

වාර ගණන නොදන්නා අවස්ථාවක මොකද කරන්නේ …? පිඟන් සෝදන්න සියළුම පිඟන් පිරිසිදුවෙනතෙක්. හරි පිළිතුර ලැබෙන තාක් දිගටම අනුමාන කරන්න . file එකක හෝ database එකක ඇති සියළුම අගයන් අවසන් වන්තුරු කියවන්න. Microsoft Virtual Academy

Loop එකේ භාවිතා කිරීමට පෙර variable එක සෑදිය යුතුයි. එක්තරා condition එකක් සත්‍යවන තාක් Loop එකක් ක්‍රියාත්මක කිරීමට While Loop එකෙන් පුළුවන්. Loop එකේ භාවිතා කිරීමට පෙර variable එක සෑදිය යුතුයි. answer = "0" while answer != "4": answer = input("What is 2 + 2 ") print ("Yes! 2 + 2 = 4") variable එකෙහි අගය 4ට සමාන නොවනතාක් Code එක නැවත නැවත ක්‍රියාත්මක කරන්න. නැවත නැවත ක්‍රියාත්මක වෙනේ indent වුන code එක විතරයි.ඒ නිසා මේ code එක ක්‍රියාත්මකවෙනේ loop එකෙන් ඉවත් වුනාට පස්සේ. Microsoft Virtual Academy

Demo While loop Microsoft Virtual Academy Last part Practice your language Microsoft Virtual Academy

මේ code එකෙන් කරන්නේ මොකක්ද කරන්නේ කියලා තේරුම්ගන්න පුළුවන්ද? ඔව් එමගින් සමචතුරස්‍රයක් ඇඳෙනවා. import turtle counter = 0 while counter < 4:     turtle.forward(100)     turtle.right(90)     counter = counter+1 Microsoft Virtual Academy

For Loop එක වෙනුවට while loop එක භාවිතා කරන්න පුළුවන්. import turtle for steps in range(4):      turtle.forward(100)      turtle.right(90) import turtle counter = 0 while counter < 4:     turtle.forward(100)     turtle.right(90)     counter = counter+1 Microsoft Virtual Academy

මේ loop එකෙන් රේඛා කීයක් අඳිනවාද? රේඛා 5ක් අඳිනවා 4ක් නෙමෙයි. import turtle counter = 0 while counter <= 4:     turtle.forward(100)     turtle.right(90)     counter = counter+1 Microsoft Virtual Academy

මේ loop එකෙන් රේඛා කීයක් අඳිනවාද? රේඛා 3ක් අඳිනවා 4ක් නෙමෙයි. import turtle counter = 1 while counter < 4:     turtle.forward(100)     turtle.right(90)     counter = counter+1 Microsoft Virtual Academy

Loop කිරීමේ ප්‍රශ්ණ Microsoft Virtual Academy Last part Practice your language Microsoft Virtual Academy

මේ loop එකෙන් රේඛා කීයක් අඳිනවාද? මේක දිගටම ක්‍රියාත්මක වෙනවා.ඒ Counter variable එකේ අගය කිසිඳු වෙනසක් සිදුනොවන නිසා. ! සමහර විට මේවගේ අත්වැරදීම් සිද්ධවෙනවා. මෙවන් loops, infinite loops යැයි හදුන්වනවා import turtle counter = 0 while counter < 3:     turtle.forward(100)     turtle.right(90)      Microsoft Virtual Academy

Demo Infinite Loop එකකින් ඉවත්වෙන්නේ කෙසේද? Microsoft Virtual Academy Last part Practice your language Microsoft Virtual Academy

For loop වලට වඩා while loop වලින් අත්වැරදීම් සිද්ධ වෙන්න පුළුවන් අවස්ථාව වැඩී. Microsoft Virtual Academy

While loop එකට බයවෙන්න එපා මෙය නිතර භාවිතාවෙනවා දත්ත කියවීමේදී (දත්ත නැති තාක් කියවීමට ) Microsoft Virtual Academy

ඔබේ අභියෝගය… etch a sketch වැඩසටහනක් නිර්මාණය කරමු පෑනේ වර්ණය , රේඛා වල දිග සහ කෝණය Userගෙන් ලබාගන්න. turtle භාවිතයෙන් ඉහත තොරතුරු වලට අනුව රූපය අඳින්න. User විසින් රේඛාවල දිග 0 ලෙස දුන්විට අඳීම නවත්වන්න. Microsoft Virtual Academy

සාරාංශය … නොදන්නා වාර ගණනක් නැවත නැවත කිරීම While loop එක භාවිතය Infinite loop එකක් යනු කුමක්ද Microsoft Virtual Academy

සුභ පැතුම් ! ඔබට දැන් යම්කිසි සිදුවීමක් නොදන්නා වාරගණනක් කිරීමට හැකියි… Microsoft Virtual Academy