1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Bezzdna [24]
2 years ago
9

Write a Python program string_functions.py that defines several functions. Each function re-implements Python's built-in string

methods
Computers and Technology
1 answer:
Svetach [21]2 years ago
3 0

Answer:

def length( mystring):

   count = 0

   for i in mystring:

       count += 1

   return count

def reversed( mystring):

   strlist = []

   for i in range(length(mystring)):

       strlist.append(mystring[(length(mystring) - 1) - i])

       txt = "".join(strlist)

   return txt

string = 'Yolanda'

print(reversed(string))

Explanation:

The python module defines two functions 'reversed' and 'length'. The length function counts the number of characters in a string variable while the reversed function reverses the string variable value.

You might be interested in
The Yuba College Library would like a program to calculate patron fines for overdue books. Fines are determined as follows: Pape
mestny [16]

Answer:

Explanation:

The following Python code creates all of the necessary functions in order to request and validate all of the inputs from the user. Once everything is entered and validated it calculates the total fee and outputs it to the user. Also calls the entire class at the end using a test variable...

class Customer:

   library_card = 0

   patrons_name = ""

   patrons_address = ""

   type_of_book = ""

   book_title = ""

   days_overdue = 0

   fee = 0.0

   book_list = ['paperback regular', 'paperback best seller', 'magazine', 'hardcover']

   def __init__(self):

       self.library_card = self.get_library_card()

       self.patrons_address = input("Patron's Address: ")

       self.book_title = input("Book Title: ")

       self.type_of_book = self.get_type_of_book()

       self.days_overdue = float(self.get_days_overdue())

       self.calculate_total()

       print("Your total Fee is: " + str(self.fee))

   def get_library_card(self):

       library_card = int(input("Enter 4-digit library card number: "))

       if (type(library_card) == type(0)) and (len(str(library_card)) == 4):

           return library_card

       else:

           print("Invalid Card number:")

           self.get_library_card()

   def get_type_of_book(self):

       type_of_book = input("Type of Book 1-4: ")

       if (int(type_of_book) > 0) and (int(type_of_book) <= 4):

           return int(type_of_book)

       else:

           print("Invalid Type")

           self.get_type_of_book()

   def get_days_overdue(self):

       days_overdue = input("Number of Days Overdue: ")

       if int(days_overdue) >= 0:

           return days_overdue

       else:

           print("Invalid number of days")

           self.get_days_overdue()

   def calculate_total(self):

       if self.type_of_book == 1:

           self.fee = 0.20 * self.days_overdue

           if self.fee > 8:

               self.fee = 8

       elif self.type_of_book == 2:

           self.fee = 0.50 * self.days_overdue

           if self.fee > 15:

               self.fee = 15

       elif self.type_of_book == 3:

           self.fee = 0.25 * self.days_overdue

           if self.fee > 5:

               self.fee = 5

       else:

           self.fee = 0.30 * self.days_overdue

           if self.fee > 23:

               self.fee = 23

test = Customer()

5 0
2 years ago
Disrupting a business's ability to conduct electronic commerce is cönsidered an act of
aalyn [17]

Answer:

Digital Restrictions

Explanation:

This is the process that arises as a result of not meeting specific ethical standards and procedures for operating an online business on the form of electronic commerce. Such situation could be as a result of important factors like:

1. Unduly registered or incorporated businesses

2. Lack of patent or trademark to shown authenticity of product or services

3. Inability to provide certified prove of ownership to avoid fraudulent acts and others.

7 0
3 years ago
Where do players resurrect if they have been destroyed in a game?
CaHeK987 [17]

Usually back to their start point. Or a random place on the map.

3 0
3 years ago
Explain the Decision making statement​
Blizzard [7]

Answer:

Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.

4 0
2 years ago
Which website can help you find antivirus software ?
sergey [27]

If you have windows you have Windows Defender Installed already!!

5 0
3 years ago
Other questions:
  • You have been contracted by a local school to evaluate their computer labs for security threats. They are most worried about the
    6·1 answer
  • 4. The same data source can be used multiple times in creating mail-merge documents.
    7·1 answer
  • The region which satisfies all of the constraints in graphical linear programming is called the:
    8·1 answer
  • What is the shortest, abbreviated version of the copy running-config startup-config command?
    6·1 answer
  • Tell me at list 5 farm animals dieases​
    10·2 answers
  • Define Indentation
    8·1 answer
  • The 'WIMP' environment is much more user friendly,why?​
    11·2 answers
  • A social cause is: O A. when one person protests without the support of others. B. something that not many citizens think or car
    8·1 answer
  • A monopoly is a market that has few competing businesses. many sellers of the same item. many sellers of a variety of products.
    8·2 answers
  • Mention the usage of crop concept in ms-word​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!