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 | 51 Comments

Python Date and Time Exercise with Solutions

Updated on:  December 8, 2021 | 11 Comments

Python Dictionary Exercise with Solutions

Updated on:  May 6, 2023 | 57 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 | 153 Comments

Updated on:  September 6, 2021 | 111 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 | 222 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 | 492 Comments

Useful Python Tips and Tricks Every Programmer Should Know

Updated on:  May 17, 2021 | 37 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

  • 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.”

Problem Solving with Python

If you like this book, please consider purchasing a hard copy version on amazon.com .

  • You will find the book chapters on the left hand menu
  • You will find navigation within a section of a chapter (one webpage) on the righthand menu
  • Sources for this text are stored on GitHub at github.com/professorkazarinoff/Problem-Solving-with-Python-37-Edition

If you find the text useful, please consider supporting the work by purchasing a hard copy of the text .

This work is licensed under a GNU General Public License v3.0

We’re fighting to restore access to 500,000+ books in court this week. Join us!

Internet Archive Audio

problem solving with python pdf

  • This Just In
  • Grateful Dead
  • Old Time Radio
  • 78 RPMs and Cylinder Recordings
  • Audio Books & Poetry
  • Computers, Technology and Science
  • Music, Arts & Culture
  • News & Public Affairs
  • Spirituality & Religion
  • Radio News Archive

problem solving with python pdf

  • Flickr Commons
  • Occupy Wall Street Flickr
  • NASA Images
  • Solar System Collection
  • Ames Research Center

problem solving with python pdf

  • All Software
  • Old School Emulation
  • MS-DOS Games
  • Historical Software
  • Classic PC Games
  • Software Library
  • Kodi Archive and Support File
  • Vintage Software
  • CD-ROM Software
  • CD-ROM Software Library
  • Software Sites
  • Tucows Software Library
  • Shareware CD-ROMs
  • Software Capsules Compilation
  • CD-ROM Images
  • ZX Spectrum
  • DOOM Level CD

problem solving with python pdf

  • Smithsonian Libraries
  • FEDLINK (US)
  • Lincoln Collection
  • American Libraries
  • Canadian Libraries
  • Universal Library
  • Project Gutenberg
  • Children's Library
  • Biodiversity Heritage Library
  • Books by Language
  • Additional Collections

problem solving with python pdf

  • Prelinger Archives
  • Democracy Now!
  • Occupy Wall Street
  • TV NSA Clip Library
  • Animation & Cartoons
  • Arts & Music
  • Computers & Technology
  • Cultural & Academic Films
  • Ephemeral Films
  • Sports Videos
  • Videogame Videos
  • Youth Media

Search the history of over 866 billion web pages on the Internet.

Mobile Apps

  • Wayback Machine (iOS)
  • Wayback Machine (Android)

Browser Extensions

Archive-it subscription.

  • Explore the Collections
  • Build Collections

Save Page Now

Capture a web page as it appears now for use as a trusted citation in the future.

Please enter a valid web address

  • Donate Donate icon An illustration of a heart shape

Introduction To Computing And Problem Solving Using Python

Bookreader item preview, share or embed this item, flag this item for.

  • Graphic Violence
  • Explicit Sexual Content
  • Hate Speech
  • Misinformation/Disinformation
  • Marketing/Phishing/Advertising
  • Misleading/Inaccurate/Missing Metadata

plus-circle Add Review comment Reviews

2 Favorites

DOWNLOAD OPTIONS

For users with print-disabilities

IN COLLECTIONS

Uploaded by SaeedCollection95 on May 10, 2020

SIMILAR ITEMS (based on metadata)

