Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 11, Problem 15PE
Program Plan Intro

Program to deal out a sequence of cards

Program plan:

  • Import the required packages
  • A class named “Deck” is defined.
  • The function named “__init__()” is defined and inside it,
    • Declare and initialize the required array variables.
    • A loop is initialized to derive the values of cards.
      • Calculate the store the values in “x” and “y”.
      • Then the cards are appended in the array named “cardSpecs[]”.
    • Declare another array named “cards[]”.
    • A loop is initialized to append the cards in the array named “cards[]”.
  • The function named “__shuffle()” is defined and inside it,
    • Declare and initialize the required array variables.
    • A loop is initialized to store the shuffled cards.
      • Calculate the store the values in “x”.
      • Then the cards are appended in a new array named “newList[]”.
      • Remove that value of x from previous array named “cards[]”.
      • Return the value stored in newList.
  • The function named “shuffle()” is defined and inside it,
    • Assign the value stored in “self.__shuffle()” to “self.cards”.
  • The function named “dealCards()” is defined and inside it,
    • Return the value stored in first “self.cards.pop()”.
  • The function named “cardsLeft()” is defined and inside it,
    • Return the length of the value stored in “self.cards()”.
  • In the “main()” function,
    • Declare the variable “deck” that creates the class named “Deck()”
    • The function named “shuffle()” is called.
    • A loop is initialized to store the shuffled cards.
      • Print the output value that returned from “deck.dealCard()”.
  • Call the function “main()”.

Blurred answer
Students have asked these similar questions
Of the five primary components of an information system (hardware, software, data, people, process), which do you think is the most important to the success of a business organization? Part A - Define each primary component of the information system. Part B - Include your perspective on why your selection is most important. Part C - Provide an example from your personal experience to support your answer.
Management Information Systems
Q2/find the transfer function C/R for the system shown in the figure Re ད
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
9.1: What is an Array? - Processing Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=NptnmWvkbTw;License: Standard Youtube License