Skip to content

Files

Latest commit

a38821e · Feb 20, 2023

History

History

python-everything_is_object

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 13, 2023
Feb 20, 2023

Python - Everything is object

Description

  • tests/ - Main functions provided by Holberton School to test the files.

Tasks

This project is mostly about answering each point in a .txt file.

  • 0. Who am I?

    • 0-answer.txt: What function would you use to print the type of an object?
  • 1. Where are you?

    • 1-answer.txt: How do you get the variable identifier (which is the memory address in the CPython implementation)?
  • 2. Right count

    • 2-answer.txt: In the following code, do a and b point to the same object?
    >>> a = 89
    >>> b = 100
    
  • 3. Right count =

    • 3-answer.txt: In the following code, do a and b point to the same object?
    >>> a = 89
    >>> b = 89
    
  • 4. Right count =

    • 4-answer.txt: In the following code, do a and b point to the same object?
    >>> a = 89
    >>> b = a
    
  • 5. Right count =+

    • 5-answer.txt: In the following code, do a and b point to the same object?
    >>> a = 89
    >>> b = a + 1
    
  • 6. Is equal

    >>> s1 = "Best School"
    >>> s2 = s1
    >>> print(s1 == s2)
    
  • 7. Is the same

    >>> s1 = "Best"
    >>> s2 = s1
    >>> print(s1 is s2)
    
  • 8. Is really equal

    >>> s1 = "Best School"
    >>> s2 = "Best School"
    >>> print(s1 == s2)
    
  • 9. Is really the same

    >>> s1 = "Best School"
    >>> s2 = "Best School"
    >>> print(s1 is s2)
    
  • 10. And with a list, is it equal

    >>> l1 = [1, 2, 3]
    >>> l2 = [1, 2, 3]
    >>> print(l1 == l2)
    
  • 11. And with a list, is it the same

    >>> l1 = [1, 2, 3]
    >>> l2 = [1, 2, 3]
    >>> print(l1 is l2)
    
  • 12. And with a list, is it really equal

    >>> l1 = [1, 2, 3]
    >>> l2 = l1
    >>> print(l1 == l2)
    
  • 13. And with a list, is it really the same

    >>> l1 = [1, 2, 3]
    >>> l2 = l1
    >>> print(l1 is l2)
    
  • 14. List append

    l1 = [1, 2, 3]
    l2 = l1
    l1.append(4)
    print(l2)
    
  • 15. List add

    l1 = [1, 2, 3]
    l2 = l1
    l1 = l1 + [4]
    print(l2)
    
  • 16. Integer incrementation

    def increment(n):
        n += 1
    a = 1
    increment(a)
    print(a)
    
  • 17. List incrementation

    def increment(n):
        n.append(4)
    l = [1, 2, 3]
    increment(l)
    print(l)
    
  • 18. List assignation

    def assign_value(n, v):
        n = v
    l1 = [1, 2, 3]
    l2 = [4, 5, 6]
    assign_value(l1, l2)
    print(l1)
    
  • 19. Copy a list object

    • 19-copy_list.py: Python function def copy_list(a_list): that returns a copy of a list.
  • 20. Tuple or not?

    a = ()
    
  • 21. Tuple or not?

    a = (1, 2)
    
  • 22. Tuple or not?

    a = (1)
    
  • 23. Tuple or not?

    a = (1, )
    
  • 24. Who I am?

    a = (1)
    b = (1)
    a is b
    
  • 25. Tuple or not

    a = (1, 2)
    b = (1, 2)
    a is b
    
  • 26. Empty is not empty

    a = ()
    b = ()
    a is b
    
  • 27. Still the same?

    • 27-answer.txt: Will the last line of this script print 139926795932424?
    >>> id(a)
    139926795932424
    >>> a
    [1, 2, 3, 4]
    >>> a = a + [5]
    >>> id(a)
    
  • 28. Richard Sim's special #4

    • 28-answer.txt: Will the last line of this script print 139926795932424?
    >>> a
    [1, 2, 3]
    >>> id (a)
    139926795932424
    >>> a += [4]
    >>> id(a)
    

Author