problem solving with python pdf

  • Table of Contents
  • Course Home
  • 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. Exercises
  • 2.1. Objectives
  • 2.2. What Is Algorithm Analysis?
  • 2.3. Big O Notation
  • 2.4.1. Solution 1: Anagram Detection Checking Off
  • 2.4.2. Anagram Detection Solution 2: Sort and Compare
  • 2.4.3. Anagram Detection Solution 3: Brute Force
  • 2.4.4. Anagram Detection Solution 4: Count and Compare
  • 2.5. Performance of Python Data Structures
  • 2.7. Dictionaries
  • 2.8. Summary
  • 2.9. Key Terms
  • 2.10. Exercises
  • 3.1. Objectives
  • 3.2. What Are Linear Structures?
  • 3.3. Stacks
  • 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. Queues
  • 3.11. The Queue Abstract Data Type
  • 3.12. Implementing a Queue in Python
  • 3.13. Queue Simulation: Hot Potato
  • 3.14.1. Main Simulation Steps
  • 3.14.2. Python Implementation
  • 3.14.3. Discussion
  • 3.15. Deques
  • 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 UnorderedList 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. 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. 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. 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 Quicksort
  • 5.13. Summary
  • 5.14. Key Terms
  • 5.15. Exercises
  • 6.1. Objectives
  • 6.2. Examples of Trees
  • 6.3. Vocabulary and Definitions
  • 6.4. Implementation
  • 6.5. List of Lists Representation
  • 6.6. Nodes and References
  • 6.7. Parse Tree
  • 6.8. Tree Traversals
  • 6.9. Priority Queues with Binary Heaps
  • 6.10. Binary Heap Operations
  • 6.11.1. The Structure Property
  • 6.11.2. The Heap Order Property
  • 6.11.3. Heap Operations
  • 6.12. Binary Search Trees
  • 6.13. Search Tree Operations
  • 6.14. Search Tree Implementation
  • 6.15. Search Tree Analysis
  • 6.16. Balanced Binary Search Trees
  • 6.17. AVL Tree Performance
  • 6.18. AVL Tree Implementation
  • 6.19. Summary of Map ADT Implementations
  • 6.20. Summary
  • 6.21. Key Terms
  • 6.22. 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. Exercises
  • 8.1. Objectives
  • 8.2. Python Lists Revisited
  • 8.3.1. Modular Arithmetic Theorems
  • 8.3.2. Modular Exponentiation
  • 8.3.3. The Greatest Common Divisor and Multiplicative Inverses
  • 8.3.4. RSA Algorithm
  • 8.4.1. The Map Abstract Data Type
  • 8.4.2. Implementing a Dictionary in Python
  • 8.5.1. A Quick Review of Digital Images
  • 8.5.2. Quantizing an Image
  • 8.5.3. An Improved Quantization Algorithm Using Octrees
  • 8.6.1. Biological Strings
  • 8.6.2. Simple Comparison
  • 8.6.3. Using Graphs: Finite State Automata
  • 8.6.4. Using Graphs: Knuth-Morris-Pratt

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 ¶

Search Page

Creative Commons License

Navigation Menu

Search code, repositories, users, issues, pull requests..., provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications You must be signed in to change notification settings

A list of python problems for beginners and intermediate developers

ProgrammingHero1/100-plus-python-coding-problems-with-solutions

Folders and files.

NameName
43 Commits

Repository files navigation

100 plus python coding problems with solutions.

Welcome to the Python problem-solving world.

Here, we will take a real-world coding related problem. We will think about the process of solving the problem and then we will solve it. After the solution, we will explain the answer.

Table of Contents:

1 -  easy ones.

  • 1.1 - Convert input
  • 1.2 - Math power
  • 1.3 - Random Number
  • 1.4 - Floor Division
  • 1.5 - Temporary variable

2 -  Number Related

2.1 - Max of two

2.2 - Max of three

2.3 - Average of numbers

2.4 - Divisible by 3 and 5

2.5 - Sum of digits

3 -  Loop Related

3.1 - Sum of elements

2 -  Number Related - 6-10

3 -  loop related - 11-16.

3.2 - Largest element of a list

3.3 - Sum of squares

3.4 - Second Largest

3.5 - Second Smallest

3.6 - Remove duplicate Chars

4 -  Conversions

  • 4.1 - Miles to Kilometers
  • 4.2 - Celsius to Fahrenheitt
  • 4.3 - Decimal to binary

4 -  Conversions - 17-21

  • 4.4 - Decimal to binary (recursive)
  • 4.5 - Binary to decimal - Premium Access

5 -  Solution Strategy

6 -  computations.

  • 6.1 - Simple Interest
  • 6.2 - Complex Interest
  • 6.3 - Calculate Grades
  • 6.4 - Gravitational Force
  • 6.5 - Triangle Area

7 -  Prime number

  • 7.1 -   Check Prime
  • 7.2 -   Prime Numbers
  • 7.3 -   Prime factors
  • 7.4 -   Smallest prime factor

