Updates from June, 2019 Toggle Comment Threads | Keyboard Shortcuts

  • Joker 1:03 PM on June 24, 2019 Permalink | Reply
    Tags: ,   

    input function always produces a string output. If you want to output an integer you have to use int. example

    If you want to number output from this below code

    user_input = input("enter a number: ")
    print(user_input ** 2)
    

    it’ll show error like

    Traceback (most recent call last):                                                                                                                  
      File "try_input.py", line 2, in <module>                                                                                                          
        print(user_input ** 2)
    

    So, you have to convert that string to an integer.

    user_input = input("enter a number: ")
    print(int(user_input) ** 2)
    

    If you try this now under 10, you’ll get 100.

    enter a number: 10
    100
    
     
  • Joker 12:36 PM on June 24, 2019 Permalink | Reply
    Tags: ,   

    Mapping two lists to a dictionary:

    keys = ["a","b","c"]
    values = [1, 2, 3]
    mydicts = dict(zip(keys, values))
    mydicts
    {'a': 1, 'b': 2, 'c': 3}
    
     
  • Joker 12:22 PM on June 24, 2019 Permalink | Reply
    Tags: ,   

    Python lists only contain one value divided by comma, dictionaries contain two values. Also, lists use [ ] third bracket and dictionaries use { } second bracket.

     
  • Joker 12:06 PM on June 24, 2019 Permalink | Reply
    Tags: ,   

    পাইথনের built in functions এর লিস্ট জানতে হলে পাইথন শেলে টাইপ করতে হবে

    dir(__builtins__)
    

    এন্টার দিলে বিল্ট ইন ফাংশনের লিস্ট চলে আসবে, লিস্টগুলো নিচে দেয়া হলোঃ

    ['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning', 'Child
    ProcessError', 'ConnectionAbortedError', 'ConnectionError', 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning', 'EOFError', 'Ell
    ipsis', 'EnvironmentError', 'Exception', 'False', 'FileExistsError', 'FileNotFoundError', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'I
    OError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError', 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt',
     'LookupError', 'MemoryError', 'ModuleNotFoundError', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented', 'NotImplementedError', 'OSError',
     'OverflowError', 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError', 'RecursionError', 'ReferenceError', 'ResourceWarning', 'Runt
    imeError', 'RuntimeWarning', 'StopAsyncIteration', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'Timeou
    tError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarn
    ing', 'UserWarning', 'ValueError', 'Warning', 'ZeroDivisionError', '_', '__build_class__', '__debug__', '__doc__', '__import__', '__loader__', '__na
    me__', '__package__', '__spec__', 'abs', 'all', 'any', 'ascii', 'bin', 'bool', 'breakpoint', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod',
     'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec', 'exit', 'filter', 'float', 'format',
     'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'l
    ist', 'locals', 'map', 'max', 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit', 'range', 'repr', 'rev
    ersed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars', 'zip']
    
     
  • Joker 4:04 AM on June 24, 2019 Permalink | Reply
    Tags: ,   

    The definition of a list is a data type that contains multiple items

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel
Create your website at WordPress.com
Get started
%d bloggers like this: