Introduction to Programming with Python

Slides:



Advertisements
Similar presentations
Computer Science & Engineering 2111 Text Functions 1CSE 2111 Lecture-Text Functions.
Advertisements

Intro to Python Welcome to the Wonderful world of GIS programing!
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Programming in python Lesson 2.
Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
Chapter 2: Variables, Operations, and Strings CSCI-UA 0002 – Introduction to Computer Programming Mr. Joel Kemp.
Bell Ringer What types are numbers are there is the python programming language?
Python Lesson Week 01. What we will accomplish today Install Python on your computer Using IDLE interactively to explore String Variables if/else while.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
Introduction to Javascript. What HTML Can & Can Not Do HTML Can HTML Can Display text Display text Display images Display images Display even animated.
Lesson 6. Python 3.3 Objectives. In this lesson students will learn how to output data to the screen and request input from the user. Students will also.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 1 Simple Python Programs Using Print, Variables, Input.
Please log on The. AN INTRODUCTION TO ‘Python is a high-level, general purpose programming language’ Python is one of the many programming languages.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Variables and Assignment CSIS 1595: Fundamentals of Programming and Problem Solving 1.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
C NOTATION Some very short story of C notation – 'convention' used in writing C codes © 1/4.
Agenda  Take up homework  Loops - Continued –For loops Structure / Example involving a for loop  Storing Characters in variables  Introduction to Functions.
Strings CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Strings CSE 1310 – Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington 1.
Strings CSE 1310 – Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington 1.
1 JavaScript and Dynamic Web Pages Lecture 7. 2 Static vs. Dynamic Pages  A Web page uses HTML tags to identify page content and formatting information.
Introduction to Python Lesson 2a Print and Types.
Input, Output and Variables GCSE Computer Science – Python.
Strings CSE 1310 – Introduction to Computers and Programming
Introduction to Programming using Python
Strings CSE 1310 – Introduction to Computers and Programming
Strings CSE 1310 – Introduction to Computers and Programming
Introduction to Programming
CMSC201 Computer Science I for Majors Lecture 02 – Intro to Python
String Methods Programming Guides.
Chapter 6 JavaScript: Introduction to Scripting
Overview of c# Programming
Input and Output Upsorn Praphamontripong CS 1110
Lesson 1 An Introduction
Computing Fundamentals
Design & Technology Grade 7 Python
Variables, Expressions, and IO
Introduction to Scripting
To write a Python program, you first need to open Pyscripter
Sequential Structures
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 2 Applications and Data.
G7 programing language Teacher / Shamsa Hassan Alhassouni.
Introduction to Programming with Python
Introduction to Programming with Python
Displaying text print Susan Ibach | Technical Evangelist
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Manipulating Text In today’s lesson we will look at:
Introduction to Programming using Python
Microsoft Azure Fundamentals Microsoft Azure මූලික දැනුම
“If you can’t write it down in English, you can’t code it.”
Chapter 3 – Introduction to C# Programming
Inputs and Variables Programming Guides.
A look at Python Programming Language 2018.
Introduction to Programming with Python
Chapter 2: Introduction to C++.
JavaScript.
Introduction to Programming with Python
Introduction to Programming with Python
JavaScript: Introduction to Scripting
Input and Output Python3 Beginner #3.
Python Lessons 7 & 8 Mr. Husch.
L L Line CSE 420 Computer Games Lecture #3 Introduction to Python.
Starter Which of these inventions is: Used most by people in Britain
What you need to do… Drag the pieces of code into the correct order like you can see in the EXAMPLE below. print ( “ int input ) = + Hello world chr ord.
CS 1111 Introduction to Programming Spring 2019
GCSE Computing.
Data Types and Expressions
PYTHON - VARIABLES AND OPERATORS
Presentation transcript:

Introduction to Programming with Python String විචල්‍යයන් හා පරිශීලක ආදානයන් ලබාගැනීම Dileepa S. Rajapaksa | http://www.windowsgeek.lk @dsrajapaksa Microsoft Virtual Academy

කලින් Video එකේ අපි කතා කලේ මොනවාද? Print Command එක මඟින් Text එකක් තිරයේ display කරන ආකාර පේලි කීපයකින් යුත් වාක්‍යයක් display එකට output කරන අයුරු Single Quotes, Double Quotes, Triple Quote භාවිතාවන අයුරු \n , \ වැනි escape sequence භාවිත වන ස්ථානයන් Microsoft Virtual Academy

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

String විචල්‍යයන් හා පරිශීලක ආදානයන් ලබාගැනීම Input Last part Practice your language Microsoft Virtual Academy

