Python Classroom notes 27/Apr/2025

Functions contd

Exercise:

  • Write a function to find the sum of numbers in number plate for numerology
9999 => 9 + 9 + 9 + 9 => 36 => 3 + 6 => 9
8273 => 8 + 2 + 7 + 3 => 20 => 2 + 0 => 2
  • solution
def sum_digits(number):
    sum = 0
    while number > 0:
        digit = number % 10 
        sum = sum + digit
        number = number // 10
        if number == 0 and sum > 9:
            number = sum
            sum = 0
    return sum

Modules and packages

  • Refer Here for the package
  • Refer Here for the sample package and using the package in the module main.py

Finding methods for a type

  • List methods
  • Tuple methods
  • set methods
  • str methods

Problem

  • Take a string as an input and return bool if the string is numeric
def is_numeric(value):
    return value.isnumeric()

  • Type Hinting in Python
  • expert usage of python functions
  • object oriented programming
  • str methods
  • list methods

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
Plugin for Social Media by Acurax Wordpress Design Studio

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