Python and Algorithmic Thinking for the Complete Beginner

Book description

Unlock the power of Python with this comprehensive guide, “Python and Algorithmic Thinking for the Complete Beginner.” It covers everything from computer basics to advanced decision and loop control structures.

Key Features

  • Comprehensive coverage from basic computer operations to advanced programming concepts
  • Step-by-step progression of each topic, along with tips and tricks to enhance coding efficiency
  • In-depth exploration of Python and algorithmic thinking with exercises and practical examples

Book Description

This course is meticulously designed to take beginners on a journey through the fascinating world of Python programming and algorithmic thinking. The initial chapters lay a strong foundation, starting with the basics of how computers operate, moving into Python programming, and familiarizing learners with integrated development environments like IDLE and Visual Studio Code.

Further, the course delves into essential programming constructs such as variables, constants, input/output handling, and operators. You'll gain practical experience with trace tables, sequence control structures, and decision control structures through comprehensive exercises and examples. The curriculum emphasizes hands-on learning with chapters dedicated to manipulating numbers, strings, and understanding complex mathematical expressions. By mastering these concepts, you'll be well-prepared to tackle more advanced topics.

The final chapters introduce you to object-oriented programming and file manipulation, rounding out your skill set. Throughout the course, practical tips and tricks are provided to enhance your coding efficiency and problem-solving skills. By the end of this course, you will have a robust understanding of Python programming and the ability to apply algorithmic thinking to solve real-world problems.

What you will learn

  • Understand how computers work and the basics of Python programming
  • Install and use integrated development environments (IDEs)
  • Develop skills in decision and loop control structures
  • Manipulate data using lists, dictionaries, and strings
  • Apply algorithmic thinking to solve complex problems
  • Gain proficiency in object-oriented programming & file manipulation

Who this book is for

This course is ideal for absolute beginners with no prior programming experience. Basic computer literacy is required, but no specific knowledge of programming or algorithms is necessary. It is also suitable for individuals looking to refresh their Python skills and enhance their understanding of algorithmic thinking. High school and college students interested in programming, professionals seeking to upskill, and hobbyists eager to learn a new programming language will all find value in this course.

Table of contents

  1. Table of Contents
  2. Preface
    1. About the Author
    2. Acknowledgments
    3. How This Book is Organized
    4. Who Should Buy This Book?
    5. Conventions Used in This Book
    6. How to Report Errata
    7. Where to Download Material About this Book
    8. If you Like this Book
  3. Part I Introductory Knowledge
    1. Chapter 1 How a Computer Works
      1. 1.1 Introduction
      2. 1.2 What is Hardware?
      3. 1.3 What is Software?
      4. 1.4 How a Computer Executes (Runs) a Program
      5. 1.5 Compilers and Interpreters
      6. 1.6 What is Source Code?
      7. 1.7 Review Questions: True/False
      8. 1.8 Review Questions: Multiple Choice
    2. Chapter 2 Python and Integrated Development Environments
      1. 2.1 What is Python?
      2. 2.2 What is the Difference Between a Script and a Program?
      3. 2.3 Why You Should Learn Python
      4. 2.4 How Python Works
      5. 2.5 Integrated Development Environments
      6. 2.6 IDLE
      7. 2.7 Microsoft Visual Studio
    3. Chapter 3 Software Packages to Install
      1. 3.1 What to Install
    4. Review in “Introductory Knowledge”
      1. Review Crossword Puzzles
      2. Review Questions
  4. Part II Getting Started with Python
    1. Chapter 4 Introduction to Basic Algorithmic Concepts
      1. 4.1 What is an Algorithm?
      2. 4.2 The Algorithm for Making a Cup of Tea
      3. 4.3 Properties of an Algorithm
      4. 4.4 Okay About Algorithms. But What is a Computer Program Anyway?
      5. 4.5 The Three Parties!
      6. 4.6 The Three Main Stages Involved in Creating an Algorithm
      7. 4.7 Flowcharts
        1. Exercise 4.7-1 Finding the Average Value of Three Numbers
      8. 4.8 What are ”Reserved Words”?
      9. 4.9 What is the Difference Between a Statement and a Command?
      10. 4.10 What is Structured Programming?
      11. 4.11 The Three Fundamental Control Structures
        1. Exercise 4.11-1 Understanding Control Structures Using Flowcharts
      12. 4.12 Your First Python Program
      13. 4.13 What is the Difference Between a Syntax Error, a Logic Error, and a Runtime Error?
      14. 4.14 What “Debugging” Means
      15. 4.15 Commenting Your Code
      16. 4.16 User-Friendly Programs
      17. 4.17 Review Questions: True/False
      18. 4.18 Review Questions: Multiple Choice
    2. Chapter 5 Variables and Constants
      1. 5.1 What is a Variable?
      2. 5.2 What is a Constant?
      3. 5.3 How Many Types of Variables and Constants Exist?
      4. 5.4 Rules and Conventions for Naming Variables and Constants in Python
      5. 5.5 What Does the Phrase “Declare a Variable” Mean?
      6. 5.6 How to Declare Variables in Python
      7. 5.7 How to Declare Constants in Python
      8. 5.8 Review Questions: True/False
      9. 5.9 Review Questions: Multiple Choice
      10. 5.10 Review Exercises
    3. Chapter 6 Handling Input and Output
      1. 6.1 How to Output Messages and Results to a User's Screen?
      2. 6.2 How to Alter the Default Behavior of a print Statement?
      3. 6.3 How to Prompt the User to Enter Data?
      4. 6.4 Review Questions: True/False
      5. 6.5 Review Questions: Multiple Choice
    4. Chapter 7 Operators
      1. 7.1 The Value Assignment Operator
      2. 7.2 Arithmetic Operators
      3. 7.3 What is the Precedence of Arithmetic Operators?
      4. 7.4 Compound Assignment Operators
        1. Exercise 7.4-1 Which Python Statements are Syntactically Correct?
        2. Exercise 7.4-2 Finding Variable Types
      5. 7.5 String Operators
        1. Exercise 7.5-1 Concatenating Names
      6. 7.6 Review Questions: True/False
      7. 7.7 Review Questions: Multiple Choice
      8. 7.8 Review Exercises
    5. Chapter 8 Trace Tables
      1. 8.1 What is a Trace Table?
        1. Exercise 8.1-1 Creating a Trace Table
        2. Exercise 8.1-2 Creating a Trace Table
        3. Exercise 8.1-3 Swapping Values of Variables
        4. Exercise 8.1-4 Swapping Values of Variables – An Alternative Approach
      2. 8.2 Review Questions: True/False
      3. 8.3 Review Exercises
    6. Chapter 9 Using IDLE or Visual Studio Code
      1. 9.1 Write, Execute and Debug Python Programs
    7. Review in “Getting Started with Python”
      1. Review Crossword Puzzles
      2. Review Questions
  5. Part III Sequence Control Structures
    1. Chapter 10 Introduction to Sequence Control Structures
      1. 10.1 What is the Sequence Control Structure?
        1. Exercise 10.1-1 Calculating the Area of a Rectangle
        2. Exercise 10.1-2 Calculating the Area of a Circle
        3. Exercise 10.1-3 Where is the Car? Calculating Distance Traveled
        4. Exercise 10.1-4 Kelvin to Fahrenheit
        5. Exercise 10.1-5 Calculating Sales Tax
        6. Exercise 10.1-6 Calculating a Sales Discount
        7. Exercise 10.1-7 Calculating a Sales Discount and Tax
      2. 10.2 Review Exercises
    2. Chapter 11 Manipulating Numbers
      1. 11.1 Introduction
      2. 11.2 Useful Mathematical Functions (Subprograms), and More
        1. Exercise 11.2-1 Calculating the Distance Between Two Points
        2. Exercise 11.2-2 How Far Did the Car Travel?
      3. 11.3 Review Questions: True/False
      4. 11.4 Review Questions: Multiple Choice
      5. 11.5 Review Exercises
    3. Chapter 12 Complex Mathematical Expressions
      1. 12.1 Writing Complex Mathematical Expressions
        1. Exercise 12.1-1 Representing Mathematical Expressions in Python
        2. Exercise 12.1-2 Writing a Mathematical Expression in Python
        3. Exercise 12.1-3 Writing a Complex Mathematical Expression in Python
      2. 12.2 Review Exercises
    4. Chapter 13 Exercises With a Quotient and a Remainder
      1. 13.1 Introduction
        1. Exercise 13.1-1 Calculating the Quotient and Remainder of Integer Division
        2. Exercise 13.1-2 Finding the Sum of Digits
        3. Exercise 13.1-3 Displaying an Elapsed Time
        4. Exercise 13.1-4 Reversing a Number
      2. 13.2 Review Exercises
    5. Chapter 14 Manipulating Strings
      1. 14.1 Introduction
      2. 14.2 The Position of a Character in a String
      3. 14.3 Useful String Functions/Methods (Subprograms), and More
        1. Exercise 14.3-1 Displaying a String Backwards
        2. Exercise 14.3-2 Switching the Order of Names
        3. Exercise 14.3-3 Creating a Login ID
        4. Exercise 14.3-4 Creating a Random Word
        5. Exercise 14.3-5 Finding the Sum of Digits
      4. 14.4 Review Questions: True/False
      5. 14.5 Review Questions: Multiple Choice
      6. 14.6 Review Exercises
    6. Review in “Sequence Control Structures”
      1. Review Crossword Puzzle
      2. Review Questions
  6. Part IV Decision Control Structures
    1. Chapter 15 Making Questions
      1. 15.1 Introduction
      2. 15.2 What is a Boolean Expression?
      3. 15.3 How to Write Simple Boolean Expressions
        1. Exercise 15.3-1 Filling in the Table
      4. 15.4 Logical Operators and Complex Boolean Expressions
        1. Exercise 15.4-1 Calculating the Results of Complex Boolean Expressions
      5. 15.5 Python's Membership Operators
      6. 15.6 Assigning the Result of a Boolean Expression to a Variable
      7. 15.7 What is the Order of Precedence of Logical Operators?
        1. Exercise 15.7-1 Filling in the Truth Table
        2. Exercise 15.7-2 Converting English Sentences to Boolean Expressions
      8. 15.8 What is the Order of Precedence of Arithmetic, Comparison, Membership, and Logical Operators?
      9. 15.9 How to Negate Boolean Expressions
        1. Exercise 15.9-1 Negating Boolean Expressions
      10. 15.10 Review Questions: True/False
      11. 15.11 Review Questions: Multiple Choice
      12. 15.12 Review Exercises
    2. Chapter 16 The Single-Alternative Decision Structure
      1. 16.1 The Single-Alternative Decision Structure
        1. Exercise 16.1-1 Trace Tables and Single-Alternative Decision Structures
        2. Exercise 16.1-2 The Absolute Value of a Number
      2. 16.2 Review Questions: True/False
      3. 16.3 Review Questions: Multiple Choice
      4. 16.4 Review Exercises
    3. Chapter 17 The Dual-Alternative Decision Structure
      1. 17.1 The Dual-Alternative Decision Structure
        1. Exercise 17.1-1 Finding the Output Message
        2. Exercise 17.1-2 Trace Tables and Dual-Alternative Decision Structures
        3. Exercise 17.1-3 Who is the Greatest?
        4. Exercise 17.1-4 Finding Odd and Even Numbers
        5. Exercise 17.1-5 Weekly Wages
      2. 17.2 Review Questions: True/False
      3. 17.3 Review Questions: Multiple Choice
      4. 17.4 Review Exercises
    4. Chapter 18 The Multiple-Alternative Decision Structure
      1. 18.1 The Multiple-Alternative Decision Structure
        1. Exercise 18.1-1 Trace Tables and Multiple-Alternative Decision Structures
        2. Exercise 18.1-2 The Days of the Week
        3. Exercise 18.1-3 Counting the Digits
      2. 18.2 Review Questions: True/False
      3. 18.3 Review Exercises
    5. Chapter 19 Nested Decision Control Structures
      1. 19.1 What are Nested Decision Control Structures?
        1. Exercise 19.1-1 Trace Tables and Nested Decision Control Structures
        2. Exercise 19.1-2 Positive, Negative or Zero?
      2. 19.2 Review Questions: True/False
      3. 19.3 Review Exercises
    6. Chapter 20 More about Flowcharts with Decision Control Structures
      1. 20.1 Introduction
      2. 20.2 Converting Python Programs to Flowcharts
        1. Exercise 20.2-1 Designing the Flowchart
        2. Exercise 20.2-2 Designing the Flowchart
        3. Exercise 20.2-3 Designing the Flowchart
      3. 20.3 A Mistake That You Will Probably Make!
      4. 20.4 Converting Flowcharts to Python Programs
        1. Exercise 20.4-1 Writing the Python Program
        2. Exercise 20.4-2 Writing the Python Program
        3. Exercise 20.4-3 Writing the Python Program
      5. 20.5 Review Exercises
    7. Chapter 21 Tips and Tricks with Decision Control Structures
      1. 21.1 Introduction
      2. 21.2 Choosing a Decision Control Structure
      3. 21.3 Streamlining the Decision Control Structure
        1. Exercise 21.3-1 “Shrinking” the Algorithm
        2. Exercise 21.3-2 “Shrinking” the Python Program
        3. Exercise 21.3-3 “Shrinking” the Algorithm
      4. 21.4 Logical Operators – to Use, or not to Use: That is the Question!
        1. Exercise 21.4-1 Rewriting the Code
        2. Exercise 21.4-2 Rewriting the Code
      5. 21.5 Merging Two or More Single-Alternative Decision Structures
        1. Exercise 21.5-1 Merging the Decision Control Structures
        2. Exercise 21.5-2 Merging the Decision Control Structures
      6. 21.6 Replacing Two Single-Alternative Decision Structures with a Dual-Alternative One
        1. Exercise 21.6-1 “Merging” the Decision Control Structures
      7. 21.7 Put the Boolean Expressions Most Likely to be True First
        1. Exercise 21.7-1 Rearranging the Boolean Expressions
      8. 21.8 Review Questions: True/False
      9. 21.9 Review Questions: Multiple Choice
      10. 21.10 Review Exercises
    8. Chapter 22 More with Decision Control Structures
      1. 22.1 Simple Exercises with Decision Control Structures
        1. Exercise 22.1-1 Is it an Integer?
        2. Exercise 22.1-2 Validating Data Input and Finding Odd and Even Numbers
        3. Exercise 22.1-3 Where is the Tollkeeper?
        4. Exercise 22.1-4 The Most Scientific Calculator Ever!
        5. Exercise 22.1-5 Converting Gallons to Liters, and Vice Versa
        6. Exercise 22.1-6 Converting Gallons to Liters, and Vice Versa (with Data Validation)
      2. 22.2 Finding Minimum and Maximum Values with Decision Control Structures
        1. Exercise 22.2-1 Finding the Name of the Heaviest Person
      3. 22.3 Decision Control Structures in Solving Mathematical Problems
        1. Exercise 22.3-1 Finding the Value of y
        2. Exercise 22.3-2 Finding the Values of y
        3. Exercise 22.3-3 Solving the Linear Equation ax + b = 0
        4. Exercise 22.3-4 Solving the Quadratic Equation ax2 + bx + c = 0
      4. 22.4 Exercises with Series of Consecutive Ranges of Values
        1. Exercise 22.4-1 Calculating the Discount
        2. Exercise 22.4-2 Validating Data Input and Calculating the Discount
        3. Exercise 22.4-3 Sending a Parcel
        4. Exercise 22.4-4 Finding the Values of y
        5. Exercise 22.4-5 Progressive Rates and Electricity Consumption
        6. Exercise 22.4-6 Progressive Rates and Text Messaging Services
      5. 22.5 Exercises of a General Nature with Decision Control Structures
        1. Exercise 22.5-1 Finding a Leap Year
        2. Exercise 22.5-2 Displaying the Days of the Month
        3. Exercise 22.5-3 Checking for Proper Capitalization and Punctuation
        4. Exercise 22.5-4 Is the Number a Palindrome?
      6. 22.6 Boolean Expressions Reference and Handy Tips
      7. 22.7 Review Exercises
    9. Review in “Decision Control Structures”
      1. Review Crossword Puzzle
      2. Review Questions
  7. Part V Loop Control Structures
    1. Chapter 23 Introduction to Loop Control Structures
      1. 23.1 What is a Loop Control Structure?
      2. 23.2 From Sequence Control to Loop Control Structures
      3. 23.3 Review Questions: True/False
    2. Chapter 24 Pre-Test, Mid-Test and Post-Test Loop Structures
      1. 24.1 The Pre-Test Loop Structure
        1. Exercise 24.1-1 Designing the Flowchart and Counting the Total Number of Iterations
        2. Exercise 24.1-2 Counting the Total Number of Iterations
        3. Exercise 24.1-3 Counting the Total Number of Iterations
        4. Exercise 24.1-4 Counting the Total Number of Iterations
        5. Exercise 24.1-5 Finding the Sum of Four Numbers
        6. Exercise 24.1-6 Finding the Sum of Odd Numbers
        7. Exercise 24.1-7 Finding the Sum of N Numbers
        8. Exercise 24.1-8 Finding the Sum of an Unknown Quantity of Numbers
        9. Exercise 24.1-9 Finding the Product of 20 Numbers
      2. 24.2 The Post-Test Loop Structure
        1. Exercise 24.2-1 Designing the Flowchart and Counting the Total Number of Iterations
        2. Exercise 24.2-2 Counting the Total Number of Iterations
        3. Exercise 24.2-3 Designing the Flowchart and Counting the Total Number of Iterations
        4. Exercise 24.2-4 Counting the Total Number of Iterations
        5. Exercise 24.2-5 Finding the Product of N Numbers
      3. 24.3 The Mid-Test Loop Structure
        1. Exercise 24.3-1 Designing the Flowchart and Counting the Total Number of Iterations
      4. 24.4 Review Questions: True/False
      5. 24.5 Review Questions: Multiple Choice
      6. 24.6 Review Exercises
    3. Chapter 25 Definite Loops
      1. 25.1 The for statement
        1. Exercise 25.1-1 Creating the Trace Table
        2. Exercise 25.1-2 Creating the Trace Table
        3. Exercise 25.1-3 Counting the Total Number of Iterations
        4. Exercise 25.1-4 Finding the Sum of Four Numbers
        5. Exercise 25.1-5 Finding the Square Roots from 0 to N
        6. Exercise 25.1-6 Finding the Sum of 1 + 2 + 3 + … + 100
        7. Exercise 25.1-7 Finding the Product of 2 × 4 × 6 × 8 × 10
        8. Exercise 25.1-8 Finding the Sum of 22 + 42 + 62 + … (2N)2
        9. Exercise 25.1-9 Finding the Sum of 33 + 66 + 99 + … (3N)3N
        10. Exercise 25.1-10 Finding the Average Value of Positive Numbers
        11. Exercise 25.1-11 Counting the Vowels
      2. 25.2 Rules that Apply to For-Loops
        1. Exercise 25.2-1 Finding the Sum of N Numbers
      3. 25.3 Review Questions: True/False
      4. 25.4 Review Questions: Multiple Choice
      5. 25.5 Review Exercises
    4. Chapter 26 Nested Loop Control Structures
      1. 26.1 What is a Nested Loop?
        1. Exercise 26.1-1 Say “Hello Zeus”. Counting the Total Number of Iterations.
        2. Exercise 26.1-2 Creating the Trace Table
      2. 26.2 Rules that Apply to Nested Loops
        1. Exercise 26.2-1 Violating the First Rule
        2. Exercise 26.2-2 Violating the Second Rule
      3. 26.3 Review Questions: True/False
      4. 26.4 Review Questions: Multiple Choice
      5. 26.5 Review Exercises
    5. Chapter 27 More about Flowcharts with Loop Control Structures
      1. 27.1 Introduction
      2. 27.2 Converting Python Programs to Flowcharts
        1. Exercise 27.2-1 Designing the Flowchart
        2. Exercise 27.2-2 Designing the Flowchart
        3. Exercise 27.2-3 Designing the Flowchart
        4. Exercise 27.2-4 Designing the Flowchart
        5. Exercise 27.2-5 Designing the Flowchart
      3. 27.3 Converting Flowcharts to Python Programs
        1. Exercise 27.3-1 Writing the Python Program
        2. Exercise 27.3-2 Writing the Python Program
        3. Exercise 27.3-3 Writing the Python Program
        4. Exercise 27.3-4 Writing the Python Program
      4. 27.4 Review Exercises
    6. Chapter 28 Tips and Tricks with Loop Control Structures
      1. 28.1 Introduction
      2. 28.2 Choosing a Loop Control Structure
      3. 28.3 The “Ultimate” Rule
      4. 28.4 Breaking Out of a Loop
      5. 28.5 Cleaning Out Your Loops
        1. Exercise 28.5-1 Cleaning Out the Loop
        2. Exercise 28.5-2 Cleaning Out the Loop
      6. 28.6 Endless Loops and How to Stop Them
      7. 28.7 The “From Inner to Outer” Method
      8. 28.8 Review Questions: True/False
      9. 28.9 Review Questions: Multiple Choice
      10. 28.10 Review Exercises
    7. Chapter 29 More with Loop Control Structures
      1. 29.1 Simple Exercises with Loop Control Structures
        1. Exercise 29.1-1 Counting the Numbers According to Which is Greater
        2. Exercise 29.1-2 Counting the Numbers According to Their Digits
        3. Exercise 29.1-3 How Many Numbers Fit in a Sum
        4. Exercise 29.1-4 Finding the Total Number of Positive Integers
        5. Exercise 29.1-5 Iterating as Many Times as the User Wishes
        6. Exercise 29.1-6 Finding the Sum of the Digits
      2. 29.2 Exercises with Nested Loop Control Structures
        1. Exercise 29.2-1 Displaying all Three-Digit Integers that Contain a Given Digit
        2. Exercise 29.2-2 Displaying all Instances of a Specified Condition
      3. 29.3 Data Validation with Loop Control Structures
        1. Exercise 29.3-1 Finding Odd and Even Numbers - Validation Without Error Messages
        2. Exercise 29.3-2 Finding the Sum of Four Numbers
      4. 29.4 Finding Minimum and Maximum Values with Loop Control Structures
        1. Exercise 29.4-1 Validating and Finding the Minimum and the Maximum Value
        2. Exercise 29.4-2 Validating and Finding the Hottest Planet
        3. Exercise 29.4-3 ”Making the Grade”
      5. 29.5 Using Loop Control Structures to Solve Mathematical Problems
        1. Exercise 29.5-1 Calculating the Area of as Many Triangles as the User Wishes
        2. Exercise 29.5-2 Finding x and y
        3. Exercise 29.5-3 The Russian Multiplication Algorithm
        4. Exercise 29.5-4 Finding the Number of Divisors
        5. Exercise 29.5-5 Is the Number a Prime?
        6. Exercise 29.5-6 Finding all Prime Numbers from 1 to N
        7. Exercise 29.5-7 Heron's Square Root
        8. Exercise 29.5-8 Calculating π
        9. Exercise 29.5-9 Approximating a Real with a Fraction
      6. 29.6 Exercises of a General Nature with Loop Control Structures
        1. Exercise 29.6-1 Fahrenheit to Kelvin, from 0 to 100
        2. Exercise 29.6-2 Rice on a Chessboard
        3. Exercise 29.6-3 Just a Poll
        4. Exercise 29.6-4 Is the Message a Palindrome?
      7. 29.7 Review Questions: True/False
      8. 29.8 Review Exercises
    8. Review in “Loop Control Structures”
      1. Review Crossword Puzzle
      2. Review Questions
  8. Part VI Data Structures in Python
    1. Chapter 30 One-Dimensional Lists and Dictionaries
      1. 30.1 Introduction
      2. 30.2 What is a List?
        1. Exercise 30.2-1 Designing a List
        2. Exercise 30.2-2 Designing Lists
        3. Exercise 30.2-3 Designing Lists
      3. 30.3 Creating One-Dimensional Lists in Python
      4. 30.4 How to Get Values from a One-Dimensional List
        1. Exercise 30.4-1 Creating the Trace Table
        2. Exercise 30.4-2 Using a Non-Existing Index
      5. 30.5 How to Alter the Value of a List Element
      6. 30.6 How to Iterate Through a One-Dimensional List
        1. Exercise 30.6-1 Finding the Sum
      7. 30.7 How to Add User-Entered Values to a One-Dimensional List
        1. Exercise 30.7-1 Displaying Words in Reverse Order
        2. Exercise 30.7-2 Displaying Positive Numbers in Reverse Order
        3. Exercise 30.7-3 Finding the Average Value
        4. Exercise 30.7-4 Displaying Reals Only
        5. Exercise 30.7-5 Displaying Elements with Odd-Numbered Indexes
        6. Exercise 30.7-6 Displaying Even Numbers in Odd–Numbered Index Positions
      8. 30.8 More about the Concatenation and Repetition Operators
      9. 30.9 What is a Dictionary?
      10. 30.10 Creating Dictionaries in Python
      11. 30.11 How to Get a Value from a Dictionary
        1. Exercise 30.11-1 Roman Numerals to Numbers
        2. Exercise 30.11-2 Using a Non-Existing Key in Dictionaries
      12. 30.12 How to Alter the Value of a Dictionary Element
        1. Exercise 30.12-1 Assigning a Value to a Non-Existing Key
      13. 30.13 How to Iterate Through a Dictionary
      14. 30.14 More about the Membership Operators
      15. 30.15 Review Questions: True/False
      16. 30.16 Review Questions: Multiple Choice
      17. 30.17 Review Exercises
    2. Chapter 31 Two-Dimensional Lists
      1. 31.1 Creating Two-Dimensional Lists in Python
      2. 31.2 How to Get Values from Two-Dimensional Lists
        1. Exercise 31.2-1 Creating the Trace Table
      3. 31.3 How to Iterate Through a Two-Dimensional List
      4. 31.4 How to Add User-Entered Values to a Two-Dimensional List
        1. Exercise 31.4-1 Displaying Reals Only
        2. Exercise 31.4-2 Displaying Odd Columns Only
      5. 31.5 What's the Story on Variables i and j?
      6. 31.6 Square Matrices
        1. Exercise 31.6-1 Finding the Sum of the Elements on the Main Diagonal
        2. Exercise 31.6-2 Finding the Sum of the Elements on the Antidiagonal
        3. Exercise 31.6-3 Filling in the List
      7. 31.7 Review Questions: True/False
      8. 31.8 Review Questions: Multiple Choice
      9. 31.9 Review Exercises
    3. Chapter 32 Tips and Tricks with Data Structures
      1. 32.1 Introduction
      2. 32.2 Processing Each Row Individually
        1. Exercise 32.2-1 Finding the Average Value
      3. 32.3 Processing Each Column Individually
        1. Exercise 32.3-1 Finding the Average Value
      4. 32.4 How to Use More Than One Data Structures in a Program
        1. Exercise 32.4-1 Using Three One-Dimensional Lists
        2. Exercise 32.4-2 Using a One-Dimensional List Along with a Two-Dimensional List
        3. Exercise 32.4-3 Using a List Along with a Dictionary
      5. 32.5 Creating a One-Dimensional List from a Two-Dimensional List
      6. 32.6 Creating a Two-Dimensional List from a One-Dimensional List
      7. 32.7 Useful Data Structures Functions/Methods (Subprograms)
      8. 32.8 Review Questions: True/False
      9. 32.9 Review Questions: Multiple Choice
      10. 32.10 Review Exercises
    4. Chapter 33 More with Data Structures
      1. 33.1 Simple Exercises with Lists
        1. Exercise 33.1-1 Creating a List that Contains the Average Values of its Neighboring Elements
        2. Exercise 33.1-2 Creating a List with the Greatest Values
        3. Exercise 33.1-3 Merging One-Dimensional Lists
        4. Exercise 33.1-4 Creating Two Lists – Separating Positive from Negative Values
        5. Exercise 33.1-5 Creating a List with Those who Contain Digit 5
      2. 33.2 Data Validation with Lists
        1. Exercise 33.2-1 Displaying Odds in Reverse Order
      3. 33.3 Finding Minimum and Maximum Values in Lists
        1. Exercise 33.3-1 Which Depth is the Greatest?
        2. Exercise 33.3-2 Which Lake is the Deepest?
        3. Exercise 33.3-3 Which Lake, in Which Country, Having Which Average Area, is the Deepest?
        4. Exercise 33.3-4 Which Students Have got the Greatest Grade?
        5. Exercise 33.3-5 Finding the Minimum Value of a Two-Dimensional List
        6. Exercise 33.3-6 Finding the City with the Coldest Day
        7. Exercise 33.3-7 Finding the Minimum and the Maximum Value of Each Row
      4. 33.4 Sorting Lists
        1. Exercise 33.4-1 The Bubble Sort Algorithm – Sorting One-Dimensional Lists with Numeric Values
        2. Exercise 33.4-2 Sorting One-Dimensional Lists with Alphanumeric Values
        3. Exercise 33.4-3 Sorting One-Dimensional Lists While Preserving the Relationship with a Second List
        4. Exercise 33.4-4 Sorting Last and First Names
        5. Exercise 33.4-5 Sorting a Two-Dimensional List
        6. Exercise 33.4-6 The Modified Bubble Sort Algorithm – Sorting One-Dimensional Lists
        7. Exercise 33.4-7 The Selection Sort Algorithm – Sorting One-Dimensional Lists
        8. Exercise 33.4-8 Sorting One-Dimensional Lists While Preserving the Relationship with a Second List
        9. Exercise 33.4-9 The Insertion Sort Algorithm – Sorting One-Dimensional Lists
        10. Exercise 33.4-10 The Three Worst Elapsed Times
      5. 33.5 Searching Elements in Data Structures
        1. Exercise 33.5-1 The Linear Search Algorithm – Searching in a One-Dimensional List that may Contain the Same Value Multiple Times
        2. Exercise 33.5-2 Display the Last Names of All Those People Who Have the Same First Name
        3. Exercise 33.5-3 The Linear Search Algorithm – Searching in a Two-Dimensional List that May Contain the Same Value Multiple Times
        4. Exercise 33.5-4 The Linear Search Algorithm – Searching in a One-Dimensional List that Contains Unique Values
        5. Exercise 33.5-5 Searching for a Social Security Number
        6. Exercise 33.5-6 The Linear Search Algorithm – Searching in a Two-Dimensional List that Contains Unique Values
        7. Exercise 33.5-7 Checking if a Value Exists in all Columns
        8. Exercise 33.5-8 The Binary Search Algorithm – Searching in a Sorted One-Dimensional List
        9. Exercise 33.5-9 Display all the Historical Events for a Country
        10. Exercise 33.5-10 Searching in Each Column of a Two-Dimensional List
      6. 33.6 Exercises of a General Nature with Data Structures
        1. Exercise 33.6-1 On Which Days was There a Possibility of Snow?
        2. Exercise 33.6-2 Was There Any Possibility of Snow?
        3. Exercise 33.6-3 In Which Cities was There a Possibility of Snow?
        4. Exercise 33.6-4 Display from Highest to Lowest Grades by Student, and in Alphabetical Order
        5. Exercise 33.6-5 Archery at the Summer Olympics
        6. Exercise 33.6-6 The Five Best Scorers
        7. Exercise 33.6-7 Counting the Frequency of Vowels
      7. 33.7 Review Questions: True/False
      8. 33.8 Review Exercises
    5. Review in “Data Structures in Python”
      1. Review Crossword Puzzle
      2. Review Questions
  9. Part VII Subprograms
    1. Chapter 34 Introduction to Subprograms
      1. 34.1 What Exactly is a Subprogram?
      2. 34.2 What is Procedural Programming?
      3. 34.3 What is Modular Programming?
      4. 34.4 Review Questions: True/False
    2. Chapter 35 User-Defined Subprograms
      1. 35.1 Subprograms that Return Values
      2. 35.2 How to Make a Call to a Function
      3. 35.3 Subprograms that Return no Values
      4. 35.4 How to Make a Call to a void Function
      5. 35.5 Formal and Actual Arguments
      6. 35.6 How Does a Function Execute?
        1. Exercise 35.6-1 Back to Basics – Calculating the Sum of Two Numbers
        2. Exercise 35.6-2 Calculating the Sum of Two Numbers Using Fewer Lines of Code!
      7. 35.7 How Does a void Function Execute?
        1. Exercise 35.7-1 Back to Basics – Displaying the Absolute Value of a Number
      8. 35.8 Review Questions: True/False
      9. 35.9 Review Exercises
    3. Chapter 36 Tips and Tricks with Subprograms
      1. 36.1 Can Two Subprograms use Variables of the Same Name?
      2. 36.2 Can a Subprogram Call Another Subprogram?
      3. 36.3 Passing Arguments by Value and by Reference
      4. 36.4 Returning a List
      5. 36.5 Default Argument Values (Optional Arguments) and Keyword Arguments
      6. 36.6 The Scope of a Variable
      7. 36.7 Converting Parts of Code into Subprograms
      8. 36.8 Recursion
      9. 36.9 Review Questions: True/False
      10. 36.10 Review Exercises
    4. Chapter 37 More with Subprograms
      1. 37.1 Simple Exercises with Subprograms
        1. Exercise 37.1-1 A Simple Currency Converter
        2. Exercise 37.1-2 Finding the Average Values of Positive Integers
        3. Exercise 37.1-3 Finding the Sum of Odd Positive Integers
        4. Exercise 37.1-4 Finding the Values of y
      2. 37.2 Exercises of a General Nature with Subprograms
        1. Exercise 37.2-1 Validating Data Input Using a Subprogram
        2. Exercise 37.2-2 Sorting a List Using a Subprogram
        3. Exercise 37.2-3 Progressive Rates and Electricity Consumption
        4. Exercise 37.2-4 Roll, Roll, Roll the… Dice!
        5. Exercise 37.2-5 How Many Times Does Each Number of the Dice Appear?
      3. 37.3 Review Exercises
    5. Review in “Subprograms”
      1. Review Crossword Puzzle
      2. Review Questions
  10. Part VIII Object-Oriented Programming
    1. Chapter 38 Introduction to Object-Oriented Programming
      1. 38.1 What is Object-Oriented Programming?
      2. 38.2 Classes and Objects in Python
      3. 38.3 The Constructor and the Keyword self
      4. 38.4 Passing Initial Values to the Constructor
      5. 38.5 Class Fields vs Instance Fields
      6. 38.6 Getter and Setter Methods vs Properties
        1. Exercise 38.6-1 The Roman Numerals
      7. 38.7 Can a Method Call Another Method of the Same Class?
        1. Exercise 38.7-1 Doing Math
      8. 38.8 Class Inheritance
      9. 38.9 Review Questions: True/False
      10. 38.10 Review Exercises
    2. Review in “Object-Oriented Programming”
      1. Review Crossword Puzzle
      2. Review Questions
  11. Part IX Files
    1. Chapter 39 Introduction to Files
      1. 39.1 Introduction
      2. 39.2 Opening a File
      3. 39.3 Closing a File
      4. 39.4 Writing in (or Appending to) a File
      5. 39.5 The File Pointer
      6. 39.6 Reading from a File
      7. 39.7 Iterating Through the Contents of a File
      8. 39.8 Review Questions: True/False
      9. 39.9 Review Exercises
    2. Chapter 40 More with Files
      1. 40.1 Exercises of a General Nature with Files
        1. Exercise 40.1-1 Calculating the Sum of 10 Numbers
        2. Exercise 40.1-2 Calculating the Average Value of an Unknown Quantity of Numbers
        3. Exercise 40.1-3 Finding Minimum and Maximum Values
        4. Exercise 40.1-4 Concatenating Files
        5. Exercise 40.1-5 Searching in a File
        6. Exercise 40.1-6 Combining Files with Subprograms
      2. 40.2 Review Exercises
    3. Review in “Files”
      1. Review Crossword Puzzle
      2. Review Questions
  12. Some Final Words from the Author

Product information

  • Title: Python and Algorithmic Thinking for the Complete Beginner
  • Author(s): Aristides Bouras
  • Release date: June 2024
  • Publisher(s): Packt Publishing
  • ISBN: 9781836209270