An Introduction to Linux

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

Conditional statements and Boolean expressions. The if-statement in Java (1) The if-statement is a conditional statement The statement is executed only.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 5, 2005.
Loops – While Loop Repetition Statements While Reading for this Lecture, L&L, 5.5.
5-1 Flow of Control Recitation-01/25/2008  CS 180  Department of Computer Science  Purdue University.
Introduction to Computer Programming Decisions If/Else Booleans.
Loops – While, Do, For Repetition Statements Introduction to Arrays
ECE122 L7: Conditional Statements February 20, 2007 ECE 122 Engineering Problem Solving with Java Lecture 7 Conditional Statements.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
Relational Operators Control structures Decisions using “if” statements  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
ECE122 L9: While loops March 1, 2007 ECE 122 Engineering Problem Solving with Java Lecture 9 While Loops.
COMP 110 Introduction to Programming Mr. Joshua Stough September 24, 2007.
CONTROL STATEMENTS Lakhbir Singh(Lect.IT) S.R.S.G.P.C.G. Ludhiana.
AN INTRODUCTION TO LINUX OPERATING SYSTEM Zihui Han.
Python quick start guide
CHAPTER 4: CONDITIONAL STRUCTURES Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
PAGES:51-59 SECTION: CONTROL1 : DECISIONS Decisions.
1. We’ve learned that our programs are read by the compiler in order, from top to bottom, just as they are written The order of statement execution is.
© 2004 Pearson Addison-Wesley. All rights reserved February 17, 2006 The ‘while’ Statement ComS 207: Programming I (in Java) Iowa State University, SPRING.
5-1 Repetition Statements Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional statements,
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 7 Conditionals and Loops 4/18/09 Python Mini-Course: Day 2 - Lesson 7.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Selection Statements. Introduction Today we learn more about learn to make decisions in Turing ▫Nested if statements, ▫case statements.
CIS 3301 C# Lesson 3 Control Statements - Selection.
Flow of Control Unless indicated otherwise, the order of statement execution through a method is linear: one after the other in the order they are written.
CS 240 – Computer Programming I Lab Kalpa Gunaratna –
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Conditionals Opening Discussion zWhat did we talk about last class? zDo you have any questions about the assignment? zPass by value limitations.
Basic Conditions. Challenge: ● Ask the user his/her name ● If it’s “Wally,” jeer him ● Pause video and try on your own.
8. DECISION STRUCTURES Rocky K. C. Chang October 18, 2015 (Adapted from John Zelle’s slides)
Control structures in C by Dr P.Padmanabham Professor (CSE)&Director Bharat Institute of Engineering &Technology Hyderabad Mobile
Copyright 2006 Addison-Wesley Brief Version of Starting Out with C++ Chapter 5 Looping.
Control Flow (Python) Dr. José M. Reyes Álamo. 2 Control Flow Sequential statements Decision statements Repetition statements (loops)
1 Flow of Control Chapter 5. 2 Objectives You will be able to: Use the Java "if" statement to control flow of control within your program.  Use the Java.
CSE202: Lecture 5The Ohio State University1 Selection Structures.
Control Flow (Python) Dr. José M. Reyes Álamo. 2 Control Flow Sequential statements Decision statements Repetition statements (loops)
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
Instructor: Alexander Stoytchev CprE 185: Intro to Problem Solving (using C)
Computer Science 1000 LOGO II. Boolean Expressions like Excel and Scratch, LOGO supports three Boolean operators less than (
PYTHON PROGRAMMING Year 9. Objective and Outcome Teaching Objective Today we will look at conditional statements in order to understand how programs can.
FOP: While Loops.
Control Flow (Python) Dr. José M. Reyes Álamo.
The Ohio State University
REPETITION CONTROL STRUCTURE
Sequence, Selection, Iteration The IF Statement
Python: Control Structures
PROGRAM CONTROL STRUCTURE
Operator Precedence Operators Precedence Parentheses () unary
If, else, elif.
The order in which statements are executed is called the flow of control. Most of the time, a running program starts at the first programming statement,
Simple Control Structures
Chapter 6: Conditional Statements and Loops
Control Structures.
Logical Operators and While Loops
While loops The while loop executes the statement over and over as long as the boolean expression is true. The expression is evaluated first, so the statement.
Selection CIS 40 – Introduction to Programming in Python
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Introduction to Computer Programming
Selection Statements.
Conditionals.
Computer Science Core Concepts
Programming Concepts and Database
Programming In Lesson 4.
Chapter 4: Boolean Expressions, Making Decisions, and Disk Input and Output Prof. Salim Arfaoui.
CHAPTER 5: Control Flow Tools (if statement)
If-Statements and If/Else Statements
Presentation transcript:

An Introduction to Linux COS 151 An Introduction to Linux

Lesson Outcome An overview of Linux OS Concept of Boolean Expressions (…If/else statement) Concept of … Flow diagram Introduction to Algorithm (Next week lectures)

Content What is Linux Linux Kernel Map Examples Operating System Linux versus Microsoft Windows Linux Kernel Map Examples While loop If and else statements

What is Linux? It’s an Operating System Linux vs. Microsoft Windows Operating systems graphic source: http://en.wikipedia.org/wiki/Operating_system https://www.youtube.com/watch?v=zA3vmx0GaO8

Linux Kernel Map The kernel is the central nervous system of Linux, include OS code which runs the whole computer. It provides resources to all other programs that you run under Linux, and manages all other programs as they run. The kernel includes the code that performs certain specialized tasks, including TCP/IP networking. The kernel design is modular, so that the actual OS code is very small to be able to load when it needs, and then free the memory afterwards, thus the kernel remains small and fast and highly extensible

Examples If and else statements While loop

Questions?

If and else statement

Boolean Expressions More complex Boolean expressions are also possible Operator Meaning == equal to != not equal to < less than <= less than or equal to > greater than >= greater than or equal to More complex Boolean expressions are also possible

Then if Statement The Java if statement has the following syntax: if (boolean-condition) statement; If the Boolean condition is true, the statement is executed; if it is false, the statement is skipped This provides basic decision making capabilities

If statement flow diagram

If .. Else Statement An else clause can be added to an if statement to make it an if-else statement: if (condition) statement1; else statement2; If the condition is true, statement1 is executed; if the condition is false, statement2 is executed

If/else flow diagram

Lets work on this example together  An algorithm for inter-library lending of materials Input: The unique code of the user (userID) Output: Message on whether the material was successfully loaned or not Algorithm: 1. Set numMaterialsLoaned to 0 2. For each material (materialID) loaned to user userID: 2.1 Check availability of materialID 2.2 If not available then 2.2.1 Print message “loan unsuccessful – material is not available” 2.3 Else 2.3.1 If materialID is reserved by another user then 2.3.1.1 Print message “loan unsuccessful – material is reserved” 2.3.2 Else 2.3.2.1 Print message “loan successful – material is loaned” 2.3.2.2 Update arrival date in database (today’s date + 15 days) 2.3.2.3 Add 1 to numMaterialsLoaned 3. Print message: “Number of materials loaned:” numMaterialsLoaned 4. Quit

While statement

The while statement A while statement has the following syntax: while (condition) statement; If the condition is true, the statement is executed; then the condition is evaluated again The statement is executed over and over until the condition becomes false If the condition of a while statement is false initially, the statement is never executed Therefore, we say that a while statement executes zero or more times The while statement

While statement flow diagram

Questions?