Updates from August, 2019 Toggle Comment Threads | Keyboard Shortcuts

  • Joker 9:50 AM on August 6, 2019 Permalink | Reply
    Tags: , PlatformIO IDE Terminal   

    Platformio Atom Ide Terminal not working in 2.9.3 – Solved 

    Do this for now. WINDOWS ONLY

    1. Uninstall platformio-ide-terminal@2.9.3 from Atom and close Atom <- Important.
    2. Download -> platformio-ide-terminal.zip <- click once there to start download
    3. extract to folder platformio-ide-terminal on you desktop
    4. open a powershell inside the platformio-ide-terminal folder
    5. type npm i or apm i press Enter Wait for install to finish, any warning about vulnerabilities via npm its OK to ignore.
    6. type apm link Enter You should see a confirmation of the linking.
    7. Open Atom and should now work

    You can check full process here 👇

     
  • Joker 10:42 AM on August 3, 2019 Permalink | Reply  

    While Loop with Password Checker 

     
  • Joker 8:30 AM on July 28, 2019 Permalink | Reply
    Tags: ,   

    পাইথনের ভাগ নিয়ে সিম্পল কিছু আলোচনা। সাধারণত পাইথনে যখন ভাগ করা হয় তখন ভাগফল floating point আকারে প্রকাশ পায়। যেমন নিচের কোডটিকে যদি আমরা রান করি

    x = 10
    y = 2
    result = x / y
    print(result)
    

    তাহলে ভাগফল আসবে 5.0 এখন আমরা যদি চাই ভাগফলে দশমিকের পরে শূণ্য আসবে না, পূর্ণ 5 সংখ্যাটাই আসবে তাহলে সেটাকে integar নাম্বার হিসেবে সিলেট করে দিতে হবে। সেটা কীভাবে?

    x = 10
    y = 2
    result = int( x / y )
    print(result)
    

    এবার কোডটিকে রান করলে সেটা পূর্ণ সংখ্যা 5 হিসেবে প্রকাশ পাবে।

    ভাগশেষ বের করতে হলে % ব্যবহার করতে হয়। যেমন, 10/3 এর ভাগশেষ জানতে হলে নিচের কোড রান করতে হবে

    x = 10
    y = 3
    result = x % y
    print=(result)
    

    কোডটি রান করে দেখুন, ভাগশেষ দেখাচ্ছে 1

    আপনি যদি পাইথনে ভাগফল এবং ভাগশেষ দুটো একইসাথে দেখতে চান তাহলে সেটা হবে divmod দিয়ে। যেমন নিচের কোডটি রান করুন

    x = 10
    y = 3
    result = divmod (x, y)
    print(result)
    

    এবার দেখুন ভাগফল এবং ভাগশেষ একইসাথে (3, 1) আকারে দেখাচ্ছে।

     
  • Joker 10:03 PM on July 20, 2019 Permalink | Reply
    Tags: ,   

    Django 2 Cheat Sheet

    Creating a new project
    django-admin startproject projectname

    Add an app to a project
    python manage.py startapp appname

    Starting the server
    python manage.py runserver

    Creating migrations
    python manage.py makemigrations

    Migrate the database
    python manage.py migrate

    Creating a Super User for the admin panel
    python manage.py createsuperuser

    Collecting static files into one folder
    python manage.py collectstatic

    
    	
     
  • Joker 8:48 PM on June 27, 2019 Permalink | Reply
    Tags: ,   

    Previous exercises, we created this function:

    >>> def string_length(mystring):
    ...    return len(mystring)
    

    Calling the function with a string as the value for the argument mystring will return the length of that string.

    If an integer is passed as an argument value:

    string_length(10)

    that would generate an error since the len() function doesn’t work for integers.

    We have to modify the function so that when an integer is passed as input, the function should output a message like “Sorry integers don’t have length.”

    So, How we do it?

    >>> def string_length(mystring):
    ...    if type(mystring) == int:
    ...        return "Sorry, integers don't have length"
    ...    else:
    ...        return len(mystring)
    ...
    >>> string_length(10)
    "Sorry integers don't have length."
    

    That’s it!

     
  • Joker 8:18 PM on June 27, 2019 Permalink | Reply
    Tags: ,   

    Create a function that takes any string as an argument and returns the length of that string.

    So, the code is:

    >>> def string_length(mystring):
    ...    return len(mystring)
    ...
    >>> print(string_length("Hello")) 
    5
    
     
  • Joker 7:41 PM on June 27, 2019 Permalink | Reply
    Tags: ,   

    Create a function that converts Celsius degrees to Fahrenheit. The formula to convert Celsius to Fahrenheit is F = C × 9/5 + 32.

    Here goes the code:

    >>> def cel_to_far(celsius):
    ...   fahrenheit = celsius *9/5+32
    ...   return fahrenheit
    ...
    >>> print(cel_to_far(10))
    50.0
    

    That’s it. here you go!

     
  • Joker 7:15 PM on June 27, 2019 Permalink | Reply
    Tags: ,   

    if you want to clear your python console, just type

    import os
    os.system('cls')
    

    and press enter. this is for windows user only.

     
  • 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}
    
     
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: