Python Looking for online/book Problems about the Python Classes

  • Thread starter Thread starter Arman777
  • Start date Start date
  • Tags Tags
    Classes Python
Click For Summary
For those learning Python classes, several online resources offer practical problems and exercises. Websites like Rosetta Code provide a variety of programming tasks across multiple languages, including Python, allowing learners to tackle real-world scenarios. While some tasks may lack existing Python solutions, users are encouraged to contribute their own, enhancing the community's resources. Additionally, reading through existing Python projects can be beneficial for understanding coding styles and best practices. Notable projects, such as bpytop, showcase advanced implementations and can serve as inspiration for learners seeking to deepen their programming skills. Online books, such as the one found at scipython.com, also offer structured examples and questions to aid in learning.
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.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

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