8 -  Reverse

  • 8.1 -   Reverse String
  • 8.2 -   Reverse String (stack)
  • 8.3 -   Reverse String (recursive)
  • 8.4 -   Reverse Number
  • 8.5 -   Reverse word

9 -  Medium

  • 9.1 -   Check palindrome
  • 9.2 -   Dictionary of cubes
  • 9.3 -   Armstrong number
  • 9.4 -   Greatest common divisor
  • 9.5 -   Least Common Multiple

10 -  Programming Contest

11 -  simple game.

  • 11.1 -   Guess game
  • 11.2 -   Rock paper scissor
  • 11.3 -   Cows and bulls
  • 11.4 -   Cows and bulls(4digits)
  • 11.5 -   Word completion
  • 11.6 -   Word hangman

12 -  Harder

  • 12.1 -   Simple Calculator
  • 12.2 -   Password generator
  • 12.3 -   Password with requirements
  • 12.4 -   Permutations
  • 12.5 -   Generate Sentences

13 -  User Submitted

  • 13.1 -   Simple Clock
  • 13.2 -   Birthday-remaining.md
  • 13.3 -   Calculate age
Only half of the task is done. More problems are coming. If you want to add more problems, feel free to send a pull request.

Many solutions

Here we are focusing on the thinking and strategies to solve a problem. However, every problem could be solved in multiple ways. And other solutions could be better and faster.

Always keep an open mind to learn multiple solutions to solve a problem.

Let’s Start

Let’s start your journey. Let’s solve every problem you face.

Let’s do it.

Next Page

tags: programming-hero python python3 problem-solving programming coding-challenge interview learn-python python-tutorial programming-exercises programming-challenges programming-fundamentals programming-contest python-coding-challenges python-problem-solving

Contributors 2

