Python Classroom notes 31/Aug/2024

Functions contd

modules in python

  • module is a file in python
  • lets say we create a file called as utils.py then utils is the module name
  • python functions, classes and variables defined in the modules can be imported in other modules.
  • A python file can be executed directly python euler3.py then we will be executing the python code and other way is using import
  • In python whenever you see anything around double underscores it has special purpose these are considered as dunder methods or member
  • the case of special variable __name__.
    • This variable will have module name if imported
    • This variable will contain value __main__ if the user executed this python file
  • Refer Here for shebang based version of python

Generators in python

Exercise: Create two functions

  • function to return total amount after simple intrest
  • function to return compound interest
  • call these functions with different values
  • Refer Here for solutions

String methods

  • ASCII and Unicode
  • Text encoding:
    • We have text encoding UTF-8 and UTF-16
  • Refer Here for python strings
  • String interpolation: Refer Here
  • Keywords are words with special meanings in python so you cannot create any names with the keywords Refer Here
  • Refer Here for functions, text and keywords examples

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube