Everything in python is an object. An object has a type, which defines its attributes and methods. For example the str
type, define the attributes and methods for a string object. An object has also an id
, which is … Read More
Category: python
Reverse a string in python recursively
If there is a string , which must be reversed , for example :
reverse of '' is '' reverse of 'a' is 'a' reverse of 'ab' is 'ba'
In python this can be done like this :
>>> ''.join(reversed('ab'))… Read More
The Ones’ complement operator ~ in python a tutorial
The ones’ complement operator ~
, will flip the bits of an integer , so one will become zero , and zero will become one. An integer in python , has :
- an unlimited number of bits .
- is
what is a character in python ?
What is a character in python ?
A character in python is represented using a Unicode code point. A Unicode code point is written by using U+
followed by a number written in hexadecimal . This number written in hexadecimal … Read More
reversed in python , a tutorial
What is reversed?
The reversed class is used to create a reverse iterator from an object .
This object , must either implement the __getitem__
and the __len__
special methods . In this case reverse will create an iterator from
Generators in python , a tutorial
What is a generator
A generator simply generates data that we are going to use someplace. For example ,if we want to generate some random characters , or if we want to generate a number in a mathematical series , … Read More
what is an object in python ?
In python , we have the class type , and we have the class object .
The class type is used to create a new type/class .
The class type is also used to get the type/class used to create … Read More
Python iterable and iterator a tutorial
what is an iterable ?
In python , objects are abstraction of data , they have methods that work with data , and help us to manipulate it . If we take a look at a list , and see … Read More
Sets in python a tutorial
In this tutorial , we will show how to use sets in python . We will start by explaining what is a set. After that we will explain how to use sets , so the various operations that we can … Read More
How To Use The TimeIt Module in python
The timeIt module is used to test how fast our code is . We can use it to compare different functions or classes or just some line of code ,and see how fast they are .Also if we want we … Read More