problem solving and python programming technical publications

Challenging Programming in Python: A Problem Solving Perspective

  • © 2024
  • Habib Izadkhah 0 ,
  • Rashid Behzadidoost 1

Department of Computer Science, University of Tabriz, Tabriz, Iran

You can also search for this author in PubMed   Google Scholar

  • Demonstrates with a lot of examples how to solve problems with Python
  • Provides an accessible introduction to Python
  • Presents challenging problems and its programming solutions from different areas of applied sciences

6754 Accesses

This is a preview of subscription content, log in via an institution to check access.

Access this book

Subscribe and save.

  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Other ways to access

Licence this eBook for your library

Institutional subscriptions

About this book

This book aims to strengthen programming skills and foster creative thinking by presenting and solving 90 challenging problems. The book is intended for individuals with elementary, intermediate, and advanced Python programming skills who aspire to take their abilities to the next level. Additionally, the book is valuable for individuals interested in enhancing their creative thinking and logical reasoning skills. It is a self-instructional book meant to provide readers with the ability to solve challenging problems independently. The presented challenges are lucidly and succinctly expressed, facilitating readers to follow along and comprehend the problem-solving process. The challenges cover various fields, making it suitable for a wide range of individuals.

The book is divided into eight chapters, beginning with an introduction in chapter one. The second chapter presents essential Python basics for programming challenging problems, while the subsequent chapters focuson specific types of challenges. These include math-based challenges in chapter three, number-based challenges in chapter four, string-based challenges in chapter five, game-based challenges in chapter six, count-based challenges in chapter seven, and miscellaneous challenges in chapter eight. Each chapter comprises a set of challenges with examples, hints, algorithms, and Python code solutions. The target audience of the book includes computer science and engineering students, teachers, software developers, and participants in programming competitions.

Similar content being viewed by others

problem solving and python programming technical publications

Welcome to Python

problem solving and python programming technical publications

Microworlds, Objects First, Computational Thinking and Programming

problem solving and python programming technical publications

Skramble: An Embeddable Python Programming Environment for Use in Learning Systems

  • Problem Solving with Phyton
  • Programming Language
  • Introduction to Phyton
  • Phyton Basics

Table of contents (8 chapters)

Front matter, introduction.

Habib Izadkhah, Rashid Behzadidoost

Python Basics

Miscellaneous problems, authors and affiliations, about the authors.

Dr. Habib Izadkhah is an associate professor at the Department of Computer Science, University of Tabriz, Iran. He worked in the industry for a decade as a software engineer before becoming an academic. His research interests include algorithms and graphs, software engineering, and bioinformatics. More recently, he has been working on developing and applying deep learning to a variety of problems, dealing with biomedical images, speech recognition, text understanding, and generative models. He has contributed to various research projects, authored a number of research papers in international conferences, workshops, and journals, and also has written five books, including Source Code Modularization: Theory and Techniques from Springer and Deep Learning in Bioinformatics from Elsevier.

Rashid Behzadidoost is a Ph.D. candidate in Computer Science at the University of Tabriz, Iran. He is currently pursuing his doctoral degree in Computer Science, specializing in artificial intelligence and natural language processing. Rashid has a deep passion for coding and enjoys solving challenging problems. He has obtained his skills through years of study, practice, and teaching. He has taught several courses on computer sciences including challenging programming, microprocessor, and data structure at the University of Tabriz.

Bibliographic Information

Book Title : Challenging Programming in Python: A Problem Solving Perspective

Authors : Habib Izadkhah, Rashid Behzadidoost

DOI : https://doi.org/10.1007/978-3-031-39999-2

Publisher : Springer Cham

eBook Packages : Engineering , Engineering (R0)

Copyright Information : The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer Nature Switzerland AG 2024

Hardcover ISBN : 978-3-031-39998-5 Published: 18 October 2023

Softcover ISBN : 978-3-031-40001-8 Due: 31 October 2024

eBook ISBN : 978-3-031-39999-2 Published: 17 October 2023

Edition Number : 1

Number of Pages : XI, 280

Number of Illustrations : 3 b/w illustrations, 7 illustrations in colour

Topics : Mathematical and Computational Engineering , Control, Robotics, Mechatronics , Professional Computing

  • Publish with us

Policies and ethics

  • Find a journal
  • Track your research

problem solving and python programming technical publications

  • Booklist / Catalogue
  • Dealers List
  • Problem Solving and Python Programming

problem solving and python programming technical publications

T. Shantha Kumar

Subject code : 978-93-5577-478-1, regulation : 2021, product tags: 0.

problem solving and python programming technical publications

Related Books

Programming & Data Structures-II

problem solving and python programming technical publications

  • Kindle Store
  • Kindle eBooks
  • Education & Teaching
Print List Price: $44.46
Kindle Price: $22.23

Save $22.23 (50%)

Amazon.com Services LLC

Promotions apply when you purchase

These promotions will be applied to this item:

Some promotions may be combined; others are not eligible to be combined with other offers. For details, please see the Terms & Conditions associated with these promotions.

Buy for others

Buying and sending ebooks to others.

  • Select quantity
  • Buy and send eBooks
  • Recipients can read on any device

These ebooks can only be redeemed by recipients in the US. Redemption links and eBooks cannot be resold.

Sorry, there was a problem.

Image unavailable.

Programming and Problem Solving using Python : Fundamentals and Applications

  • To view this video download Flash Player

Programming and Problem Solving using Python : Fundamentals and Applications [Print Replica] Kindle Edition

  • Language English
  • Sticky notes Not Enabled
  • Publication date December 15, 2020
  • File size 16888 KB
  • Page Flip Not Enabled
  • Word Wise Not Enabled
  • Enhanced typesetting Not Enabled
  • See all details

Fire Tablets

  • Fire HD 8 (8th Generation)
  • Fire 7 (9th Generation)
  • Fire HD 10 (9th Generation)
  • Fire HD 8 (10th Generation)
  • Fire HD 10 (11th Generation)
  • Fire HD 10 Plus
  • Fire 7 (12th Generation)
  • Fire HD 8 (12th Generation)
  • Fire HD 8 Plus

Free Kindle Reading Apps

  • Kindle for Android Phones
  • Kindle for Android Tablets
  • Kindle for iPhone
  • Kindle for iPad
  • Kindle for Mac
  • Kindle for PC
  • Kindle for Web

Product details

  • ASIN ‏ : ‎ B08QSDH7R4
  • Publisher ‏ : ‎ TECHNICAL PUBLICATIONS; 1st edition (December 15, 2020)
  • Publication date ‏ : ‎ December 15, 2020
  • Language ‏ : ‎ English
  • File size ‏ : ‎ 16888 KB
  • Text-to-Speech ‏ : ‎ Not enabled
  • Enhanced typesetting ‏ : ‎ Not Enabled
  • X-Ray ‏ : ‎ Not Enabled
  • Word Wise ‏ : ‎ Not Enabled
  • Sticky notes ‏ : ‎ Not Enabled
  • Format ‏ : ‎ Print Replica
  • #2,324 in Computers & Technology Teaching & Reference
  • #2,592 in Computers & Technology Education
  • #4,185 in College & University Education

Customer reviews

  • 5 star 4 star 3 star 2 star 1 star 5 star 0% 0% 0% 0% 0% 0%
  • 5 star 4 star 3 star 2 star 1 star 4 star 0% 0% 0% 0% 0% 0%
  • 5 star 4 star 3 star 2 star 1 star 3 star 0% 0% 0% 0% 0% 0%
  • 5 star 4 star 3 star 2 star 1 star 2 star 0% 0% 0% 0% 0% 0%
  • 5 star 4 star 3 star 2 star 1 star 1 star 0% 0% 0% 0% 0% 0%

Customer Reviews, including Product Star Ratings help customers to learn more about the product and decide whether it is the right product for them.

To calculate the overall star rating and percentage breakdown by star, we don’t use a simple average. Instead, our system considers things like how recent a review is and if the reviewer bought the item on Amazon. It also analyzed reviews to verify trustworthiness.

No customer reviews

Report an issue.

  • About Amazon
  • Investor Relations
  • Amazon Devices
  • Amazon Science
  • Sell products on Amazon
  • Sell on Amazon Business
  • Sell apps on Amazon
  • Become an Affiliate
  • Advertise Your Products
  • Self-Publish with Us
  • Host an Amazon Hub
  • › See More Make Money with Us
  • Amazon Business Card
  • Shop with Points
  • Reload Your Balance
  • Amazon Currency Converter
  • Amazon and COVID-19
  • Your Account
  • Your Orders
  • Shipping Rates & Policies
  • Returns & Replacements
  • Manage Your Content and Devices
 
 
 
 
  • Conditions of Use
  • Privacy Notice
  • Consumer Health Data Privacy Disclosure
  • Your Ads Privacy Choices

problem solving and python programming technical publications

problem solving and python programming technical publications

  • Runestone in social media: Follow @iRunestone Our Facebook Page
  • Table of Contents
  • Assignments
  • Peer Instruction (Instructor)
  • Peer Instruction (Student)
  • Change Course
  • Instructor's Page
  • Progress Page
  • Edit Profile
  • Change Password
  • Scratch ActiveCode
  • Scratch Activecode
  • Instructors Guide
  • About Runestone
  • Report A Problem
  • This Chapter
  • 1. Introduction' data-toggle="tooltip" >

Problem Solving with Algorithms and Data Structures using Python ¶

PythonDS Cover

By Brad Miller and David Ranum, Luther College