@ProRasel

  • R2021 SYLLABUS
  • R2017 SYLLABUS
  • R2013 SYLLABUS
  • R2021, R2017, R2013 UG / PG SYLLABUS
  • Civil 1st Sem R2021
  • Civil 2nd Sem R2021
  • Civil 3rd Sem R2021
  • Civil 4th Sem R2021
  • CIVIL 1st SEM R2017
  • CIVIL 2nd SEM R2017
  • CIVIL 3rd SEM R2017
  • CIVIL 4TH SEM R2017
  • CIVIL 5TH SEM R2017
  • CIVIL 6TH SEM R2017
  • THIRD SEMESTER
  • FOURTH SEMESTER
  • FIFTH SEMESTER
  • SIXTH SEMESTER
  • SEVENTH SEMESTER
  • EIGHTH SEMESTER
  • ARCHITECTURE BOOKS
  • BUILDING MATERIALS BOOKS
  • BUILDING DESIGN BOOKS
  • FLUID MECHANICS BOOKS
  • MECHANICS OF MATERIALS BOOKS
  • SURVEYING BOOKS
  • STRUCTURAL ANALYSIS BOOKS
  • SOIL MECHANICS BOOKS
  • CONCRETE TECH BOOKS
  • HIGHWAY ENGINEERING BOOKS
  • CONSTRUCTION TECHNOLOGY BOOKS
  • FOUNDATION ENGINEERING BOOKS
  • GEOGRAPHIC ENGINEERING BOOKS
  • TUNNEL CONSTRUCTION BOOKS
  • CIVIL GATE NOTES COLLECTION
  • CIVIL IS-CODE BOOKS
  • CIVIL PROJECT COLLECTION
  • MOCK TEST FOR PRACTICE
  • CSE 1st Sem R2021
  • CSE 2nd Sem R2021
  • CSE 3rd Sem R2021
  • CSE 4th Sem R2021
  • CSE 1st SEM R2017
  • CSE 2nd SEM R2017
  • CSE 3rd SEM R2017
  • CSE 4th SEM R2017
  • CSE 5th SEM R2017
  • CSE 6th SEM R2017
  • ALGORITHM BOOKS
  • ANDROID BOOKS
  • COMPILER DESIGN BOOKS
  • COMPUTER ORGANISATION & ARCHITECTURE BOOKS
  • PROGRAMMING BOOKS
  • NETWORKS BOOKS
  • DATA BASE BOOKS
  • DIGITAL SIGNAL PROCESSING BOOKS
  • HACKING BOOKS
  • OPERATING SYSTEM BOOKS
  • SOFTWARE ENGINEERING BOOKS
  • NETWORK SECURITY BOOKS
  • THEORY OF COMPUTATION & COMMUNICATION BOOKS
  • COMPUTER CODE BOOKS
  • CSE GATE NOTES COLLECTION
  • CSE PROJECT COLLECTION
  • EEE 1st Sem R2021
  • EEE 2nd Sem R2021
  • EEE 3rd Sem R2021
  • EEE 4th Sem R2021
  • EEE 1st SEM R2017
  • EEE 2nd SEM R2017
  • EEE 3rd SEM R2017
  • EEE 4th SEM R2017
  • EEE 5th SEM R2017
  • EEE 6th SEM R2017
  • EEE EIGHTH SEMESTER
  • ELECTRICAL WIRING BOOKS
  • ELECTRICAL MEASUREMENT BOOKS
  • ELECTRICAL DRIVE BOOKS
  • HIGH VOLTAGE ENGINEERING BOOKS
  • POWER SUPPLY ENGINEERING BOOKS
  • POWER PLANT ENGINEERING BOOKS
  • RENEWABLE ENERGY BOOKS
  • ENERGY ENGINEERING BOOKS
  • TRANSFORMER BOOKS
  • WIND ENERGY BOOKS
  • EEE GATE NOTES COLLECTION
  • EEE PROJECT COLLECTION
  • ECE 1st Sem R2021
  • ECE 2nd Sem R2021
  • ECE 3rd Sem R2021
  • ECE 4th Sem R2021
  • ECE 1st SEM R2017
  • ECE 2nd SEM R2017
  • ECE 3rd SEM R2017
  • ECE 4th SEM R2017
  • ECE 5th SEM R2017
  • ECE 6th SEM R2017
  • AMPLIFIER BOOKS
  • POWER ELECTRONICS BOOKS
  • ELECTRONIC DEVICE BOOKS
  • OPTO ELECTRONICS BOOKS
  • MICRO CONTROLLER BOOKS
  • IMAGE PROCESSING BOOKS
  • WIRELESS TRANSMISSION BOOKS
  • MICROWAVE BOOKS COLLECTION
  • RADIO FREQUENCY BOOKS
  • MECHATRONICS BOOKS
  • ECE GATE NOTES COLLECTION
  • ECE PROJECT COLLECTION
  • Mech 1st Sem R2021
  • Mech 2nd Sem R2021
  • MECH 3rd Sem R2021
  • MECH 4th Sem R2021
  • MECH 1st SEM R2017
  • MECH 2nd SEM R2017
  • MECH 3rd SEM R2017
  • MECH 4th SEM R2017
  • MECH 5th SEM R2017
  • MECH 6th SEM R2017
  • CAD/CAM/CIM BOOKS
  • MACHINE DESIGN BOOKS
  • MANUFACTURING TECHNOLOGY BOOKS
  • PRODUCTION TECHNOLOGY BOOKS
  • VIBRATION BOOKS
  • STRENGTH OF MATERIALS BOOKS
  • MECHANICAL DESIGN BOOKS
  • THERMODYNAMICS BOOKS
  • HEAT AND MASS TRANSFER BOOKS
  • REFRIGERATION & A.C. BOOKS
  • MECHANICAL DRAWING BOOKS
  • WELDING TECHNOLOGY BOOKS
  • IC ENGINE BOOKS
  • MECH SPECIAL EXAM BOOKS
  • MECH GATE NOTES COLLECTION
  • MECH DATA BOOKS COLLECTION
  • MECH PROJECT COLLECTION
  • AERONAUTICAL MAJOR BOOKS
  • AERO SPACE BOOKS
  • AERO SPACE CRAFT BOOKS
  • AIRCRAFT BOOKS
  • AERO DYNAMICS BOOKS
  • ODD SEM LAB MANUALS
  • EVEN SEM LAB MANUALS
  • R2017 LAB MANUAL
  • IIT-JEE SYLLABUS
  • IIT-JEE QP COLLECTION
  • IIT-JEE RANK BOOSTER
  • IIT-JEE MATHS
  • IIT-JEE PHYSICS
  • IIT-JEE PHYSICS TOPIC WISE NOTES
  • IIT-JEE CHEMISTRY
  • IIT-JEE CHEMISTRY TOPIC WISE NOTES
  • GATE IES TANCET SYLLABUS
  • CIVIL GATE COLLECTION
  • CSE GATE COLLECTION
  • ECE GATE COLLECTION
  • EEE GATE COLLECTION
  • MECH GATE COLLECTION
  • IES OBJECTIVE PAPERS
  • IES SUBJECTIVE PAPERS
  • RRB EXAM COLLECTION
  • SSC EXAM COLLECTION
  • APTITUDE BOOKS
  • REASONING BOOKS
  • BANK AWARENESS BOOKS
  • ENGLISH GRAMMAR BOOKS
  • Articles For You
  • Admit Cards

