Selamat Datang di “Programming Essentials in Python”

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Question Bank. Explain the syntax of if else statement? Define Union Define global and local variables with example Concept of recursion with example.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
I210 review Fall 2011, IUB. Python is High-level programming –High-level versus machine language Interpreted Language –Interpreted versus compiled 2.
Lists Introduction to Computing Science and Programming I.
CS 330 Programming Languages 10 / 14 / 2008 Instructor: Michael Eckmann.
Math class methods & User defined methods Introduction to Computers and Programming in JAVA: V
Python quick start guide
Introduction to Python Basics of the Language. Install Python Find the most recent distribution for your computer at:
Python November 28, Unit 9+. Local and Global Variables There are two main types of variables in Python: local and global –The explanation of local and.
Course A201: Introduction to Programming 11/04/2010.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Chapter Function Basics CSC1310 Fall Function function (subroutine, procedure)a set of statements different inputs (parameters) outputs In.
With Python.  One of the most useful abilities of programming is the ability to manipulate files.  Python’s operations for file management are relatively.
Introducing Python CS 4320, SPRING Resources We will be following the Python tutorialPython tutorial These notes will cover the following sections.
CSCI/CMPE 4341 Topic: Programming in Python Review: Exam I Xiang Lian The University of Texas – Pan American Edinburg, TX 78539
Python Functions.
Introduction to Computing Using Python for loop / def- ining a new function  Execution control structures ( if, for, function call)  def -ining a new.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
I Power Higher Computing Software Development High Level Language Constructs.
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Methods. Methods also known as functions or procedures. Methods are a way of capturing a sequence of computational steps into a reusable unit. Methods.
Function Basics. Function In this chapter, we will move on to explore a set of additional statements that create functions of our own function (subroutine,
PYTHON FUNCTIONS. What you should already know Example: f(x) = 2 * x f(3) = 6 f(3)  using f() 3 is the x input parameter 6 is the output of f(3)
 Python for-statements can be treated the same as for-each loops in Java Syntax: for variable in listOrstring: body statements Example) x = "string"
PROGRAMMING USING PYTHON LANGUAGE ASSIGNMENT 1. INSTALLATION OF RASPBERRY NOOB First prepare the SD card provided in the kit by loading an Operating System.
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
 The real power of PHP comes from its functions; it has more than 1000 built-in functions.  PHP User Defined Functions  Besides the built-in PHP functions,
ITM 3521 ITM 352 Functions. ITM 3522 Functions  A function is a named block of code (i.e. within {}'s) that performs a specific set of statements  It.
Lesson 3 Functions. Lesson 3 Functions are declared with function. For example, to calculate the cube of a number function function name (parameters)
Information and Computer Sciences University of Hawaii, Manoa
Lesson 06: Functions Class Participation: Class Chat:
Exam #1 You will have exactly 30 Mins to complete the exam.
Topics Introduction to Functions Defining and Calling a Void Function
Introduction to Python
CHAPTER 4 CLIENT SIDE SCRIPTING PART 3 OF 3
Tuples and Lists.
CMSC201 Computer Science I for Majors Lecture 17 – Dictionaries
Containers and Lists CIS 40 – Introduction to Programming in Python
Variables, Expressions, and IO
Functions CIS 40 – Introduction to Programming in Python
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Functions.
JavaScript: Functions.
11/10/2018.
CHAPTER FOUR Functions.
Arrays, For loop While loop Do while loop
Learning to Program in Python
Functions BIS1523 – Lecture 17.
Python Primer 2: Functions and Control Flow
CS190/295 Programming in Python for Life Sciences: Lecture 6
Coding Concepts (Sub- Programs)
Lesson 06: Functions Class Chat: Attendance: Participation
CSC1018F: Intermediate Python
Tonga Institute of Higher Education
Basics (Cont...).
G. Pullaiah College of Engineering and Technology
Topics Introduction to Functions Defining and Calling a Function
Introduction to Computer Science
Class code for pythonroom.com cchsp2cs
ITM 352 Functions.
 A function is a named sequence of statement(s) that performs a computation. It contains  line of code(s) that are executed sequentially from top.
Python Basics. Topics Features How does Python work Basic Features I/O in Python Operators Control Statements Function/Scope of variables OOP Concepts.
Dictionary.
Tuple.
Selamat Datang di “Programming Essentials in Python”
Selamat Datang di “Programming Essentials in Python”
Presentation transcript:

Selamat Datang di “Programming Essentials in Python” Instruktur: Hendi Hermawan, S.T., M.T.I. hendiananta@gmail.com / 085710098205

Profil Hendi Hermawan, S.T., M.T.I. hendiananta@gmail.com / 085710098205 Dosen: Teknik Informatika, UMB, 2004-2010 Multimedia, STDI Interstudi, 2010-2014 Teknik Informatika, STTI NIIT I-Tech, 2005-2014 Teknik Informatika, Univ. Pembangunan Jaya, 2014-skg Instruktur Cisco Academy Indonesia Founder depokhosting.com

Silabus “Programming Essentials in Python” Senin - Part 1: Basics Modul 1 - Introduction to python and computer programming Modul 2 - Data types, variables, basic input-output operations, basic operators Modul 3 - Boolean values, conditional execution, loops, lists and list processing, logical and bitwise operations Selasa - Part 1: Basics Modul 4 - Functions, tuples, dictionaries, and data processing

Silabus “Programming Essentials in Python” Rabu - Part 2: Intermediate Modul 5 - Modules, packages, string and list methods, and exceptions Kamis - Part 2: Intermediate Modul 6 - The object-oriented approach: classes, methods, objects, and the standard objective features; exception handling, and working with files Jum’at Review materi Ujian Teori Ujian Praktek

Function, Tuples, Dictionaries, and Data Processing Modul 4

In This Module, You Will Learn About Defining and using functions; Different ways of passing arguments; Name scopes; Tuples and dictionaries; Data processing.

Function A function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function. A function can return data as a result.

Function - Creating & Calling a Function A function is defined , using the def keyword, example:

Function - Creating & Calling a Function Example: Output:

Function - Parametrized Functions Information can be passed to functions as parameter. Parameters are specified after the function name, inside the parentheses. You can add as many parameters as you want, just separate them with a comma. The following example has a function with one parameter (fname). When the function is called, we pass along a first name, which is used inside the function to print the full name

Function - Parametrized Functions Example Output:

Function - Default Parameter Value The following example shows how to use a default parameter value. If we call the function without parameter, it uses the default value. Example: Output:

Function - Default Parameter Value Example: Output:

Function - Return Values To let a function return a value, use the return statement Example: Output:

Function - Return Values

Function - Passing a List as a Parameter You can send any data types of parameter to a function (string, number, list, dictionary etc.), and it will be treated as the same data type inside the function. E.g. if you send a List as a parameter, it will still be a List when it reaches the function. Example: Output:

Function - Functions and scopes A variable existing outside a function has a scope inside the functions' bodies, excluding those of them which define a variable of the same name. Example: Output:

Function - Functions and scopes The global keyword Using this keyword inside a function with the name (or names separated with commas) of a variable(s), forces Python to refrain from creating a new variable inside the function - the one accessible from outside will be used instead. Output:

Function – Two or More Parameter Example: Let's get started on a function to evaluate the Body Mass Index (BMI). It seems that this new function will have two parameters. Its name will be bmi, but if you prefer any other name, use it instead. Let's code the function.

Function – Two or More Parameter Example: Output:

Function – Recursion Python also accepts function recursion, which means a defined function can call itself. Recursion is a common mathematical and programming concept. It means that a function calls itself. This has the benefit of meaning that you can loop through data to reach a result.

Function – Recursion Example: Output:

Tuples A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets. Example: Output:

Tuples What else can tuples do for you? the len() function accepts tuples, and returns the number of elements contained inside; the + operator can join tuples together (we've shown you this already) the * operator can multiply tuples, just like lists; the in and not in operators work in the same way as in lists.

Tuples Example: Output:

Dictionary A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values. Example