Starting Out with Python (4th Edition)
4th Edition
ISBN: 9780134444321
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 7, Problem 7AW
Program Plan Intro
List concatenation:
- • In Python, a list can be concatenated with the other lists to make a new list.
- • List concatenation in Python can be done using “+” operator.
- • The “+” operator can concatenate two lists.
Algorithm to concatenate two lists is as follows:
- • Create a list of integers and assign it to “list1”.
- • Create another list that stores the integers and assign it to “list2”.
- • Use the “+” operator to concatenate “list1” and “list2” and assign the resultant list to “list3”.
- • Print the list “list3” using the “print()” function.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Pyhton code please help, indentation would be greatly appreciated
reverse_number_in_list(number_list:list)-> list
This function will be given a list of numbers your job is to reverse all the numbers in the list and return a list with the reversed numbers. If a number ends with 0 you need to remove all the trailing zeros before reversing the number. An example of reversing numbers with trailing zeros: 10 -> 1, 590 -> 95. None of the numbers in the number_list will be less than 1.
Example:
number_list = [13, 45, 690, 57]
output = [31, 54, 96, 75]
Code Snippet: Insert the value "orange" as the second element of the list.
fruits = ['apple', 'banana', 'cherry']
fruits. (1, "orange")
print(______)
Question: What are the index value of the given ordered set of fruits? What is the
python function to insert the orange as the second element of the list. And what
is the missing parameter to display the final output.
1,2,3
fruits
☐insert()
0,1,2
☐append()
Chapter 7 Solutions
Starting Out with Python (4th Edition)
Ch. 7.2 - What will the following code display? numbers =...Ch. 7.2 - Prob. 2CPCh. 7.2 - Prob. 3CPCh. 7.2 - Prob. 4CPCh. 7.2 - Prob. 5CPCh. 7.2 - Prob. 6CPCh. 7.2 - Prob. 7CPCh. 7.2 - Prob. 8CPCh. 7.3 - Prob. 9CPCh. 7.3 - Prob. 10CP
Ch. 7.3 - Prob. 11CPCh. 7.3 - Prob. 12CPCh. 7.3 - Prob. 13CPCh. 7.4 - What will the following code display? names =...Ch. 7.5 - Prob. 15CPCh. 7.5 - Prob. 16CPCh. 7.5 - Prob. 17CPCh. 7.5 - Prob. 18CPCh. 7.8 - Prob. 19CPCh. 7.8 - Prob. 20CPCh. 7.8 - Write a set of nested loops that display the...Ch. 7.9 - Prob. 22CPCh. 7.9 - Prob. 23CPCh. 7.9 - Prob. 24CPCh. 7.9 - Prob. 25CPCh. 7.10 - Prob. 26CPCh. 7.10 - Prob. 27CPCh. 7.10 - Prob. 28CPCh. 7.10 - Prob. 29CPCh. 7.10 - Prob. 30CPCh. 7.10 - To create a bar chart with the bar function, what...Ch. 7.10 - Assume the following statement calls the bar...Ch. 7.10 - Prob. 33CPCh. 7 - This term refers to an individual item in a list....Ch. 7 - This is a number that identifies an item in a...Ch. 7 - Prob. 3MCCh. 7 - This is the last index in a list. a. 1 b. 99 c. 0...Ch. 7 - This will happen if you try to use an index that...Ch. 7 - This function returns the length of a list. a....Ch. 7 - When the operator's left operand is a list and...Ch. 7 - This list method adds an item to the end of an...Ch. 7 - This removes an item at a specific index in a...Ch. 7 - Prob. 10MCCh. 7 - If you call the index method to locate an item in...Ch. 7 - Prob. 12MCCh. 7 - This file object method returns a list containing...Ch. 7 - Which of the following statement creates a tuple?...Ch. 7 - Prob. 1TFCh. 7 - Prob. 2TFCh. 7 - Prob. 3TFCh. 7 - Prob. 4TFCh. 7 - A file object's writelines method automatically...Ch. 7 - You can use the + operator to concatenate two...Ch. 7 - Prob. 7TFCh. 7 - You can remove an element from a tuple by calling...Ch. 7 - Prob. 1SACh. 7 - Prob. 2SACh. 7 - What will the following code display? values = [2,...Ch. 7 - Prob. 4SACh. 7 - Prob. 5SACh. 7 - Prob. 6SACh. 7 - Prob. 1AWCh. 7 - Prob. 2AWCh. 7 - Prob. 3AWCh. 7 - Prob. 4AWCh. 7 - Write a function that accepts a list as an...Ch. 7 - Prob. 6AWCh. 7 - Prob. 7AWCh. 7 - Prob. 8AWCh. 7 - Total Sales Design a program that asks the user to...Ch. 7 - Prob. 2PECh. 7 - Rainfall Statistics Design a program that lets the...Ch. 7 - Prob. 4PECh. 7 - Prob. 5PECh. 7 - Larger Than n In a program, write a function that...Ch. 7 - Drivers License Exam The local driver s license...Ch. 7 - Name Search If you have downloaded the source code...Ch. 7 - Prob. 9PECh. 7 - World Series Champions If you have downloaded the...Ch. 7 - Prob. 11PECh. 7 - Prob. 12PECh. 7 - Magic 8 Ball Write a program that simulates a...Ch. 7 - Expense Pie Chart Create a text file that contains...Ch. 7 - 1994 Weekly Gas Graph In the student sample...
Knowledge Booster
Similar questions
- 6. sum_highest_five This function takes a list of numbers, finds the five largest numbers in the list, and returns their sum. If the list of numbers contains fewer than five elements, raise a ValueError with whatever error message you like. Sample calls should look like: >>> sum_highest_five([10, 10, 10, 10, 10, 5, -17, 2, 3.1])50>>> sum_highest_five([5])Traceback (most recent call last): File "/usr/lib/python3.8/idlelib/run.py", line 559, in runcode exec(code, self.locals) File "<pyshell#44>", line 1, in <module> File "/homework/final.py", line 102, in sum_highest_five raise ValueError("need at least 5 numbers")ValueError: need at least 5 numbersarrow_forward*Coding language is Python Write a program that opens the productsales.txt file and reads the sales into a list. The program should output the following information, in this order: The total of all sales in the list The average of all sales in the list The lowest sale in the list The highest sale in the list NOTE: Your program should include at least one user-defined function, in addition to the main function. 4147 1594 2235 8433 10000 129 5555 7030 9764 7465 1111 4444 8954 2243 2895 1436 4978 5486 1436 9846 4789 8456 2497 2280 6375arrow_forwardAlert - don't use AIarrow_forward
- Assume list1 references a list. After the following statement executes, list1 and list2 willreference two identical but separate lists in memory:list2 = list1 (T/F)arrow_forwardWhat will the following code print?list1 = [40, 50, 60]list2 = [10, 20, 30]list3 = list1 + list2print(list3)arrow_forwardPS: Do not use regular expressions or built in function. Please answer it according to the questions. TY Suppose you have a sitting arrangement of the students who will give the final exam in a list. The list contains the last two digits of their student ID as giv below. sitting_list = [10,30,20,70,11,15,22,16,58,100,12,56,70,801 Now you want to organize the sitting arrangement of the students in your own way. You decide to sort all the students in the even indices of the list in ascending order and all the students in the odd indices of the list in descending order So, write a python program that organizes the list for you in this way. Sample Output [10. 100. 11, 80, 12. 70, 20, 56, 22, 30, 58, 16, 70, 15]arrow_forward
- Complete the display_coins_list(coins_list) function. This function takes a list (always nine elements in length) as a parameter. The function displays 3 lines in total. An example of the output is as shown below: 123456789 --------- $ $$ $ The first line shows the digits 1 to 9 (as indicated in the example output above). The second line shows a single line of 9 "-" symbols (hyphens). The third line shows the coins list, formatted as in the examples. For example: Test Result display_coins_list(['-', '$', '-', '$', '-', '$', '-', '-', '$']) 123456789 --------- -$-$-$--$ data = ['$', '-', '$', '-', '$', '-', '-', '-', '$'] display_coins_list(data) 123456789 --------- $-$-$---$arrow_forwardPS: Do not use any built in function or regular expressions. Code this is python. TY. Suppose you have a list named my_list as given below. my list = [10,1,20,3,6,2,5,11,15,2,12,14,17,18,29] Now use selection sort to sort my list into ascending order. Output [1, 2, 2, 3, 5, 6, 10, 11, 12, 14, 15, 17, 18, 20, 29]arrow_forwardIn Python pleasearrow_forward
- O Launch Meeting Zoom 9 Is Everyone Really Equal? X Reading Response 6 - Goog X E Ch7: Oppression & Sexism 6 Thank you for downloading x du/courses/46018/assignments/294537 docstring explaining what it does! 1. count_perfect_squares This function takes a single argument, nums , which is a list of numbers. The function counts up how many of the numbers in the input list are "perfect squares", which is to say that they are a square of an integer. Sample calls should look like this: >>> count_perfect_squares ([2, 3, 4, 16, 100, 5, 1]) 4 >>> count_perfect_squares([]) >>> count_perfect_squares([13])arrow_forwardWhat does this code print? list1 [1998, 2002, 1997, 2000] print (list1 * 2 )arrow_forwardReturn Growing NumList This function will be given a single number, it should return a list of strings of numbers. Each string in the list will only contain a single number repeated an arbitrary amount of times. The number each string will contain will be equal to the current string's index+1. The number in the string should be repeated the same number of times as the string's index+1. Each number in the string should be separated by a space. This list should stop when its size equals the max number specified. Signature: public static ArrayList returnGrowingNumList(int max) Example: INPUT: 3 OUTPUT: [1, 22, 333] INPUT: 6 OUTPUT: [1, 22, 333, 444 4, 55555, 666666]arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning