Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(In python) ff Problem 1: Write a function mytype(v) that performs the same action as type (), and can recog- nize integers, floats, strings, and

(In python)

ffimage text in transcribed

Problem 1: Write a function mytype(v) that performs the same action as type (), and can recog- nize integers, floats, strings, and lists. Do this by first using str(v), and then reading the string. Assume that lists can only contain numbers (not strings, other lists, etc...), and assume that strings can be anything that is not an integer, float or list. Note that an empty list () should also be recognized as a list. Test cases: mytype (10) and mytype (-10) should return "int"; mytype (-1.25) and mytype (10.0) should return "float"; mytype ([1, 2, 3]) and mytype([]) should return "list"; mytype ("abc") and mytype({1,2}) should return "string"; Problem 2: Write a function findpdfs (L) that takes as input a list L of filenames (such as "IMG2309.jpg, lecturel.pdf, homework.py"), and returns a list of the names of all PDF files, without extension ("lecturel). Assume that filenames may contain only letters and numbers. Test case: L = ["IMG2309.jpg", "lecture1.pdf", "homework.py", "homework2.pdf"] findpdfs(L) should return ("lecture1", "homework2")

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

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

2 What are the implications for logistics strategy?

Answered: 1 week ago