1 answer

Def second_index(a_list, number): Accepts a list of integers and an integer, and returns the index of...

Question:

def second_index(a_list, number): Accepts a list of integers and an integer, and returns the index of the SECOND occurrence o

def second_index(a_list, number): Accepts a list of integers and an integer, and returns the index of the SECOND occurrence of the integer in the list. It returns None if the number does not occur two or more times in the list. Example 1: second_index ([2,34,3,45,34,45,3,3), 3) returns 6 Example 2: second_index( [2,34,3,45,34,45,3,3), 45) returns 5 Example 3: second_index ( [2,34,3,45,134,45,3,3), 134) returns None Example 4: second_index( [2,34,3,45, 134,45,3,3), 100) returns None return None def hasEveryLetter(s): #s is a string Returns True if every letter of the (lowercase) alphabet can be found (at least once) in s, False otherwise return None

Answers

Code with explanation:

def second_index(a_list,number):
#list of all occurance
lst=[i for i, n in enumerate(a_list) if n == number ]
if len(lst)>1:
return lst[1]
else:
return None
  
print(second_index([2,34,3,45,34,45,3,3],3))
print(second_index([2,34,3,45,34,45,3,3],45))
print(second_index([2,34,3,45,134,45,3,3],134))
print(second_index([2,34,3,45,134,45,3,3],100))

===============================================

screenshot of output with code:

In [10]: def second_index(a_list, number): #list of all occurance 1st=[i for i, n in enumerate(a_list) if n == number ] if le

===========================================================================

Code with explanation:

def hasEveryLetter(s):
for x in s:
#check if the letter is lower
if x.islower():
#count the number of occurance of each letter
#in given string
cnt=[i for i, n in enumerate(s) if n == x]
#if occurance is greater than 1
#return False
if(len(cnt)>1):
return False
return True

print(hasEveryLetter("Apple"))
print(hasEveryLetter("aPPle"))
print(hasEveryLetter("bankruptcy"))
print(hasEveryLetter("Demography"))

===========================================

screenshot of output with code:

In [20]: def hasEveryLetter(s): for x in s: #check if the letter is Lower if x.islower(): #count the number of occurance of e

In [21]: def hasEveryLetter(s): for x in s: #check if the letter is Lower if x.islower(): #count the number of occurance of e

.

Similar Solved Questions

