Question

Create a list named alpha containing 10 components of type int. Output the value of the...

Create a list named alpha containing 10 components of type int. Output the value of the first component of the list alpha. Set the value of the fifth component of the list alpha to 62. Set the value of the tenth component of the list to three times the value of the fifth component of alpha. Use a for loop to output the value of a component of alpha if its index is a multiple of 3. in python

0 0
Add a comment Improve this question Transcribed image text
Answer #1
# Create a list named alpha containing 10 components of type int.
alpha = [3, 9, 1, 2, 0, 5, 4, 8, 1, 2]
# Output the value of the first component of the list alpha.
print(alpha[0])
# Set the value of the fifth component of the list alpha to 62.
alpha[4] = 62
# Set the value of the tenth component of the list to three times the value of the fifth component of alpha.
alpha[9] = 3 * alpha[4]
# Use a for loop to output the value of a component of alpha if its index is a multiple of 3
for i in range(len(alpha)):
    if i % 3 == 0:
        print(alpha[i], end=' ')
print()
Add a comment
Know the answer?
Add Answer to:
Create a list named alpha containing 10 components of type int. Output the value of 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
  • Write a C++ program: Declares an array named numberList with 50 components of the type int....

    Write a C++ program: Declares an array named numberList with 50 components of the type int. Initialize the array so that the first 25 components are equal to the square of the counter (or index) variable and the last 25 components are equal to 1, 2, 3, … , 25. Output the array so that exactly ten elements per line are printed.

  • PYTHON LANGUAGE Task 11 -Create a list with 5 items having 3 distinct data types -output...

    PYTHON LANGUAGE Task 11 -Create a list with 5 items having 3 distinct data types -output the second element of the list -output the last element of the list using -negative index -positive index -len method Task 12 -Create a list with 3 items -add an item to the end of the list -remove the first item of the list -determine if an item exists in the list -if it does, display its index -if it does not, give user...

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

  • Python Write the definition of a class Counter containing: An instance variable named counter of type...

    Python Write the definition of a class Counter containing: An instance variable named counter of type int An instance variable named limit of type int. A constructor that takes two int arguments and assigns the first one to counter and the second one to limit A method named increment. It does not take parameters or return a value; if the instance variable counter is less than limit, increment just adds one to the instance variable counter. A method named decrement....

  • 1. (TCO 1) What is the output of the following C++ code? int list[5] = {0,...

    1. (TCO 1) What is the output of the following C++ code? int list[5] = {0, 5, 10, 15, 20}; int j; for (j = 0; j < 5; j++)      cout << list[j]; (Points : 4)         0 1 2 3 4         0 5 10 15         0 5 10 15 20         5 10 15 20 Question 2.2. (TCO 1) What is stored in alpha after the following code executes? int alpha[5] = {0}; int j; for (j = 0; j...

  • Create a Python list (use first three letters of your name followed by the letter L...

    Create a Python list (use first three letters of your name followed by the letter L as the name of the list.) with the following data: 10, 20.0, 50.00, 7000, 7500, 7700, 7800, 8000, 9000, ‘python’. Display the entire list with an appropriate message. Display the 4th element in the list with an appropriate message. Display the first 3 values of the list only. Display all the values starting from the sixth element to the end of the list. Change...

  • a) Declare and instantiate an array named scores of twenty-five elements of type int.   (b)Write a...

    a) Declare and instantiate an array named scores of twenty-five elements of type int.   (b)Write a statement that declares an array namedstreetAddress that contains exactly eighty elements of typechar. 2. In a single statement: declare, create and initialize an arraynamed a of ten elements of type int with the values of the elements (starting with the first) set to 10, 20,..., 100 respectively. 3. Declare an array reference variable, week, and initialize it to an array containing the strings "mon",...

  • | ome Insert Design Layout References Mailings View Help Tell me what you want to do from the l U...

    | ome Insert Design Layout References Mailings View Help Tell me what you want to do from the l Unless you need to edit, it's safer to stay in 11. Write C++ statements that do the following: a. Declare an array alpha of 10 rows and 20 columns of type int. b. Initialize the array alpha to 0. c. Store 1 in the first row and 2 in the remaining rows d. Store 5 in the first column, and make...

  • 1. Provide code to create a selection list named orderDay containing the values and option text...

    1. Provide code to create a selection list named orderDay containing the values and option text SAT and SUN placed in the Weekend option group, and the option text MON, TUE, WED, THU, and FRI placed in the Weekday option group. 2. Provide code to create two radio buttons for the compType field with the values PC and Mac. Make PC the default value. 3. Kelsey has written the following code to create a data field for users to select...

  • Create a java program that reads an input file named Friends.txt containing a list 4 names...

    Create a java program that reads an input file named Friends.txt containing a list 4 names (create this file using Notepad) and builds an ArrayList with them. Use sout<tab> to display a menu asking the user what they want to do:   1. Add a new name   2. Change a name 3. Delete a name 4. Print the list   or 5. Quit    When the user selects Quit your app creates a new friends.txt output file. Use methods: main( ) shouldn’t do...

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