4. Write a function remove_repetition that takes any list 1st and returns a new list with the same entries as 1st, except all instances of consecutive repetition are no longer present. For example, remove_repetition([3, 4, 4, 6, 4, 3, 3, 3, 1]) should return the new
4. Write a function remove_repetition that takes any list 1st and returns a new list with the same entries as 1st, except all instances of consecutive repetition are no longer present. For example, remove_repetition([3, 4, 4, 6, 4, 3, 3, 3, 1]) should return the new
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Python help
![You will create and submit a single script including each of the following function definitions (see
the assignment page in Canvas for a starter script). Remember to pay close attention to whether
your result should be return ed or print ed.
You should print enough test cases below each of your function definitions to be reasonably
sure it works for all types of inputs as described in the problem. Your test cases should be
different from any of the examples provided in the problem.
FOr all questions on Part 2, you may not use any buill-in functions or methods other than
range,
len,
and append.
1. A list of mumbers is said to be balanced if the sum of its first half is cqual to the sumn of its
second half (if the list has odd length, then we ignore the center value in both sums). Write
a function is balanced that takes any list of numbers num list and returns True if the](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5f674f25-25cd-4157-a3b0-b4cefdd441a9%2Fb4d126f0-3ea0-4fc3-9d61-ec97daeb83ca%2Fdt693n_processed.jpeg&w=3840&q=75)
Transcribed Image Text:You will create and submit a single script including each of the following function definitions (see
the assignment page in Canvas for a starter script). Remember to pay close attention to whether
your result should be return ed or print ed.
You should print enough test cases below each of your function definitions to be reasonably
sure it works for all types of inputs as described in the problem. Your test cases should be
different from any of the examples provided in the problem.
FOr all questions on Part 2, you may not use any buill-in functions or methods other than
range,
len,
and append.
1. A list of mumbers is said to be balanced if the sum of its first half is cqual to the sumn of its
second half (if the list has odd length, then we ignore the center value in both sums). Write
a function is balanced that takes any list of numbers num list and returns True if the
![4. Write a function remove_repetition that takes any list 1st and returns a new list with
the same entries as 1st , except all instances of consecutive repetition are no longer present.
For example, remove_repetition([3, 4, 4, 6, 4, 3, 3, 3, 1]) should return the new
2
list [3, 4, 6, 4, 3, 1] .
5. Write a function n_gram that takes any string word and a positive integer n, and that
returns a list containing all adjacent substrings of length n in word
For example, n_gram('hello', 2) should return the list ['he', 'el', 'll', 'lo'].
and n gram ('science', 5) should return the list ['scien', 'cienc', 'ience']. If n
is larger than len (word), then the list returned should be empty.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5f674f25-25cd-4157-a3b0-b4cefdd441a9%2Fb4d126f0-3ea0-4fc3-9d61-ec97daeb83ca%2Fu45im27_processed.jpeg&w=3840&q=75)
Transcribed Image Text:4. Write a function remove_repetition that takes any list 1st and returns a new list with
the same entries as 1st , except all instances of consecutive repetition are no longer present.
For example, remove_repetition([3, 4, 4, 6, 4, 3, 3, 3, 1]) should return the new
2
list [3, 4, 6, 4, 3, 1] .
5. Write a function n_gram that takes any string word and a positive integer n, and that
returns a list containing all adjacent substrings of length n in word
For example, n_gram('hello', 2) should return the list ['he', 'el', 'll', 'lo'].
and n gram ('science', 5) should return the list ['scien', 'cienc', 'ience']. If n
is larger than len (word), then the list returned should be empty.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 4 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education