Here you will find a number of tasks as an exercise to the next practical work.
Where are minimal function bodies with the task as docstring.
The functions must be implemented without standard methods or functions (except for Len function
() ). Should there be a standard function for solving the problem, use it to check the result. Areas ( [from: to] ) may be used provided they are needed. def isint (string)
"" "checks if the string is a whole number (optional sign,
digits only)" ""
pass
def isintb (string, base)
"" "checks whether the string to an integer base base (sign
optional, only numbers)" "" pass
def ISNUM (string)
"" "checks if the string is a number (optional sign, digits, and
comma)" "" pass
def horner (number, base):
"" "calculated from decimal number (string) to the base base .
returns number "" "pass
def sumdigits (number):
" "" Calculates the sum of digits of the given number (int) "" "pass
def sumdigits_s (string):
"" ". Calculates the sum of digits of the given number (str) if
it at all is a number Returns -1 if no valid number" ""
pass
def isipv4 (string ):
"" "Checks if the given string contains an IPv4 address
IPv4 addresses are 4 numbers between 0 and 255, separated by a point
are examples.. 127.0.0.1, 193 170 149 129, 81 200 .64.185
Invalid: 81.2010.64.185, 123.23.12, 127,0,0,1, "" "pass
def anz_vokale (string):
" "" Count the vowels in the string and deliver Number return "" "pass
def anz_zahlen (string):
" "" determines the number of integers in the string. A number
is an unbroken sequence of digits.
example anz_zahlen ("x 34 3 12k33 44 hello 23") returns 6 "" "pass
def sum_zahlen (string):
" "" determines the sum of the integers in the string. A number
is an unbroken sequence of digits.
example anz_zahlen ("x 34 3 12k33 44 hello 23") returns 149 "" "pass
def iskonto (string):
" "" Checks whether the string contains a valid account number. This
The following rules apply: first
exactly 9 digits (there may be spaces in between
second is the last digit is a digit and it is
The account number is exactly 9 digits long and are at the correct end time when the follow
formed sum to zero:
numbers with odd index added (= Teilsumme1);
numbers with even index are doubled and added each
product if it is single digits, otherwise the
added sum of the product (= Teilsumme2);
sum = teilsumme1 + Teilsumme2
example
123 456 782 1 + 3 + 5 + 7 + 2 = 18 Teilsumme1
2 * 2 + 4 * 2 + (1 +2) + (1 +6) = 22 Teilsumme2
6 * 2 = 12 8 * 2 = 16 40 Total
------
mod 10 = zero
examples Account numbers:
697199107 correct account number
723016699 incorrect account number
"" "
pass
def reverse_s (string):
" "" returns string in reverse order "" "
pass
def toupper (string):
"" "returns in this String to upper case" "" pass
def tolower (string):
"" "returns string in lowercase" ""
pass
def isupper (string):
"" "check if string contains only letters" ""
pass
def islower (string):
"" "check if string contains only lowercase" ""
pass
def ispalindrom (string):
"" "Checks if the string is a palindrome (from the front and rear
same reads) "."
pass
def ispalindrom_l (list):
"" "Checks if the list is read from the front and rear the same" ""
. pass
def reverse_l (list):
"" "returns the list in reverse order" ""
pass
sum (list) def:
"" "returns the sum of all numbers in the list" ""
pass
def mean (list):
"" "returns the mean (average) of all numbers in the list" "" pass
def rmdups (list):
"" "(Remove Duplicates) returns list from which all multiples removed
(row)
examples. [1, 2, 2, 2, 5, 2, 3, 2, 2, 23] -> [1, 2, 5, 2, 3, 2 , 23]
[99, 99, 23, 99, 99, 12, 2] -> [99, 23, 99, 12, 2]
[] -> []
[1, 2, 4, 10] -> [1, 2, 4, 10] "" "pass
def rmalldups (list):
" "" (Remove ALL fixed) list of all supplies from multiple
away (do not have to stand behind one another).
examples: [1, 2, 2, 2, 5, 2, 3, 2, 2, 23] -> [1, 2, 5, 3, 23]
[99, 99, 23, 99, 99, 12, 2] -> [99, 23, 12, 2]
[] -> []
[1, 2, 4, 10] -> [1, 2, 4, 10] "" "pass
def binsearch (List, Search):
" "" returns the index of search in the sorted list or list - 1, when examined in
list does not occur. It is the binary search to use!
"" "
pass
def sumdigits (number):
" "" Calculates the sum of digits of the given number (int) "" "
pass
def sumteilbar (List, Part):
" "" Computes the sum of all "pass def
IsSorted (list):
" divisible by prime numbers of the list "" "" Checks whether the list filter, ie, whether e1 \u0026lt;= e2 \u0026lt;= e3 \u0026lt;= ... \u0026lt;= En
e1, e2, ... s are the n elements of the list with length n "" "pass
def printlxl (List1, List2):
" "" prints a multiplication table of the two lists.
For example:
a = [1, 2, 4, 5] are
b = [3, 2, 2]
printlxl (a, b) then running this:
3 2 2 6 4 4 12 8 8
15 10 10
The first list determines the number of rows, the second the number of columns
. There is always an element of the first list with one of the
second list multiplied.
"" "pass
def lxl (List1, List2):
" "" provides a multiplication table of the two lists (list of
lists).
For example:
a = [1, 2, 4, 5]
b = [3, 2, 2]
lxl (a, b) returns the following list:
[[3, 2, 2], [6 , 4, 4], [12, 8, 8], [15, 10, 10]]
formatted clear:
[[3, 2, 2],
[6, 4, 4]
[12, 8 , 8],
[15, 10, 10]]
The first list determines the number of "lines", the second is the number
the "column". There is always an element of the first list multiplied with one of the
second list.
"" ".
pass
Write to the functions of each appropriate test programs