NPTEL » Python for Data Science

Assignment 2

Due date: 2019-09-11, 23:59 IST.
Your last recorded submission was on 2019-09-10, 10:56 IST
1 point
Package that deals with dataframe is
 
 
 
 
1 point
The data type of the following python object 'a' is: a={23, 24, 25, 26, 27}
 
 
 
 
1 point
Variable ‘a’ is defined as
       a = ‘gOOd moRning’
       Command to convert ‘a’ from ‘gOOd moRning’ to ‘Good Morning’ is:-
 
 
 
 
1 point
Which of the following python data structure is immutable?
 
 
 
 
1 point
Identify the braces used to create a dictionary in Python.
 
 
 
 
1 point
The command used to add elements to a list
 
 
 
 

Using the list ‘Stationery’ answer questions 7-8
Product = ['Pencil', 'Pen', 'Eraser', 'Pencil Box', 'Scale']
Price= [5, 10, 2, 20, 12]  
Brand = ['Camlin', 'Rotomac', 'Nataraj', 'Camel', 'Apsara']
Stationery = [Product, Price, Brand]
1 point
The command to add “Notebook” as the first element inside the first level of the list      “Stationery” is:-
 
 
 
 
1 point
Command to replace the element of Brand, “Camel” with “Camlin” inside the list is:-
 
 
 
 
1 point
The list "Months" is defined as:-

       Months = ['Jan', 'Mar', 'June', 'Aug', 'June', 'Feb', 'Nov', 'Dec', 'June', 'Apr', 'May',     'June']

       Which of the following commands returns the number of occurrences of ‘June’?
 
 
 
 
1 point
 Choose the correct command to sort 'Ages' in ascending order

    Ages = [ ’20’, ‘26’, ‘56’, ‘54’, ‘32’, ‘28’, ‘23’, ‘99’, ‘87’, ‘10’, ‘65’, ‘88’, ‘66’,
                  ‘48’, ‘42’, ‘27’, ‘33’, ‘38’,  ‘83’, ‘94’, ‘66’, ‘44’]
 
 
 
 

Answer questions 11 and 12 using the information given below: 
   
 D = [‘MONDAY’, ‘TUESDAY’,  ‘WEDNESDAY’, ‘THURSDAY’, ‘FRIDAY’, ‘SATURDAY’, ‘SUNDAY’]
1 point
 The command to print WEDNESDAY, THURSDAY from the list “D” is
 
 
 
 
1 point
 The command used to reverse the above list “D” is:-
 
 
 
 
1 point
 The command to clear all the elements from a Set is:-
 
 
 
 

Answer questions 14 and 15 using the information given below:   
Mylist =[‘a’, ‘a’, ‘b’, ‘b’, ‘b’, ‘c’, ‘c’, ‘d’, ‘e’] 
1 point
 The output of the code: Mylist.index(‘d’) is
 
 
 
 
1 point
 The output after you run the command:
         Mylist.pop(0)         print(Mylist)
 
 
 
 
1 point
 The command to find the number of elements in the following list “N
          N = [24, 27, 29, 26, 25, 23, 20]
 
 
 
 

Create a dictionary ‘Country’ that maps the following countries to their capitals respectively. 

1 point
 The command to replace “Sydney” with “Canberra” is:-
 
 
 
 


Create the following sets X1 and X2 using the data provided below and answer the questions 18 and 19

1 point
 The output of X1.intersection(X2) will be
 
 
 
 
1 point
 The command X1.symmetric_difference(X2)
 
 
 
 
1 point
Which of the following is a code template for creating objects in Python?
 
 
 
 


Create the following Matrix “Y” in Python and answer questions 21 to 23 :

1 point
  The determinant of the matrix “Y” rounded off to the zeroth decimal place is
 
 
 
 
1 point
  Inverse of matrix “Y” rounded off to second decimal place is

 ([[- 0.73, 0.68, 0.11],
 [0.09,  -0.27, 0.04],
 [0.18,  0.05,  -0.13]])

([[ 0.73, -0.68, -0.11],
[-0.09,  0.27, -0.04],
[-0.18,  0.05,  0.13]])

 ([[ 0.73, 0.68, 0.11],
[0.09,  0.27, 0.04],
[0.18,  0.05,  0.13]])

([[- 0.73, -0.68, -0.11],
[-0.09,  -0.27, -0.04],
[-0.18,  -0.05, -0.13]])
1 point
  The column sum of YT is
 
 
 
 

netaji gandi Wednesday, September 11, 2019
NPTEL » Python for Data Science

Assignment 1

Due date: 2019-09-11, 23:59 IST.
Your last recorded submission was on 2019-09-04, 21:20 IST
1 point
 The command used to clear console in Spyder is:-
 
 
 
 
1 point
Which of the following is a valid variable name?
 
 
 
 
1 point
Python files are saved with extension 
 
 
 
 
1 point
Which of the following statement is invalid?
 
 
 
 
1 point
The command to display an output in Python is:-
 
 
 
 
1 point
Assignment operator used in Python is: -
 
 
 
 
1 point
Consider the variables a and b. Values of a and b are 280 and 15 respectively. The operation that will return a remainder is: -
 
 
 
 
1 point
Python command used to calculate 25 is given by:-
 
 
 
 
1 point
The values of variables p and q are 15 and 3 respectively. What is the value of ‘p’ after running the code below?
    p*=q
 
 
 
 
1 point
 Which command would you use to find the data type of a variable
 
 
 
 