There is a wonderful collection of YouTube videos recorded by Gerry Jenkins to support all of the chapters in this text.

  • 1.1. Objectives
  • 1.2. Getting Started
  • 1.3. What Is Computer Science?
  • 1.4. What Is Programming?
  • 1.5. Why Study Data Structures and Abstract Data Types?
  • 1.6. Why Study Algorithms?
  • 1.7. Review of Basic Python
  • 1.8.1. Built-in Atomic Data Types
  • 1.8.2. Built-in Collection Data Types
  • 1.9.1. String Formatting
  • 1.10. Control Structures
  • 1.11. Exception Handling
  • 1.12. Defining Functions
  • 1.13.1. A Fraction Class
  • 1.13.2. Inheritance: Logic Gates and Circuits
  • 1.14. Summary
  • 1.15. Key Terms
  • 1.16. Discussion Questions
  • 1.17. Programming Exercises
  • 2.1.1. A Basic implementation of the MSDie class
  • 2.2. Making your Class Comparable
  • 3.1. Objectives
  • 3.2. What Is Algorithm Analysis?
  • 3.3. Big-O Notation
  • 3.4.1. Solution 1: Checking Off
  • 3.4.2. Solution 2: Sort and Compare
  • 3.4.3. Solution 3: Brute Force
  • 3.4.4. Solution 4: Count and Compare
  • 3.5. Performance of Python Data Structures
  • 3.7. Dictionaries
  • 3.8. Summary
  • 3.9. Key Terms
  • 3.10. Discussion Questions
  • 3.11. Programming Exercises
  • 4.1. Objectives
  • 4.2. What Are Linear Structures?
  • 4.3. What is a Stack?
  • 4.4. The Stack Abstract Data Type
  • 4.5. Implementing a Stack in Python
  • 4.6. Simple Balanced Parentheses
  • 4.7. Balanced Symbols (A General Case)
  • 4.8. Converting Decimal Numbers to Binary Numbers
  • 4.9.1. Conversion of Infix Expressions to Prefix and Postfix
  • 4.9.2. General Infix-to-Postfix Conversion
  • 4.9.3. Postfix Evaluation
  • 4.10. What Is a Queue?
  • 4.11. The Queue Abstract Data Type
  • 4.12. Implementing a Queue in Python
  • 4.13. Simulation: Hot Potato
  • 4.14.1. Main Simulation Steps
  • 4.14.2. Python Implementation
  • 4.14.3. Discussion
  • 4.15. What Is a Deque?
  • 4.16. The Deque Abstract Data Type
  • 4.17. Implementing a Deque in Python
  • 4.18. Palindrome-Checker
  • 4.19. Lists
  • 4.20. The Unordered List Abstract Data Type
  • 4.21.1. The Node Class
  • 4.21.2. The Unordered List Class
  • 4.22. The Ordered List Abstract Data Type
  • 4.23.1. Analysis of Linked Lists
  • 4.24. Summary
  • 4.25. Key Terms
  • 4.26. Discussion Questions
  • 4.27. Programming Exercises
  • 5.1. Objectives
  • 5.2. What Is Recursion?
  • 5.3. Calculating the Sum of a List of Numbers
  • 5.4. The Three Laws of Recursion
  • 5.5. Converting an Integer to a String in Any Base
  • 5.6. Stack Frames: Implementing Recursion
  • 5.7. Introduction: Visualizing Recursion
  • 5.8. Sierpinski Triangle
  • 5.9. Complex Recursive Problems
  • 5.10. Tower of Hanoi
  • 5.11. Exploring a Maze
  • 5.12. Dynamic Programming
  • 5.13. Summary
  • 5.14. Key Terms
  • 5.15. Discussion Questions
  • 5.16. Glossary
  • 5.17. Programming Exercises
  • 6.1. Objectives
  • 6.2. Searching
  • 6.3.1. Analysis of Sequential Search
  • 6.4.1. Analysis of Binary Search
  • 6.5.1. Hash Functions
  • 6.5.2. Collision Resolution
  • 6.5.3. Implementing the Map Abstract Data Type
  • 6.5.4. Analysis of Hashing
  • 6.6. Sorting
  • 6.7. The Bubble Sort
  • 6.8. The Selection Sort
  • 6.9. The Insertion Sort
  • 6.10. The Shell Sort
  • 6.11. The Merge Sort
  • 6.12. The Quick Sort
  • 6.13. Summary
  • 6.14. Key Terms
  • 6.15. Discussion Questions
  • 6.16. Programming Exercises
  • 7.1. Objectives
  • 7.2. Examples of Trees
  • 7.3. Vocabulary and Definitions
  • 7.4. List of Lists Representation
  • 7.5. Nodes and References
  • 7.6. Parse Tree
  • 7.7. Tree Traversals
  • 7.8. Priority Queues with Binary Heaps
  • 7.9. Binary Heap Operations
  • 7.10.1. The Structure Property
  • 7.10.2. The Heap Order Property
  • 7.10.3. Heap Operations
  • 7.11. Binary Search Trees
  • 7.12. Search Tree Operations
  • 7.13. Search Tree Implementation
  • 7.14. Search Tree Analysis
  • 7.15. Balanced Binary Search Trees
  • 7.16. AVL Tree Performance
  • 7.17. AVL Tree Implementation
  • 7.18. Summary of Map ADT Implementations
  • 7.19. Summary
  • 7.20. Key Terms
  • 7.21. Discussion Questions
  • 7.22. Programming Exercises
  • 8.1. Objectives
  • 8.2. Vocabulary and Definitions
  • 8.3. The Graph Abstract Data Type
  • 8.4. An Adjacency Matrix
  • 8.5. An Adjacency List
  • 8.6. Implementation
  • 8.7. The Word Ladder Problem
  • 8.8. Building the Word Ladder Graph
  • 8.9. Implementing Breadth First Search
  • 8.10. Breadth First Search Analysis
  • 8.11. The Knight’s Tour Problem
  • 8.12. Building the Knight’s Tour Graph
  • 8.13. Implementing Knight’s Tour
  • 8.14. Knight’s Tour Analysis
  • 8.15. General Depth First Search
  • 8.16. Depth First Search Analysis
  • 8.17. Topological Sorting
  • 8.18. Strongly Connected Components
  • 8.19. Shortest Path Problems
  • 8.20. Dijkstra’s Algorithm
  • 8.21. Analysis of Dijkstra’s Algorithm
  • 8.22. Prim’s Spanning Tree Algorithm
  • 8.23. Summary
  • 8.24. Key Terms
  • 8.25. Discussion Questions
  • 8.26. Programming Exercises

Acknowledgements ¶

We are very grateful to Franklin Beedle Publishers for allowing us to make this interactive textbook freely available. This online version is dedicated to the memory of our first editor, Jim Leisy, who wanted us to “change the world.”

[PDF] GE3151 Problem Solving and Python Programming (PSPP) Books, Lecture Notes, 2 marks with answers, Important Part B 16 Marks Questions, Question Bank & Syllabus

Download GE3151 Problem Solving and Python Programming (PSPP) Books Lecture Notes Syllabus Part-A 2 marks with answers GE3151 Problem Solving and Python Programming Important Part-B 16 marks Questions , PDF Books, Question Bank with answers Key, GE3151 Problem Solving and Python Programming Syllabus & Anna University GE3151 Problem Solving and Python Programming Question Papers Collection.

Students Click to Join our WhatsApp Group | Telegram Channel

Download link is provided for Students to download the Anna University GE3151 Problem Solving and Python Programming Syllabus Question Bank Lecture Notes Part A 2 marks with answers & Part B 16 marks Question Bank with answer , Anna University Question Paper Collection, All the materials are listed below for the students to make use of it and get good (maximum) marks with our study materials.

“GE3151 Problem Solving and Python Programming Notes, Lecture Notes, Previous Years Question Papers “

“GE3151 Problem Solving and Python Programming Important 16 marks Questions with Answers”

“GE3151 Problem Solving and Python Programming Important 2 marks & 16 marks Questions with Answers”

“GE3151 Problem Solving and Python Programming Important Part A & Part B Questions”

“GE3151 Problem Solving and Python Programming Syllabus, Local Author Books, Question Banks”

You all must have this kind of questions in your mind. Below article will solve this puzzle of yours. Just take a look and download the study materials for your preparation.

GE3151 Problem Solving and Python Programming (PSPP) Notes Part A & Part B Important Questions with Answers

GE3151 Problem Solving and Python Programming – Study Materials – Details

01
Common to All Departments (Civil, CSE, ECE, EEE & Mech)
First Year
R2021
GE3151 Problem Solving and Python Programming (PSPP)
Syllabus, Question Banks, Local Authors Books, Lecture Notes, Important Part A 2 Marks Questions and Important Part B 16 Mark Questions, Previous Years Anna University Question Papers Collections.
PDF (Free Download)

GE3151 Problem Solving and Python Programming (PSPP) “R2021 – SYLLABUS”

GE3151 PROBLEM SOLVING AND PYTHON PROGRAMMING

UNIT I COMPUTATIONAL THINKING AND PROBLEM SOLVING

Fundamentals of Computing – Identification of Computational Problems -Algorithms, building blocks of algorithms (statements, state, control flow, functions), notation (pseudo code, flow chart, programming language), algorithmic problem solving, simple strategies for developing algorithms (iteration, recursion). Illustrative problems: find minimum in a list, insert a card in a list of sorted cards, guess an integer number in a range, Towers of Hanoi.

UNIT II DATA TYPES, EXPRESSIONS, STATEMENTS

Python interpreter and interactive mode, debugging; values and types: int, float, boolean, string, and list; variables, expressions, statements, tuple assignment, precedence of operators, comments; Illustrative programs: exchange the values of two variables, circulate the values of n variables, distance between two points.

UNIT III CONTROL FLOW, FUNCTIONS, STRINGS

Conditionals: Boolean values and operators, conditional (if), alternative (if-else), chained conditional (if-elif-else); Iteration: state, while, for, break, continue, pass; Fruitful functions: return values, parameters, local and global scope, function composition, recursion; Strings: string slices, immutability, string functions and methods, string module; Lists as arrays. Illustrative programs: square root, gcd, exponentiation, sum an array of numbers, linear search, binary search.

UNIT IV LISTS, TUPLES, DICTIONARIES

Lists: list operations, list slices, list methods, list loop, mutability, aliasing, cloning lists, list parameters; Tuples: tuple assignment, tuple as return value; Dictionaries: operations and methods; advanced list processing – list comprehension; Illustrative programs: simple sorting, histogram, Students marks statement, Retail bill preparation.

UNIT V FILES, MODULES, PACKAGES

Files and exception: text files, reading and writing files, format operator; command line arguments, errors and exceptions, handling exceptions, modules, packages; Illustrative programs: word count, copy file, Voter’s age validation, Marks range validation (0-100).

  TEXT BOOKS:

  • Allen B. Downey, “Think Python : How to Think like a Computer Scientist”, 2nd Edition, O’Reilly Publishers, 2016.
  • Karl Beecher, “Computational Thinking: A Beginner's Guide to Problem Solving and programming”, 1st Edition, BCS Learning & Development Limited, 2017.

REFERENCES:

  • Paul Deitel and Harvey Deitel, “Python for Programmers”, Pearson Education, 1st Edition,
  • G Venkatesh and Madhavan Mukund, “Computational Thinking: A Primer for Programmers and Data Scientists”, 1st Edition, Notion Press, 2021.
  • John V Guttag, "Introduction to Computation and Programming Using Python: With Applications to Computational Modeling and Understanding Data‘‘, Third Edition, MIT Press 2021
  • Eric Matthes, “Python Crash Course, A Hands – on Project Based Introduction to Programming”, 2nd Edition, No Starch Press, 2019.
  • https://www.python.org/
  • 6. Martin C. Brown, “Python: The Complete Reference”, 4th Edition, Mc-Graw Hill,2018.

DOWNLOAD LINK

Anna University GE3151 Problem Solving and Python Programming Books Question Banks Lecture Notes Syllabus GE3151 Problem Solving and Python Programming Part A 2 Marks with Answers Part – B 16 Marks Questions with Answers & Anna University GE3151 Problem Solving and Python Programming Question Paper Collection and Local Author Books.

Click below the link “DOWNLOAD” to save the Book/Material (PDF)

Kindly Note : There are different collection of GE3151 Problem Solving and Python Programming study materials are listed below. Based on your requirement choose the suitable material for your preparation.

GE3151 Problem Solving and Python Programming Lecture Notes

Ge3151 lecture notes collection 01 – download, ge3151 lecture notes collection 02 – download, ge3151 lecture notes collection 03 – download, ge3151 lecture notes collection 04 – download, ge3151 lecture notes collection 05 – download.

GE3151 Problem Solving and Python Programming Unit wise 2 marks Question with Answers

Ge3151 2 marks collection 01 – download, ge3151 2 marks collection 02 – download, ge3151 important question collection 03 – download, ge3151 important question collection 04 – download, ge3151 problem solving and python programming unit wise 2 marks, 16 marks questions with answers, ge3151 student notes collection 01 – download, ge3151 student notes collection 02 – download, ge3151 student notes collection 03 – download, ge3151 student notes collection 04 – download, ge3151 student notes collection 05 – download, ge3151 problem solving and python programming important questions & question bank collection, ge3151 questions bank collection 01 – download, ge3151 questions bank collection 02 – download, ge3151 questions bank collection 03 – download, ge3151 problem solving and python programming anna university question paper collection, ge3151 anna university question papers collection 01 – download, ge3151 anna university question papers collection 02 – download, ge3151 previous year collection  – download.

We need Your Support, Kindly Share this Web Page with Other Friends

If you have any Engg study materials with you kindly share it, It will be useful to other friends & We Will Publish The Book/Materials Submitted By You Immediately Including The Book/Materials Credits (Your Name) Soon After We Receive It (If The Book/Materials Is Not Posted Already By Us)

If You Think This Materials Is Useful, Kindly Share it .

problem solving and python programming technical publications

Click Here To Check Anna University Recent Updates.

Click here to download anna university ug/ pg regulation 2021 syllabus ., click here to check anna university results, other useful links, click here to download other semester civil engineering r2021 study material., click here to download other semester cse r2021 study material., click here to download other semester ece r2021 study material., click here to download other semester eee r2021 study material., click here to download other semester mechanical engineering r2021 study material., click here to download department wise r2017 & r2013 study materials., click here to download gate exam study materials., click here to download competitive exam (rrb & ssc) study materials., click here to download competitive exam (iit – jee exam) study materials., click here to download engineering text books (all departments) collection..

Thank you for visiting my thread. Hope this post is helpful to you. Have a great day !

Kindly share this post with your friends to make this exclusive release more useful.

LEAVE A REPLY Cancel reply

Save my name, email, and website in this browser for the next time I comment.

Notify me of follow-up comments by email.

Notify me of new posts by email.

Trending Today

Computer Science Engineering Books Huge Collection (Subject wise)

