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
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