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
poizon [28]
3 years ago
5

one_diff(a?): Description: Determine if there is exactly one character different between exactly two strings. Parameters: Determ

ine these from the description, and the provided examples. Return value: True If there is exactly one character different, False otherwise Example: one_diff("banana", "apple") → False one_diff("need", "reed") → True one_diff("goof", "good") → True one_diff("food", "feed") → False

Computers and Technology
1 answer:
Vladimir79 [104]3 years ago
3 0

Answer:

See explaination

Explanation:

def one_diff(s1,s2):#mthod return true if s1 and s2 has one difference

l1=list(s1)#store characters to list

l2=list(s2)

c=0

if len(l1)!=len(l2):

return False

for i in l1:

if i in l2:#for each character if it is in l1 and l2 continue

continue

else:

c+=1

if c==1:

return True#ret True if cis 1 else False

return False

def exchange(s,*k):#method that exchanges characters

l=list(k)

if len(l)!=0:#check validity of arguments

for i in l:

if i<0 and i+(2*i)>len(s):

res=s

elif i>len(s):

res=s

return res

if len(l)==0:#if no indexes are given

c1=s[0]

c2=s[-1]

res=c2

res=res+s[1:]

res=res[0]+res[1:].replace(c2,c1)

return (res)

elif len(l)==1:#if one index is given

c1=s[l[0]]

c2=s[-1]

res=''

for i in s:

if i==c1 or i==c2:

if i==c2:

res+=c1

else:

res+=c2

else:

res+=i

return (res)

else:#if two indexes are given

c1=s[l[0]]

c2=s[l[1]]

res=''

for i in s:

if i==c1 or i==c2:

if i==c2:

res+=c1

else:

res+=c2

else:

res+=i

return (res)

def is_chain(*k):#method that checks words for one difference

l=list(k)

if len(l)==0:

return False

if len(l)==1:

return True

if len(l)>1:

for i in range(len(l)-1):#for two words in l

if one_diff(l[i],l[i+1]):#call one_diff method

continue

else:

return False

return True

def scramble(s):#method that exchanges characters

i=0

while i<len(s)-1:

s=exchange(s,i,i+1)

i+=2

print(s)

please check out the screenshots in attachment.

You might be interested in
Smileys Pizzeria has a special on cheese pizza this month. 6- inch personal pizzas are $5, 10-inch small pizzas are $8, 14-inch
ValentinkaMS [17]

Answer:

THE PROGRAM IS ANEW ONE IT IS CALLED SMILEYS CHOOSER

Explanation:

4 0
3 years ago
How can you ensure that the website you are using is secured?
poizon [28]
By having the lock by the website address
3 0
3 years ago
Cell B10 contains a date, such as 9/1/2014. Which formula determines how many days have passed between that date and the current
Jet001 [13]
<span>If using excel, you can use this formula: DATEDIF(start_date, end_date, unit) For instance, DATEDIF(9/1/2014, today, "d") or DATEDIF(B10, today, "d")</span>
3 0
3 years ago
Read 2 more answers
There is one clear definition of IT. True False
Elenna [48]

Answer:

That is False. it has more definitions not only one.

8 0
3 years ago
Which of these functions may be used with positional arguments? Select four options.
jeyben [28]

Answer:

AVERAGE

COUNT

SUM

MAX

Explanation:

The functions that may be used with positional arguments include:

AVERAGE

COUNT

SUM

MAX

The basic functions formulae include SUM, AVERAGE, COUNT, MAX and MIN.

SUM: This is the sum total of all the numbers in the rows.

COUNT: This is the used to count the range of cells that contains numbers.

AVERAGE: This is the average of all the numbers in the rows.

MIN: This is the lowest number in the rows.

MAX: This will return the highest number that is found in the set of values.

It should be noted that the COUNTIF is not used with positional arguments.

8 0
3 years ago
Other questions:
  • The ____ is designed to placeshift multimedia content; that is, to allow individuals to view their multimedia content at a more
    7·1 answer
  • What types of data are commonly entered into a cell ?
    7·2 answers
  • How do all apple phones work?
    7·1 answer
  • Which is the correct formula to add the values in cells A1 and B1? A. SUM(A1+B1) B. =SUM(A1+B1) C. =SUMA1+B1 D. A1+B1
    9·2 answers
  • Which language is the most popular language for writing apple os x?
    9·1 answer
  • How do you feel about your self as a responsive citizen?​
    7·1 answer
  • A network administrator determines who may access network resources by assigning users
    10·1 answer
  • Match each statement from the passage with the message it represents.
    10·1 answer
  • Words that are restricted for use in object names because they belong to the SQL programming language are called _______________
    13·1 answer
  • Need help with these plss correct answers
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!