Looking for online/book Problems about the Python Classes

  • Context: Python 
  • Thread starter Thread starter Arman777
  • Start date Start date
  • Tags Tags
    Classes Python
Click For Summary

Discussion Overview

The discussion revolves around finding problems related to Python classes for practice. Participants are seeking resources, including online sites and books, that provide exercises or examples, ideally with solutions.

Discussion Character

  • Exploratory
  • Homework-related

Main Points Raised

  • One participant is looking for problems involving Python classes, providing a specific example of a class structure involving an Admin class and a Privileges class.
  • Another participant suggests the website www.rosettacode.org as a resource for various programming tasks in multiple languages, including Python.
  • A different participant notes that while they have checked Rosetta Code, they found a lack of specific problems related to Python classes.
  • One participant encourages others to pick a task from Rosetta Code and solve it in Python, mentioning the opportunity to improve existing solutions.
  • Another participant expresses a desire for additional resources beyond Rosetta Code.
  • A participant shares a link to an online book that contains examples and questions related to Python, emphasizing the importance of reading others' code for learning purposes.
  • The same participant mentions exploring Python projects like numpy and sci-py for insights into coding practices and features.
  • They also highlight a specific Python project called bpytop as an interesting example of a project that implements a Linux command.

Areas of Agreement / Disagreement

Participants have not reached a consensus on the best resources for Python class problems, and multiple suggestions and viewpoints remain. Some participants find Rosetta Code useful, while others express dissatisfaction with its offerings.

Contextual Notes

Some participants note the variability in the quality of examples on Rosetta Code, suggesting that not all solutions are well-written or suitable for Python.

Who May Find This Useful

Individuals learning Python, particularly those focused on object-oriented programming and seeking practical exercises or examples.

Arman777
Insights Author
Gold Member
Messages
2,163
Reaction score
191
I started to learn classes in python and I am looking for problems about them. Are there any good online sites that I can find problems about them. If they also contain solutions, that would be great, but if not that is also okay.

Problems can have the form like

An administrator is a special kind of user. Write a class called Admin that inherits from the User class you wrote in Exercise 9-3 (page 166) or Exercise 9-5 (page 171). Add an attribute, privileges, that stores a list of strings like "can add post", "can delete post", "can ban user", and so on. Write a method called show_privileges() that lists the administrator’s set of privileges. Create an instance of Admin, and call your method

Write a separate Privileges class. The class should have one attribute, privileges, that stores a list of strings as described in Exercise 9-7. Move the show_privileges() method to this class. Make a Privileges instance as an attribute in the Admin class. Create a new instance of Admin and use your method to show its privileges.


etc.
 
Technology news on Phys.org
jedishrfu said:
There’s always the www.rosettacode.org site where a variety of tasks are written in a multitude of languages including python.
I have looked at it, but it seems there is not much problem about it
 
Pick a rosetta task and solve it in python. There are quite a few to choose from. In some cases, there is no python solution so they would welcome a solution that works.

one thing to be aware of is that some examples are not the best examples for the specific language so if you saw a poorly written python solution you could submit your better or alternate solution.
 
I ll try but is there anything else ?
 
I found this online book with examples and questions.

https://scipython.com/book/

A big part of programming though is reading other people’s code so you could find python projects and try to find nuggets of knowledge in the project code like style, naming conventions and python language features. I've found really odd stuff in popular python projects like numpy and sci py for example.

there’s a cool python project called bpytop that implements a fancy version of the Linux top command in python.
 

Similar threads

  • · Replies 43 ·
2
Replies
43
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 23 ·
Replies
23
Views
3K
  • · Replies 25 ·
Replies
25
Views
6K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
10K