Question

Please use python to explain. Assume that the variables x and y refer to strings. Write...

Please use python to explain.

Assume that the variables x and y refer to strings. Write a code segment that prints these strings in alphabetical order. You should assume that they are not equal.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Assume that the variables x and y refer to strings.

code segment that prints these strings in alphabetical order. You should assume that they are not equal.

if(x < y):
    print(x,y)
else:
    print(y,x)

Add a comment
Know the answer?
Add Answer to:
Please use python to explain. Assume that the variables x and y refer to strings. Write...
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
  • Using Python The variables x and y refer to numbers. Write a code segment that prompts...

    Using Python The variables x and y refer to numbers. Write a code segment that prompts the user for an arithmetic operator and prints the value obtained by applying that operator to x and y. Using the following information run an example in Python Idle op = input("Enter an arithmetic operator: ") if op == "+":     print(x + y) elif op == "-":     print(x – y) elif op == "*":     print(x * y) elif op == "/":...

  • Python: We defined two variables, x = 'Python' and y = '3.0'. Write code to concatenate...

    Python: We defined two variables, x = 'Python' and y = '3.0'. Write code to concatenate the two numbers (the result should be 'Python3.0').

  • Lab2: Processing Strings Part#1 – Counting Vows Assume s is a string of lower case characters....

    Lab2: Processing Strings Part#1 – Counting Vows Assume s is a string of lower case characters. Write a program that counts up the number of vowels contained in the string s. Valid vowels are: 'a', 'e', 'i', 'o', and 'u'. For example, if s = 'azcbobobegghakl', your program should print: Number of vowels: 5 Part#2 – Counting Bobs Assume s is a string of lower case characters. Write a program that prints the number of times the string 'bob' occurs...

  • Do in Python Problem 2 Assume s is a string of lower case characters. Write a...

    Do in Python Problem 2 Assume s is a string of lower case characters. Write a program that prints the number of times the string ' lol' occurs in s For example, if s= 'azclololegghakl', then your program should print S Number of times lol occu rs is: 2 Problem 3 Assume s is a string of lower case characters Write a program that prints the longest substring of s in which the letters occur in alphabetical order. For example,...

  • Write a Python Program What should the values of X and Y be, so that the...

    Write a Python Program What should the values of X and Y be, so that the following code prints the 'd' found inside one of the elements of alist? alist = [['47a','47b'],'47c','47d',[['47e','47f'],'47g']] print(alist[X][Y]) Then write another print(...) statement that prints the the 'b' inside of alist, by indexing again into to its specific location within alist.

  • In python please. Write a program that reads whitespace delimited strings (words) and an integer (freq)....

    In python please. Write a program that reads whitespace delimited strings (words) and an integer (freq). Then, the program outputs the strings from words that have a frequency equal to freq in a case insensitive manner. Your specific task is to write a function wordsOfFreqency(words, freq), which will return a list of strings (in the order in which they appear in the original list) that have a frequency same as the function parameter freq. The parameter words to the function...

  • USE Python 1. Assign value 555 to the variable x, write code to square the variable...

    USE Python 1. Assign value 555 to the variable x, write code to square the variable x and print out the result. 2. Given a string x, write a program to check if its first character is the same as its last character. If yes, the code should output "True" . 3. We defined two variables, x = 'Python' and y = '3.0'. Write code to concatenate the two numbers (the result should be 'Python3.0').

  • Python code Write a program that will ask the user to input two strings, assign the...

    Python code Write a program that will ask the user to input two strings, assign the strings to variables m and n If the first or second string is less than 10 characters, the program must output a warning message that the string is too short The program must join the strings m and n with the join function The output must be displayed. Please name the program and provide at least one code comment (10)

  • Please use MatLab and comment code. Problem 2 Write a MATI AB user-defined function y-M?SotxType): x...

    Please use MatLab and comment code. Problem 2 Write a MATI AB user-defined function y-M?SotxType): x is a vector containing numbers. and Type can be 'Ascending' or Descending'. This function should sort the given vector x in the ascending or descending order based on the user's request and return the desired vector as the output. Do not use MATLAB built-in function sort. Hint: When you call this function you need to use for Ascending or Descending since they are strings.

  • Write a MIPS program with two variables in the .data segment - x and y. The...

    Write a MIPS program with two variables in the .data segment - x and y. The program should load x into a register. It should then isolate the last twelve bits of x (the twelve bits furthest to the right). It should finally store the resulting value in the variable y. So, for example, if x contains 1111 0000 1111 0000 1111 0011 1100 1010, your program should store the value 0000 0000 0000 0000 0000 0011 1100 1010 in...

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