[PDF] Computer Science Engineering Books Huge Collection (Subject wise) Free Download

All time trending.

problem solving and python programming technical publications

[PDF] Anna University Nov/ Dec 2021 Online Exam Instructions to the...

Get new updates email alerts.

Enter your E- Mail Address to Subscribe this Blog and Receive Notifications of New Posts by E-Mail.

problem solving and python programming technical publications

Today Updates

Multiband RF Circuits and Techniques for Wireless Transmitters By Wenhua Chen

[PDF] Multiband RF Circuits and Techniques for Wireless Transmitters By Wenhua...

Quantum Mechanics for Pedestrians 2 By Jochen Pade

[PDF] Quantum Mechanics for Pedestrians 2 By Jochen Pade Free Download

Made Easy Academy Power Plant Engineering Handwritten Notes

[PDF] Made Easy Academy Power Plant Engineering Handwritten Notes for IES...

problem solving and python programming technical publications

[PDF] Architectural Technology: Research and Practice By Stephen Emmitt Free Download

IES Objective Civil Engineering Previous Years Papers Collection

[PDF] Engineering Service Exam(IES ESE) Objective Civil Engineering Previous Years Papers...

Gate Academy Air Pollution Notes

[PDF] Gate Academy Air Pollution Notes for IES IAS GATE SSC...

Chemical Bonding (Chemistry) Notes for IIT-JEE Exam

[PDF] Chemical Bonding (Chemistry) Notes for IIT-JEE Exam Free Download

Popular files.

EC8702 Ad hoc and Wireless Sensor Networks

[PDF] EC8702 Ad hoc and Wireless Sensor Networks Lecture Notes, Books,...

EE8002 Design of Electrical Apparatus

EE8002 Design of Electrical Apparatus Lecture Notes, Books, Important Part-A 2...

CS8651 Internet Programming

CS8651 Internet Programming Lecture Notes, Books, Important Part-A 2 Marks Questions...

BE3251 Basic Electrical and Electronics Engineering

[PDF] BE3251 Basic Electrical and Electronics Engineering (BEEE) Books, Lecture Notes,...

problem solving and python programming technical publications

[PDF] CS6551 Computer Networks Lecture Notes, Books, Important 2 Marks Questions...

problem solving and python programming technical publications

[PDF] EC8391 Control Systems Engineering Lecture Notes, Books, Important Part-A 2...

Trending on learnengineering.in.

IES Electronics and Telecommunication Engineering Objective Previous Years Papers Collection

[PDF] Engineering Service Exam(IES ESE) Objective Electronics and Telecommunication Engineering Previous...

Alkyne (Chemistry) Notes for IIT-JEE Exam

[PDF] Alkyne (Chemistry) Notes for IIT-JEE Exam Free Download

A Handbook on Civil Engineering By Jyoti Nag

[PDF] A Handbook on Civil Engineering By Jyoti Nag for RRB...

Hydrocarbon (Chemistry) Notes for IIT-JEE Exam

[PDF] Hydrocarbon (Chemistry) Notes for IIT-JEE Exam Free Download

General Organic Chemistry (Chemistry) Notes for IIT-JEE Exam

[PDF] General Organic Chemistry (Chemistry) Notes for IIT-JEE Exam Free Download

Electrostatics (Physics) Notes for IIT-JEE Exam

[PDF] Electrostatics (Physics) Notes for IIT-JEE Exam Free Download

Foundations for Radio Frequency Engineering By Geyi Wen

[PDF] Foundations for Radio Frequency Engineering By Geyi Wen Free Download

Sponsored by.

Website Designed and Maintained by LearnEngineering Network | Website CDN by   MaxCDN   |   Website Security by   Sucuri .

Check your Email after Joining and Confirm your mail id to get updates alerts.

...Join Now...

Search Your Files

problem solving and python programming technical publications

  • Privacy Policy
  • DMCA & Copyright
  • User Content Policy
  • Report Problems/Bug/Abuse

Join our Telegram Group & Share your contents, doubts, knowledge with other Students/Graduates 

problem solving and python programming technical publications

Official Telegram Channel 

Articles for you (New Session Especially for readers)

New Mock (Free Quiz) Website  

Jobs Alerts Group

problem solving and python programming technical publications

  • Higher Education Textbooks
  • Computer Science

Sorry, there was a problem.

Kindle app logo image

Download the free Kindle app and start reading Kindle books instantly on your smartphone, tablet or computer – no Kindle device required .

Read instantly on your browser with Kindle for Web.

Using your mobile phone camera, scan the code below and download the Kindle app.

QR code to download the Kindle App

Image Unavailable

Problem Solving and Python Programming

  • To view this video download Flash Player

Problem Solving and Python Programming Paperback – 1 August 2021

Save extra with 2 offers.

  • Free Delivery

10 days Replacement

  • Amazon Delivered
  • Pay on Delivery
  • Secure transaction
Replacement Reason Replacement Period Replacement Policy
Physical Damage,
Defective,
Wrong and Missing Item
10 days from delivery Replacement

Replacement Instructions

problem solving and python programming technical publications

Purchase options and add-ons

  • ISBN-10 8195175503
  • ISBN-13 978-8195175505
  • Edition First Edition
  • Publisher New Age International Private Limited
  • Publication date 1 August 2021
  • Language English
  • Dimensions 20.3 x 25.4 x 4.7 cm
  • Print length 556 pages
  • See all details

Customers who viewed this item also viewed

Let Us Python-6Th Edition

Product description

About the author, product details.

  • Publisher ‏ : ‎ New Age International Private Limited; First Edition (1 August 2021); NEW AGE International Pvt Ltd
  • Language ‏ : ‎ English
  • Paperback ‏ : ‎ 556 pages
  • ISBN-10 ‏ : ‎ 8195175503
  • ISBN-13 ‏ : ‎ 978-8195175505
  • Item Weight ‏ : ‎ 810 g
  • Dimensions ‏ : ‎ 20.3 x 25.4 x 4.7 cm
  • Country of Origin ‏ : ‎ India
  • Packer ‏ : ‎ NEW AGE International, 7/30A, Near LIC Flats, Daryaganj, ND110002
  • #2,039 in Programming Languages (Books)

Customer reviews

  • 5 star 4 star 3 star 2 star 1 star 5 star 70% 0% 30% 0% 0% 70%
  • 5 star 4 star 3 star 2 star 1 star 4 star 70% 0% 30% 0% 0% 0%
  • 5 star 4 star 3 star 2 star 1 star 3 star 70% 0% 30% 0% 0% 30%
  • 5 star 4 star 3 star 2 star 1 star 2 star 70% 0% 30% 0% 0% 0%
  • 5 star 4 star 3 star 2 star 1 star 1 star 70% 0% 30% 0% 0% 0%

No customer reviews

  • Press Releases
  • Amazon Science
  • Sell on Amazon
  • Sell under Amazon Accelerator
  • Protect and Build Your Brand
  • Amazon Global Selling
  • Supply to Amazon
  • Become an Affiliate
  • Fulfilment by Amazon
  • Advertise Your Products
  • Amazon Pay on Merchants
  • Your Account
  • Returns Centre
  • Recalls and Product Safety Alerts
  • 100% Purchase Protection
  • Amazon App Download
 
  • Conditions of Use & Sale
  • Privacy Notice
  • Interest-Based Ads

problem solving and python programming technical publications

  • Table of Contents
  • Scratch ActiveCode
  • Navigation Help
  • Help for Instructors
  • About Runestone
  • Report A Problem
  • 1. Introduction
  • 2. Analysis
  • 3. Basic Data Structures
  • 4. Recursion
  • 5. Sorting and Searching
  • 6. Trees and Tree Algorithms
  • 7. Graphs and Graph Algorithms

Problem Solving with Algorithms and Data Structures using Python ¶

By Brad Miller and David Ranum, Luther College (as remixed by Jeffrey Elkner)

  • 1.1. Objectives
  • 1.2. Getting Started
  • 1.3. What Is Computer Science?
  • 1.4. What Is Programming?
  • 1.5. Why Study Data Structures and Abstract Data Types?
  • 1.6. Why Study Algorithms?
  • 1.7. Review of Basic Python
  • 1.8.1. Built-in Atomic Data Types
  • 1.8.2. Built-in Collection Data Types
  • 1.9.1. String Formatting
  • 1.10. Control Structures
  • 1.11. Exception Handling
  • 1.12. Defining Functions
  • 1.13.1. A Fraction Class
  • 1.13.2. Inheritance: Logic Gates and Circuits
  • 1.14. Summary
  • 1.15. Key Terms
  • 1.16. Discussion Questions
  • 1.17. Programming Exercises
  • 2.1. Objectives
  • 2.2. What Is Algorithm Analysis?
  • 2.3. Big-O Notation
  • 2.4.1. Solution 1: Checking Off
  • 2.4.2. Solution 2: Sort and Compare
  • 2.4.3. Solution 3: Brute Force
  • 2.4.4. Solution 4: Count and Compare
  • 2.5. Performance of Python Data Structures
  • 2.7. Dictionaries
  • 2.8. Summary
  • 2.9. Key Terms
  • 2.10. Discussion Questions
  • 2.11. Programming Exercises
  • 3.1. Objectives
  • 3.2. What Are Linear Structures?
  • 3.3. What is a Stack?
  • 3.4. The Stack Abstract Data Type
  • 3.5. Implementing a Stack in Python
  • 3.6. Simple Balanced Parentheses
  • 3.7. Balanced Symbols (A General Case)
  • 3.8. Converting Decimal Numbers to Binary Numbers
  • 3.9.1. Conversion of Infix Expressions to Prefix and Postfix
  • 3.9.2. General Infix-to-Postfix Conversion
  • 3.9.3. Postfix Evaluation
  • 3.10. What Is a Queue?
  • 3.11. The Queue Abstract Data Type
  • 3.12. Implementing a Queue in Python
  • 3.13. Simulation: Hot Potato
  • 3.14.1. Main Simulation Steps
  • 3.14.2. Python Implementation
  • 3.14.3. Discussion
  • 3.15. What Is a Deque?
  • 3.16. The Deque Abstract Data Type
  • 3.17. Implementing a Deque in Python
  • 3.18. Palindrome-Checker
  • 3.19. Lists
  • 3.20. The Unordered List Abstract Data Type
  • 3.21.1. The Node Class
  • 3.21.2. The Unordered List Class
  • 3.22. The Ordered List Abstract Data Type
  • 3.23.1. Analysis of Linked Lists
  • 3.24. Summary
  • 3.25. Key Terms
  • 3.26. Discussion Questions
  • 3.27. Programming Exercises
  • 4.1. Objectives
  • 4.2. What Is Recursion?
  • 4.3. Calculating the Sum of a List of Numbers
  • 4.4. The Three Laws of Recursion
  • 4.5. Converting an Integer to a String in Any Base
  • 4.6. Stack Frames: Implementing Recursion
  • 4.7. Introduction: Visualizing Recursion
  • 4.8. Sierpinski Triangle
  • 4.9. Complex Recursive Problems
  • 4.10. Tower of Hanoi
  • 4.11. Exploring a Maze
  • 4.12. Dynamic Programming
  • 4.13. Summary
  • 4.14. Key Terms
  • 4.15. Discussion Questions
  • 4.16. Glossary
  • 4.17. Programming Exercises
  • 5.1. Objectives
  • 5.2. Searching
  • 5.3.1. Analysis of Sequential Search
  • 5.4.1. Analysis of Binary Search
  • 5.5.1. Hash Functions
  • 5.5.2. Collision Resolution
  • 5.5.3. Implementing the Map Abstract Data Type
  • 5.5.4. Analysis of Hashing
  • 5.6. Sorting
  • 5.7. The Bubble Sort
  • 5.8. The Selection Sort
  • 5.9. The Insertion Sort
  • 5.10. The Shell Sort
  • 5.11. The Merge Sort
  • 5.12. The Quick Sort
  • 5.13. Summary
  • 5.14. Key Terms
  • 5.15. Discussion Questions
  • 5.16. Programming Exercises
  • 6.1. Objectives
  • 6.2. Examples of Trees
  • 6.3. Vocabulary and Definitions
  • 6.4. List of Lists Representation
  • 6.5. Nodes and References
  • 6.6. Parse Tree
  • 6.7. Tree Traversals
  • 6.8. Priority Queues with Binary Heaps
  • 6.9. Binary Heap Operations
  • 6.10.1. The Structure Property
  • 6.10.2. The Heap Order Property
  • 6.10.3. Heap Operations
  • 6.11. Binary Search Trees
  • 6.12. Search Tree Operations
  • 6.13. Search Tree Implementation
  • 6.14. Search Tree Analysis
  • 6.15. Balanced Binary Search Trees
  • 6.16. AVL Tree Performance
  • 6.17. AVL Tree Implementation
  • 6.18. Summary of Map ADT Implementations
  • 6.19. Summary
  • 6.20. Key Terms
  • 6.21. Discussion Questions
  • 6.22. Programming Exercises
  • 7.1. Objectives
  • 7.2. Vocabulary and Definitions
  • 7.3. The Graph Abstract Data Type
  • 7.4. An Adjacency Matrix
  • 7.5. An Adjacency List
  • 7.6. Implementation
  • 7.7. The Word Ladder Problem
  • 7.8. Building the Word Ladder Graph
  • 7.9. Implementing Breadth First Search
  • 7.10. Breadth First Search Analysis
  • 7.11. The Knight’s Tour Problem
  • 7.12. Building the Knight’s Tour Graph
  • 7.13. Implementing Knight’s Tour
  • 7.14. Knight’s Tour Analysis
  • 7.15. General Depth First Search
  • 7.16. Depth First Search Analysis
  • 7.17. Topological Sorting
  • 7.18. Strongly Connected Components
  • 7.19. Shortest Path Problems
  • 7.20. Dijkstra’s Algorithm
  • 7.21. Analysis of Dijkstra’s Algorithm
  • 7.22. Prim’s Spanning Tree Algorithm
  • 7.23. Summary
  • 7.24. Key Terms
  • 7.25. Discussion Questions
  • 7.26. Programming Exercises

