Looking for online/book Problems about the Python Classes

In summary: It’s a really cool project and I’d love to see someone write a similar one for Windows.In summary, online resources can be used to find problems and solutions about learning Python.
  • #1
Arman777
Insights Author
Gold Member
2,168
193
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
  • #3
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
 
  • #4
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.
 
  • #5
I ll try but is there anything else ?
 
  • #6
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.
 

Related to Looking for online/book Problems about the Python Classes

1. What are Python classes?

Python classes are a way to group related functions and variables together to create objects. These objects can then be used to perform specific tasks or operations.

2. How do I create a class in Python?

To create a class in Python, you use the class keyword followed by the name of the class. Inside the class, you can define functions (also known as methods) and variables (also known as attributes) that are specific to that class.

3. What are some common problems that can be solved using Python classes?

Python classes can be used to solve a wide range of problems, including creating data structures, building web applications, and automating tasks. They are especially useful for organizing and managing complex code and data.

4. How can I find online or book resources for learning more about Python classes?

There are many online and book resources available for learning about Python classes. Some popular options include the official Python documentation, online tutorials and courses, and books such as "Python Crash Course" and "Learning Python". It's also helpful to join online communities and forums where you can ask questions and get support from other users.

5. Is there a specific recommended approach for learning about Python classes?

The best approach for learning about Python classes may vary depending on your individual learning style and goals. However, a common recommendation is to start by understanding the basic syntax and concepts of classes and then practice by creating simple classes and gradually building up to more complex ones.

Similar threads

  • Programming and Computer Science
2
Replies
43
Views
2K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
23
Views
2K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
25
Views
3K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
10
Views
2K
  • Programming and Computer Science
Replies
3
Views
429
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
8
Views
2K
Back
Top