Question

CODIO python problem Write a function isRed() that accepts a string parameter and looks for the...

CODIO python problem

Write a function isRed() that accepts a string parameter and looks for the presence of the word ‘red’ in the string. If it is found, return boolean True otherwise False. Finally output the result of calling the function with the value in text.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
# Write a function isRed() that accepts a string parameter
def isRed(s):
    # and looks for the presence of the word 'red' in the string.
    if 'red' in s:
        # If it is found, return boolean True
        return True
    # otherwise False.
    else:
        return False


# Finally output the result of calling the function with the value in text.
text = 'Hello red is in it'  # you might want to use text string already provided to you here...
print(isRed(text))

Add a comment
Know the answer?
Add Answer to:
CODIO python problem Write a function isRed() that accepts a string parameter and looks for the...
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 3.6 (Short and Simple Codes Please) Write a recursive function, reverse, that accepts a parameter...

    PYTHON 3.6 (Short and Simple Codes Please) Write a recursive function, reverse, that accepts a parameter containing a string value and returns the original string in reverse. For example, calling reverse('goodbye') would return 'eybdoog'. Reversing a string involves: No action if the string is empty or only has 1 character Concatenating the last character with the result of reversing the string consisting of the second through next-to-last character, followed by the first character

  • python Problem 3 (Palindrome) Write a function called ispalindrome(string) that takes a string (with spaces) as...

    python Problem 3 (Palindrome) Write a function called ispalindrome(string) that takes a string (with spaces) as argument and returns True if that string (ignoring spaces) is a palindrome. A palindrome is a word or phrase that spells the same thing forwards as backwards (ignoring spaces). Your program should use a recursive process to determine the result, by comparing the first and last letters of the string, and if necessary, calling ispalindrome() on the rest of the string. Sample run: print(ispalindrome('never...

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. Write a function...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. Write a function named capital_letter that accepts a string as an argument and checks if each word in the string begins with a capital letter. If so, the function will return true, otherwise, return false. Please see the outcome below: Outcome number 1: Enter a string: Python Is Really Fun! True Sample run number 2: Enter a string: i Love Python False Note: Try to keep this...

  • 1. Write a function called ordinal_sum that accepts a string argument and returns the sum of...

    1. Write a function called ordinal_sum that accepts a string argument and returns the sum of the ordinal values of each character in the string. The ordinal value of a character is its numeric Unicode code point in decimal. 2. Write code that creates a Python set containing each unique character in a string named my_string. For example, if the string is 'hello', the set would be {'h', 'e', 'l', 'o'} (in any order). Assign the set to a variable...

  • Write a function is_mirror(s) that takes as input a string s and returns True if s...

    Write a function is_mirror(s) that takes as input a string s and returns True if s is a mirrored string (i.e., a string that could have been produced by your mirror function) and False otherwise. Examples: >>> is_mirror('baconnocab') result: True >>> is_mirror('baconnoca') result: False Warning Your function should return a boolean value – either True or False, without any quotes around them. If you see quotes around the result when you make the calls above from the console, you must...

  • 1.1. Write a function named "areFirstTwoTheSame AsLast TwoChars" that accepts a string. It returns true if...

    1.1. Write a function named "areFirstTwoTheSame AsLast TwoChars" that accepts a string. It returns true if the first two characters and the last two characters of the string are the same. It returns false otherwise. In addition, if the string is empty or has only one character, it also returns false. For example, these are the strings with their expected return values false falsc "AB" true "ABA" false "ABAB" trus "ABBA" false "ABCABC false "ABCCAB" true 1.2 Write a function...

  • Write a function named "find_key" that takes a key-value store as a parameter with strings as...

    Write a function named "find_key" that takes a key-value store as a parameter with strings as keys and integers as values. The function returns a boolean representing true if the string "focus" is in the input as a key, false otherwise(javascript)

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

  • Write a python function called gen_pattern that accepts a string as an argument. Your function should...

    Write a python function called gen_pattern that accepts a string as an argument. Your function should generate a string pattern based on argument provided: If the string provided is a number and that number is even generate a pattern of hash signs. ex. gen_pattern(‘4’): #### If the string provided is odd, generate pattern of stars. Ex: gen_pattern(3): *** If string is not a number just output “ Not a number”

  • 1. Write a Python function that accepts a string and calculate the number of upper case...

    1. Write a Python function that accepts a string and calculate the number of upper case letters and lower case letters. Sample String : 'The quick Brow Fox' Expected Output : No. of Upper case characters : 3 No. of Lower case Characters : 12

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
ADVERTISEMENT