Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Programming Programming Project Pica Centro 2 Important notes: please write the Pica Centro program in Python 2 only and please need to include a

Python Programming Programming Project

Pica Centro

2 Important notes: please write the Pica Centro program in Python 2 only and please need to include a main() function and a single call to get that logic going in the program.

Overview

In this assignment, you will be writing a Python script that implements the logical deduction game Pica Centro.

When completing this assignment, the student should demonstrate mastery of the following concepts:

Variable Declarations

Global Declarations (Variables and Constants)

Function Syntax

General Python Scripting Structure

Boolean Logic

Conditional Logic Control Structures

Basic Python Console I/O

Flagging

Intuitive Interface Design

Nested Control Structures

Intermediate Conditional Logic Algorithm Design

Assignment

Pica Centro is an educational game used to teach children deductive reasoning at a young age. The game involves two players, a number selector and a guesser. The number selector selects a secret 3-digit number, writes it down, and hides it from the guesser. The guesser then proposes a 3-digit number to the number selector and is given a response as a count of picas and centros.

A pica is given if one of the digits in the guessers number is correct, but in the wrong position. A centro is given if one of the digits in the guessers number is correct and in the correct position. Any single digit in the guessers number can be a pica, centro, or neither, but cannot be both. Consider the following transcript of a sample game:

The number selector secretly chooses the number: 1 5 8

The guesser guesses the number: 1 9 4

The number selector responds with: PICA = 0, CENTRO = 1

(this is because the digit 1 correct and also in the correct location within the guess)

The guesser guesses the number: 9 8 6

The number selector responds with: PICA = 1, CENTRO = 0

(this is because the digit 8 is correct, but was placed in the wrong position within the guess)

The guesser guesses the number: 1 7 8

The number selector responds with: PICA = 0, CENTRO = 2

(this is because the digit 1 is correct and in the correct position and the digit 8 is correct and in the correct position; the digit 7 is not present in the secret number)

The guesser guesses the number: 1 5 8

The number selector responds with: PICA = 0, CENTRO = 3

(this is because all of the digits are correct and all in the correct positions)

THE GUESSER WINS

Assignment

In this assignment, you will be writing a Python script that implements a simple version of this game. The program should begin by allowing a user to enter a secret number (one digit at a time). The digits are then stored and the screen is cleared to hide the secret number from the guesser. Recall the function definition used to clear the console in a Python script:

def clearScreen():

clear = * 100

print clear

The program will then give the guesser ten guesses to try and figure out the number. After each guess, the program should display a neat table clearly showing the guess presented and the number of picas and centros for that guess. If the guesser is able to deduce the original number, the program should display a victory message and end. If the guesser exhausts all ten guesses without getting the secret number, the program should display a defeat message and also end.

When writing this program, be sure to demonstrate the concepts of global variables, functions, conditional logic, and formatted IO in Python. Adhere to all established Python programming conventions and make your solution as intuitive and clean as possible. Also keep in mind that this program can be written without the use of any repetition structures (no loops are required). However, if you choose to use loops to optimize the logic of your program, you are welcome to do so.

The Python program is needs to output the following:

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribed

Sample Trial #1 -You WIN WELCOME TO PICA-CENTRO Please enter the first digit in your number6 Please enter the second digit in your number:2 Please enter the third digit in your number3 The secret number has been set to: 6 2 3 PRESS ANY KEY TO CLEAR THE SCREEN AND BEGIN THE GAM THE SCREEN CLEARS> GUESS #01 Please enter the first digit in your guess 7 Please enter the second digit in your guess Please enter the third digit in your guess 6 I YOUR GUESS I PICA I CENTRO 178 6 GUESS #02 Please enter the first digit in your guess : 6 Please enter the second digit in your guess: 9 Please enter the third digit in your guess4 1 YOUR GUESS 1 CENTRO 1 6 9 4 GUESS #03 Please enter the first digit in your guess6 Please enter the second digit in your guess: 3 Please enter the third digit in your guess2 YOUR GUESS I PICA I CENTRO 6 3 2 GUESS #04 Please enter the first digit in your guess 6 Please enter the second digit in your guess: 2 Please enter the third digit in your guess 3 I YOUR GUESS I PICA I CENTRO 6 2 3 VICTORY The secret number was: 6 2 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

Students also viewed these Databases questions

Question

1. How will you, as city manager, handle these requests?

Answered: 1 week ago