Outline. multiple choice quiz bottom-up design. the modules main program: quiz.py namespaces in Python



Similar documents
Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage

A Python Tour: Just a Brief Introduction CS 303e: Elements of Computers and Programming

transmission media and network topologies client/server architecture layers, protocols, and sockets

Software Development Life Cycle at SSPL. An Summary of Methodologies We Offer

(Refer Slide Time: 01:52)

International Journal of Advance Research in Computer Science and Management Studies

Python and Cython. a dynamic language. installing Cython factorization again. working with numpy

Programming in Python. Basic information. Teaching. Administration Organisation Contents of the Course. Jarkko Toivonen. Overview of Python

CS 389 Software Engineering. Lecture 2 Chapter 2 Software Processes. Adapted from: Chap 1. Sommerville 9 th ed. Chap 1. Pressman 6 th ed.

ADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

IT3203 Fundamentals of Software Engineering (Compulsory) BIT 2 nd YEAR SEMESTER 3

El Dorado Union High School District Educational Services

Introduction to Python

Lecture Objectives. Software Life Cycle. Software Engineering Layers. Software Process. Common Process Framework. Umbrella Activities

How To Understand Software Engineering

Exercise 4 Learning Python language fundamentals

Software Engineering. Software Development Process Models. Lecturer: Giuseppe Santucci

A. Waterfall Model - Requirement Analysis. System & Software Design. Implementation & Unit Testing. Integration & System Testing.

Development models. 1 Introduction. 2 Analyzing development models. R. Kuiper and E.J. Luit

IT3205: Fundamentals of Software Engineering (Compulsory)

Peter Mileff PhD SOFTWARE ENGINEERING. The Basics of Software Engineering. University of Miskolc Department of Information Technology

Welcome to Introduction to programming in Python

CDC UNIFIED PROCESS JOB AID

CSCE 110 Programming I Basics of Python: Variables, Expressions, and Input/Output

CSE 435 Software Engineering. Sept 16, 2015

2! Multimedia Programming with! Python and SDL

Intro to scientific programming (with Python) Pietro Berkes, Brandeis University

Elite: A New Component-Based Software Development Model

CS 1133, LAB 2: FUNCTIONS AND TESTING

How To Develop Software

Module 2. Software Life Cycle Model. Version 2 CSE IIT, Kharagpur

CS 3530 Operating Systems. L02 OS Intro Part 1 Dr. Ken Hoganson

IV. Software Lifecycles

Acknowledgement. Software Engineering. CS 3141: Team Software Project Introduction

Outline. Definitions. Course schedule

Software Development Process Models

Component Based Development in Software Engineering

CSC 221: Computer Programming I. Fall 2011

Software Process Models. Xin Feng

Software Life Cycle. Management of what to do in what order


Introduction to: Computers & Programming: Review for Midterm 2

SOFTENG250FC: Introduction to Software Engineering

Software Processes. Coherent sets of activities for specifying, designing, implementing and testing software systems

Crash Dive into Python

Umbrella: A New Component-Based Software Development Model

Name of pattern types 1 Process control patterns 2 Logic architectural patterns 3 Organizational patterns 4 Analytic patterns 5 Design patterns 6

Computer Science for San Francisco Youth

Welcome to Introduction to Computers and Programming Course using Python

Software Engineering Reference Framework

Software Paradigms (Lesson 1) Introduction & Procedural Programming Paradigm

Computer Programming. Course Details An Introduction to Computational Tools. Prof. Mauro Gaspari:

Software Life Cycle Processes

A Note for Students: How to Use This Book

Software Process for QA

SOFTWARE ENGINEERING INTERVIEW QUESTIONS

AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping

Principles of Software Engineering: Software Methodologies. COSI 120b, Spring 2005

Higher National Unit specification. General information. Software Development: Analysis and Design (SCQF level 7) Unit code: HA4C 34.

And the Models Are System/Software Development Life Cycle. Why Life Cycle Approach for Software?

The Elective Part of the NSS ICT Curriculum D. Software Development

CS 253: Intro to Systems Programming

Configuration Management: An Object-Based Method Barbara Dumas

Classical Software Life Cycle Models

