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
Add the following binary numbers. 101110010 and 111001101
bonufazy [111]

Answer:

101110010 is 370 in decimal (base 10, what we usually do math in) and 111001101 is 461 in decimal. The sum of 370 and 461 is 831, and 831 is binary is 1100111111. So, if you want the answer in decimal it is \boxed{831_{10}} and if you want the answer in binary, it is \boxed{1100111111_2}.

4 0
3 years ago
Which of the following translates packets so that the node can understand them once they enter through a port?
FinnZ [79.3K]
A cluster compute server includes nodes coupled in a network ... Each VNIC typically is assigned its own MAC address by the VMM or VM, ... translation or mapping storage at the NIC of each node in the cluster ...... a wired or wireless network (e.g., network accessible storage (NAS)). .... Google Translate ...
5 0
4 years ago
Read 2 more answers
Harvey is creating a presentation for his school project. He wants to have the same look on all the slides of his presentation.
Misha Larkins [42]
He should use PowerPoint and the design should be feathered
8 0
4 years ago
What materials could I use to make diy headphones and game controller (doesn't have to work) it needs to be handmade so no store
Veseljchak [2.6K]
The materials you could use to make DIY headphones are the following:
Headband - A headphone has a headband used to put over your head. You can use a normal headband for this.
Small Tin Cans - This can be used for the housing of the speaker.
Foam - The speaker has earpads. You can use foam for this.
Wire with jack - You can use a wire with a jack from an old broken earphone or headphone.
Speakers - This one is hardest and the most important part of the headphone. You can look up how to make one using magnets and copper wire or you can just recycle an old pair of working speakers that fit in tin can housing.
4 0
3 years ago
If a citation has a volume, title, and page numbers, it is a:
Sergeu [11.5K]

Answer:

It has to be Journal Article Citation

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • What does a file extension tell you?
    14·1 answer
  • A ____ is any manipulation of data, usually with the goal of producing information.
    9·1 answer
  • Which of the following is a malicious program that can replicate and spread from computer to computer?
    8·2 answers
  • Once i have internet connection do i need anything else to surf the web
    6·1 answer
  • A poem for coduction
    15·2 answers
  • Develop a Python module that will prompt the user for a target sum that is greater than 0 and less than 1 for the following Geom
    13·1 answer
  • Network Industries, Inc., wants to monitor its employees’ electronic com-munications. To avoid liability under laws related to e
    12·1 answer
  • Within a single program, __________________ allows multiple parts, or threads, to run simultaneously.
    15·1 answer
  • In a company you are in charge of system maintainance. Justify with 5 reasons why your role is key
    6·1 answer
  • Can you plz type down a word.
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!