SlideShare a Scribd company logo
1 of 3
Data Dictionary
Name Data Type* Usage** Initial
Value/Range
Description
again string input y or Y To control the while loop
count int constant 0 To holdthe numberof guesses
guess int input 1-20 Holdthe usersguess
name string input ------------------ Holdthe usersname
number int constant 1-20 Randomnumberfunction
*Data Type – integer,floatingpoint,string,Boolean
**Usage – input,output,calculation,constant
Test Data
Set Number** NUMBER Guess Results
1 random 3 To Low
2 random 20 To High
3 random 8 To High
4 random 17 To High
5 random 4 To Low
6 random 7 Good Job
1 random 7 To Low
2 random 9 To Low
3 random 11 To Low
4 random 13 To Low
5 random 14 To Low
6 random 18 You failedtoguest
my numberinsix
guesses
*one columnneededforeachvariable usedinthe programom
**minimumof 3 setsof testdata
Pseudocode
What followsisabasictemplate formostprograms
Declare constants
number= random.randint(1, 20)
Declare variables
again= y or Y
guess
name
Get input
Hello!Whatisyour name?
While guess<1 or guess> 20
Invalidinputpleaseenteranumberbetween1and20
While again== ‘y’ or again== ‘Y’:
Well,Name,I’mthinkingof a numberbetween1and 20?
Take a Guess
Performprocessing
Count= 1
While count< 6:
Count= count+ 1
If guess== number
Count= count- 1
Congratulationsyouguessthe numberinnumberof attemptsguesses
If guess > number
Guessto high
Take a guess
If guess< number
Guessto low
Take a Guess
While guess!=number
Displayoutput
Display Congratulationsyouguessthe numberincounterguesses
Display
Guessto high
Take a guess
Display
Guessto low
Take a guess
Display
You failedtoguestmynumberinsix guesses
Wouldyoulike toplayagain Y/N

More Related Content

What's hot

Lesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbersLesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbersPVS-Studio
 
basic of desicion control statement in python
basic of  desicion control statement in pythonbasic of  desicion control statement in python
basic of desicion control statement in pythonnitamhaske
 
Python - Control Structures
Python - Control StructuresPython - Control Structures
Python - Control StructuresLasithNiro
 
Simple if else statement,nesting of if else statement &amp; else if ladder
Simple if else statement,nesting of if else statement &amp; else if ladderSimple if else statement,nesting of if else statement &amp; else if ladder
Simple if else statement,nesting of if else statement &amp; else if ladderMoni Adhikary
 
Conditionalstatement
ConditionalstatementConditionalstatement
ConditionalstatementRaginiJain21
 
25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manualkamesh dagia
 
Conditional statements in vb script
Conditional statements in vb scriptConditional statements in vb script
Conditional statements in vb scriptNilanjan Saha
 
Calculating the hamming code (tutorial)
Calculating the hamming code (tutorial)Calculating the hamming code (tutorial)
Calculating the hamming code (tutorial)kiriinyaKev
 
Managing input and output operations in c
Managing input and output operations in cManaging input and output operations in c
Managing input and output operations in cniyamathShariff
 
The Ring programming language version 1.7 book - Part 22 of 196
The Ring programming language version 1.7 book - Part 22 of 196The Ring programming language version 1.7 book - Part 22 of 196
The Ring programming language version 1.7 book - Part 22 of 196Mahmoud Samir Fayed
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statementsSaad Sheikh
 
If statements in c programming
If statements in c programmingIf statements in c programming
If statements in c programmingArchana Gopinath
 
Data Input and Output
Data Input and OutputData Input and Output
Data Input and OutputSabik T S
 

What's hot (20)

Lesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbersLesson 9. Pattern 1. Magic numbers
Lesson 9. Pattern 1. Magic numbers
 
basic of desicion control statement in python
basic of  desicion control statement in pythonbasic of  desicion control statement in python
basic of desicion control statement in python
 
Python - Control Structures
Python - Control StructuresPython - Control Structures
Python - Control Structures
 
Simple if else statement,nesting of if else statement &amp; else if ladder
Simple if else statement,nesting of if else statement &amp; else if ladderSimple if else statement,nesting of if else statement &amp; else if ladder
Simple if else statement,nesting of if else statement &amp; else if ladder
 
Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
 
Lecture 6- Intorduction to C Programming
Lecture 6- Intorduction to C ProgrammingLecture 6- Intorduction to C Programming
Lecture 6- Intorduction to C Programming
 
Conditionalstatement
ConditionalstatementConditionalstatement
Conditionalstatement
 
Introduction to Input/Output Functions in C
Introduction to Input/Output Functions in CIntroduction to Input/Output Functions in C
Introduction to Input/Output Functions in C
 
25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual
 
First session
First sessionFirst session
First session
 
Conditional statements in vb script
Conditional statements in vb scriptConditional statements in vb script
Conditional statements in vb script
 
Calculating the hamming code (tutorial)
Calculating the hamming code (tutorial)Calculating the hamming code (tutorial)
Calculating the hamming code (tutorial)
 
Managing input and output operations in c
Managing input and output operations in cManaging input and output operations in c
Managing input and output operations in c
 
C preprocesor
C preprocesorC preprocesor
C preprocesor
 
The Ring programming language version 1.7 book - Part 22 of 196
The Ring programming language version 1.7 book - Part 22 of 196The Ring programming language version 1.7 book - Part 22 of 196
The Ring programming language version 1.7 book - Part 22 of 196
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
If statements in c programming
If statements in c programmingIf statements in c programming
If statements in c programming
 
Data Input and Output
Data Input and OutputData Input and Output
Data Input and Output
 
CPU INPUT OUTPUT
CPU INPUT OUTPUT CPU INPUT OUTPUT
CPU INPUT OUTPUT
 
5 format
5 format5 format
5 format
 

Viewers also liked

Những người phụ nữ làm thay đổi thế giới
Những người phụ nữ làm thay đổi thế giới Những người phụ nữ làm thay đổi thế giới
Những người phụ nữ làm thay đổi thế giới Viet_Cuong
 
Proyecto diseña el cambio jalisco
Proyecto diseña el cambio jaliscoProyecto diseña el cambio jalisco
Proyecto diseña el cambio jaliscodec-admin
 
The Rise of Marketplace Lending
The Rise of Marketplace LendingThe Rise of Marketplace Lending
The Rise of Marketplace LendingRon Suber
 
Cem 350 manufactured home issues
Cem 350 manufactured home issuesCem 350 manufactured home issues
Cem 350 manufactured home issuesmiresmaeil
 

Viewers also liked (12)

121
121121
121
 
Những người phụ nữ làm thay đổi thế giới
Những người phụ nữ làm thay đổi thế giới Những người phụ nữ làm thay đổi thế giới
Những người phụ nữ làm thay đổi thế giới
 
Qiod
QiodQiod
Qiod
 
Proyecto diseña el cambio jalisco
Proyecto diseña el cambio jaliscoProyecto diseña el cambio jalisco
Proyecto diseña el cambio jalisco
 
akashreport
akashreportakashreport
akashreport
 
Pragas do cafeeiro
Pragas do cafeeiroPragas do cafeeiro
Pragas do cafeeiro
 
The Rise of Marketplace Lending
The Rise of Marketplace LendingThe Rise of Marketplace Lending
The Rise of Marketplace Lending
 
NAV9000 teaser
NAV9000 teaserNAV9000 teaser
NAV9000 teaser
 
Heath Big Local Supportive Care Centre
Heath Big Local Supportive Care CentreHeath Big Local Supportive Care Centre
Heath Big Local Supportive Care Centre
 
Cem 350 manufactured home issues
Cem 350 manufactured home issuesCem 350 manufactured home issues
Cem 350 manufactured home issues
 
Fatty acids
Fatty acidsFatty acids
Fatty acids
 
PCIAC Report 2016
PCIAC Report 2016PCIAC Report 2016
PCIAC Report 2016
 

Similar to Guess a number game

ch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.pptch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.pptMahyuddin8
 
Write a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdfWrite a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdffashioncollection2
 
02a fundamental c++ types, arithmetic
02a   fundamental c++ types, arithmetic 02a   fundamental c++ types, arithmetic
02a fundamental c++ types, arithmetic Manzoor ALam
 
03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...Intro C# Book
 
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and LoopsPython Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and LoopsP3 InfoTech Solutions Pvt. Ltd.
 
Chapter 3 malik
Chapter 3 malikChapter 3 malik
Chapter 3 malikOshal Shah
 
Chapter 3 malik
Chapter 3 malikChapter 3 malik
Chapter 3 malikOshal Shah
 
Chapter 3 malik
Chapter 3 malikChapter 3 malik
Chapter 3 malikOshal Shah
 
STRINGS_IN_PYTHON 9-12 (1).pptx
STRINGS_IN_PYTHON 9-12 (1).pptxSTRINGS_IN_PYTHON 9-12 (1).pptx
STRINGS_IN_PYTHON 9-12 (1).pptxTinku91
 
functions2-200924082810.pdf
functions2-200924082810.pdffunctions2-200924082810.pdf
functions2-200924082810.pdfpaijitk
 
2 1. variables & data types
2 1. variables & data types2 1. variables & data types
2 1. variables & data types웅식 전
 
02. Primitive Data Types and Variables
02. Primitive Data Types and Variables02. Primitive Data Types and Variables
02. Primitive Data Types and VariablesIntro C# Book
 
1_Python Basics.pdf
1_Python Basics.pdf1_Python Basics.pdf
1_Python Basics.pdfMaheshGour5
 
ch03-parameters-objects.ppt
ch03-parameters-objects.pptch03-parameters-objects.ppt
ch03-parameters-objects.pptMahyuddin8
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]vikram mahendra
 
Write a function that takes as a parameter an integer (as a long valu.docx
 Write a function that takes as a parameter an integer (as a long valu.docx Write a function that takes as a parameter an integer (as a long valu.docx
Write a function that takes as a parameter an integer (as a long valu.docxajoy21
 

Similar to Guess a number game (20)

Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
 
ch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.pptch05-program-logic-indefinite-loops.ppt
ch05-program-logic-indefinite-loops.ppt
 
Write a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdfWrite a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdf
 
02a fundamental c++ types, arithmetic
02a   fundamental c++ types, arithmetic 02a   fundamental c++ types, arithmetic
02a fundamental c++ types, arithmetic
 
03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...03 and 04 .Operators, Expressions, working with the console and conditional s...
03 and 04 .Operators, Expressions, working with the console and conditional s...
 
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and LoopsPython Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and Loops
 
Chapter 3 malik
Chapter 3 malikChapter 3 malik
Chapter 3 malik
 
Chapter 3 malik
Chapter 3 malikChapter 3 malik
Chapter 3 malik
 
Chapter 3 malik
Chapter 3 malikChapter 3 malik
Chapter 3 malik
 
Data Handling
Data Handling Data Handling
Data Handling
 
STRINGS_IN_PYTHON 9-12 (1).pptx
STRINGS_IN_PYTHON 9-12 (1).pptxSTRINGS_IN_PYTHON 9-12 (1).pptx
STRINGS_IN_PYTHON 9-12 (1).pptx
 
functions2-200924082810.pdf
functions2-200924082810.pdffunctions2-200924082810.pdf
functions2-200924082810.pdf
 
2 1. variables & data types
2 1. variables & data types2 1. variables & data types
2 1. variables & data types
 
02. Primitive Data Types and Variables
02. Primitive Data Types and Variables02. Primitive Data Types and Variables
02. Primitive Data Types and Variables
 
Python
PythonPython
Python
 
1_Python Basics.pdf
1_Python Basics.pdf1_Python Basics.pdf
1_Python Basics.pdf
 
ch03-parameters-objects.ppt
ch03-parameters-objects.pptch03-parameters-objects.ppt
ch03-parameters-objects.ppt
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
 
Introduction to Python
Introduction to Python  Introduction to Python
Introduction to Python
 
Write a function that takes as a parameter an integer (as a long valu.docx
 Write a function that takes as a parameter an integer (as a long valu.docx Write a function that takes as a parameter an integer (as a long valu.docx
Write a function that takes as a parameter an integer (as a long valu.docx
 

Guess a number game

  • 1. Data Dictionary Name Data Type* Usage** Initial Value/Range Description again string input y or Y To control the while loop count int constant 0 To holdthe numberof guesses guess int input 1-20 Holdthe usersguess name string input ------------------ Holdthe usersname number int constant 1-20 Randomnumberfunction *Data Type – integer,floatingpoint,string,Boolean **Usage – input,output,calculation,constant Test Data Set Number** NUMBER Guess Results 1 random 3 To Low 2 random 20 To High 3 random 8 To High 4 random 17 To High 5 random 4 To Low 6 random 7 Good Job 1 random 7 To Low 2 random 9 To Low 3 random 11 To Low 4 random 13 To Low 5 random 14 To Low 6 random 18 You failedtoguest my numberinsix guesses *one columnneededforeachvariable usedinthe programom **minimumof 3 setsof testdata Pseudocode What followsisabasictemplate formostprograms Declare constants number= random.randint(1, 20)
  • 2. Declare variables again= y or Y guess name Get input Hello!Whatisyour name? While guess<1 or guess> 20 Invalidinputpleaseenteranumberbetween1and20 While again== ‘y’ or again== ‘Y’: Well,Name,I’mthinkingof a numberbetween1and 20? Take a Guess Performprocessing Count= 1 While count< 6: Count= count+ 1 If guess== number Count= count- 1 Congratulationsyouguessthe numberinnumberof attemptsguesses If guess > number Guessto high Take a guess If guess< number Guessto low Take a Guess While guess!=number Displayoutput Display Congratulationsyouguessthe numberincounterguesses
  • 3. Display Guessto high Take a guess Display Guessto low Take a guess Display You failedtoguestmynumberinsix guesses Wouldyoulike toplayagain Y/N