Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write the follwing code using Python 3. Also, please show all outputs. 1. Using the keys method for dictionaries and the sort method for

Please write the follwing code using Python 3. Also, please show all outputs.

1. Using the keys method for dictionaries and the sort method for lists, write a for loop that prints the keys and corresponding values of a dictionary in the alphabetical order of the keys.

2. As an alternative to the range function, some programmers like to increment a counter inside a while loop and stop the while loop when the counter is no longer less than the length of the array. Rewrite the following code using a while loop instead of a for loop.

a = [7,12,9,14,15,18,12] b = [9,14,8,3,15,17,15] big = [ ] for i in range ( len ( a ) ): big.append ( max ( a [ i ],b [ i ] ) ) 

1. Write a loop that reads each line of a file. It should count the number of characters in each line and keep track of the total number of characters read. Once you have a total of 1,000 or more characters, break from the loop. (You can use a break statement to do this.)

2. Modify the program written in question 3 so that it doesn't count characters on any line that begins with a pound sign (#).

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_2

Step: 3

blur-text-image_3

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

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

Give a full definition of the market for foreign exchange.

Answered: 1 week ago

Question

1. What are your creative strengths?

Answered: 1 week ago

Question

What metaphors might describe how we work together?

Answered: 1 week ago