Question

plz run this python code & display the results Write a python funciton alphabetic(val) that takes...

plz run this python code & display the results

Write a python funciton alphabetic(val) that takes a string as input and returns True if the words in the sentence appear in alphabetic
order, and False otherwise. Note repeated words are allowed.

>>> alphabetic("the sun is bright")
False

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


ANSWER:-

CODE:-

def alphabetic(val):
    # split the string by space, then it returns a list of words
    words = [word.lower() for word in val.split(" ")]
    for i in range(0,len(words)-1):
        if words[i] > words[i+1]:
            return False
    return True

NOTE:- If you have any doubts, please comment below.Please give positive rating.THUMBS UP.THANK YOU!!!

OUTPUT:-

Add a comment
Know the answer?
Add Answer to:
plz run this python code & display the results Write a python funciton alphabetic(val) that takes...
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
  • Write a python code that takes in an number 0-9 and prints out the word of...

    Write a python code that takes in an number 0-9 and prints out the word of the number. For example 1 would print out one. Below is the skeleton of the code that needs to be filled in. def num2string(num): """ Takes as input a number, num, and returns the corresponding name as a string. Examples: num2string(0) returns "zero", num2string(1)returns "one" Assumes that input is an integer ranging from 0 to 9 """ numString = "" ################################### ### FILL IN...

  • """ Add_to_front(self, val) and add_to_back(self, val) functions can be used which are already done in python...

    """ Add_to_front(self, val) and add_to_back(self, val) functions can be used which are already done in python class. Name of list is LList class node(object): def __init__(self, data, next=None): self.data = data self.next = next # Note: use the attributes directly; no setters or getters! class LList(object): def __init__(self): self._size = 0 self._head = None self._tail = None """ def set_data_at_index(self, idx, val): """ The value stored at index idx changes to val return True if the index was valid otherwise...

  • Please write a code in Java where it says your // your code here to run...

    Please write a code in Java where it says your // your code here to run the code smoothly. Import statements are not allowed. _ A Java method is a collection of statements that are grouped together to perform an operation. Some languages also call this operation a Function. When you call the System.out.println() method, for example, the system actually executes several statements in order to display a message on the console. Please write the code according to functions assigned...

  • Please write a code in Java where it says your // your code here to run...

    Please write a code in Java where it says your // your code here to run the code smoothly. Import statements are not allowed for this assignment, so don't use them. _ A Java method is a collection of statements that are grouped together to perform an operation. Some languages also call this operation a Function. When you call the System.out.println() method, for example, the system actually executes several statements in order to display a message on the console. Please...

  • this us python plz follow the instructions while u solving I need the code and sane...

    this us python plz follow the instructions while u solving I need the code and sane output QUESTION 1 Write a program that performs the following: 1) request a sentence (at least two words with no punctuation marks) input by the user 2) display the first word 3) display the last letter of the first word 4) display the last word 5) display the first letter of the last word input text can be any content just make sure to...

  • Python 3: Write a LinkedList method named contains, that takes a value as a parameter and...

    Python 3: Write a LinkedList method named contains, that takes a value as a parameter and returns True if that value is in the linked list, but returns False otherwise. class Node: """ Represents a node in a linked list """ def __init__(self, data): self.data = data self.next = None class LinkedList: """ A linked list implementation of the List ADT """ def __init__(self): self.head = None def add(self, val): """ Adds a node containing val to the linked list...

  • Write a Python function called more() that takes three string inputs and outputs a string Formally,...

    Write a Python function called more() that takes three string inputs and outputs a string Formally, the function signature and output are given by rucharist, char: str words str) > str Use the same names for the input arguments as shown above Note that charl and char2 will always be a string of length 1 (ie, it is a single character. The function checks which of charl or char2 appears more often in the word string and returns that character...

  • Can I see that source code in python Write the following value-returning function: encoded - Takes...

    Can I see that source code in python Write the following value-returning function: encoded - Takes a string as parameter and returns the string with each vowel substituted by its corresponding number as follows: a -1 e-2 0-4 。u_5 The function MUST USE string slicing Write a main program that will take an input string (text) from command line and it will display the input text encoded. You will call the encoded function to get the text encoded.

  • USING JAVA Consider the following methods: StringBuilder has a method append(). If we run: StringBuilder s...

    USING JAVA Consider the following methods: StringBuilder has a method append(). If we run: StringBuilder s = new StringBuilder(); s.append("abc"); The text in the StringBuilder is now "abc" Character has static methods toUpperCase() and to LowerCase(), which convert characters to upper or lower case. If we run Character x = Character.toUpperCase('c');, x is 'C'. Character also has a static isAlphabetic() method, which returns true if a character is an alphabetic character, otherwise returns false. You will also need String's charAt()...

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

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