Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!