Question

   PYTHON --create a function that accepts a list of numbers and an int that returns...

  
PYTHON

--create a function that accepts a list of numbers and an int that returns index of 2nd occurrence of the int in list, otherwise returns None if # does not repeat more 2 or more times
EX: [10,24,3,45,10,49,4,5], 10) returns 4

--create a function that accepts a string that returns true if every letter of the alphabet can be found at least one time in the string, (has to be the lowercase alphabet), and false otherwise.
  

for BOTH you can ONLY use these functions --- append, len, str, float, range, strip, split, int


0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.

Source Code:

def firstRepeat(lst,num):
   count=0
   for i in range(0,len(lst)):
       if(lst[i]==num):
           count=count+1
       if(lst[i]==num and count==2):
          return i

print(firstRepeat([10,24,3,45,10,49,4,5],10))

main.py 1. def firstRepeat(lst, num): 2 count=0 3 for i in range(0, len(lst)): 4- if(lst[i]==num): 5 count=count+1 6 if(lst[i

2.

Source Code:

def isAll(string):
   isChar=False
   alpha=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
   for i in range(0,26):
       isChar=False
       for j in range(0,len(string)):
           if(alpha[i]==string[j]):
               isChar=True
       if(isChar==False):
           return False
   return True

print(isAll("abcdefghijklmnopqrstuvwxy")) # returns false because there is no 'z'
print(isAll("abcdefghijklmnopqrstuvwxyz")) # returns true

,x,y,z] main.py 1def isall(string): 2 isChar=False 3 alpha=[a,b,c,d, e 4 for i in range(0,26): 5 ischar=Fals

Add a comment
Know the answer?
Add Answer to:
   PYTHON --create a function that accepts a list of numbers and an int that returns...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PYTHON --create a program that accepts a list of words and returns the longest word inside...

    PYTHON --create a program that accepts a list of words and returns the longest word inside that list can only use --- append, len, str, float, range, strip, split, int --create a program that accepts a list of words and a specific length. function will returns a new list that contains the words found with the specific length, and return an empty list if none are found can only use --- append, len, str, float, range, strip, split, int

  • python program- ---create a function that returns the longest word inside a list of words ---create...

    python program- ---create a function that returns the longest word inside a list of words ---create a function with two parameters (phrase,wordList) that returns a count of how many words are spelled incorrectly that cannot be found in wordList (a list of words) for both you can only use these functions --- append, len, str, float, range, strip, split, int.

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

    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...

  • python function will Return True if string x contains 3 vowels in a row, in consecutive...

    python function will Return True if string x contains 3 vowels in a row, in consecutive locations, false otherwise. assuming that 'vowels' refer to the following lowercase lttrs: a,e,i,o,u programs fails partially, only allowed to use float, str, int, appen, split, strip, len, range def vowels_three(x): for i in range (o, len(x), 2): if x[i] not in ('a,e,i,o,u'): return False return True

  • Python code that: Accepts a list of integers and an integer, and returns the index of...

    Python code that: 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

  • Python code that Returns True if every letter of the (lowercase) alphabet can be found (at...

    Python code that Returns True if every letter of the (lowercase) alphabet can be found (at least once) in s, False otherwise

  • Using Python, if you could help me with the code # Create a modified version of...

    Using Python, if you could help me with the code # Create a modified version of the search linear function defined # above to return all # occurrences of the search word in the text # An occurrence is the index of a word in the text that matches your given # search string. # e.g. if "hatter" occurs at positions 0, 6, 12 then return [ 0, 6, 12] def search_linear_occurrences(xs, target): """ Find and return a list of...

  • In c++ code and test a function with prototype float except(int arg); that accepts an int...

    In c++ code and test a function with prototype float except(int arg); that accepts an int argument and returns the expression 1.0 / arg if arg != 0; otherwise, except() throws an exception of type string. A suitable message might be “Error – attempt to divide by zero”.

  • Using Python, if you could help me with the code # Create a modified version of the search linear function defined # above to return all # occurrences of the search word in the text # An occurrence is...

    Using Python, if you could help me with the code # Create a modified version of the search linear function defined # above to return all # occurrences of the search word in the text # An occurrence is the index of a word in the text that matches your given # search string. # e.g. if "hatter" occurs at positions 0, 6, 12 then return [ 0, 6, 12] def search_linear_occurrences(xs, target): """ Find and return a list of...

  • Python Create a function that checks user input in an attempt to create a password. The...

    Python Create a function that checks user input in an attempt to create a password. The valid_password function accepts a password as an argument and returns either true or false to indicate whether the password is valid. A valid password must be at least 7 characters in length, have at least one uppercase letter, one lowercase letter, and one digit. Respond with output to the user as to whether the password is valid or not, and allow the user to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT