Python Class Room Diary – Be easy in My Python class ...
SET-AKENDRIYA VIDYALAYA SANGATHAN, AGRA REGIONPRE BOARD EXAMINAION 2019-20CLASS XII INFORMATICS PRACTICES(065)Time allowed: 3 hoursMax. Marks: 70 MARKING SCHEMESection AAnswer the following questions :1a)Find the output of following programimport numpy as np d=np.array([100,200,300,400,500,600,700]) print(d[-6:-2])1Ans :[200 300 400 500] (1 mark for correct output)b)Point out the incorrect statement:Both Series and ndarrays can be passed as arguments to Numpy functions.The major difference between Series and ndarray is that the data is arranged based on label in Series, when Series is operated on.A DataFrame is similar to a fixed-size dict because you can use the index labels to get and set values.None of the above.1Ans :Option C (1 mark for correct Option C )c)Fill in the blank with appropriate numpy method to calculate and print the variance of an array.import numpy as npdata=np.array([10,20,30,40,50,60])print(np.(data,ddof=0) ORCreate an ndarray with values ranging from 10 to 40 each specified with a difference of 3.1Ans : print(np.var(data,ddof=0)) (1 mark for appropriate function var)ORimport numpy as np (1 mark for appropriate arrange function)Z=np.arange(10,40,3)d)Explain the use of vsplit( ) function with syntax and example.2Ans :numpy.vsplit is a special case of split() function where axis is 1 indicating a vertical split regardless of the dimension of the input array.a = np.arange(16).reshape(4,4)b = np.vsplit(a,2) print b (1 mark for correct use of vsplit( ), 1 mark for correct example.) e)Write a Python programming code to display a bar chart of the popularity of programming Languages.Sample data:Programming languages: Java, Python, PHP, JavaScript, C#, C++Popularity: 22.2, 17.6, 8.8, 8, 7.7, 6.72Ans :import matplotlib.pyplot as plt x = ['Java', 'Python', 'PHP', 'JavaScript', 'C#', 'C++']popularity = [22.2, 17.6, 8.8, 8, 7.7, 6.7]x_pos = [i for i, _ in enumerate(x)]plt.bar(x_pos, popularity)(1/2 mark for each line of code) ( 2 mark for correct code or similar code)f)What is series ?Explain with the help of an example.2Ans :Pandas Series is a one dimensional labeled array capable of holding data of any type(integer,string,float,python objects etc)The axis labels are collectively called index.Exampleimport pandas as pddata=pd.Series([1,2,3,4,5])print(data)(g)Write a Numpy program to find out smallest and sum of array elements 0,1,2,3,4,5,6,7,8,9.ORWrite a python programming code to display and create a 8x8 ndarray and fill it with a checkerboard pattern i.e. 0 and 1 at alternative positions.3Ans:import numpy as np arr=np.array([0,1,2,3,4,5,6,7,8,9])#s1a=arr.min() #s2b=arr.sum() #s3print(a) print(b) ORimport numpy as nparr=np.array([0,1,2,3,4,5,6,7,8,9])#s1print(::-1)#s2print(a.T)#s33 marks for correct codeORimport numpy as npc=np.zeros((8,8),dtype=int)c[1::2,::3]=1c[::2,1::2]=1Print(c)Answer the following questions :2a)Which Pandas Dataframe function is used to get list from DataFrame column headers:print(list(df.columns.values))print(list(df.rows.values))print(list(df.columns.index))print(list(df.head))1Ans :OPTION Ab)Find the output of following program: import pandas as pddf = pd.DataFrame([[1, 2], [4, 5], [7, 8]], index=['cobra', 'viper', 'sidewinder'],columns=['max_speed', 'shield']) print(df.loc['cobra', 'shield'])1Ans : 2c)Explain Pandas iterrow(). Give example.1iterrows() ? iterate over the rows as (index,series) pairs. Example :df = pd.DataFrame(np.random.randn(4,3),columns = ['col1','col2','col3'])for row_index,row in df.iterrows(): print row_index,rowd)Which method is used to compare two dataframe?1Ans :equals()e)How does pivot-table differ() from pivot()? 2Ans :pivot() is used for pivoting without aggregation. Therefor, it can’t deal with duplicate values for one index/column pair. pivot_table is a generalization of pivot that can handle duplicate values for one pivoted index/column pair. Specifically, you can give pivot_table a list of aggregation functions using keyword argument aggfunc. The default aggfunc of pivot_table is numpy.mean. ( 2 mark for correct answer.)f)Write a python code to create a dataframe as per given structure in the figure.CountryRank0Russia1211Colombia402Chile1003Equador1304Nigeria112ORWrite a small python code to create a dataframe with headings (sid, age) from the list given below.[ [‘S1’,20],[‘S2’,30],[‘S3’,40], [‘S4’,50] ]Ans : import pandas as pddata = pd.DataFrame({'Country': ['Russia','Colombia','Chile','Equador','Nigeria'],'Rank':[121,40,100,130,11]}) ( 2 mark for correct answer.)print(data)OR( 2 mark for correct answer.)import pandas as pd df1=pd.dataframe([‘S1’,20],[‘S2’,30] ],columns=[‘id’,’age’] ]df2= pd.dataframe([‘S3’,40],[‘S4’,50] ],columns=[‘id’,’age’] ]df1.=df1.append(df2)g)Consider the following dataframe, and answer the questions given below:import pandas as pddata = pd.DataFrame(np.arange(12).reshape((3, 4)), index=['Ohio', 'Colorado', 'New York'],columns=['one', 'two', 'three', 'four'])Write the code to rename column name from 'Ohio' to 'SanF'.Write the code to find mean value from above dataframedf over theindex and column axis. (Skip NaN value).Use sum() function to find the sum of all the values over the index axis. ORConsider the following dataframe df and answer the questions given below: import pandas as pd?df = pd.DataFrame([[10, 20, 30, 40], [7, 14, 21, 28], [55, 15, 8, 12],???????????????????[15, 14, 1, 8], [7, 1, 1, 8], [5, 4, 9, 2]],??????????????????columns=['Apple', 'Orange', 'Banana', 'Pear'],??????????????????index=['Basket1', 'Basket2', 'Basket3', 'Basket4',?'Basket5', 'Basket6'] )?i) Write a command to calculate minimum value for each of the columnsii) Write a command to calculate maximum value for each of the rowsiii) Write a command to complete mean, mode and median3Ans : (i) data.rename(index = {'Ohio':'SanF'}, columns={'one':'one_p','two':'two_p'},inplace=True) (ii) print(df.mean(axis = 1, skipna = True)) print(df.mean(axis = 0, skipna = True)) (iii) print(df.sum(axis = 1, skipna = True) ( 1 marks each,3 mark for correct answer.) ORprint("\n----------- Minimum -----------\n")print(df[['Apple', 'Orange', 'Banana', 'Pear']].min())?print("\n----------- Maximum -----------\n")print(df[['Basket1', 'Basket2', 'Basket3', 'Basket4',?????????????????????????'Basket5', 'Basket6']].max())print("\n----------- Calculate Mean -----------\n")print(df.mean())?print("\n----------- Calculate Median -----------\n")print(df.median())?print("\n----------- Calculate Mode -----------\n")print(df.mode()) ( 1 marks each,3 mark for correct answer.)h) Consider the following dataframe named carPriceDf , carsHorsepowerDf and answer the questions given below:Car_Price = {'Company': ['Toyota', 'Honda', 'BMV', 'Audi'], 'Price': [23845, 17995, 135925 , 71400]}carPriceDf = pd.DataFrame.from_dict(Car_Price)car_Horsepower = {'Company': ['Toyota', 'Honda', 'BMV', 'Audi'], 'horsepower': [141, 80, 182 , 160]}carsHorsepowerDf = pd.DataFrame.from_dict(car_Horsepower) Write the commands to do the following operations on the dataframes :To add dataframes carPriceDf and carsHorsepowerDfTo subtract carsHorsepowerDf from carPriceDfTo Merge two data frames, and append second data frame as a new column to the first data frame.3Ans :(i) print((pd.concat([carPriceDf , carsHorsepowerDf]))(ii) print(carPriceDf.subtract(carsHorsepowerDf))(iii) carsDf = pd.merge(carPriceDf, carsHorsepowerDf, on="Company")print(carsDf) ( 1 marks each,3 mark for correct answer.)i)Find the output of the following code:import pandas as pdimport numpy as nps1 = pd.Series(['100', '200', 'python', '300.12', '400'])s2 = pd.Series(['10', '20', 'php', '30.12', '40'])print("Data Series:")print(s1)print(s2)df = pd.concat([s1, s2], axis=1)print("New DataFrame combining two series:")print(df)4Ans :Data Series:0 1001 2002 python3 300.124 400 0 101 202 php3 30.124 40 New DataFrame combining two series: 0 10 100 101 200 202 python php3 300.12 30.124 400 40 ( 01 mark for correct output of print(s1), 01 mark for correct output of print(s2), 02 mark for correct output of print(df) )Section BAnswer the following questions :3a)Which of the following is NOT the phase consisting on spiral model of software development.A) PlanningB) DesignC) EngineeringD) Risk-Analysis1Ans :Option Bb)is the process of checkinq the developed software for its correctness and error free workingSpecificationDesiqn/ImplementationValidation/TestingEvolution1Ans : Option Cc)Write down any one benefit of version control.1Ans :merge all the changes into a common version. (1 mark for correct answer)d) What are differences between commit/update and push/pull requests ?2Ans :Commit refers to updating the file in local repository on a distributed version control system. Push refers to updating the file in remote repository on a distributed version control (2 mark for correct answer)e)Explain waterfall model. Also mention one advantage and one disadvantage of waterfallsoftware process. ORExplain spiral delivery model. Also mention one advantage and one disadvantage of spiral delivery3Ans :The water fall model is a linear and sequential approach of software development where software develops systematically from one phase to another in a downward fashion. The model is divided into different phases and the output of one phase is used as input of next phase.The phases are as follows:1. Requirements specifications 2. Analysis and system design3. Implementation and unit testing 4. Integration and system testing5. Operation and maintenanceAdvantage : Simple and easy to understandDisadvantage : No working software till the last phase 3 marks (1 mark for explanation 1 mark for correct advantage and 1mark for correctdisadvantage) ORSpiral Model is a combination of a waterfall model and iterative model. Each phase in spiral model begins with a design goal and ends with the client reviewing the progress.Advantage- Additional functionality or changes can be done at a later stageCost estimation becomes easy as the prototype building is done in small fragmentsDisadvantage-Risk of not meeting3 marks (1 mark for explanation 1 mark for correct advantage and 1mark for correctdisadvantage)f)What is agile software development? Give difference between traditional approach of software development and agile methods. OR Define about scrum and pair programming used in agile software development.Agile software developmentAgile software development refers to a group of software development methodologies based oniterative development, where requirements and solutions evolve through collaboration between self-organizing cross-functional teams.Agile is a process that helps teams provide quick and unpredictable responses to the feedback theyreceive on their project. It creates opportunities to assess a project's direction duringthe development cycle. Teams assess the project in regular meetings called sprints or iterations.The main difference between traditional and agile approaches is the sequence of project phases – requirements gathering, planning, design, development, testing and UAT. In traditional development methodologies, the sequence of the phases in which the project is developed is linear where as in Agile, it is iterative.(2 mark for correct explanation of Agile software development and 2 mark for difference ) ORScrum is an agile framework for managing knowledge work, with an emphasis on softwaredevelopment, although it has wide application in other fields and is slowly starting to be explored by traditional project teams more generally. It is designed for teams of three to nine members, who break their work into actions that can be completed within time boxed iterations, called sprints, no longer than one month and most commonly two weeks, then track progress and re-plan in 15-minute time boxed stand-up meetings, called daily scrums.Pair programming is an agile software development technique in which two programmers worktogether at one workstation. One, the driver, writes code while the other, the observer or navigatorreviews each line of code as it is typed in. The two programmers switch roles frequently. (11/2 mark for correct explanation of Scrum and 11/2 mark for correct explanation for Pair programming )g)Draw a use-case diagram for a online cab / taxi booking app. ORDraw a use-case diagram for a Bank ATM system.4Ans :39370065405391160-2635885 (4 marks for correct use case diagram)Section CAnswer the following questions :4a)Which command is used to create a new app named OLA in Django project?1Ans : python manage.py startapp OLAb)The COUNT function in SQL returns the number of ______________A. Values B. Distinct values C. Group By D. ColumnsORWhich Command is used for changing values in Mysql tableA. Alter B. UpdateC. Select D. Delete1Ans : Option AORUpdatec)Mandatory arguments required to connect any database from PythonUsername, Password, Hostname, Database Name, Port.Username, Password, HostnameUsername, Password, Hostname, Database NameUsername, Password, Database Name1Ans : Option Cd)What is the name of a special control structure that facilitates the row-by-row processing of records in the result set during Python-MySQL connectivity?1Ans : Database cursor.e)Which command is used for destroying table in mysql ?1Ans : Dropf)The doc_name column of a table hospital is given belowDoc_nameAvinashRanjeetAmanKushagraBased on the information ,find the output of the following queries:(i)Write mysql command to display Doc_name starting with letter ‘K’ having any length.(ii) Write mysql command to display Doc_name ending with letter ‘A’ having only four character.(iii) Write mysql command to change name ‘Aman’ by new name ‘Arun’. 3Ans : (i)select doc_name from hospital where doc_name like “K%”.(ii) select doc_name from hospital where doc_name like “_ _ _A”.(iii)Update Hospital set Doc_name=’Arun’ where Doc_name=’Aman’;g)Observe?the?table?‘Club’?given?below: ClubMember_idMember_nameAddressAgeFeesM001SumitNew?Delhi201000M002NishaGurgaon191500M003NiharikaNew?Delhi212100M004SachinFaridabad181500i.??????????What?is?the?cardinality?and?degree?of?the?above?given?table?ii.????????If?a?new?column?contact_no?has?been?added?and?two?more?members?havejoined?the?club?then?how?these?changes?will?affect?the?degree?andcardinality?of?the?above?given?table. iii. Write MySQL?command to add a?new?column?contact_no.3Ans : i.??????????Cardinality:4Degree:?5(??mark?for?each?correct?answer)ii.????????Cardinality:?6Degree:?6 (??mark?for?each?correct?answer) iii. Alter?table?Club?add?contact_no??varchar(20); (1 Mark Each for queries from (i) to (iii) )h)Consider the table FLIGHT given below. Write commands in SQL for (i) to (iv) and output for (v) to (vi). ( queries from (i) to (iii)=1 Mark Each & from (iv) to (v)= ? Mark Each)((i) Display details of all flights starting from Delhi. (ii) Display details of flights that have more than 4 number of flights operating. (iii) Display flight codes, starting place, destination, number of flights in descending order of number of flights.(iv)Add on column “Remarks” in given table FLIGHT .(v) SELECT MAX(NO_FLIGHTS) FROM FLIGHT; (vi)SELECT START, COUNT(*) FROM FLIGHT GROUP BY Start;4Ans : (i)select * from flight where start=’delhi’; (ii) select * from flights where no_flights>4; (iii) select flcode, start, destination, no_flights from flight order by no_flights desc;(iv)Alter Table Flight add Remarks varchar(20) (v) 7 (vi) DELHI 3MUMBAI2KANPUR1INDORE1 (1 Mark Each for queries from (i) to (iii), ? Mark Each for correct output )OR(i)In a bank,a database named PNB is created in mysql whose password is “123”.Reema is trying toad a new record of PNB having details(‘E1’,’Meena’,’Delhi’) in a PNB table.(ii)Write the python code to read the contents of “first.csv” file consisting of data from a mysql table and print data of table on the screen in tabular form of table.Ans.import mysql.connectorMydb=mysql.connector.connect(host=”localhost”,user=”root”,passwd=”123”,database=”PNB”)mycursor=mydb.cursor()mycursor.excute(“insert into PNB values(‘E1’,’Meena’,’Delhi’);”)mit()(ii)f=open(‘first.csv’,’r’)with f:reader =csv.reader(f)for row in reader: for e in row: print(e) Section DAnswer the following questions :5a)Vinod is preparing financial analysis report of its organisation. Can he copy and paste information from the Internet for reference in his report?1Ans : Yes, he can do this but only after giving the reference to all the sources, otherwise it will be treated as copyright violation.b)What does the term “Intellectual Property Rights” covers?1Ans : The term “Intellectual Property Rights” covers Copyrights, Trademarks and Patents.c)What are the environmental issues of e-waste?1Ans : E-waste, or electronic waste, is waste from all sorts of electronics ranging from computers and mobile phones, to household electronics such as food processors, pressure cookers, etc. The effects of improper disposal of this e-waste on the environment are little known; however, damage to the atmosphere is one of the biggest environmental impacts of e-waste.d)What do you understand by the term Plagiarism? Write two software used as plagiarism checker.2Ans : Plagiarism is “copying and publication” of another author’s “language, thoughts, ideas, or expressions” and the representation of them as one’s own original work. Plagiarism is considered academic dishonesty and a breach of journalistic ethics.The software available for Plagiarism checker are:(i) DupliChecker (ii) Grammarly (iii) Paperrater (iv) Plagiarisma(1 mark for correct explanation of Plagiarism and 1 mark for two software)(2 mark for correct answer) e)List down some points about societal changes introduced by technology.2Ans : Technology is the application of scientific knowledge to the making of tools to solve specific problems. Technological advances such as automobiles, airplanes, radio, television, cellular phones, computers, modems, and fax machines have brought major advances and changes to the world. (2 mark for correct answer)f)What do you understand by Computer ethics? ORExplain the role of online social media campaigns, crowdsourcing and smart mobs in society.3Computer ethics are a set of moral principles that govern the behaviour of a group or an individual and regulate the use of computers. These include intellectual property rights (such as copyrighted electronic content), privacy concerns, and how computers affect our society. (3 mark for correct answer) ORRole of Social Media Campaigns:-A social media campaign should focus around a singular business goal, whether it's on Facebook or Instagram. Common goals for a social media campaigns include: Getting feedback from users. Building email marketing lists Increasing website trafficCrowdsourcing is the practice of engaging a ‘crowd’ or group for a common goal — often innovation, problem solving, or efficiency. It is powered by new technologies, social media and web 2.0. Crowdsourcing can take place on many different levels and across various industries.Smart mobs, so named because each person in the group uses technology to receive information on where to go and what to do. This ability to stay on top of current eventsmakes smart mobs extremely effective3 marks (1 mark for one correct role of social media campaign, 1 mark for one correct role of Crowdsourcing and 1 mark for one correct role of Smart mob)role of Crowdsourcing and 1 mark for one correct role of Smart mob) ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- natural selection as a cause and as explanation
- assignment no
- informatics practices new 065 class xii
- python class room diary be easy in my python class
- provisional agenda for the tenth to fifteenth
- list of tables national blood authority national blood
- home convention on biological diversity
- book excerpt brain on fire by susannah cahalan
Related searches
- take my online class reviews
- take my online class craigslist
- do my online class for me
- python class methods
- python class method cls
- python class static method
- python class and method examples
- python class static member
- python class method decorator
- python class str method
- python class documentation
- python class docstring