LearnEngineering.in

  • First Sem R2021
  • R2021 Notes

[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 with python pdf

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

A Beginner's Guide to R (Use R!) By Alain Zuur and Elena N. Ieno

[PDF] A Beginner’s Guide to R (Use R!) By Alain...

All time trending.

problem solving with python pdf

[PDF] ME8351 Manufacturing Technology – I Lecture Notes, Books, Important Part-A...

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 with python pdf

Today Updates

R K Kanodia Electric Circuits and Electric Field Notes

[PDF] R K Kanodia Electric Circuits and Electric Field Notes for...

J & P Transformer Book By Martin Heathcote

[PDF] J & P Transformer Book By Martin Heathcote Free Download

Probability Theory By Alexandr A. Borovkov

[PDF] Probability Theory By Alexandr A. Borovkov Free Download

Chapterwise Solved Papers Bank PO Quantitative Aptitude By K Kundan

[PDF] Chapterwise Solved Papers Bank PO Quantitative Aptitude By K Kundan...

Principles of Musical Acoustics By William M. Hartmann

[PDF] Principles of Musical Acoustics By William M. Hartmann Free Download

Objective Electronics & Telecommunication Engineering (Diploma Level) By Dr.M.P.Sinha

[PDF] Objective Electronics & Telecommunication Engineering (Diploma Level) By Dr.M.P.Sinha &...

Smart Buildings Systems for Architects, Owners and Builders By James M Sinopoli

[PDF] Smart Buildings Systems for Architects, Owners and Builders By James...

Popular files.

[PDF] CE8591 Foundation Engineering

[PDF] CE8591 Foundation Engineering Lecture Notes, Books, Important Part-A 2 Marks...

EC8691 Microprocessors and Microcontrollers

EC8691 Microprocessors and Microcontrollers Lecture Notes, Books, Important Part-A 2 Marks...

ME6703 Computer Integrated Manufacturing System

[PDF] ME6703 Computer Integrated Manufacturing System Lecture Notes, Books, Important 2...

CS6302 Database Management Systems

[PDF] CS6302 Database Management Systems Lecture Notes, Books, Important 2 Marks...

EC6202 Electronic Devices and Circuits

[PDF] EC6202 Electronic Devices and Circuits Lecture Notes, Books, Important 2...

IT6601 Mobile Computing

[PDF] IT6601 Mobile Computing Lecture Notes, Books, Important 2 Marks Questions...

Trending on learnengineering.in.

Diffraction of Light (Physics) Notes for IIT-JEE Exam

[PDF] Diffraction of Light (Physics) Notes for IIT-JEE Exam Free Download

Verbal Reasoning By K.Kundan

[PDF] Verbal Reasoning By K.Kundan for Bank Exam Free Download

Master in Computer Knowledge By Mahendra

[PDF] Master in Computer Knowledge By Mahendra for Bank Exam Free...

RRB Assistant Loco Pilot ALP Exam Papers

[PDF] RRB Assistant Loco Pilot ALP Exam Papers By RRB Portal...

Carboxylic Acid and their Derivatives (Chemistry) Notes for IIT-JEE Exam

[PDF] Carboxylic Acid and their Derivatives (Chemistry) Notes for IIT-JEE Exam...

RRB Non Technical (NTPC) Previous Year Exam Papers

[PDF] RRB Non Technical (NTPC) Previous Year Exam Papers By RRB...

Mahendra's Master in English Volume 1

[PDF] Mahendra’s Master in English Volume 1 By Mahendra’s for...

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 with python pdf

  • 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 with python pdf

Official Telegram Channel 

Articles for you (New Session Especially for readers)

New Mock (Free Quiz) Website  

Jobs Alerts Group

For IEEE Members

Ieee spectrum, follow ieee spectrum, support ieee spectrum, enjoy more free content and benefits by creating an account, saving articles to read later requires an ieee spectrum account, the institute content is only available for members, downloading full pdf issues is exclusive for ieee members, downloading this e-book is exclusive for ieee members, access to spectrum 's digital edition is exclusive for ieee members, following topics is a feature exclusive for ieee members, adding your response to an article requires an ieee spectrum account, create an account to access more content and features on ieee spectrum , including the ability to save articles to read later, download spectrum collections, and participate in conversations with readers and editors. for more exclusive content and features, consider joining ieee ., join the world’s largest professional organization devoted to engineering and applied sciences and get access to all of spectrum’s articles, archives, pdf downloads, and other benefits. learn more about ieee →, join the world’s largest professional organization devoted to engineering and applied sciences and get access to this e-book plus all of ieee spectrum’s articles, archives, pdf downloads, and other benefits. learn more about ieee →, access thousands of articles — completely free, create an account and get exclusive content and features: save articles, download collections, and talk to tech insiders — all free for full access and benefits, join ieee as a paying member., how good is chatgpt at coding, really, study finds that while ai can be great, it also struggles due to training limitations.

Illustration of ghostly hands with 0s an 1s hovering over a keyboard

This article is part of our exclusive IEEE Journal Watch series in partnership with IEEE Xplore.

Programmers have spent decades writing code for AI models , and now, in a full circle moment, AI is being used to write code. But how does an AI code generator compare to a human programmer?

A study published in the June issue of IEEE Transactions on Software Engineering evaluated the code produced by OpenAI’s ChatGPT in terms of functionality, complexity and security. The results show that ChatGPT has an extremely broad range of success when it comes to producing functional code—with a success rate ranging from anywhere as poor as 0.66 percent and as good as 89 percent—depending on the difficulty of the task, the programming language, and a number of other factors.

While in some cases the AI generator could produce better code than humans, the analysis also reveals some security concerns with AI-generated code.

Yutian Tang is a lecturer at the University of Glasgow who was involved in the study. He notes that AI-based code generation could provide some advantages in terms of enhancing productivity and automating software development tasks—but it’s important to understand the strengths and limitations of these models.

“By conducting a comprehensive analysis, we can uncover potential issues and limitations that arise in the ChatGPT-based code generation... [and] improve generation techniques,” Tang explains.

To explore these limitations in more detail, his team sought to test GPT-3.5’s ability to address 728 coding problems from the LeetCode testing platform in five programming languages: C, C++, Java, JavaScript, and Python .

“A reasonable hypothesis for why ChatGPT can do better with algorithm problems before 2021 is that these problems are frequently seen in the training dataset.” —Yutian Tang, University of Glasgow

Overall, ChatGPT was fairly good at solving problems in the different coding languages—but especially when attempting to solve coding problems that existed on LeetCode before 2021. For instance, it was able to produce functional code for easy, medium, and hard problems with success rates of about 89, 71, and 40 percent, respectively.

“However, when it comes to the algorithm problems after 2021, ChatGPT’s ability to generate functionally correct code is affected. It sometimes fails to understand the meaning of questions, even for easy level problems,” Tang notes.

For example, ChatGPT’s ability to produce functional code for “easy” coding problems dropped from 89 percent to 52 percent after 2021. And its ability to generate functional code for “hard” problems dropped from 40 percent to 0.66 percent after this time as well.

“A reasonable hypothesis for why ChatGPT can do better with algorithm problems before 2021 is that these problems are frequently seen in the training dataset,” Tang says.

Essentially, as coding evolves, ChatGPT has not been exposed yet to new problems and solutions. It lacks the critical thinking skills of a human and can only address problems it has previously encountered. This could explain why it is so much better at addressing older coding problems than newer ones.

“ChatGPT may generate incorrect code because it does not understand the meaning of algorithm problems.” —Yutian Tang, University of Glasgow

Interestingly, ChatGPT is able to generate code with smaller runtime and memory overheads than at least 50 percent of human solutions to the same LeetCode problems.

The researchers also explored the ability of ChatGPT to fix its own coding errors after receiving feedback from LeetCode. They randomly selected 50 coding scenarios where ChatGPT initially generated incorrect coding, either because it didn’t understand the content or problem at hand.

While ChatGPT was good at fixing compiling errors, it generally was not good at correcting its own mistakes.

“ChatGPT may generate incorrect code because it does not understand the meaning of algorithm problems, thus, this simple error feedback information is not enough,” Tang explains.

The researchers also found that ChatGPT-generated code did have a fair amount of vulnerabilities, such as a missing null test, but many of these were easily fixable. Their results also show that generated code in C was the most complex, followed by C++ and Python, which has a similar complexity to the human-written code.

Tangs says, based on these results, it’s important that developers using ChatGPT provide additional information to help ChatGPT better understand problems or avoid vulnerabilities.

“For example, when encountering more complex programming problems, developers can provide relevant knowledge as much as possible, and tell ChatGPT in the prompt which potential vulnerabilities to be aware of,” Tang says.

  • What to Do When the Ghost in the Machine Is You ›
  • How Coders Can Survive—and Thrive—in a ChatGPT World ›
  • Coding Assistant - ChatGPT ›

Michelle Hampson is a freelance writer based in Halifax. She frequently contributes to Spectrum's Journal Watch coverage, which highlights newsworthy studies published in IEEE journals.

Floch Forster

That's yesterday's news, try it with version 4o, it's free.

Richard Wickens

"struggles due to training limitations" isn't that EVERYONE's problem with EVERYTHING.

"I could be an awesome guitar playing, but I struggle due to training limitations."

"I could be a great Opera singer, but I struggle due to training limitations."

"I could be a great jockey, but I am 6'4"...." Ok, well maybe not everything.

ChatGPT sucks at coding because it's not an AI - it's a big ass word predictor.

Sam Sperling

I actually think the key here is writing good test suits to ensure AI does the right thing...

Here is the full argument: https://medium.com/@samuel.sperling/software-2-1-ai-is-coding-now-why-test-mastery-is-your-new-job-security-31a65e792f7f

Soft Robot Can Amputate and Reattach Its Own Legs

Video friday: unitree talks robots, food service robots just need the right ingredients, related stories, what to do when the ghost in the machine is you, chatgpt’s new upgrade teases ai’s multimodal future, chatgpt may be a better improviser than you.

IMAGES

  1. Problem Solving with Algorithms and Data Structures Using Python—3rd

    problem solving with python pdf

  2. Programming And Problem Solving With Python By Ashok Namdev Kamthane

    problem solving with python pdf

  3. (PDF) Fundamentals of Problem Solving and Python Programming

    problem solving with python pdf

  4. O Level Made Simple Programming & Problem Solving Through 'PYTHON

    problem solving with python pdf

  5. Problem Solving using Python

    problem solving with python pdf

  6. CSC102 Problem Solving with Python

    problem solving with python pdf

VIDEO

  1. File Handling and Dictionaries

  2. Object Oriented Programming

  3. Python на примерах (Васильев А. Н.)

  4. Solving Python question on HackerRank : Part 1 #programming #python #coding #hacker #beginners #job

  5. Solving "The Python Challenge" (Level 3)

  6. Computer Extension Name || #extension #extensions || File Extension Question by vikas sir

COMMENTS

  1. PDF Algorithmic Problem Solving with Python

    Algorithmic Problem Solving with Python John B. Schneider Shira Lynn Broschat Jess Dahmen February 22, 2019

  2. Welcome to 101 Exercises for Python Fundamentals

    Welcome to 101 Exercises for Python Fundamentals Solving these exercises will help make you a better programmer. Solve them in order, because each solution builds scaffolding, working code, and knowledge you can use on future problems. Read the directions carefully, and have fun!

  3. Python Exercises, Practice, Challenges

    Coding Exercises with solutions for Python developers. Practice 220+ Python Topic-specific exercises. Solve Python challenges, assignments, programs.

  4. Problem Solving with Algorithms and Data Structures using Python

    An interactive version of Problem Solving with Algorithms and Data Structures using Python.

  5. ProfessorKazarinoff/Problem-Solving-with-Python-37-Edition

    Problem-Solving-with-Python-37-Edition Repo for the book: Problem Solving with Python 3.7 Edition by Peter D. Kazarinoff, PhD

  6. PDF Notes of Lesson Ge3151- Problem Solving and Python Programming

    Algorithmic Algorithmic Algorithmic problem problem problem solving solving solving is is is solving solving solving problem problem problem that that that require require require the the the formulation formulation formulation of of of an an an algorithm algorithm algorithm for for for the the the solution. solution. solution.

  7. Problem Solving with Python 3. 7 Edition

    Get started solving problems with the Python programming language!This book introduces some of the most famous scientific libraries for Python: * Python's math and statistics module to do calculations * Matplotlib to build 2D and 3D plots * NumPy to complete calculations on arrays * Jupiter Notebooks to share results with a team * SymPy to solve equations * PySerial to control an Arduino with ...

  8. Problem Solving with Python

    Website companion for the book Problem Solving with Python by Peter D. Kazarinoff

  9. PDF Introduction to Computing and Problem Solving with PYTHON

    ntroduce the reader on digital computers and programming. The third Chapter gives an introduction to Python which include. reserved keywords, identifiers, variables and operators. The fourth Chapter gives d. tailed explanation about data types and their operations. Chapter 5 illustrates flow con.

  10. Real World Python: A Hacker's Guide To Solving Problems With Code (PDF

    Real World Python: A Hacker's Guide To Solving Problems With Code (PDF Ebook) Topics Python Programming Collection opensource Language English Real World Python: A Hacker's Guide To Solving Problems With Code (PDF Ebook) Addeddate 2021-05-22 14:38:23 Identifier real-world-python-a-hackers-guide-to-solving-problems-with-code Identifier-ark ark:/13960/t1rg6vz3b Scanner Internet Archive HTML5 ...

  11. PDF Introduction to Problem Solving

    What is Problem solving? Problem solving is a process of transforming the description of a problem into the solution of that problem by using our knowledge of the problem domain and by relying on our ability to select and use appropriate problem-solving Strategies, Techniques and Tools.

  12. Introduction To Computing And Problem Solving Using Python

    Introduction To Computing And Problem Solving Using Python. Topics Computer Science, Python Collection opensource Language English Addeddate 2020-05-10 15:09:05 ... PDF download. download 1 file . SINGLE PAGE PROCESSED JP2 ZIP download. download 1 file ...

  13. PDF Problem Solving with Algorithms and Data Structures

    Computer science is the study of problems, problem-solving, and the solutions that come out of the problem-solving process. Given a problem, a computer scientist's goal is to develop an algorithm, a step-by-step list of instructions for solving any instance of the problem that might arise.

  14. PDF Ge8151 Problem Solving and Python Programming Unit I Algorithmic ...

    Problem solving is the systematic approach to define the problem and creating number of solutions. The problem solving process starts with the problem specifications and ends with a Correct program.

  15. Problem Solving with Algorithms and Data Structures using Python

    An interactive version of Problem Solving with Algorithms and Data Structures using Python.

  16. Problem Solving with Algorithms and Data Structures using Python

    Problem Solving with Algorithms and Data Structures Using Python This book began as a paper book, first published by Franklin Beedle & Associates back in 2005. Written by Brad Miller and David Ranum. We are grateful for the vision of Jim Leisy who gave us permission to take our text and publish it online as an interactive textbook.

  17. PDF Project 1: Problem Solving with Python

    Your speci c problem may have a possible, elegant solution that is only a few lines of code. We only ask and expect you to demonstrate knowledge of Python which we cover in class: e.g., reading les, using functions, and when appropriate, using basic data structures like lists and dictionaries, and constructs like if-statements and for-loops.

  18. PDF Microsoft Word

    CIS 1051 introduces students to computers, computer programming, and problem solving using programs written in the Python language. Topics covered include the general characteristics of computers; techniques of problem solving and algorithm specifications; and the implementation, debugging, and testing of computer programs.

  19. Problem Solving and Programming with Python

    The following are the important features of the book: Complete coverage of the Problem Solving and Python Programming syllabus offered by Anna University Offers simple and lucid treatment of concepts supported with illustrations for easy understanding. Contains separate chapters on Strings, Files, Classes, and Exception Handling.

  20. 100 Plus Python Coding Problems With Solutions

    100 Plus Python Coding Problems With Solutions Welcome to the Python problem-solving world.

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

    Learnengineering.in 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 ...

  22. 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.

  23. Enhancing Computer Programming Education with LLMs: A Study on

    The results of our study indicate that prompt engineering significantly enhances the problem-solving capabilities of LLMs in the context of computer programming education. The multi-step prompts, in particular, demonstrate the potential to guide LLMs through complex problem-solving processes by providing a structured and iterative approach.

  24. How Good Is ChatGPT at Coding, Really?

    Downloading full PDF issues is exclusive for IEEE Members ... ChatGPT was fairly good at solving problems in the different coding languages—but especially when attempting to solve coding ...