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
icon
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
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.
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
Introduction to computer system
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
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education