Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 3: Strings and filing in Python 3.6 (wth is a file actually, is it another library???) a) Write a function named binary_to_decimal that parses

Question 3: Strings and filing in Python 3.6 (wth is a file actually, is it another library???)

a) Write a function named binary_to_decimal that parses a binary number as a string into a decimal form, and returns it as an integer. You can assume that the string is never empty and only contains characters 0 or 1.

b) Write a function named uncompressed that takes a compressed string as an input and returns an uncompressed string, where each alphabetic character is preceded by a single digit, indicating the number of times that the character should be entered in the uncompressed version of the string. For example:

The uncompressed version of 2a5b1c is aabbbbbc

The uncompressed version of 1a1b2c is to abcc

The uncompressed version of 1a9b3b1c is abbbbbbbbbbbbc

c) Write a function named get_base_counts2 by modifying get_base_counts that you wrote in homework problem set 4. get_base_counts2 takes a string as an input. The input string may contain letters other than A, C, G, and T. The function should return the counts of only A, C, G, and T in the form of a dictionary (even if the input string does not have any of those letters!) The input string is only invalid if it contains non-letters and lower case letters, in which case the function should return The input DNA string is invalid. If there are any uppercase letters other than A, C, G, and T, the string is not invalid, but the counts of those letters should not be added into the dictionary (note that this is different from the invalidity condition for get_base_counts).

d) Suppose that a text file contains an unspecified number of scores. Write a function named process_scores that takes in a file object f as an argument, reads the scores from f and returns their total and average. Scores are separated by whitespace on a single line. Use scores.txt for testing.

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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions