Fundamentals 20 min read

Python Basics: Numbers, Strings, Functions, Data Structures, Classes, and Tools

An extensive Python tutorial covering numeric operations, string handling, built‑in functions, data structures, class and object concepts, as well as useful tools such as iterators, file I/O, serialization, and common utilities, illustrated with clear code examples.

Python Programming Learning Circle
Python Programming Learning Circle
Python Programming Learning Circle
Python Basics: Numbers, Strings, Functions, Data Structures, Classes, and Tools

This article provides a comprehensive introduction to core Python features. It begins with numeric operations, showing how to compute absolute values, convert between bases, and use functions like abs() , bin() , oct() , and hex() . It also demonstrates creating complex numbers and performing division with divmod() .

The next section focuses on string manipulation, including converting strings to bytes with bytes(s, encoding='utf-8') , casting objects to strings using str() , executing code strings via compile() and exec() , and formatting strings with the format() method.

Function usage is explored in depth, covering built‑in functions such as sorted() , sum() , and the use of nonlocal and global statements. It explains defining functions with various parameter types, using lambda expressions, and creating reusable slice objects.

Data structure examples include creating dictionaries, frozen sets, regular sets, slices, tuples, and converting between these types. The article also illustrates how to inspect and manipulate objects using functions like callable() , hasattr() , getattr() , type() , and isinstance() .

Object‑oriented concepts are covered, showing how to define classes, check callability, implement __repr__ , use class methods, manage attributes dynamically, and understand metaclasses. It demonstrates that classes themselves are objects created by the type metaclass.

The tools section introduces useful utilities such as enumerate() , memory size inspection with sys.getsizeof() , filtering with filter() , creating iterators via iter() and reversed() , aggregating iterables with zip() , chaining operations, and serializing objects to JSON using the json module.

pythonData StructuresTutorialfunctionsobjects
Python Programming Learning Circle
Written by

Python Programming Learning Circle

A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.