Twise Random

A site about computer science .
Skip to content
  • apple
  • android
  • c
  • cpp
  • data structure and algorithms
  • macos
  • python
  • tutorials

Category: python

__eq__ , __ne__ , __lt__ , __gt__ , __ge__ , __le__ in python a tutorial

Posted on September 1, 2021September 1, 2021 by mohamad wael

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

python

Reverse a string in python recursively

Posted on July 11, 2020October 29, 2020 by mohamad wael

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
python

The Ones’ complement operator ~ in python a tutorial

Posted on October 9, 2019February 13, 2021 by mohamad wael

 

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
… Read More
operators

what is a character in python ?

Posted on August 5, 2019November 30, 2020 by mohamad wael

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

python ascii, code points, encoding, hex, octal, ord, unicode

reversed in python , a tutorial

Posted on July 30, 2019October 29, 2020 by mohamad wael

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

… Read More
python __reversed__, generator, iterable, reversed

Generators in python , a tutorial

Posted on July 28, 2019September 26, 2020 by mohamad wael

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

python

what is an object in python ?

Posted on July 24, 2019October 29, 2020 by mohamad wael

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 object, type

Python iterable and iterator a tutorial

Posted on July 17, 2019October 29, 2020 by mohamad wael

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

python iterable, iterator, next, python

Sets in python a tutorial

Posted on July 11, 2019November 30, 2020 by mohamad wael

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

python set

How To Use The TimeIt Module in python

Posted on July 7, 2019September 26, 2020 by mohamad wael

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

modules python, speed, testing, timeit, timeit.repeat, timeit.timeit