1 point
Value of variable p is 45. Command to coerce p from integer datatype to float datatype is:-
 
 
 
 
1 point
Indicate which command would you use to set the working directory
 
 
 
 
1 point
Comments in Python begin with
 
 
 
 
1 point
 What type of object is x? 
   x=(“Python”, “version”, “3.7”)
 
 
 
 
1 point
Which of the following method can be used to initialize multiple variables with a common value?
1.x=y: y=33
2.x=y=z=33
3.x=33; y=x; z=y
4.x,y,z=33
 
 
 
 
1 point
What will be the output after the following statements are executed?
X=300 
Y= 17
X%=Y
print(X)
 
 
 
 
1 point
What is the command to clear a single variable ‘a’ from the variable explorer?
 
 
 
 
1 point
Which of the package is used for visualization in Python
 
 
 
 
1 point
 “not in” belongs to which type of operator in Python?
 
 
 
 
1 point
“is not” belongs to which type of operator in Python?
 
 
 
 

netaji gandi
NPTEL » Programming, Data Structures And Algorithms Using Python

Week 5 Programming Assignment



Here are some basic facts about tennis scoring: A tennis match is made up of sets. A set is made up of games.
To win a set, a player has to win 6 games with a difference of 2 games. At 6-6, there is often a special tie-breaker. In some cases, players go on playing till one of them wins the set with a difference of two games.
Tennis matches can be either 3 sets or 5 sets. The player who wins a majority of sets wins the match (i.e., 2 out 3 sets or 3 out of 5 sets) The score of a match lists out the games in each set, with the overall winner's score reported first for each set. Thus, if the score is 6-3, 5-7, 7-6 it means that the first player won the first set by 6 games to 3, lost the second one 5 games to 7 and won the third one 7 games to 6 (and hence won the overall match as well by 2 sets to 1).
You will read input from the keyboard (standard input) containing the results of several tennis matches. Each match's score is recorded on a separate line with the following format:
Winner:Loser:Set-1-score,...,Set-k-score, where 2 ≤ k ≤ 5
For example, an input line of the form
Halep:Wozniacki:3-6,6-3,6-3
indicates that Halep beat Wozniacki 3-6, 6-3, 6-3 in a best of 3 set match.
The input is terminated by a blank line.
You have to write a Python program that reads information about all the matches and compile the following statistics for each player:
  1. Number of best-of-5 set matches won
  2. Number of best-of-3 set matches won
  3. Number of sets won
  4. Number of games won
  5. Number of sets lost
  6. Number of games lost
You should print out to the screen (standard output) a summary in decreasing order of ranking, where the ranking is according to the criteria 1-6 in that order (compare item 1, if equal compare item 2, if equal compare item 3 etc, noting that for items 5 and 6 the comparison is reversed).
For instance, given the following data
Federer:Nadal:2-6,6-7,7-6,6-3,6-1
Nadal:Federer:6-3,4-6,6-4,6-3
Federer:Nadal:6-0,7-6,6-7,6-3
Nadal:Federer:6-4,6-4
Federer:Nadal:2-6,6-2,6-0
Nadal:Federer:6-3,4-6,6-3,6-4
Federer:Nadal:7-6,4-6,7-6,2-6,6-2
Nadal:Federer:7-5,7-5
Halep:Wozniacki:3-6,6-3,6-3
your program should print out the following
Federer 3 1 13 142 16 143
Nadal 2 2 16 143 13 142
Halep 0 1 2 15 1 12
Wozniacki 0 0 1 12 2 15
You can assume that there are no spaces around the punctuation marks ":", "-" and ",". Each player's name will be spelled consistently and no two players have the same name.


Answer:

stats={}
line=input()
while line:
  (wsets,lsets,wgames,lgames)=(0,0,0,0)
  (winner,loser,setscores)=line.strip().split(':',2)
  
  sets=setscores.split(',')
  for set in sets:
    (winstr,losestr)=set.split('-')
    win=int(winstr)
    lose=int(losestr)
    wgames=wgames+win
    lgames=lgames+lose
    if win > lose:
      wsets=wsets+1
    else:
      lsets=lsets+1
  for player in [winner,loser]:
    try:
      stats[player]
    except KeyError:
      stats[player]=[0,0,0,0,0,0]
  if wsets >= 3:
    stats[winner][0]=stats[winner][0]+1
  else:
    stats[winner][1]=stats[winner][1]+1
  stats[winner][2]=stats[winner][2]+wsets
  stats[winner][3]=stats[winner][3]+wgames
  stats[winner][4]=stats[winner][4]-lsets
  stats[winner][5]=stats[winner][5]-lgames
  stats[loser][2]=stats[loser][2]+lsets
  stats[loser][3]=stats[loser][3]+lgames
  stats[loser][4]=stats[loser][4]-wsets
  stats[loser][5]=stats[loser][5]-wgames
  line=input()
statlist=[(stat[0],stat[1],stat[2],stat[3],stat[4],stat[5],name) for name in stats.keys() for stat in [stats[name]]]
statlist.sort(reverse=True)
for entry in statlist:
  print(entry[6],entry[0],entry[1],entry[2],entry[3],-entry[4],-entry[5])
  

netaji gandi Wednesday, September 4, 2019

Smart India Hackathon (SIH) 2025: Complete Guide with Problem Statements, Timeline & Idea PPT Template

  Smart India Hackathon (SIH) 2025: Complete Guide with Problem Statements, Timeline & Idea PPT Template Lets Code • September 8, 2025 I...