1 answer
What is #"concentration"#? How does concentration change when volume changes?
What is #"concentration"#? How does concentration change when volume changes?...
1 answer
1. The reflector of a flashlight is in the shape of a parabloid of revolution. its diameter is 8 ...
1. The reflector of a flashlight is in the shape of a parabloid of revolution. its diameter is 8 inches and its depth is 4 inches. how far from the vertex should the light bulb be placed so that the rays will be reflectes parallel to the axis? place the light bulb ? inch(es) from the vertex 2.The C...
1 answer
To better understand the concept of static equilibrium a laboratory procedure asks the student to make...
To better understand the concept of static equilibrium a laboratory procedure asks the student to make a calculation before performing the experiment. The apparatus consists of a round level table in the center of which is a massless ring. There are three strings tied to different spots on the ring....
1 answer
Apple’s Tim Cook Leads Different
Your answers for each question should be between 400 to 500 words.1. What kind of stress related to Tim Cook who was replacing the renowned Steve Jobs?  Discuss possible stress he may have related to demand, opportunity and constraint, whichever applicable.       &...
1 answer
5. Beginning (1/1/2019) retained earnings (RE) is $100. Ending balances (12/31/2019) are: Additional Paid In Capital...
5. Beginning (1/1/2019) retained earnings (RE) is $100. Ending balances (12/31/2019) are: Additional Paid In Capital (APIC) 190; Cash 200; Notes Payable ((N/P) long-term) 50; Unearned Revenue 30; Net Income 150; Accounts Receivable (A/R) 100; Supplies (asset) 50; Dividends 50; Prepaid Insurance 50; ...
1 answer
In a market with a duopoly, if market demand is find the Cournot Reaction curves and...
In a market with a duopoly, if market demand is find the Cournot Reaction curves and the Cournot quantity solutions then deduce the price in the case where Marginal cost curves for either of the duopoly firms is and . Compare your results to the case where a Monopolist that has a replaces the du...
1 answer
Write a C program that has a local and a global variable. The program uses a...
Write a C program that has a local and a global variable. The program uses a fork to create a child process. The parent process modifies both variables to be 10 and 20 and prints out the values. Then the child process modifies both variables to be 100 and 200 and prints out the values? Explain the p...
1 answer
Lauren drinks a variety of soft drinks. Over the past month, she has had 18 diet...
Lauren drinks a variety of soft drinks. Over the past month, she has had 18 diet colas, 4 cans of lemonade, and 5 cans of root beer. a. Given this history, what is the probability that her next drink will be a diet cola? Lemonade? Root beer? b. What definition of probability should be used to answer...
1 answer
Question 26 An invoice . O is a demand for immediate payment O must be paid...
Question 26 An invoice . O is a demand for immediate payment O must be paid within 10 days from the date of the invoice O is the bill that the purchaser receives from the vendor O is the purchaser's request for payment from the seller Moving to another question will save this response....
1 answer
The following adjusted trial balance contains the accounts and bal fiscal year ances of Cruz Company...
The following adjusted trial balance contains the accounts and bal fiscal year ances of Cruz Company as of December 31, 2017, the end of its Account TitleDebit Credit No 101 Cash 126 Supplies 128 Prepaid insurance 167 Equipment 168 Accumulated depreciation-Equipment 381 T. Cruz, Capital 302 T. Cruz,...
1 answer
Course Home < HW #21 Fundamental Problem 6.8 1 of 7 Part A Determine the force...
Course Home < HW #21 Fundamental Problem 6.8 1 of 7 Part A Determine the force in members LK, KC, and CD of the Pratt truss. State if the members are in tension or compression. Take that P1 18 kN, P2 33 kN and Po = 44 KN .(Figure 1) Determine the force in the member KC, and state if the member is...
1 answer
Calculate the number of grams of AgCl formed when 0.200 L of 0.200 M AgNO3 reacts...
Calculate the number of grams of AgCl formed when 0.200 L of 0.200 M AgNO3 reacts with an excess of CaCl2. The equation is: 2 AgNO3(aq) + CaCl2(aq) -------> 2 AgCl(s) + Ca(NO3)2(aq)...
1 answer
Which of the following may be false? a. alpha + beta 1 b. power + beta 1 Power is defined as a. t...
Which of the following may be false? a. alpha + beta 1 b. power + beta 1 Power is defined as a. the probability of rejecting Ho if Ho is false b. the probability of accepting Hy if Hy is true c. the probability of rejecting Ho if Ho is false and the probability of accepting c. 1- power beta d. 1- be...
1 answer
What is the slope of the line perpendicular to #2x-5y=3#?
What is the slope of the line perpendicular to #2x-5y=3#?...
1 answer
2. Suppose the variables Y1 and Y2 have the following properties: 2. Suppose the variables Yi...
2. Suppose the variables Y1 and Y2 have the following properties: 2. Suppose the variables Yi and Y2 have the following properties: E(%) = 4, Var(%) = 19,E(%) = 6.5, Var(%) = 5.25,E(,%) = 30 Calculate the following; please show the underlying work: a) (3 pts) Cov(Y,Y2) b) (3 pts) Cov(4Y1,3Y2) c) (3...
1 answer
A neonate born at 32 weeks’ gestation (weight 2005 GMs) is admitted to the Neonatal Intensive...
A neonate born at 32 weeks’ gestation (weight 2005 GMs) is admitted to the Neonatal Intensive Care Unit (NICU) with a diagnosis of sepsis. The orders read: Aminophylline 5 mg/kg IV q 6 hrs Cefotaxime (Claforam) 50 mg/kg IV Q 12 hrs How many mg of aminophylline (available as 50 mg/10 ml), will...
1 answer
2019***** ppl keep answering with 2018 Exercise 12-19 (LO. 2) Compute the 2019 AMT exemption for...
2019***** ppl keep answering with 2018 Exercise 12-19 (LO. 2) Compute the 2019 AMT exemption for the following taxpayers. If an amount is zero, enter "O". Click here to access the exemption table. a. Bristol, who is single, reports AMTI of $650,000. Her AMT exemption is s x . b. Marley and N...
1 answer
Ricky's Piano Rebuilding Company has been operating for one year (2016). At the start of 2017,...
Ricky's Piano Rebuilding Company has been operating for one year (2016). At the start of 2017, its income statement accounts had zero balances and its balance sheet account balances were as follows: Cash Accounts Receivable Supplies Equipment Land Building $ 7,800 Accounts Payable 30,400 Deferre...