Question

Python 3.6 (known limitations) 1 mashup=(2, abc, 1, def] 2 x=mashup[1][0] 3 print(x) Edit this code xecuted

can some one help me explain this please? I dont understand it

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

mashup = [2,'abc',1,'def']

mashup is a list that contains 2 , 'abc', 1, 'def'

List index is stating from 0

So,

mashup[0] = 2
mashup[0] = 'abc'
mashup[0] = 1
mashup[0] = 'def'

You can see in below picture. I have printed mashup[0],mashup[1],mashup[2],mashup[3]

main.py 1 2 mashup = [2, abc,1, def] 3 4 print(mashup[@]) 5 print(mashup[1]) 6 print(mashup[2]) 7 print(mashup[:]) 8 9 2

Now mashup[1] = 'abc'. abc is a string.

To access each character of string
mashup[1][0] = 'a'
mashup[1][1] = 'b'
mashup[1][2] = 'c'

You can see the below picture.

main.py 1 2 mashup = [2, abc,1, def] 3 4 print(mashup[1][@]) 5 print(mashup[1][1]) 6 print(mashup[1][2]) 7 8 a с Program

x = mashup[1][0]

Above statement will assign the value of mashup[1][0] to x

So value of x becomes value of mashup[1][0] that is 'a'

So value of x becomes a.

and then print(x) will print the value of x. that is 'a'. So output is a

main.py 1 2 mashup = [2, abc,1, def] x = mashup[1][@] 4 print(x) 5 3 6 a ...Program finished with exit code o Press ENTER

Add a comment
Know the answer?
Add Answer to:
can some one help me explain this please? I dont understand it Python 3.6 (known limitations)...
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
  • hi i dont know and understand what this assignment wants me to do can some please...

    hi i dont know and understand what this assignment wants me to do can some please explain it to me thank you Modify the print_face function to have a third parameter mouth and use it in the final print statement. def print_face(eye, face_char): print(' ', eye, ' ', eye) # Print eyes print(' ', face_char) # Print nose print(' ', face_char*5) # Print mouth return print_face('o', 'x')

  • HI CAN SOMEONE PLEASE HELP ME WITH THIS 2 QUESHTIONS. I dont understand them how I...

    HI CAN SOMEONE PLEASE HELP ME WITH THIS 2 QUESHTIONS. I dont understand them how I got them wrong please. 1. Dmitri Mendeleeve's chart of elements: A. was used as a calendar B.placed elements together with similar properties C.shifted the elements to fill in the gaps D.had many defects because of unknown elements 2. Temperature is a measure of the heat content of an object True or False

  • Hi I need help to understand what to do in this questions I have imported the file using mongodimport but I dont know the rest can someone please help me to understand and give me some examples of the...

    Hi I need help to understand what to do in this questions I have imported the file using mongodimport but I dont know the rest can someone please help me to understand and give me some examples of the way to make the commands to work. To complete this step, type in the following Linux commands to perform the import in the right directory: ../startMongod.sh #first step will always be to start mongo cd datasets/ #change into the directory with...

  • In python, please help me fill in these functions given their limitations. Please use for loops....

    In python, please help me fill in these functions given their limitations. Please use for loops. def palindrome(x): """ For a given string, determine if the string is a palindrome. (The same forward and back) Input: String of any size (including empty) Return: Boolean (True if palindrome, False otherwise) Limitation: You must use a loop. Only function allowed to be used is len (if needed). Cannot use "in" besides "for var in container" """ pass def getCount(char, strng): """ Get...

  • This is for Pycharm a python course. Can I get some help doing this and understand...

    This is for Pycharm a python course. Can I get some help doing this and understand it? ⑤ : ib tps://canvas.pasadena.edu/courses/1032754/assi a ☆ 西%N m Crowfall. Th O computing, with-c- O PHP Tutorial | SoloL ontoja. on tojav.. Write functions . def main) . def sphereVolume(r) . def sphereSurfacelr) def cylinderVolumetr. h) . def cylinderSurface(r, h) . def coneVolumefr, h) . def coneSurface(r, h) ences rations main() # call amin function at teh end In the main display, a menu...

  • Can someone please help me understand question 2? I understand the first one, but for some...

    Can someone please help me understand question 2? I understand the first one, but for some reason I keep getting the second one wrong In the class lecture notes, the result of the first-order perturbation calculation for the energy of lithium was given as E" - 2J12+ILL-K2. This energy is added to the EC value obtained by treating each electron as if it were in an independent hydrogen-like orbital in order to estimate the total energy of the lithium atom....

  • need help with balancing brackets in python. I don't really understand it much. an unbalanced one...

    need help with balancing brackets in python. I don't really understand it much. an unbalanced one will look like this: (<x)>(())() For this exercise, you must write a function called balanced brackets brackets in the string, that is: '(' , ') and >', are correctly balanced. This function will be passed a string as an input, and you must check that any parentheses or angled Here are a few examples of strings where brackets are correctly balanced: a (<bcd>ef)g abcde...

  • PYTHON. Continues off another code. I don't understand this. Someone please help! Comment the lines please...

    PYTHON. Continues off another code. I don't understand this. Someone please help! Comment the lines please so I can understand LinkedList ADT: class myLinkedList:     def __init__(self):         self.__head = None         self.__tail = None         self.__size = 0     def insert(self, i, data):         if self.isEmpty():             self.__head = listNode(data)             self.__tail = self.__head         elif i <= 0:             self.__head = listNode(data, self.__head)         elif i >= self.__size:             self.__tail.setNext(listNode(data))             self.__tail = self.__tail.getNext()         else:             current = self.__getIthNode(i - 1)             current.setNext(listNode(data,...

  • Can someone please help me with this: I dont have strong opinion about this. Please help...

    Can someone please help me with this: I dont have strong opinion about this. Please help me, I really need help with this. It is related to the article "microbes of the upper troposphere" Summarize the opinion about microorganisms in the troposphere in one or two paragraphs. Support your argument with evidence.

  • These are three questions i dont understand please help me in all of them 2) For...

    These are three questions i dont understand please help me in all of them 2) For the following reaction identify the Bronsted acid, the Bronsted base, the conjugate base of the Bronsted acid, and the conjugate acid of the Bronsted base. Bronsted acid Bronsted base Conj base of Conj acid of Bronsted acid Bronsted base

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
Active Questions
ADVERTISEMENT