Acknowledgements ¶

We are very grateful to Franklin Beedle Publishers for allowing us to make this interactive textbook freely available. This online version is dedicated to the memory of our first editor, Jim Leisy, who wanted us to “change the world.”

Indices and tables ¶

  • Module Index
  • Search Page

Creative Commons License

Technical Publications

Problem Solving & Python Programming for BE Anna University - CBCS SCHEME - REGULATION 2021, SEM. - 1 (COMMON) (GE3151)

Syllabus Problem Solving and Python Programming - GE3151 UNIT IComputational Thinking and Problem Solving Fundamentals of Computing - Identification of Computational Problems - Algorithms, building blocks of algorithms (statements, state, control flow, functions), notation (pseudo code, flow chart, programming language), algorithmic problem solving, simple strategies for developing algorithms (iteration, recursion). Illustrative problems : find minimum in a list, insert a card in a list of sorted cards, guess an integer number in a range, Towers of Hanoi. (Chapter - 1) UNIT IIData Types, Expressions, Statements Python interpreter and interactive mode, debugging; values and types : int, float, boolean, string, and list; variables, expressions, statements, tuple assignment, precedence of operators, comments; Illustrative programs : exchange the values of two variables, circulate the values of n variables, distance between two points. (Chapter - 2) UNIT IIIControl Flow, Functions, Strings Conditionals : Boolean values and operators, conditional (if), alternative (if-else),chained conditional (if-elif-else);Iteration : state, while, for, break, continue, pass; Fruitful functions: return values,parameters, local and global scope, function composition, recursion; Strings: string slices,immutability, string functions and methods, string module; Lists as arrays. Illustrative programs: square root, gcd, exponentiation, sum an array of numbers, linear search, binary search. (Chapter - 3) UNIT IVLists, Tuples, Dictionaries Lists : list operations, list slices, list methods, list loop, mutability, aliasing, cloning lists, list parameters; Tuples: tuple assignment, tuple as return value; Dictionaries: operations and methods; advanced list processing - list comprehension; Illustrative programs : simple sorting, histogram, Students marks statement, Retail bill preparation. (Chapter - 4) UNIT VFiles, Modules, Packages Files and exceptions : text files, reading and writing fi

Pickup available at Nashik Warehouse

Usually ready in 24 hours

Python Practice Problems: Prepare for Your Next Interview

Python Practice Problems: Get Ready for Your Next Interview

Table of Contents

Problem Description

Problem solution.

Are you a Python developer brushing up on your skills before an interview ? If so, then this tutorial will usher you through a series of Python practice problems meant to simulate common coding test scenarios. After you develop your own solutions, you’ll walk through the Real Python team’s answers so you can optimize your code, impress your interviewer, and land your dream job!

In this tutorial, you’ll learn how to:

  • Write code for interview-style problems
  • Discuss your solutions during the interview
  • Work through frequently overlooked details
  • Talk about design decisions and trade-offs

This tutorial is aimed at intermediate Python developers. It assumes a basic knowledge of Python and an ability to solve problems in Python. You can get skeleton code with failing unit tests for each of the problems you’ll see in this tutorial by clicking on the link below:

Download the sample code: Click here to get the code you’ll use to work through the Python practice problems in this tutorial.

Each of the problems below shows the file header from this skeleton code describing the problem requirements. So download the code, fire up your favorite editor, and let’s dive into some Python practice problems!

Python Practice Problem 1: Sum of a Range of Integers

Let’s start with a warm-up question. In the first practice problem, you’ll write code to sum a list of integers . Each practice problem includes a problem description. This description is pulled directly from the skeleton files in the repo to make it easier to remember while you’re working on your solution.

You’ll see a solution section for each problem as well. Most of the discussion will be in a collapsed section below that. Clone that repo if you haven’t already, work out a solution to the following problem, then expand the solution box to review your work.

Here’s your first problem:

Sum of Integers Up To n ( integersums.py ) Write a function, add_it_up() , that takes a single integer as input and returns the sum of the integers from zero to the input parameter. The function should return 0 if a non-integer is passed in.

Remember to run the unit tests until you get them passing!

Here’s some discussion of a couple of possible solutions.

Note: Remember, don’t open the collapsed section below until you’re ready to look at the answer for this Python practice problem!

Solution for Sum of a Range of Integers Show/Hide

How did writing the solution go? Ready to look at the answer?

For this problem, you’ll look at a few different solutions. The first of these is not so good:

In this solution, you manually build a while loop to run through the numbers 1 through n . You keep a running sum and then return it when you’ve finished the loop.

This solution works, but it has two problems:

It doesn’t display your knowledge of Python and how the language simplifies tasks like this.

It doesn’t meet the error conditions in the problem description. Passing in a string will result in the function throwing an exception when it should just return 0 .

You’ll deal with the error conditions in the final answer below, but first let’s refine the core solution to be a bit more Pythonic .

The first thing to think about is that while loop . Python has powerful mechanisms for iterating over lists and ranges. Creating your own is usually unnecessary, and that’s certainly the case here. You can replace the while loop with a loop that iterates over a range() :

You can see that the for...range() construct has replaced your while loop and shortened the code. One thing to note is that range() goes up to but does not include the number given, so you need to use n + 1 here.

This was a nice step! It removes some of the boilerplate code of looping over a range and makes your intention clearer. But there’s still more you can do here.

Summing a list of integers is another thing Python is good at:

Wow! By using the built-in sum() , you got this down to one line of code! While code golf generally doesn’t produce the most readable code, in this case you have a win-win: shorter and more readable code.

There’s one problem remaining, however. This code still doesn’t handle the error conditions correctly. To fix that, you can wrap your previous code in a try...except block:

This solves the problem and handles the error conditions correctly. Way to go!

Occasionally, interviewers will ask this question with a fixed limit, something like “Print the sum of the first nine integers.” When the problem is phrased that way, one correct solution would be print(45) .

If you give this answer, however, then you should follow up with code that solves the problem step by step. The trick answer is a good place to start your answer, but it’s not a great place to end.

If you’d like to extend this problem, try adding an optional lower limit to add_it_up() to give it more flexibility!

Python Practice Problem 2: Caesar Cipher

The next question is a two-parter. You’ll code up a function to compute a Caesar cipher on text input. For this problem, you’re free to use any part of the Python standard library to do the transform.

Hint: There’s a function in the str class that will make this task much easier!

The problem statement is at the top of the skeleton source file:

Caesar Cipher ( caesar.py ) A Caesar cipher is a simple substitution cipher in which each letter of the plain text is substituted with a letter found by moving n places down the alphabet. For example, assume the input plain text is the following: abcd xyz If the shift value, n , is 4, then the encrypted text would be the following: efgh bcd You are to write a function that accepts two arguments, a plain-text message and a number of letters to shift in the cipher. The function will return an encrypted string with all letters transformed and all punctuation and whitespace remaining unchanged. Note: You can assume the plain text is all lowercase ASCII except for whitespace and punctuation.

Remember, this part of the question is really about how well you can get around in the standard library. If you find yourself figuring out how to do the transform without the library, then save that thought! You’ll need it later!

Here’s a solution to the Caesar cipher problem described above.

Note: Remember, don’t open the collapsed section below until you’re ready to look at the answers for this Python practice problem!

Solution for Caesar Cipher Show/Hide

This solution makes use of .translate() from the str class in the standard library. If you struggled with this problem, then you might want to pause a moment and consider how you could use .translate() in your solution.

Okay, now that you’re ready, let’s look at this solution:

You can see that the function makes use of three things from the string module:

  • .ascii_lowercase
  • .maketrans()
  • .translate()

In the first two lines, you create a variable with all the lowercase letters of the alphabet (ASCII only for this program) and then create a mask , which is the same set of letters, only shifted. The slicing syntax is not always obvious, so let’s walk through it with a real-world example:

You can see that x[3:] is all the letters after the third letter, 'c' , while x[:3] is just the first three letters.

Line 6 in the solution, letters[shift_num:] + letters[:shift_num] , creates a list of letters shifted by shift_num letters, with the letters at the end wrapped around to the front. Once you have the list of letters and the mask of letters you want to map to, you call .maketrans() to create a translation table.

Next, you pass the translation table to the string method .translate() . It maps all characters in letters to the corresponding letters in mask and leaves all other characters alone.

This question is an exercise in knowing and using the standard library. You may be asked a question like this at some point during an interview. If that happens to you, it’s good to spend some time thinking about possible answers. If you can remember the method— .translate() in this case—then you’re all set.

But there are a couple of other scenarios to consider:

You may completely draw a blank. In this case, you’ll probably solve this problem the way you solve the next one , and that’s an acceptable answer.

You may remember that the standard library has a function to do what you want but not remember the details.

If you were doing normal work and hit either of these situations, then you’d just do some searching and be on your way. But in an interview situation, it will help your cause to talk through the problem out loud.

Asking the interviewer for specific help is far better than just ignoring it. Try something like “I think there’s a function that maps one set of characters to another. Can you help me remember what it’s called?”

In an interview situation, it’s often better to admit that you don’t know something than to try to bluff your way through.

Now that you’ve seen a solution using the Python standard library, let’s try the same problem again, but without that help!

Python Practice Problem 3: Caesar Cipher Redux

For the third practice problem, you’ll solve the Caesar cipher again, but this time you’ll do it without using .translate() .

The description of this problem is the same as the previous problem. Before you dive into the solution, you might be wondering why you’re repeating the same exercise, just without the help of .translate() .

That’s a great question. In normal life, when your goal is to get a working, maintainable program, rewriting parts of the standard library is a poor choice. The Python standard library is packed with working, well-tested, and fast solutions for problems large and small. Taking full advantage of it is a mark of a good programmer.

That said, this is not a work project or a program you’re building to satisfy a need. This is a learning exercise, and it’s the type of question that might be asked during an interview. The goal for both is to see how you can solve the problem and what interesting design trade-offs you make while doing it.

So, in the spirit of learning, let’s try to resolve the Caesar cipher without .translate() .

For this problem, you’ll have two different solutions to look at when you’re ready to expand the section below.

Solutions for Caesar Cipher Redux Show/Hide

For this problem, two different solutions are provided. Check out both and see which one you prefer!

For the first solution, you follow the problem description closely, adding an amount to each character and flipping it back to the beginning of the alphabet when it goes on beyond z :

Starting on line 14, you can see that caesar() does a list comprehension , calling a helper function for each letter in message . It then does a .join() to create the new encoded string. This is short and sweet, and you’ll see a similar structure in the second solution. The interesting part happens in shift_n() .

Here you can see another use for string.ascii_lowercase , this time filtering out any letter that isn’t in that group. Once you’re certain you’ve filtered out any non-letters, you can proceed to encoding. In this version of encoding, you use two functions from the Python standard library:

Again, you’re encouraged not only to learn these functions but also to consider how you might respond in an interview situation if you couldn’t remember their names.

ord() does the work of converting a letter to a number, and chr() converts it back to a letter. This is handy as it allows you to do arithmetic on letters, which is what you want for this problem.

The first step of your encoding on line 7 gets the numeric value of the encoded letter by using ord() to get the numeric value of the original letter. ord() returns the Unicode code point of the character, which turns out to be the ASCII value.

For many letters with small shift values, you can convert the letter back to a character and you’ll be done. But consider the starting letter, z .

A shift of one character should result in the letter a . To achieve this wraparound, you find the difference from the encoded letter to the letter z . If that difference is positive, then you need to wrap back to the beginning.

You do this in lines 8 to 11 by repeatedly adding 26 to or subtracting it from the character until it’s in the range of ASCII characters. Note that this is a fairly inefficient method for fixing this issue. You’ll see a better solution in the next answer.

Finally, on line 12, your conversion shift function takes the numeric value of the new letter and converts it back to a letter to return it.

While this solution takes a literal approach to solving the Caesar cipher problem, you could also use a different approach modeled after the .translate() solution in practice problem 2 .

The second solution to this problem mimics the behavior of Python’s built-in method .translate() . Instead of shifting each letter by a given amount, it creates a translation map and uses it to encode each letter:

Starting with caesar() on line 11, you start by fixing the problem of amount being greater than 26 . In the previous solution, you looped repeatedly until the result was in the proper range. Here, you take a more direct and more efficient approach using the mod operator ( % ).

The mod operator produces the remainder from an integer division. In this case, you divide by 26 , which means the results are guaranteed to be between 0 and 25 , inclusive.

Next, you create the translation table. This is a change from the previous solutions and is worth some attention. You’ll see more about this toward the end of this section.

Once you create the table , the rest of caesar() is identical to the previous solution: a list comprehension to encrypt each letter and a .join() to create a string.

shift_n() finds the index of the given letter in the alphabet and then uses this to pull a letter from the table . The try...except block catches those cases that aren’t found in the list of lowercase letters.

Now let’s discuss the table creation issue. For this toy example, it probably doesn’t matter too much, but it illustrates a situation that occurs frequently in everyday development: balancing clarity of code against known performance bottlenecks.

If you examine the code again, you’ll see that table is used only inside shift_n() . This indicates that, in normal circumstances, it should have been created in, and thus have its scope limited to, shift_n() :

The issue with that approach is that it spends time calculating the same table for every letter of the message. For small messages, this time will be negligible, but it might add up for larger messages.

Another possible way that you could avoid this performance penalty would be to make table a global variable . While this also cuts down on the construction penalty, it makes the scope of table even larger. This doesn’t seem better than the approach shown above.

At the end of the day, the choice between creating table once up front and giving it a larger scope or just creating it for every letter is what’s called a design decision . You need to choose the design based on what you know about the actual problem you’re trying to solve.

If this is a small project and you know it will be used to encode large messages, then creating the table only once could be the right decision. If this is only a portion of a larger project, meaning maintainability is key, then perhaps creating the table each time is the better option.

Since you’ve looked at two solutions, it’s worth taking a moment to discuss their similarities and differences.

Solution Comparison

You’ve seen two solutions in this part of the Caesar cipher, and they’re fairly similar in many ways. They’re about the same number of lines. The two main routines are identical except for limiting amount and creating table . It’s only when you look at the two versions of the helper function, shift_n() , that the differences appear.

The first shift_n() is an almost literal translation of what the problem is asking for: “Shift the letter down the alphabet and wrap it around at z .” This clearly maps back to the problem statement, but it has a few drawbacks.

Although it’s about the same length as the second version, the first version of shift_n() is more complex. This complexity comes from the letter conversion and math needed to do the translation. The details involved—converting to numbers, subtracting, and wrapping—mask the operation you’re performing. The second shift_n() is far less involved in its details.

The first version of the function is also specific to solving this particular problem. The second version of shift_n() , like the standard library’s .translate() that it’s modeled after, is more general-purpose and can be used to solve a larger set of problems. Note that this is not necessarily a good design goal.

One of the mantras that came out of the Extreme Programming movement is “You aren’t gonna need it” (YAGNI). Frequently, software developers will look at a function like shift_n() and decide that it would be better and more general-purpose if they made it even more flexible, perhaps by passing in a parameter instead of using string.ascii_lowercase .

While that would indeed make the function more general-purpose, it would also make it more complex. The YAGNI mantra is there to remind you not to add complexity before you have a specific use case for it.

To wrap up your Caesar cipher section, there are clear trade-offs between the two solutions, but the second shift_n() seems like a slightly better and more Pythonic function.

Now that you’ve written the Caesar cipher three different ways, let’s move on to a new problem.

Python Practice Problem 4: Log Parser

The log parser problem is one that occurs frequently in software development. Many systems produce log files during normal operation, and sometimes you’ll need to parse these files to find anomalies or general information about the running system.

For this problem, you’ll need to parse a log file with a specified format and generate a report:

Log Parser ( logparse.py ) Accepts a filename on the command line. The file is a Linux-like log file from a system you are debugging. Mixed in among the various statements are messages indicating the state of the device. They look like this: Jul 11 16:11:51:490 [139681125603136] dut: Device State: ON The device state message has many possible values, but this program cares about only three: ON , OFF , and ERR . Your program will parse the given log file and print out a report giving how long the device was ON and the timestamp of any ERR conditions.

Note that the provided skeleton code doesn’t include unit tests. This was omitted since the exact format of the report is up to you. Think about and write your own during the process.

A test.log file is included, which provides you with an example. The solution you’ll examine produces the following output:

While that format is generated by the Real Python solution, you’re free to design your own format for the output. The sample input file should generate equivalent information.

In the collapsed section below, you’ll find a possible solution to the log parser problem. When you’re ready, expand the box and compare it with what you came up with!

Solution for Log Parser Problem Show/Hide

Full Solution

Since this solution is longer than what you saw for the integer sums or the Caesar cipher problems, let’s start with the full program:

That’s your full solution. You can see that the program consists of three functions and the main section. You’ll work through them from the top.

Helper Function: get_next_event()

First up is get_next_event() :

Because it contains a yield statement, this function is a generator . That means you can use it to generate one event from the log file at a time.

You could have just used for line in datafile , but instead you add a little bit of filtering. The calling routine will get only those events that have dut: Device State: in them. This keeps all the file-specific parsing contained in a single function.

This might make get_next_event() a bit more complicated, but it’s a relatively small function, so it remains short enough to read and comprehend. It also keeps that complicated code encapsulated in a single location.

You might be wondering when datafile gets closed. As long as you call the generator until all of the lines are read from datafile , the for loop will complete, allowing you to leave the with block and exit from the function.

Helper Function: compute_time_diff_seconds()

The second function is compute_time_diff_seconds() , which, as the name suggests, computes the number of seconds between two timestamps:

There are a few interesting points to this function. The first is that subtracting the two datetime objects results in a datetime.timedelta . For this problem, you will report total seconds, so returning .total_seconds() from the timedelta is appropriate.

The second item of note is that there are many, many packages in Python that simplify handling dates and times. In this case, your use model is simple enough that it doesn’t warrant the complexity of pulling in an external library when the standard library functions will suffice.

That said, datetime.datetime.strptime() is worthy of mention. When passed a string and a specific format, .strptime() parses that string with the given format and produces a datetime object.

This is another place where, in an interview situation, it’s important not to panic if you can’t remember the exact names of the Python standard library functions.

Helper Function: extract_data()

Next up is extract_data() , which does the bulk of the work in this program. Before you dive into the code, let’s step back and talk about state machines.

State machines are software (or hardware) devices that transition from one state to another depending on specific inputs. That’s a really broad definition that might be difficult to grasp, so let’s look at a diagram of the state machine you’ll be using below:

State machine with two states: ON and OFF with transitions between the states.

In this diagram, the states are represented by the labeled boxes. There are only two states here, ON and OFF , which correspond to the state of the device. There are also two input signals, Device State: ON and Device State: OFF . The diagram uses arrows to show what happens when an input occurs while the machine is in each state.

For example, if the machine is in the ON state and the Device State: ON input occurs, then the machine stays in the ON state. No change happens. Conversely, if the machine receives the Device State: OFF input when it’s in the ON state, then it will transition to the OFF state.

While the state machine here is only two states with two inputs, state machines are often much more complex. Creating a diagram of expected behavior can help you make the code that implements the state machine more concise.

Let’s move back to extract_data() :

It might be hard to see the state machine here. Usually, state machines require a variable to hold the state. In this case, you use time_on_started to serve two purposes:

  • Indicate state: time_on_started holds the state of your state machine. If it’s None , then the machine is in the OFF state. If it’s not None , then the machine is ON .
  • Store start time: If the state is ON , then time_on_started also holds the timestamp of when the device turned on. You use this timestamp to call compute_time_diff_seconds() .

The top of extract_data() sets up your state variable, time_on_started , and also the two outputs you want. errs is a list of timestamps at which the ERR message was found, and total_time_on is the sum of all periods when the device was on.

Once you’ve completed the initial setup, you call the get_next_event() generator to retrieve each event and timestamp. The action it receives is used to drive the state machine, but before it checks for state changes, it first uses an if block to filter out any ERR conditions and add those to errs .

After the error check, the first elif block handles transitions to the ON state. You can transition to ON only when you’re in the OFF state, which is signaled by time_on_started being False . If you’re not already in the ON state and the action is "ON" , then you store the timestamp , putting the machine into the ON state.

The second elif handles the transition to the OFF state. On this transition, extract_data() needs to compute the number of seconds the device was on. It does this using the compute_time_diff_seconds() you saw above. It adds this time to the running total_time_on and sets time_on_started back to None , effectively putting the machine back into the OFF state.

Main Function

Finally, you can move on to the __main__ section. This final section passes sys.argv[1] , which is the first command-line argument , to extract_data() and then presents a report of the results:

To call this solution, you run the script and pass the name of the log file. Running your example code results in this output:

Your solution might have different formatting, but the information should be the same for the sample log file.

There are many ways to solve a problem like this. Remember that in an interview situation, talking through the problem and your thought process can be more important than which solution you choose to implement.

That’s it for the log-parsing solution. Let’s move on to the final challenge: sudoku!

Python Practice Problem 5: Sudoku Solver

Your final Python practice problem is to solve a sudoku puzzle!

Finding a fast and memory-efficient solution to this problem can be quite a challenge. The solution you’ll examine has been selected for readability rather than speed, but you’re free to optimize your solution as much as you want.

The description for the sudoku solver is a little more involved than the previous problems:

Sudoku Solver ( sudokusolve.py ) Given a string in SDM format, described below, write a program to find and return the solution for the sudoku puzzle in the string. The solution should be returned in the same SDM format as the input. Some puzzles will not be solvable. In that case, return the string “Unsolvable”. The general SDM format is described here . For our purposes, each SDM string will be a sequence of 81 digits, one for each position on the sudoku puzzle. Known numbers will be given, and unknown positions will have a zero value. For example, assume you’re given this string of digits: 004006079000000602056092300078061030509000406020540890007410920105000000840600100 The string represents this starting sudoku puzzle: 0 0 4 0 0 6 0 7 9 0 0 0 0 0 0 6 0 2 0 5 6 0 9 2 3 0 0 0 7 8 0 6 1 0 3 0 5 0 9 0 0 0 4 0 6 0 2 0 5 4 0 8 9 0 0 0 7 4 1 0 9 2 0 1 0 5 0 0 0 0 0 0 8 4 0 6 0 0 1 0 0 The provided unit tests may take a while to run, so be patient. Note: A description of the sudoku puzzle can be found on Wikipedia .

You can see that you’ll need to deal with reading and writing to a particular format as well as generating a solution.

When you’re ready, you can find a detailed explanation of a solution to the sudoku problem in the box below. A skeleton file with unit tests is provided in the repo.

Solution for Sudoku Solver Show/Hide

This is a larger and more complex problem than you’ve looked at so far in this tutorial. You’ll walk through the problem step by step, ending with a recursive function that solves the puzzle. Here’s a rough outline of the steps you’ll take:

  • Read the puzzle into a grid form.
  • Place the number in the cell.
  • Remove that number from the row, column, and small square.
  • Move to the next position.
  • If no possible numbers remain, then declare the puzzle unsolvable .
  • If all cells are filled, then return the solution .

The tricky part of this algorithm is keeping track of the grid at each step of the process. You’ll use recursion, making a new copy of the grid at each level of the recursion, to maintain this information.

With that outline in mind, let’s start with the first step, creating the grid.

Generating a Grid From a Line

To start, it’s helpful to convert the puzzle data into a more usable format. Even if you eventually want to solve the puzzle in the given SDM format , you’ll likely make faster progress working through the details of your algorithm with the data in a grid form. Once you have a solution that works, then you can convert it to work on a different data structure.

To this end, let’s start with a couple of conversion functions:

Your first function, line_to_grid() , converts the data from a single string of eighty-one digits to a list of lists. For example, it converts the string line to a grid like start :

Each inner list here represents a horizontal row in your sudoku puzzle.

You start with an empty grid and an empty line . You then build each line by converting nine characters from the values string to single-digit integers and then appending them to the current line . Once you have nine values in a line , as indicated by index % 9 == 0 on line 7, you insert that line into the grid and start a new one.

The function ends by appending the final line to the grid . You need this because the for loop will end with the last line still stored in the local variable and not yet appended to grid .

The inverse function, grid_to_line() , is slightly shorter. It uses a generator expression with .join() to create a nine-digit string for each row. It then appends that string to the overall line and returns it. Note that it’s possible to use nested generators to create this result in fewer lines of code, but the readability of the solution starts to fall off dramatically.

Now that you’ve got the data in the data structure you want, let’s start working with it.

Generating a Small Square Iterator

Your next function is a generator that will help you search for the smaller three-by-three square a given position is in. Given the x- and y-coordinates of the cell in question, this generator will produce a list of coordinates that match the square that contains it:

A Sudoku grid with one of the small squares highlighted.

In the image above, you’re examining cell (3, 1) , so your generator will produce coordinate pairs corresponding to all the lightly shaded cells, skipping the coordinates that were passed in:

Putting the logic for determining this small square in a separate utility function keeps the flow of your other functions more readable. Making this a generator allows you to use it in a for loop to iterate through each of the values.

The function to do this involves using the limitations of integer math:

There are a lot of threes in a couple of those lines, which makes lines like ((x + 3) // 3) * 3 look confusing. Here’s what happens when x is 1 .

Using the rounding of integer math allows you to get the next-highest multiple of three above a given value. Once you have this, subtracting three will give you the multiple of three below the given number.

There are a few more low-level utility functions to examine before you start building on top of them.

Moving to the Next Spot

Your solution will need to walk through the grid structure one cell at a time. This means that at some point, you’ll need to figure out what the next position should be. compute_next_position() to the rescue!

compute_next_position() takes the current x- and y-coordinates as input and returns a tuple containing a finished flag along with the x- and y-coordinates of the next position:

The finished flag tells the caller that the algorithm has walked off the end of the puzzle and has completed all the squares. You’ll see how that’s used in a later section.

Removing Impossible Numbers

Your final low-level utility is quite small. It takes an integer value and an iterable. If the value is nonzero and appears in the iterable, then the function removes it from the iterable:

Typically, you wouldn’t make this small bit of functionality into a function. You’ll use this function several times, though, so it’s best to follow the DRY principle and pull it up to a function.

Now you’ve seen the bottom level of the functionality pyramid. It’s time to step up and use those tools to build a more complex function. You’re almost ready to solve the puzzle!

Finding What’s Possible

Your next function makes use of some of the low-level functions you’ve just walked through. Given a grid and a position on that grid, it determines what values that position could still have:

A Sudoku grid showing a starting point to indicate possible values for a specific cell.

For the grid above, at the position (3, 1) , the possible values are [1, 5, 8] because the other values are all present, either in that row or column or in the small square you looked at earlier.

This is the responsibility of detect_possible() :

The function starts by checking if the given position at x and y already has a nonzero value. If so, then that’s the only possible value and it returns.

If not, then the function creates a set of the numbers one through nine. The function proceeds to check different blocking numbers and removes those from this set.

It starts by checking the column and row of the given position. This can be done with a single loop by just alternating which subscript changes. grid[x][index] checks values in the same column, while grid[index][y] checks those values in the same row. You can see that you’re using test_and_remove() here to simplify the code.

Once those values have been removed from your possible set, the function moves on to the small square. This is where the small_square() generator you created before comes in handy. You can use it to iterate over each position in the small square, again using test_and_remove() to eliminate any known values from your possible list.

Once all the known blocking values have been removed from your set, you have the list of all possible values for that position on that grid.

You might wonder why the code and its description make a point about the position being “on that grid.” In your next function, you’ll see that the program makes many copies of the grid as it tries to solve it.

You’ve reached the heart of this solution: solve() ! This function is recursive, so a little up-front explanation might help.

The general design of solve() is based on testing a single position at a time. For the position of interest, the algorithm gets the list of possible values and then selects those values, one at a time, to be in this position.

For each of these values, it creates a grid with the guessed value in this position. It then calls a function to test for a solution, passing in the new grid and the next position.

It just so happens that the function it calls is itself.

For any recursion, you need a termination condition. This algorithm has four of them:

  • There are no possible values for this position. That indicates the solution it’s testing can’t work.
  • It’s walked to the end of the grid and found a possible value for each position. The puzzle is solved!
  • One of the guesses at this position, when passed back to the solver, returns a solution.
  • It’s tried all possible values at this position and none of them will work.

Let’s look at the code for this and see how it all plays out:

The first thing to note in this function is that it makes a .deepcopy() of the grid. It does a deep copy because the algorithm needs to keep track of exactly where it was at any point in the recursion. If the function made only a shallow copy, then every recursive version of this function would use the same grid.

Once the grid is copied, solve() can work with the new copy, temp . A position on the grid was passed in, so that’s the number that this version of the function will solve. The first step is to see what values are possible in this position. As you saw earlier, detect_possible() returns a list of possible values that may be empty.

If there are no possible values, then you’ve hit the first termination condition for the recursion. The function returns False , and the calling routine moves on.

If there are possible values, then you need to move on and see if any of them is a solution. Before you do that, you can add a little optimization to the code. If there’s only a single possible value, then you can insert that value and move on to the next position. The solution shown does this in a loop, so you can place multiple numbers into the grid without having to recur.

This may seem like a small improvement, and I’ll admit my first implementation did not include this. But some testing showed that this solution was dramatically faster than simply recurring here at the price of more complex code.

Note: This is an excellent point to bring up during an interview even if you don’t add the code to do this. Showing them that you’re thinking about trading off speed against complexity is a strong positive signal to interviewers.

Sometimes, of course, there will be multiple possible values for the current position, and you’ll need to decide if any of them will lead to a solution. Fortunately, you’ve already determined the next position in the grid, so you can forgo placing the possible values.

If the next position is off the end of the grid, then the current position is the final one to fill. If you know that there’s at least one possible value for this position, then you’ve found a solution! The current position is filled in and the completed grid is returned up to the calling function.

If the next position is still on the grid, then you loop through each possible value for the current spot, filling in the guess at the current position and then calling solve() with the temp grid and the new position to test.

solve() can return only a completed grid or False , so if any of the possible guesses returns a result that isn’t False , then a result has been found, and that grid can be returned up the stack.

If all possible guesses have been made and none of them is a solution, then the grid that was passed in is unsolvable. If this is the top-level call, then that means the puzzle is unsolvable. If the call is lower in the recursion tree, then it just means that this branch of the recursion tree isn’t viable.

Putting It All Together

At this point, you’re almost through the solution. There’s only one final function left, sudoku_solve() :

This function does three things:

  • Converts the input string into a grid
  • Calls solve() with that grid to get a solution
  • Returns the solution as a string or "Unsolvable" if there’s no solution

That’s it! You’ve walked through a solution for the sudoku solver problem.

Interview Discussion Topics

The sudoku solver solution you just walked through is a good deal of code for an interview situation. Part of an interview process would likely be to discuss some of the code and, more importantly, some of the design trade-offs you made. Let’s look at a few of those trade-offs.

The biggest design decision revolves around using recursion. It’s possible to write a non-recursive solution to any problem that has a recursive solution. Why choose recursion over another option?

This is a discussion that depends not only on the problem but also on the developers involved in writing and maintaining the solution. Some problems lend themselves to rather clean recursive solutions, and some don’t.

In general, recursive solutions will take more time to run and use more memory than non-recursive solutions. But that’s not always true and, more importantly, it’s not always important .

Similarly, some teams of developers are comfortable with recursive solutions, while others find them exotic or unnecessarily complex. Maintainability should play into your design decisions as well.

One good discussion to have about a decision like this is around performance. How fast does this solution need to execute? Will it be used to solve billions of puzzles or just a handful? Will it run on a small embedded system with memory constraints, or will it be on a large server?

These external factors can help you decide which is a better design decision. These are great topics to bring up in an interview as you’re working through a problem or discussing code. A single product might have places where performance is critical (doing ray tracing on a graphics algorithm, for example) and places where it doesn’t matter at all (such as parsing the version number during installation).

Bringing up topics like this during an interview shows that you’re not only thinking about solving an abstract problem, but you’re also willing and able to take it to the next level and solve a specific problem facing the team.

Readability and Maintainability

Sometimes it’s worth picking a solution that’s slower in order to make a solution that’s easier to work with, debug, and extend. The decision in the sudoku solver challenge to convert the data structure to a grid is one of those decisions.

That design decision likely slows down the program, but unless you’ve measured, you don’t know. Even if it does, putting the data structure into a form that’s natural for the problem can make the code easier to comprehend.

It’s entirely possible to write a solver that operates on the linear strings you’re given as input. It’s likely faster and probably takes less memory, but small_square() , among others, will be a lot harder to write, read, and maintain in this version.

Another thing to discuss with an interviewer, whether you’re live coding or discussing code you wrote offline, is the mistakes and false turns you took along the way.

This is a little less obvious and can be slightly detrimental, but particularly if you’re live coding, taking a step to refactor code that isn’t right or could be better can show how you work. Few developers can write perfect code the first time. Heck, few developers can write good code the first time.

Good developers write the code, then go back and refactor it and fix it. For example, my first implementation of detect_possible() looked like this:

Ignoring that it doesn’t consider the small_square() information, this code can be improved. If you compare this to the final version of detect_possible() above, you’ll see that the final version uses a single loop to test both the horizontal and the vertical dimensions.

Wrapping Up

That’s your tour through a sudoku solver solution. There’s more information available on formats for storing puzzles and a huge list of sudoku puzzles you can test your algorithm on.

That’s the end of your Python practice problems adventure! But if you’d like more, head on over to the video course Write and Test a Python Function: Interview Practice to see an experienced developer tackle an interview problem in real time.

Congratulations on working through this set of Python practice problems! You’ve gotten some practice applying your Python skills and also spent some time thinking about how you can respond in different interviewing situations.

In this tutorial, you learned how to:

Remember, you can download the skeleton code for these problems by clicking on the link below:

Feel free to reach out in the comments section with any questions you have or suggestions for other Python practice problems you’d like to see! Also check out our “Ace Your Python Coding Interview” Learning Path to get more resources and for boosting your Python interview skills.

Good luck with the interview!

🐍 Python Tricks 💌

Get a short & sweet Python Trick delivered to your inbox every couple of days. No spam ever. Unsubscribe any time. Curated by the Real Python team.

Python Tricks Dictionary Merge

About Jim Anderson

Jim Anderson

Jim has been programming for a long time in a variety of languages. He has worked on embedded systems, built distributed build systems, done off-shore vendor management, and sat in many, many meetings.

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Aldren Santos

Master Real-World Python Skills With Unlimited Access to Real Python

Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:

Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:

What Do You Think?

What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment below and let us know.

Commenting Tips: The most useful comments are those written with the goal of learning from or helping out other students. Get tips for asking good questions and get answers to common questions in our support portal . Looking for a real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session . Happy Pythoning!

Keep Learning

Related Topics: intermediate best-practices career

Keep reading Real Python by creating a free account or signing in:

Already have an account? Sign-In

Almost there! Complete this form and click the button below to gain instant access:

Python Practice Problems Sample Code

🔒 No spam. We take your privacy seriously.

problem solving and python programming technical publications

Python Programming

Practice Python Exercises and Challenges with Solutions

Free Coding Exercises for Python Developers. Exercises cover Python Basics , Data structure , to Data analytics . As of now, this page contains 18 Exercises.

What included in these Python Exercises?

Each exercise contains specific Python topic questions you need to practice and solve. These free exercises are nothing but Python assignments for the practice where you need to solve different programs and challenges.

  • All exercises are tested on Python 3.
  • Each exercise has 10-20 Questions.
  • The solution is provided for every question.
  • Practice each Exercise in Online Code Editor

These Python programming exercises are suitable for all Python developers. If you are a beginner, you will have a better understanding of Python after solving these exercises. Below is the list of exercises.

Select the exercise you want to solve .

Basic Exercise for Beginners

Practice and Quickly learn Python’s necessary skills by solving simple questions and problems.

Topics : Variables, Operators, Loops, String, Numbers, List

Python Input and Output Exercise

Solve input and output operations in Python. Also, we practice file handling.

Topics : print() and input() , File I/O

Python Loop Exercise

This Python loop exercise aims to help developers to practice branching and Looping techniques in Python.

Topics : If-else statements, loop, and while loop.

Python Functions Exercise

Practice how to create a function, nested functions, and use the function arguments effectively in Python by solving different questions.

Topics : Functions arguments, built-in functions.

Python String Exercise

Solve Python String exercise to learn and practice String operations and manipulations.

Python Data Structure Exercise

Practice widely used Python types such as List, Set, Dictionary, and Tuple operations in Python

Python List Exercise

This Python list exercise aims to help Python developers to learn and practice list operations.

Python Dictionary Exercise

This Python dictionary exercise aims to help Python developers to learn and practice dictionary operations.

Python Set Exercise

This exercise aims to help Python developers to learn and practice set operations.

Python Tuple Exercise

This exercise aims to help Python developers to learn and practice tuple operations.

Python Date and Time Exercise

This exercise aims to help Python developers to learn and practice DateTime and timestamp questions and problems.

Topics : Date, time, DateTime, Calendar.

Python OOP Exercise

This Python Object-oriented programming (OOP) exercise aims to help Python developers to learn and practice OOP concepts.

Topics : Object, Classes, Inheritance

Python JSON Exercise

Practice and Learn JSON creation, manipulation, Encoding, Decoding, and parsing using Python

Python NumPy Exercise

Practice NumPy questions such as Array manipulations, numeric ranges, Slicing, indexing, Searching, Sorting, and splitting, and more.

Python Pandas Exercise

Practice Data Analysis using Python Pandas. Practice Data-frame, Data selection, group-by, Series, sorting, searching, and statistics.

Python Matplotlib Exercise

Practice Data visualization using Python Matplotlib. Line plot, Style properties, multi-line plot, scatter plot, bar chart, histogram, Pie chart, Subplot, stack plot.

Random Data Generation Exercise

Practice and Learn the various techniques to generate random data in Python.

Topics : random module, secrets module, UUID module

Python Database Exercise

Practice Python database programming skills by solving the questions step by step.

Use any of the MySQL, PostgreSQL, SQLite to solve the exercise

Exercises for Intermediate developers

The following practice questions are for intermediate Python developers.

If you have not solved the above exercises, please complete them to understand and practice each topic in detail. After that, you can solve the below questions quickly.

Exercise 1: Reverse each word of a string

Expected Output

  • Use the split() method to split a string into a list of words.
  • Reverse each word from a list
  • finally, use the join() function to convert a list into a string

Steps to solve this question :

  • Split the given string into a list of words using the split() method
  • Use a list comprehension to create a new list by reversing each word from a list.
  • Use the join() function to convert the new list into a string
  • Display the resultant string

Exercise 2: Read text file into a variable and replace all newlines with space

Given : Assume you have a following text file (sample.txt).

Expected Output :

  • First, read a text file.
  • Next, use string replace() function to replace all newlines ( \n ) with space ( ' ' ).

Steps to solve this question : -

  • First, open the file in a read mode
  • Next, read all content from a file using the read() function and assign it to a variable.
  • Display final string

Exercise 3: Remove items from a list while iterating

Description :

In this question, You need to remove items from a list while iterating but without creating a different copy of a list.

Remove numbers greater than 50

Expected Output : -

  • Get the list's size
  • Iterate list using while loop
  • Check if the number is greater than 50
  • If yes, delete the item using a del keyword
  • Reduce the list size

Solution 1: Using while loop

Solution 2: Using for loop and range()

Exercise 4: Reverse Dictionary mapping

Exercise 5: display all duplicate items from a list.

  • Use the counter() method of the collection module.
  • Create a dictionary that will maintain the count of each item of a list. Next, Fetch all keys whose value is greater than 2

Solution 1 : - Using collections.Counter()

Solution 2 : -

Exercise 6: Filter dictionary to contain keys present in the given list

Exercise 7: print the following number pattern.

Refer to Print patterns in Python to solve this question.

  • Use two for loops
  • The outer loop is reverse for loop from 5 to 0
  • Increment value of x by 1 in each iteration of an outer loop
  • The inner loop will iterate from 0 to the value of i of the outer loop
  • Print value of x in each iteration of an inner loop
  • Print newline at the end of each outer loop

Exercise 8: Create an inner function

Question description : -

  • Create an outer function that will accept two strings, x and y . ( x= 'Emma' and y = 'Kelly' .
  • Create an inner function inside an outer function that will concatenate x and y.
  • At last, an outer function will join the word 'developer' to it.

Exercise 9: Modify the element of a nested list inside the following list

Change the element 35 to 3500

Exercise 10: Access the nested key increment from the following dictionary

Under Exercises: -

Python Object-Oriented Programming (OOP) Exercise: Classes and Objects Exercises

Updated on:  December 8, 2021 | 52 Comments

Python Date and Time Exercise with Solutions

Updated on:  December 8, 2021 | 10 Comments

Python Dictionary Exercise with Solutions

Updated on:  May 6, 2023 | 56 Comments

Python Tuple Exercise with Solutions

Updated on:  December 8, 2021 | 96 Comments

Python Set Exercise with Solutions

Updated on:  October 20, 2022 | 27 Comments

Python if else, for loop, and range() Exercises with Solutions

Updated on:  July 6, 2024 | 296 Comments

Updated on:  August 2, 2022 | 155 Comments

Updated on:  September 6, 2021 | 109 Comments

Python List Exercise with Solutions

Updated on:  December 8, 2021 | 200 Comments

Updated on:  December 8, 2021 | 7 Comments

Python Data Structure Exercise for Beginners

Updated on:  December 8, 2021 | 116 Comments

Python String Exercise with Solutions

Updated on:  October 6, 2021 | 221 Comments

Updated on:  March 9, 2021 | 23 Comments

Updated on:  March 9, 2021 | 51 Comments

Updated on:  July 20, 2021 | 29 Comments

Python Basic Exercise for Beginners

Updated on:  August 31, 2023 | 498 Comments

Useful Python Tips and Tricks Every Programmer Should Know

Updated on:  May 17, 2021 | 23 Comments

Python random Data generation Exercise

Updated on:  December 8, 2021 | 13 Comments

Python Database Programming Exercise

Updated on:  March 9, 2021 | 17 Comments

  • Online Python Code Editor

Updated on:  June 1, 2022 |

About PYnative

PYnative.com is for Python lovers. Here, You can get Tutorials, Exercises, and Quizzes to practice and improve your Python skills .

Explore Python

  • Learn Python
  • Python Basics
  • Python Databases
  • Python Exercises
  • Python Quizzes
  • Python Tricks

To get New Python Tutorials, Exercises, and Quizzes

Legal Stuff

We use cookies to improve your experience. While using PYnative, you agree to have read and accepted our Terms Of Use , Cookie Policy , and Privacy Policy .

Copyright © 2018–2024 pynative.com

Join Our Newsletter

Join our subscribers list to get the latest news, updates and special offers directly in your inbox

  • Interview Q & A
  • Python Interview Q & A

[2024] Python Algorithms Interview Questions

Prepare for your python coding interviews with our comprehensive guide on the most common algorithms interview questions. explore essential topics like sorting algorithms, dynamic programming, graph traversal, and more. enhance your problem-solving skills and boost your confidence with practical examples and explanations..

[2024] Python Algorithms Interview Questions

1. What is an algorithm, and why is it important in programming?

2. explain the difference between a list and a tuple in python. when would you use each, 3. what is a sorting algorithm can you describe the bubble sort algorithm, 4. describe the quicksort algorithm and its time complexity., 5. how does the binary search algorithm work what is its time complexity, 6. what is the difference between depth-first search (dfs) and breadth-first search (bfs) algorithms, 7. explain the concept of dynamic programming with an example., 8. what is a greedy algorithm can you provide an example, 9. what are hash tables, and how do they work, 10. describe the concept of recursion. can you provide an example, 11. what is a heap, and how is it used in algorithms, 12. explain the concept of memoization. how is it different from dynamic programming, 13. what is the difference between merge sort and quicksort, 14. what are some common string algorithms in python, 15. describe the concept of a linked list. what are its advantages and disadvantages, 16. how does the a* (a-star) algorithm work what is its primary use, 17. explain the concept of a binary search tree (bst). how do you perform in-order traversal.

  • Traverse the left subtree.
  • Visit the root node.
  • Traverse the right subtree.

18. What is the concept of “Big O” notation, and why is it important?

19. describe the depth-first search (dfs) algorithm. what are its applications, 20. what is a trie (prefix tree), and how is it used, 21. explain the concept of dijkstra’s algorithm. what is it used for, 22. what is a balanced binary tree provide an example., 23. describe the concept of a "backtracking" algorithm with an example., 24. what is the difference between an iterative and a recursive algorithm.

  • Iterative Algorithm : Uses loops (e.g., for, while) to repeat steps until a condition is met. It is generally more space-efficient.
  • Recursive Algorithm : The function calls itself to solve sub-problems until a base case is reached. It can be more elegant but may use more memory due to function call stack overhead.

25. Explain the concept of the Knapsack problem and how it can be solved.

26. what is a graph, and what are some common ways to represent it, 27. describe the concept of a “hash function” and its use in hash tables., 28. what is the floyd-warshall algorithm used for, 29. explain the concept of the "divide and conquer" algorithm paradigm with an example., 30. what is a permutation, and how can you generate all permutations of a string in python, 31. describe the concept of the “union-find” data structure. what is it used for, 32. what is the difference between bfs and dfs in terms of implementation, 33. explain how you can use python to solve the problem of finding the longest increasing subsequence in an array., 34. what is a “graph traversal” algorithm, and why is it important, 35. describe the concept of “greedy algorithms” with an example., 36. what is the difference between a linear search and a binary search, 37. what is the concept of “dynamic programming” and how is it different from “divide and conquer”, 38. explain the concept of “topological sorting” and its applications., 39. what is a “segment tree” and what problems does it solve, 40. describe the “kadane’s algorithm” and its use case..

  • Python algorithms interview questions
  • Python coding interview questions
  • algorithm interview questions
  • Python programming
  • coding interview preparation
  • data structures and algorithms
  • Python algorithm examples
  • technical interview questions
  • coding interview tips

problem solving and python programming technical publications

Ashwini Ghugarkar

Related Posts

[2024] Python Interview Questions for Beginners

[2024] Python Interview Questions for Beginners

[2024] Python Interview Questions for Data Science

[2024] Python Interview Questions for Data Science

[2024] Common Python Interview Questions

[2024] Common Python Interview Questions

Popular posts.

How to Install Red Hat Enterprise Linux (RHEL) 9 ? RHEL 9 Installation Step by Step with Screenshots.

How to Install Red Hat Enterprise Linux (RHEL) 9 ? RHEL...

Aayushi   May 18, 2022  12117

Get 50% Discount on Azure Certification Exam Voucher AZ 900 | AZ 104 | AZ 305 | AZ 400 | AZ 500 | AZ 204

Get 50% Discount on Azure Certification Exam Voucher AZ...

Aayushi   Oct 15, 2022  9553

50% Discount on CKA, CKAD and CKS  Certification 2023 | Kubernetes CKA, CKAD and CKS Exam Discount Voucher

50% Discount on CKA, CKAD and CKS Certification 2023 |...

Aayushi   Oct 11, 2022  9428

What is Linux Operating System and its Evolution and Future

What is Linux Operating System and its Evolution and Fu...

Aayushi   May 3, 2020  7496

50% Discount on Cisco( New CCNA & CCNP) Certification fee | Cisco Exam Discount Voucher

50% Discount on Cisco( New CCNA & CCNP) Certification f...

Aayushi   Feb 25, 2021  7109

Know Everything about RHCSA (Red Hat Certified System Administrator)  Training and Certification Ex200v9

Know Everything about RHCSA (Red Hat Certified System A...

Aayushi   Sep 15, 2022  1482

How to Install Red Hat Enterprise Linux (RHEL) 9 ? RHEL 9 Installation Step by Step with Screenshots.

Red Hat Remote Individual Certification Exams of RHCSA,...

Aayushi   May 22, 2020  2660

Why is Certified Ethical Hacker (CEH v12) So Popular Certification Exam in the Field of Cyber Security?

Why is Certified Ethical Hacker (CEH v12) So Popular Ce...

Aayushi   May 21, 2020  3397

What is kubernetes and Containers? Why is So Popular?

What is kubernetes and Containers? Why is So Popular?

Aayushi   May 15, 2020  2095

  • Networking (5)
  • Security (117)
  • Interview Q & A (216)
  • Python Interview Q & A (12)
  • Common Interview Q & A (15)
  • Cloud Admin Interview Q & A (29)
  • Linux System Admin Interview Q & A (0)
  • Networking Interview Q & A (1)
  • Penetration Testing Interview Q & A (0)
  • WAPT Interview Q & A (0)
  • VAPT Interview Q & A (50)
  • Ethical Hacking Interview Q & A (76)
  • Study Material (2)
  • IT Exams (39)
  • Red Hat Certification (5)
  • AWS Certification (1)
  • Cyber Security Certification (3)

Random Posts

fixer

The Top Eight Kali Linux Tools For 2023

What is Data Analytics and Its Career Opportunities?

What is Data Analytics and Its Career Opportunities?

How To Become A Cyber Security Analyst

How To Become A Cyber Security Analyst

[2024] Top 50+ Cloud Deployment Strategies Interview Questions and Answers

[2024] Top 50+ Cloud Deployment Strategies Interview Questions and Ans...

Best Cyber Security Training Center In India

Best Cyber Security Training Center In India

  • PentesterLab
  • Linux courses after B.Com
  • inheritance in OOP
  • cloud automation interview questions
  • first attempt
  • cybersecurity syllabus
  • generative ai use cases
  • VMware certified associate exam cost
  • network security interview questions
  • cloud networking interview questions
  • CVE databases
  • CKA success strategies
  • VAPT interview preparation
  • August 2024
  • January 2024
  • December 2023
  • November 2023
  • September 2023
  • August 2023
  • January 2023
  • December 2022
  • January 2022
  • November 2021
  • August 2021
  • February 2021
  • November 2019
  • Academic Performance
  • AU Syllabus
  • Duplicate Certificate
  • Internal Marks
  • Malpractice
  • Notes & QP
  • Recent Notifications
  • Transcripts
  • WH (With-Held)
  • Entries feed
  • Comments feed
  • WordPress.org

STUCOR

Problem Solving and Python Programming (GE8151) Notes, Question Papers & Syllabus

APR/MAY 2023 EXAMS

NOTES/QB MATERIAL
PART A B & C
NOTES
PART A B & C
NOTES
QN’ PAPERS
SYLLABUS

Engineering Graphics (GE3251) [EG] Notes, Question Papers & Syllabus

Basic electrical, electronics and instrumentation engineering (be3252) [beeie] notes, question papers & syllabus, electric circuit analysis (ee3251) [eca] notes, question papers & syllabus.

Trusted by 1.7 Million Students & 25,000+ Faculty Members - Download App

COMMENTS

  1. Programming and Problem Solving using Python

    Technical Publications, Dec 1, 2020 - Computers - 234 pages. This textbook is designed to learn python programming from scratch. At the beginning of the book general problem solving concepts such as types of problems, difficulties in problem solving, and problem solving aspects are discussed. From this book, you will start learning the Python ...

  2. The Best Python Books

    The book is well written and presents learning to code as a way to teach children problem-solving skills. As is commonly the case, this book begins with a Python installation guide. ... Any of the books in this section will give you a deeper understanding of Python programming concepts and teach you how to write developer-style Python code ...

  3. Challenging Programming in Python: A Problem Solving Perspective

    About this book. This book aims to strengthen programming skills and foster creative thinking by presenting and solving 90 challenging problems. The book is intended for individuals with elementary, intermediate, and advanced Python programming skills who aspire to take their abilities to the next level. Additionally, the book is valuable for ...

  4. Problem Solving and Programming with Python

    ar engineering students of Anna University. The objective of this book is to introduce the students to the fundamentals of problem solving strategies and the concepts of Python programming language, and enable them to apply the. e concepts for solving real-world problems.The book is organized into 10 chapters that provide comprehensive coverage ...

  5. Charulatha Publications -Problem Solving and Python Programming

    Problem Solving and Python Programming T. Shantha Kumar Subject Code : 978-93-5577-478-1 Regulation : 2021

  6. Programming and Problem Solving using Python: Fundamentals and

    At the beginning of the book general problem solving concepts such as types of problems, difficulties in problem solving, and problem solving aspects are discussed. From this book, you will start learning the Python programming by knowing about the variables, constants, keywords, data types, indentation and various programming constructs. ...

  7. Programming and Problem Solving using Python

    At the beginning of the book general problem solving concepts such as types of problems, difficulties in problem solving, and problem solving aspects are discussed. From this book, you will start learning the Python programming by knowing about the variables, constants, keywords, data types, indentation and various programming constructs.

  8. Problem Solving with Algorithms and Data Structures using Python

    An interactive version of Problem Solving with Algorithms and Data Structures using Python. ... Problem Solving with Algorithms and Data Structures using Python ... Object-Oriented Programming in Python: Defining Classes. 1.13.1. A Fraction Class; 1.13.2. Inheritance: Logic Gates and Circuits; 1.14. Summary

  9. Problem Solving and Python Programming

    This book is meant for Python beginners. We can learn python programming language well with the practice of applications in that particular programming language. The purpose of this book is to learn python easily with the variety of applications. This book makes the reader to get familiar with Python. It mainly focuses on problem solving using python.

  10. Introduction to Computing & Problem Solving With PYTHON

    This book 'Introduction to Computing and Problem Solving with Python' will help every student,teacher and researcher to understand the computing basics and advanced PythonProgramming language. The Python programming topics include the reserved keywords,identifiers, variables, operators, data types and their operations, flowcontrol techniques which include decision making and looping, modules ...

  11. PDF Introduction to Computing and Problem Solving with PYTHON

    The third Chapter gives an introduction to Python which includes reserved keywords, identifiers, variables and operators. The fourth Chapter gives detailed explanation about data types and their operations. Chapter 5 illustrates flow control techniques which include decision making and looping. Functions are covered in Chapter 6.

  12. Programming and Problem Solving using Python (Engineering Reference Bo

    At the beginning of the book general problem solving concepts such as types of problems, difficulties in problem solving, and problem solving aspects are discussed. From this book, you will start learning the Python programming by knowing about the variables, constants, keywords, data types, indentation and various programming constructs.

  13. [PDF] GE3151 Problem Solving and Python Programming (PSPP) Books

    Download link is provided for Students to download the Anna University GE3151 Problem Solving and Python Programming Syllabus Question Bank Lecture Notes Part A 2 marks with answers & Part B 16 marks Question Bank with answer, Anna University Question Paper Collection, All the materials are listed below for the students to make use of it and get good (maximum) marks with our study materials.

  14. [PDF] GE3171 Problem Solving and Python Programming ...

    Download GE3171 Problem Solving and Python Programming Laboratory Manual (Lab Manual) from the below link.The students & the lectures can download the Anna University GE3171 Problem Solving and Python Programming Lab Manual for their Laboratory examination in the first semester examination of GE3171 subject. The students to make use of it and score good (maximum) marks in the exams with our ...

  15. Problem Solving and Python Programming

    Problem Solving and Python Programming is a textbook designed for the undergraduate and postgraduate students of Computer Science Engineering (CSE), Information Technology (IT), and Computer Applications. It will help the students to understand the fundamentals and applications of Python. The book will also serve as a useful reference for ...

  16. Problem Solving with Algorithms and Data Structures using Python

    An interactive version of Problem Solving with Algorithms and Data Structures using Python. ... Problem Solving with Algorithms and Data Structures using Python ... Object-Oriented Programming in Python: Defining Classes. 1.13.1. A Fraction Class; 1.13.2. Inheritance: Logic Gates and Circuits; 1.14. Summary

  17. Programming With Python by Anuradha A. Puntambekar and Yogesh ...

    The importance of Programming with Python For is well known in various engineering fields. Overwhelming response to my books on various subjects inspired me to write this book. The book is structured to cover the key aspects of the subject Programming with Python. The book uses plain, lucid language to explain fundamentals of this subject. The book provides logical method of explaining various ...

  18. [PDF] GE3151 Problem Solving and Python Programming ...

    Download GE3151 Problem Solving and Python Programming (PSPP) Books Lecture Notes Syllabus Part A 2 marks with answers GE3151 Problem Solving and Python Programming (PSPP) Important Part B 16 Mark Questions, PDF Books, Question Bank ... G.K.Publications GATE Book; S K Mondal's GATE, IES & IAS 20 Years Question Answers;

  19. Problem Solving & Python Programming for BE Anna University

    Rs. 340.00. Tax included. Shipping calculated at checkout. Syllabus Problem Solving and Python Programming - GE3151 UNIT IComputational Thinking and Problem Solving Fundamentals of Computing - Identification of Computational Problems - Algorithms, building blocks of algorithms (statements, state, control flow, functions), notation (pseudo code ...

  20. Python Practice Problems: Get Ready for Your Next Interview

    Python Practice Problem 5: Sudoku Solver. Your final Python practice problem is to solve a sudoku puzzle! Finding a fast and memory-efficient solution to this problem can be quite a challenge. The solution you'll examine has been selected for readability rather than speed, but you're free to optimize your solution as much as you want.

  21. [PDF] GE8151 Problem Solving and Python Programming ...

    Download GE8151 Problem Solving and Python Programming (PSPP) Books Lecture Notes Syllabus Part A 2 marks with answers GE8151 Problem Solving and Python Programming (PSPP) Important Part B 13 marks, Direct 16 Mark Questions and Part C 15 marks Questions, PDF Books, Question Bank with answers Key, GE8151 Problem Solving and Python Programming (PSPP) Syllabus […]

  22. Python Exercises, Practice, Challenges

    Each exercise has 10-20 Questions. The solution is provided for every question. Practice each Exercise in Online Code Editor. These Python programming exercises are suitable for all Python developers. If you are a beginner, you will have a better understanding of Python after solving these exercises. Below is the list of exercises.

  23. [2024] Python Algorithms Interview Questions

    Prepare for your Python coding interviews with our comprehensive guide on the most common algorithms interview questions. Explore essential topics like sorting algorithms, dynamic programming, graph traversal, and more. Enhance your problem-solving skills and boost your confidence with practical examples and explanations.

  24. Problem Solving and Python Programming (GE8151) Notes ...

    Problem Solving and Python Programming (GE8151) Notes, Question Papers & Syllabus December 8, 2022 CIVIL-SEM1 CSE-SEM1 ECE-SEM1 EEE-SEM1 IT-SEM1 MECH-SEM1 Notes & QP APR/MAY 2023 EXAMS