User ගෙන් Input එකක් ලබාගන්න පුළුවන්නම් ගොඩාක් වැඩ කරන්න පුළුවන්. Website වලින් ලිපිනය , Credit card විස්තර ලබාගැනීමෙන් Userගේ ගෙදරටම භාණ්ඩ එවන්න පුළුවන්. රක්ෂණ සමාගම් වලට පාරිභෝගිකයාගේ විස්තර අවශ්‍යයි. Calculator එකටත් අංක ඇතුලත්කර පිළිතුරු ලබාගත හැකිය Cortana ඕනෑම දෙයකට උත්තර දෙනවා අපි ප්‍රශ්ණයක් ඇහුවොත්. Microsoft Virtual Academy

අපි Userගෙන් තොරතුරු ලබාගන්නේ කොහොමද? name = input("What is your name? ") Input function එක මගින් හැකියාවක් තියෙනවා Message එකක් user ට display කරන්න සහ user Type කරන values නැවත් ලබාගන්න. අපි variables භාවිතා කරන්නේ User ඇතුලත් කරන Values මතකයේ තබාගන්න. අපේ මේ උදාහරණයේ තියෙන variable එකේ නම තමයි name කියන්නේ.අපිට ඒ සඳහා ඕනෑම නමක් දෙන්න පුළුවන් හැබැයි space හැර. Microsoft Virtual Academy

Demo User inputs ලබාගැනීම Microsoft Virtual Academy

අපි මේ values ගබඩාකරලා තියාගනේ කොහේද? Last part Practice your language Microsoft Virtual Academy

Variable එකක් සාමාන්‍ය පෙට්ටියක් විදිහට සලකමු… අපිට කැමති වෙලාවක ඒකට යම් කිසි දෙයක් දාන්න සහ ඉවතට ගන්න හැකියාව තියනවා… name Amal Microsoft Virtual Academy

Amal Avengers Colombo favoriteMovie name city Value එකකට වඩා, ගබඩාකරලා තියාගැනීමට අවශ්‍යනම්, තවත් variables සෑදියයුතුයි. favoriteMovie name Amal Avengers city Colombo Microsoft Virtual Academy

ඔබට ගබඩාකල අගයන් නැවත භාවිතාකරන්නට පුළුවන්. name = input("What is your name? ")   print(name) Microsoft Virtual Academy

ඒවගේම ඒ අගයන් පසුව Code එකෙන්ම වෙනස්කරගන්නත් පුළුවන්. name = input("What is your name? ")   print(name) name = "Mary" Microsoft Virtual Academy

Demo User ඇතුලත්කල අගයන් නැවත භාවිතාකිරීම Microsoft Virtual Academy

Variables ගැන … Microsoft Virtual Academy Last part Practice your language Microsoft Virtual Academy

Variable සඳහා නම් නීති නිර්දේශය හිස්තැන් ඇතුලත්විය නොහැක. Case sensitive firstName හා firstname යනු වෙනස් Variable දෙකකි. අංකයකින් ආරම්භ කල නොහැකියි. නිර්දේශය සවිස්තරාත්මක වියයුතුයි ඒත් වඩා දිගු නොවියයුතුයි. (favoriteApp not yourFavoriteAppInWindowsPhone) Casing ක්‍රම camelCasing හෝ PascalCasing Microsoft Virtual Academy

පහත ඒවායෙන් Variable එකක් සඳහා සුදුසු නම් මොනවාද? First Name Date 3Name DOB DateOfBirth YourFavoriteSignInTheHoroscope Microsoft Virtual Academy

Variable මෙහෙයවීම - Variable Manipulation Last part Practice your language Microsoft Virtual Academy

+ ලකුණ මගින් Variable හා Strings එකතු කළහැකියි. firstName = input("What is your first name? ") lastName = input("What is your last name? " ) print("Hello" + firstName + lastName) Microsoft Virtual Academy

හිස්තැන් හෝ විරාම ලකුණු යෙදීම firstName = input("What is your first name? ") lastName = input("What is your last name? " ) print("Hello " + firstName + " " + lastName) Microsoft Virtual Academy

Demo Variable මෙහෙයවීම Microsoft Virtual Academy

Story teller program එකක් නිර්මාණය කරන්න ඔබට පුළුවන් animal = input("What is your favorite animal? " ) building = input("Name a famous building: ") color = input("What is your favorite color? ") print("Hickory Dickory Dock!") print("The "+color+" "+animal+" ran up the "+building) Microsoft Virtual Academy

Variable තුළ ඇති Content මෙහෙයවීමට ඔබට හැකියාවක් තියෙනවා message = 'Hello world' print(message.lower()) print(message.upper()) print(message.swapcase()) Microsoft Virtual Academy

Demo String functions මගින් values මෙහෙයවීම Microsoft Virtual Academy

Geek Tip! lower, upper, සහ swapcase යනු එකිනෙකට වෙනස් string functions වේ. අප විසින් Variable එක තුල ගබඩා කරනු ලබන්නේ String එකක් නිසා අපට Python String Functions භාවිතයෙන් මෙම strings හැසිරවිය හැකිය. Microsoft Virtual Academy

මේ Functions වලින් මොකද කරන්නේ ? message = 'Hello world' print(message.find('world')) print(message.count('o')) print(message.capitalize()) print(message.replace('Hello','Hi')) Microsoft Virtual Academy

Demo Find, count, functions භාවිතා කරන ආකාරය Microsoft Virtual Academy

Visual Studio awesomeness Last part Practice your language Microsoft Virtual Academy

pop up list එක දැක්කාද? ඒකට කියන්නේ IntelliSense. ‘.’ Type කලවිට ඔබට භාවිතාකලහැකි functions ලැයිස්තුවක් ඔබට Visual Studio විසින් පෙන්වනවා. ඔබට CTRL+J හෝ CTRL+SPACE භාවිතයෙන් IntelliSense Launch කරන්න පුළුවන්. Microsoft Virtual Academy

Demo IntelliSense Microsoft Virtual Academy

Programmers ලා මේ හැම Function එකක්ම මතක තියාගෙන ඉන්නේ නැහැ IntelliSense Documentation Internet එකේ සෙවීමෙන් Microsoft Virtual Academy

අපි කොහොමද? Country code එක මොන විදිහට Type කලත් ඒක Upper Case වලින් පෙන්වන විදිහ. countryCode = input("Please enter your country code: ") print(countryCode.upper()) Microsoft Virtual Academy

Demo Uppercase වලට පරිවර්තනය Microsoft Virtual Academy

ඔබ දුටුවාද ? postalCode = " " Variables සමඟ වැඩකිරීමේදී IntelliSense ඇතැම්විට වැඩ කරන්නේ නෑ. ඇතැම් අවස්තාවලදී Variable එකේ string value එකක් ගබඩාකරන්න යනබව අපේ program එක දන්නේ නැති හින්දා. ඕනෑම Programming Language එකකදී තමන්ගේ variable initialize කරතැබීම හොඳපුරුද්දක්. ඒ කියන්නේ ඒ variable හදද්දිම ඒවාට ආරම්භක value එකක් දෙන එක. postalCode = " " postalCode = input("Please enter your postal code: ") print(postalCode.upper()) Microsoft Virtual Academy

කොහොමද කරන්නේ.. කොහොමද අපි user ගෙන් නම අරගෙන මුල් නමේ මුල් අකුර uppercase වලට හරවලා ඉතිරිය lowercase වලින් තියන්නේ. name = " "  name = input("Please enter your name: ") print(name.capitalize()) Microsoft Virtual Academy

Demo capitalize() එක භාවිතය Microsoft Virtual Academy

Functions හා variables මගින් අපිට තවත් වැරදි සිදුවෙන්න ඉඩ තියෙනවා. පහත හැම code පේලියකම වැරද්දක් තියෙනවා… message = Hello world 23message = 'Hello world' New message = 'Hi there' print(message.upper) print(mesage.lower()) print(message.count()) message = 'Hello world' 23message = 'Hello world' New message = 'Hi there' print(message.upper()) print(message.lower()) print(message.count('H')) Microsoft Virtual Academy

ඔබේ අභියෝගය… තමන්ට තමන්ගේම කතාවක් නිර්මාණය කරන්න පුළුවන් වැඩසටහනක් නිර්මාණය කරන්න. තමන්ගේම කතාවක් හෝ පොතකින් කතාවක් ලබාගන්න. කතාවට User ගෙන් name, place, adjectives, adverbs වගේ තොරතුරු ලබාගෙන එවා කතාවේ අදාල තැන්වලට යොදන්න.දැන් තමන්ගේම කතාවක් Userට පෙන්වන්න. User විසින් type කරන ඕනෑම වචනයක ඇති uppercase, lowercase භාවිතයන් නිවැරදි කරන්න. ( උදා: Adjective සඳහා uppercase භාවිතාකරනවා නම් එය lowercase වලට හැරවියයුතුයි ) Microsoft Virtual Academy

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

සාරාංශය… User කෙනෙක් ගෙන් input එකක් ලබා ගන්න අයුරු විචල්‍යයන් නැතහොත් variable ගැන Variable එකකට අගයක් ගබඩා කරන හැටි සහ එය නැවත භාවිත කරන අයුරු Variables අවශ්‍ය අකාරයට හසුරවන ආකාරය Microsoft Virtual Academy