Introduction to Systems Analysis and Design

What is a life cycle model?

Software Development: The Waterfall Model

Total Quality Management (TQM) Quality, Success and Failure. Total Quality Management (TQM) vs. Process Reengineering (BPR)

Introduction to the course, Eclipse and Python

Introduction to Functional Verification. Niels Burkhardt

SMock A Test Platform for the Evaluation of Monitoring Tools

Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur

A system is a set of integrated components interacting with each other to serve a common purpose.

William E. Hart Carl Laird Jean-Paul Watson David L. Woodruff. Pyomo Optimization. Modeling in Python. ^ Springer

Software Development Processes. Software Life-Cycle Models

Module 2. Software Life Cycle Model. Version 2 CSE IIT, Kharagpur

CS 1632 SOFTWARE QUALITY ASSURANCE. 2 Marks. Sample Questions and Answers

Software Engineering. An Introduction. Fakhar Lodhi

Getting Started with the Internet Communications Engine

The Software Development Process

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Chapter 2 Writing Simple Programs

Outline. mass storage hash functions. logical key values nested tables. storing information between executions using DBM files

Python Loops and String Manipulation

Some programming experience in a high-level structured programming language is recommended.

Karunya University Dept. of Information Technology

Introduction to Python

Software Engineering Question Bank

Testing, Debugging, and Verification

Software Quality Testing Course Material

IT2404 Systems Analysis and Design (Compulsory)

Introduction to Software Paradigms & Procedural Programming Paradigm

Surveying and evaluating tools for managing processes for software intensive systems

To introduce software process models To describe three generic process models and when they may be used

Chapter 10 Practical Database Design Methodology and Use of UML Diagrams

Latest Trends in Testing. Ajay K Chhokra

Unit I. Introduction

Other Required Courses (14-18 hours)

Transcription:

Outline 1 Modular Design multiple choice quiz bottom-up design 2 Python Implementation the modules main program: quiz.py namespaces in Python 3 The Software Cycle quality of product and process waterfall and spiral model 4 Summary + Assignments MCS 260 Lecture 22 Introduction to Computer Science Jan Verschelde, 4 March 2015 Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 1 / 28

modular design software cycle & quality 1 Modular Design multiple choice quiz bottom-up design 2 Python Implementation the modules main program: quiz.py namespaces in Python 3 The Software Cycle quality of product and process waterfall and spiral model 4 Summary + Assignments Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 2 / 28

Multiple Choice Quiz problem specification To test our knowledge of computer science concepts, we would like an automatic multiple choice quiz. Our friend the computer will 1 show a question with multiple possible answers 2 wait for us to make a choice 3 immediately evaluate our choice 4 ask us if we want to continue 5 at the end print how well we did Wanted: a small but extendable program. Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 3 / 28

a screen shot: a first prototype The main program quiz.py, executed at the prompt $: $ python quiz.py The octal system has base... 1. 16 2. 8 3. 10 4. 2 type a number between 1 and 4 : 2 this is the correct answer continue? (y/n) n #correct : 1 #wrong : 0 -> 100.00% Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 4 / 28

Tools for Use what does Python provide? Python provides 1 a command line or Python shell environment 2 data structures: lists, tuples, and dictionaries 3 if-elif-else, loops, and functions 4 random number generators in the module random 5 our modules will reflect our bottom-up design What is there at the bottom of our program? Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 5 / 28

modular design software cycle & quality 1 Modular Design multiple choice quiz bottom-up design 2 Python Implementation the modules main program: quiz.py namespaces in Python 3 The Software Cycle quality of product and process waterfall and spiral model 4 Summary + Assignments Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 6 / 28

The Bottom of our Program A multiple choice quiz consists of 1 questions that have short answers; 2 answers, correct ones and variations. Every question and answer will be a string. Dictionaries seem very appropriate: 1 the questions are numbered, key = number, the values are strings 2 answers for the corresponding question have the same key as the question 3 answers are dictionaries of dictionaries 4 convention: correct answer comes first Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 7 / 28

The Other Modules We separate the functionalities: 1 generating questions and evaluating answers; 2 showing questions and asking answers. Two modules of functions: questions and dialogue. Both modules import the Q&A dictionary and export their functions to the main program. The formulation of questions and answers is centralized in the Q&A dictionary. A multiple choice question then consists of 1 the number of the question; 2 a permutation of the answers. In Python we use a tuple, e.g.: (3,[2,1,3,4]). Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 8 / 28

The Modular Design At the bottom: the Q&A dictionary. Two libraries of functions: questions and dialogue. automated quiz generate questions dialogue with user Q&A dictionary Information Hiding: the main program does not import the Q&A dictionary. Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 9 / 28

modular design software cycle & quality 1 Modular Design multiple choice quiz bottom-up design 2 Python Implementation the modules main program: quiz.py namespaces in Python 3 The Software Cycle quality of product and process waterfall and spiral model 4 Summary + Assignments Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 10 / 28

the Q&A dictionary in the file quand.py QUESTIONS = { \ 1: How many bits go in one byte?, \ 2: Who is the main developer of Python?, \ 3: Which statement is true?, \ 4: The octal system has base... \ } ANSWERS = { \ 1:{ 1: 8, 2: 4, 3: 2, 4: 16 }, \ 2:{ 1: Guido van Rossum, 2: John von Neumann, \ 3: Rashi Gupta, 4: John Backus }, \ 3:{ 1: a compiler translates source code, \ 2: a compiler executes object code, \ 3: a compiler formats source code, \ 4: a compiler stores code on file }, \ 4:{ 1: 8, 2: 2, 3: 10, 4: 16 } \ } Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 11 / 28

specification of questions.py help(questions) shows under FUNCTIONS: evaluate(ans, chc) Evaluates choice chc to True or False where ans is a list of answers. generate() Returns a multiple choice question as a tuple (qst, ans), where qst is a number, and ans is a list of numbers with answers. update_tally(tly, boolvar) Updates tally of True or False answers where tly is a list of two elements and boolvar is True or False, returns the updated tally. Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 12 / 28

specification of dialogue.py help(dialogue) shows under FUNCTIONS: prompt_choice(num) Asks the user for a choice where num is the number of choices. show_outcome(boolvar) Reports outcome to user where boolvar is True or False. show_question(qst, ans) Displays the questions and the answers on input is the number qst of the question and the list ans of answers. show_tally(tly) Shows final tally, tly is list. Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 13 / 28

modular design software cycle & quality 1 Modular Design multiple choice quiz bottom-up design 2 Python Implementation the modules main program: quiz.py namespaces in Python 3 The Software Cycle quality of product and process waterfall and spiral model 4 Summary + Assignments Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 14 / 28

the main program in the file quiz.py import questions import dialogue from random import shuffle TLY = [0, 0] while True: (QST, ANS) = questions.generate() shuffle(ans) dialogue.show_question(qst, ANS) CHC = dialogue.prompt_choice(len(ans)) EVA = questions.evaluate(ans, CHC) dialogue.show_outcome(eva) TLY = questions.update_tally(tly, EVA) MORE = raw_input( continue? (y/n) ) if MORE!= y : break dialogue.show_tally(tly) Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 15 / 28

two functions in questions.py import quand def generate(): """ Returns a multiple choice question as a tuple (qst, ans), where qst is a number, and ans is a list of numbers with answers. """ import random qst = random.randint(1, len(quand.questions)) ans = range(1, len(quand.answers[qst])+1) return (qst, ans) def evaluate(ans, chc): """ Evaluates choice chc to True or False where ans is a list of answers. """ return (ans[chc-1] == 1) Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 16 / 28

show_question() in dialogue.py import quand def show_question(qst, ans): """ Displays the questions and the answers on input is the number qst of the question and the list ans of answers. """ print quand.questions[qst] choice = 1 for answer in ans: prt = %d % choice +. prt = prt + quand.answers[qst][answer] print prt choice = choice + 1 Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 17 / 28

giving feedback def show_outcome(boolvar): """ Reports outcome to user where boolvar is True or False. """ if boolvar: print this is the correct answer else: print wrong, please try again def show_tally(tly): """ Shows final tally, tly is list. """ cnt = #correct : %d % tly[1] cnt += #wrong : %d % tly[0] frm = 100.0*tly[1]/sum(tly) cnt += -> %.2f%% % frm print cnt Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 18 / 28

