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
goldfiish [28.3K]
3 years ago
11

This assignment is based on Exercise 8.4 from your textbook. Each of the following Python functions is supposed to check whether

its argument has any lowercase letters.
For each function, describe what it actually does when called with a string argument. If it does not correctly check for lowercase letters, give an example argument that produces incorrect results, and describe why the result is incorrect.

# 1

def any_lowercase1(s):
for c in s:
if c.islower():
return True
else:
return False


# 2

def any_lowercase2(s):
for c in s:
if 'c'.islower():
return 'True'
else:
return 'False'


# 3

def any_lowercase3(s):
for c in s:
flag = c.islower()
return flag


# 4

def any_lowercase4(s):
flag = False
for c in s:
flag = flag or c.islower()
return flag


# 5

def any_lowercase5(s):
for c in s:
if not c.islower():
return False
return True
Computers and Technology
1 answer:
Svetradugi [14.3K]3 years ago
4 0

Explanation:

#1 is wrong because if the first character is not lowercase, it stops and returns false, ignoring all the other characters. It can be fixed by removing the else: statement and moving the return False statement outside of the loop.

This is efficient; if one lowercase character is encountered, the function 'knows enough' and can return true. Only if no lowercase is encountered it has to loop all the way to the end.

You can try this out on repl.it.

Many of the others functions have problems in them. #4 looks OK.

You might be interested in
Tom teaches in a high school. He wishes to sort a spreadsheet containing students' marks in various subjects by descending order
cricket20 [7]

Answer:

Select the data to sort

Explanation:

4 0
3 years ago
What is the most common form of renewable energy used to generate electricity
sertanlavr [38]

i think that it’s either sunlight or solar energy

6 0
3 years ago
Can someone see what this says? ​
Rzqust [24]

Not really. xD

I only see "Not A.." and It's backwards too soooo..

3 0
3 years ago
In what section of the MSDS would you find information that may help if you use this substance in a lab with a Bunsen burner?
dybincka [34]

Answer:

The answer is "Fire-fighting measures".

Explanation:

This section is used to includes instructions to combat a chemicals flame. It is also known as the identify sources, which include the instructions for effective detonating devices and details for removing devices only appropriate for just a specific situation. It is the initiatives list, that is necessary destruction technology, materials; flaming inferno dangers.

8 0
3 years ago
Abby wants to simply share a snapshot of her calendar with another user. Which option should she choose to achieve this
Papessa [141]

Answer:

Screenshot

Explanation:

Just a guess

8 0
3 years ago
Read 2 more answers
Other questions:
  • Write a calculator program using a switch statement that: a) Prompts the user to enter two numbers b) Prompts the user to select
    13·1 answer
  • Today encoding scheme has taken over ascII by what
    5·1 answer
  • Stress results from _______. A. Outside stimulus b. Internal stimulus c. Outside calm d. Internal calm
    12·2 answers
  • What is the full form of bcc please tell​
    15·2 answers
  • A(n) _____ measures the ability to juggle a variety of demands, as in a manager's job where the candidate is presented with simu
    8·1 answer
  • What should be done with statements or sections which are unclear?
    12·2 answers
  • An accompanying ____ gives audience members reference notes and review material for your presentation.
    6·1 answer
  • Video is a medium that's looks real anyways, but is real________________.
    10·1 answer
  • Communication media that use an antenna for transmitting data through air or water are called _____.
    14·1 answer
  • A source mainly provides <br> from a text or piece of media.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!