Python question Application: Python Fragment Formulation (Q1 – Q4) In this group of questions you are asked to produce short pieces of Python code. When you are asked to "write a Python expression" to complete a task, you can either give the expression in one line or break down the task into several lines. The last expression you write must represent the required task. Question 1 (Reduce parentheses) Give an equivalent version of this expression by removing as many redundant parentheses as possible, without expanding the brackets or simplifying.        (x**(2**y))+(y*((z+x)**3))     Question 2 (Translate arithmetic concept into Python) You are given a list of numbers, named numbers, containing 3 integers. Write a python expression (one line) that evaluates to True if and only if the product of any two numbers in the given list is greater than the sum of all three numbers.  Note: the product of two numbers, x and y is x*y.     Question 3 (List/table access) You are given a table, car_count, which has three columns, day (string), hour (integer in 24 hour format) and number of cars (positive integer), that contain the count of cars that pass through an intersection. For example:  car_count = [['Monday',0,0],['Monday',1,0], ...,['Wednesday',13,7],...]

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section: Chapter Questions
Problem 7PP
icon
Related questions
Question

Python question

Application: Python Fragment Formulation (Q1 – Q4)

In this group of questions you are asked to produce short pieces of Python code. When you are asked to "write a Python expression" to complete a task, you can either give the expression in one line or break down the task into several lines. The last expression you write must represent the required task.

Question 1 (Reduce parentheses)

Give an equivalent version of this expression by removing as many redundant parentheses as possible, without expanding the brackets or simplifying.       

(x**(2**y))+(y*((z+x)**3))

 

 

Question 2 (Translate arithmetic concept into Python)

You are given a list of numbers, named numbers, containing 3 integers. Write a python expression (one line) that evaluates to True if and only if the product of any two numbers in the given list is greater than the sum of all three numbers. 

Note: the product of two numbers, x and y is x*y.

 

 

Question 3 (List/table access)

You are given a table, car_count, which has three columns, day (string), hour (integer in 24 hour format) and number of cars (positive integer), that contain the count of cars that pass through an intersection. For example: 

car_count = [['Monday',0,0],['Monday',1,0], ...,['Wednesday',13,7],...]

Note that the table can have any number of rows.

Write a Python code that determines the day and hour in which a maximum number of cars passes through, out of the data stored in the car_count table. If there are more than one day plus hour that has the maximum value, consider the first occurrence only. Store your answers in two different variables, one for the day and the other for the hour. 

 

 

Question 4 (Translate complex logical condition)

Write a function, common_neighbours(g, x, y), that takes in an adjacency matrix representation of a graph, g, and a vertex  x, and a vertex y,  and returns the list of vertices that are neighbours of both x  and y. 

Note: a neighbour of a given vertex is directly connected to that vertex by an edge.     

Expert Solution
steps

Step by step

Solved in 5 steps with 6 images

Blurred answer
Knowledge Booster
Mathematical functions
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr