Question

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.

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

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

1)

To print d, X=2 and Y=2

2)

To print b,

print(alist[0][1][2]);

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Write a Python Program What should the values of X and Y be, so that 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
  • 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 == "/":...

  • 1) Translate the following equation into a Python assignment statement 2) Write Python code that prints...

    1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...

  • PYTHON PART 1) SIMPLE IF STATEMENTS INSIDE A LOOP. The first part of your program should...

    PYTHON PART 1) SIMPLE IF STATEMENTS INSIDE A LOOP. The first part of your program should do the following: • Write a section of code that prints off the numbers from 50 to 100. • It should also print off the letter grade that goes with that number on the same line using an if statement o 0 – 59 = F o 60 – 69 = D o 70 – 79 = C o 80 – 89 = B...

  • Swapping Values in python Summary In this lab, you complete a Python program that swaps values...

    Swapping Values in python Summary In this lab, you complete a Python program that swaps values stored in three variables and determines maximum and minimum values. The Python file provided for this lab contains the necessary input and output statements. You want to end up with the smallest value stored in the variable named first and the largest value stored in the variable named third. You need to write the statements that compare the values and swap them if appropriate....

  • (Python 3) Write a program that reads the contents of a text file. The program should...

    (Python 3) Write a program that reads the contents of a text file. The program should then create a dictionary in which the keys are individual words found in the file and the values are the number of times each word appears and a list that contains the line numbers in the file where the word (the key) is found. Then the program will create another text file. The file should contain an alphabetical listing of the words that are...

  • Write, save, and run a Python program that will do the following when run: Let’s consider...

    Write, save, and run a Python program that will do the following when run: Let’s consider the following assignment: a = 1 * 2 + 38 / 8 You want to change the precedence of the operators so that the addition operations are executed first. How would you re-write the assignment? Write a print statement to show the output. Let’s consider the following assignments: x = 'z' y= ['x', 'z', 'q'] Now, apparently x is a member of y. Write...

  • on python Here is a dictionary:   dictionary = { ' x ' : 55, ' y...

    on python Here is a dictionary:   dictionary = { ' x ' : 55, ' y ' : 15, ' z ' : 35} Write the code that will print all of the keys and values:

  • Write a program that takes the x, y coordinates of a point in the Cartesian plane...

    Write a program that takes the x, y coordinates of a point in the Cartesian plane and prints a message telling either which axis the point lies on or the quadrant in which it is found. Sample Output (-1.0, -2.5) is in quadrant 3 (0.0, -4.8) is on the y-axis IN C CODE PLEASE! (NOT C++)

  • *Java* Hi. I need some help with creating generic methods in Java. Write a program GenMethods...

    *Java* Hi. I need some help with creating generic methods in Java. Write a program GenMethods that has the following generic methods: (1) Write the following method that returns a new ArrayList. The new list contains the nonduplicate (i.e., distinct) elements from the original list. public static ArrayList removeDuplicates(ArrayList list) (2) Write the following method that shuffles an ArrayList. It should do this specifically by swapping two indexes determined by the use of the random class (use Random rand =...

  • Write a python program that displays specific messages using the IF Statement: Ask the user to...

    Write a python program that displays specific messages using the IF Statement: Ask the user to enter a valid marital status (SINGLE or MARRIED), and then use a conditional statement to print one of the following messages: |GENDER|MESSAGE |:|: |SINGLE|Proceed to Waiting Area in Zone 1 |MARRIED|Proceed to Waiting Area in Zone 2 |Not Valid|Enter valid status and try again

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