modular design software cycle & quality 1 Modular Design multiple choice quiz bottom-up design 2 Python Implementation the modules main program: quiz.py namespaces in Python 3 The Software Cycle quality of product and process waterfall and spiral model 4 Summary + Assignments Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 19 / 28

namespaces in Python A namespace is a collection of names available to use. Importing from modules enlarges the current namespace. dir() returns a list of the attributes of the module >>> import random >>> dir(random) [..., uniform,... ] >>> import numpy.random >>> dir(numpy.random) [..., uniform,... ] There are two uniform random number generators: random.uniform() and numpy.random.uniform(). >>> from random import uniform as u1 >>> from numpy.random import uniform as u2 u1() and u2 now belong to the current namespace Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 20 / 28

The Software Cycle We are experiencing the software crisis: the industrial sector can not keep up with the ever growing demands of the market. Symptoms: 1 products are delivered late 2 the cost exceed budgets 3 too many bugs appear The relative cost of hardware versus software was 80% versus 20% in the 1960s became 20% versus 80% in the 1980s keeps going in the same direction. Reason: hardware production is technology intensive, whereas software creation is human intensive. Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 21 / 28

modular design software cycle & quality 1 Modular Design multiple choice quiz bottom-up design 2 Python Implementation the modules main program: quiz.py namespaces in Python 3 The Software Cycle quality of product and process waterfall and spiral model 4 Summary + Assignments Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 22 / 28

Quality of Software Design industrial quality Industrial quality refers to products 1 that must meet a target value on average, 2 and within a tolerable standard deviation. example: a search engine should give one page of relevant answers within an average of 10 seconds, and standard deviation of 2 seconds. We distinguish between quality of product and process: 1 a high quality product meets user s expectations, 2 also the quality of the production process matters! External qualities can be observed directly by the user. example: easy to use Internal qualities can be measured only by the producer. example: design documentation Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 23 / 28

Software Quality Features what is good software? A short list of important criteria: correctness must satisfy requirements How reliable is the software? efficiency economical use of resources such as hardware and time Do we understand how the complexity of the problem and the software relate? modifiability to different environments and requirements How hard is it to correct errors or to add new features? reusability of the same software in different applications Mathematical libraries are a typical example of reusable software. Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 24 / 28

modular design software cycle & quality 1 Modular Design multiple choice quiz bottom-up design 2 Python Implementation the modules main program: quiz.py namespaces in Python 3 The Software Cycle quality of product and process waterfall and spiral model 4 Summary + Assignments Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 25 / 28

The Waterfall Model seven phases in sequence The software life cycle model describes the software production in seven phases: 1 feasibility study: cost-benefit analysis 2 system requirements specification: what must it do? 3 system architecture design: modules and relations 4 implementation and verification of modules 5 system integration and verification 6 installation: deliver software to the user 7 maintenance: fixing bugs and adding new features As the phases occur in a strict sequence, just as water never flows upwards, this model is like a waterfall. This deductive or top-down description of the life cycle has its merits, especially with feedback. Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 26 / 28

The Spiral Model Four sectors in the software development: 1 requirements analysis and specification 2 system architecture design 3 implementation 4 verification Incremental development of software: 1 think of a product with limited scope 2 create the design of the first product 3 implement a prototype 4 test and deliver the prototype Based on feedback, enlarge the specifications, revise the designs, build new prototypes, test and deliver again. As the cycles over the four sectors get larger, the complexity of the software grows. Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 27 / 28

Summary + Assignments Read 7.2 in Computer Science, an overview. Assignments: 1 Enlarge the Q&A answer dictionary with a least six more questions about relevant CS concepts. 2 Modify the program so the user has the option to see the correct answer when wrong. 3 Design your own trivia quiz. 4 Consider a quiz about the first 13 states of the union. The quiz links names of states with their captitals and year when they joined the union. 5 Develop a modular implementation of your own trivia quiz or of the quiz in the previous exercise. Intro to Computer Science (MCS 260) software cycle & quality L-22 4 March 2015 28 / 28