Hello dosto! Welcome to my Blog . I am so happy to visit my blog. In this blog you can find your maximum information as like related to Coursera in, you find all quiz and assignment weekly as your course embedded.
Coursera: Python data structures Assignment 7.1 Week 3 Write a program that prompts for a file name, then opens that file and reads through the file, and print the contents of the file in upper case. Use the file words.txt to produce the output below. You can download the sample data at http://www.py4e.com/code3/words.txt Solution: # Use words.txt as the file name fname = input("Enter file name: ") fh = open(fname,'r') for i in fh.readlines(): print(i.upper().rstrip()) Coursera official website: https://www.coursera.org/learn/python-data/home/welcome
Coursera : Python data structures Assignment 8.4 Week 4 8.4 Open the file romeo.txt and read it line by line. For each line, split the line into a list of words using the split() method. The program should build a list of words. For each word on each line check to see if the word is already in the list and if not append it to the list. When the program completes, sort and print the resulting words in alphabetical order. You can download the sample data at http://www.py4e.com/code3 Solution: fname = input("Enter file name: ") fh = open(fname) lst = list() for line in fh: for i in line.rstrip().split(' '): lst.append(i) lst = list(set(lst)) lst.sort() print(lst) Coursera official website: https://www.coursera.org/learn/python-data/home/welcome
Coursera: Programming for everybody with Python Assignment 5.2 Week 7 Question:- 5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter 7, 2, bob, 10, and 4 and match the output below. Solution:- largest = None smallest = None while True: try: num = input("Enter a number: ") if num == "done": break #print (num) num = int(num) if largest is None or largest < num: largest = num elif smallest is None or smallest > num: smallest = num except ValueError: print("Invalid input") print ("Maximum is", largest) print ("Minimum is", smallest) Official website for Coursera: https://...
Coursera Chapter 6 (This course ahead of Programming for everybody with Python' ) Quiz solutions:- Coursera official website: https://www.coursera.org/learn/python-data/home/welcome
Great
ReplyDelete