Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

jupyter (unsaved changes) Logout File Edit View Insert Cell Kernel Widgets Help Not Trusted Python 3 (ipykernel) + 8 Run Markdown : Problem Set 1

image text in transcribed

jupyter (unsaved changes) Logout File Edit View Insert Cell Kernel Widgets Help Not Trusted Python 3 (ipykernel) + 8 Run Markdown : Problem Set 1 1: Boolean Connectives Construct functions func_not, func_and, and func_or that take Boolean variables and output a single boolean variable according to the truth tables for these connectives, func_not should take one argument and func_and and func_or should take two. Obviously, this is trvial if you use the biult in python not, and, and or fucntions, so do not use them. In [ ]: 2: The Closest Square Create a function that takes as an input an integer and finds the nearest perfect square. Hint: You can round numbers with the round function, you can take the absolute value with the abs function. These can be learned about using the great resource: google In [ ]: Now, write a function that takes as an argument a list of integers and returns the same list of integers sorted by their distance to the nearest perfect square. To do this, use pythons sort by function feature, which you can read about here. As a test case, arr = [35, 27, 22, 40, 66, 81, 193, 125, 243, 782, 781, 534] should sort to [81, 35, 27, 66, 782, 22, 193,781, 40, 125, 534, 243] In [ ]: 3: Grades Write a function, final_grade_ranking that takes two inputs: a dictionary (containing students as keys and a list of grades of length n) and a set of

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions

Question

How do retail promotions differ from consumer promotions?

Answered: 1 week ago

Question

Why are co-op advertising programmes not always good for a brand?

Answered: 1 week ago