You are on page 1of 12
1MCA-B PYTHON Programming 26-07-2022(Tuesday 11-1PM) Regular lab Questions-Practice Instructions: Answer minimum of one question. These are Practice exercises and mandatory submissions within 01:00PM. You need to upload your .py file and word file with the screenshot of the output as an image, all test cases should be covered. You are discouraged from using search engines for obtaining code. Alternating can use any cheat sheet for developing your code. Meter to foot conversion. Conversion of kilometers to miles ‘The three sides of a triangle are 3, 4 and 6m, respectively. What is its area? asks the user for an integer, and then displays the number of digits in the integer, and the logarithm of the integer. 5. John deposited an initial sum of Rs.3000 in his account. After 3 years, the balance reaches Rs.3335.8 due to composite interest. What is the interest rate per annual? 6. Write a program that prints the following sequence of numbers: 7. 1,-1/3,1/5,... (-1)*1/(2i- 1), where iis user ‘input. 8. Design a program to extract digits from the given integer. Find the sum of odd positioned and even positioned digits and identify the biggest among them. For example, if the input is 78345, its position is taken as given below: the sum of odd positioned digit is 7+3+5=15 and even positioned digit is 8+4=12 eeNe 7 8 3 a 5 Number 5 4 3 2 i position 9. An electric power distribution company charges its domestic consumers as follows: ‘Consumption Units Rates of Charge 0-200 Rs. 0.5 per unit 201-400 Rs. 100 plus Rs. 0.65 per unit excess of 200 401-600 Rs. 230 plus Rs.0.80 per unit excess of 400 601 and above Rs.390 plus Rs. 1.00 per unit excess of 600, Read the customer number and power consumed and prints the amount to be paid by the customer. 10, Read Employee Id, Experience and Basic Salary and Job ID. IfJob Id is 1 then DA is 45% of the basic salary and HRA is Rs. 5500. If Job Id is 2 then DA is 40% of the basic salary and HRA is Rs. 4500. For all the other Job ids DA is 35% of the basic salary and HRA is Rs. 3500. For all the above Job ids PF to be deducted is 4%. For the job ids 1&2 Rs. 100 to be deducted as Professional Tax. Calculate the net pay. NOTE: Netpay==basic salary + Allowances-deductions Allowances=DA+HRA Deductions=PF+Professional tax Instructions: 1MCA-B PYTHON Programming 02-08-2022(Tuesday 11-1PM) Q1-Regular lab Questions-List &String Answer ALL questions. These exercises are mandatory to submit within 01:00PM. You need to upload your .py file and word file with the screenshot of the output as an image, all test cases should be covered. You are discouraged from using search engines for obtaining code. Alternating can use any cheat sheet for developing your code. 1 2 6. write a python program to find the frequency of every word in the given paragraph. Write a program to compute the number of characters, words and given paragraph Write a python program to find whether the given string is in alphabetical order or not (return true ifthe input string is in alphabetical order else return false) Write a python program to encrypt given string using the following method: Encrypt Method: Add a number ‘n’(given by the user ) to each alphabet in the given string to create the corresponding letter. Example: Input: bat Encrypt Method:value of n = 3 Outputzedu. Given the list of CGPA of students CGPA=[9,7,6,5,10,3,9,6,6,4] Write: a) An expression that evaluates to the number of 6 CGPA b) A statement that changes the last CGPA to 3 ©) An expression that evaluates to the maximum CGPA d) A statement that sorts the list CGPA e) An expression that evaluates to the average CGPA es in the 1MCA-B PYTHON Programming. 05-08-2022(Friday 2PM-4PM) Q2-Regular lab Questions-List &Function Instructions: Answer ALL questions. These exercises are mandatory to submit within 04:00PM. You need to upload your .py file and word file with the screenshot of the output as an image, all test cases should be covered. You are discouraged from using search engines for obtaining code, Alternating can use any cheat sheet for developing your code. 1. Writea “Python” program to code signup page requires to input name and a password. But the password must be strong. The password is consider to be strong if't satisfies the given criteria: © Its length is atleast 8. + Itcontains at least one digit. (0123456789) + Itcontains at least one lowercase English alphabet. (abcdefghijkimnopqrstuvwxyz) © Itcontains at least one uppercase English alphabet. (ABCDEFGHIJKLMNOPQRSTUVWXYZ) © Itcontains at least one valid special character. The valid special characters are: 1@#S%"*R* ‘Type a random string of length in the password field and check if entered password is strong and if not suggest a good password. Write a python script which accepts the password as input and checks if it is strong or not. If it is strong print the following statement "Secure Password! Go Ahead and Register.” Else suggest a strong password. You need to use lambda functions for checking if the password is strong or not and also to create a strong password. Note: When input is a weak password print new password every time you run the script. 2, Write a PYTHON script with List comprehension for the following + _ Isgiven listis divisible by 3 or NOT? ‘+ Display multiplication table of 15 ‘+ Square of even numbers ina list Sum of digits of all EVEN numbers in a list Remove duplicate numbers in alist AMCA-B PYTHON Programming 12-08-2022(Friday 2PM-4PM) Q3-Regular lab Questions-Tupple & Set Instructions: Answer ALL questions. These exereises are mandatory to submit within 4:00PM. You need to ‘plosd your py file and word fle with the screenshot ofthe output aan image al test eases should be covered. You are discouraged from using search engines for obtaining code ‘Alternating can use any cheat sheet for developing your code. 4. Given ast tuples that represents houses for rent, the number of bedrooms and ther ees, kes: [mains 44000), (elm st, 11200) (pine st’, 2, 1600], Sort the list in the folowing ways: ‘alascending order by number of rooms ‘binascending order of price ‘lnascending order of prce-per-oom 2. Implement a function pay() that takes as input two arguments: an hourly wage andthe numberof hours an employee worked last week. Your function should compute and return the employe’ py. Any hours worked beyond 40 is overtime an shouldbe paid 1S times the regular hourly wage. >>> pay(1035) 350 >>>pay(1045) 4780 22 You sometimes binge-wateh series and recently you watched “Seam 1992" in SonyLV. ‘You were fascinated by the main character and also find stock market trading Interesting. Asa “Python Gur’, you want to write a python sript for helping a stock broker in his day-to-day activity. You encounter the following problem and write a solution to tuple: He understands the instructions and completes the trading but finds dificult to ‘help the stock broker by printing tas a string. Consider the explanation and folowing Ingut is atuple whic contain tuples as elements Each element in the tuple will have Company initial, quantity, pic, status where status ‘sbuytb)orsells) ‘the inp is (ABC 300,453.07" (¥2"120298.5"5"ASD"2945.5,5",QWE" 16023, 76) utpu wil be Itinput is empty tuple print “Buys: 0 Selko Itheinput is nots per format equled for example (s0F 20045 prin “nvalid input” Note:The stockbrokers quite busy throughout the day so ran the program to accept input teratvey til the broker says am gonna elit right” 4 Wistea Python program to Create two sts AB and perform the follwing ‘print only unique items fom two sets print aset of elements present in Set Aor B, but not both ‘riot common elements rom two sets ‘Update set by adding items fom setA except common tems AMCAE PYTHON Programmi 16-08-2022( Tuesday 1TAM-1PM) 04- Regular lab Questions- Dictionary & Custom Module upoal your py fe and output wih al test cases ofall questions a5 aut le You are ‘scouraged trom using search engines for obaining code Aerating can we any chet sheet for developing your code 1. Write a function bitkDste( that takes the fll name of famous erick players (2 sting) and thir Wrthdtes, You sould wee thi dctionry to tre the tame of ach player ( Via Kobi. 5 November 1989; "Imesh Yadav 25 Ober 1987; ‘Maneh Pandey 10 September 1907, "Hoh Sharm 30 Apel 1987, "Ravindr Jads'6 December 1986, Mardi Fandy'11 October 1998") >birhDateRoit Sharma} 2, Whe a uncon, sp). whlch takes a srg armen representing apiece of tex and returns adobe representing the sentences in the et The keys othe de are Scaence nies, starting rom 1 For eample Thought new ata or $3.5 The medel was recommended by my fend Dr. Sai ke ‘sfunewonalites bt found ta the same model sl for ony $2.83 amon cam, Lessons Irae? is worth checking oline pies belore shopping” spins} ‘ 1 ought a ew apap for $35", 2-The medal war eevommended by my fend, De. Seith” 3°71 the ite fancinaitin, but Found that the same medel i sold fr only $20 at 51s worth checking online pies etre soppia") MineToere are thre boundary punctuation, 7,7: However, ambigus exist in many ‘aes For example "is pial a setence boundary marker when flowed by a space bit Spell ers Suc as ‘Dealsendswi-As a esl no program can perfec handle al eases Try tomake the function work inmost stations 2. (a). You tke using QR code wher ever you can you have QR ends an T-Shir app sir, ‘nyour LinkedIn profil Now you would ike te cdetnpyton - using QR code ‘Wate Rincon "EncodaQ wich takes int ving oda mest 7 chaacers with nium of one eer and etn ack is containing encod QR cde Ae alee 72, Binary conversion 972 1201001000 ath the fret charactor ‘pad wih 19000000 she encoded coe fe e¥000000001001000 scl vais 108.Bhary conversion of 105 f 1101001 andes i second character edith 01000000 othe encoded cae for 1s 0100000001101001 helena a the encoded strings rater than 70 append wth 0 Uselambéa functions wherever you tn Kappreprate (8) Puce stove fonction ina mde and use another srg fllthe incon inthe sp MCAI71 Python Programming CAT 1 Date:19/08/2022 Time 2PM 3.30PM. |. Writea function called “decode” which pass an argument “seeret.code” (String datatype). The “seereL.code” ts as the name secret, It contains words and ‘numbers in between them, the function “decode” will order the words depending fn the numbers and print the secret message. Consier the following example and run your progam forthe given test eases, "thls damn erty 12, the function decode( wl print >this is Test eae 1 secret code="informa7tion Metet SaturdSay a2fo6r ot cate" the Function decode) wil print->"Met at cafe on Saturday for information Test case2: secret code-"ao6t exerc2ise Thils 14 wilt suctks eod7de’, the function ‘decode) will print->" This exercee sucks Iwill not code’ Test case secret code ="tIhis ets any 12", the function decode() will print->"this is Test ease 4 seret code ="go7there'Is antes 2a the w6e thaSt the function decade() will Drint->"Here’s tothe ones that we got Test ease s serelcode =" O1khe7re 13 happening o2k sede wha’ the funtion decede() ‘nil pent >" Ok ok see what's happening here 2 You are doing a part tine job asa “boxoffice cer sells movie Ueket). Anew movie has released andthe tickets priced R250 There is a lang ine of people to buy tiekets and they have Rs.250.Rs500 or Rs 1000, Intally you donot have ‘ny money and you want to sell tickets to all giving change wherever requited Wate a finction which acepts a lst containing the money people have and return “True” If you can sel tickets to all of them else false. The below example ‘il explain i better: Taput=[250250,500) (Output-True As you have change of250 to give itto the 3 person) Use the following test cases Output= True Upload single python script for both questions. ‘Upload a single output txt with all test cases as single le for both questions, [Name the ies as relsternumber-CAT py, registermumber.CAT¢xt Yu are bound by the code of ethics and discipline, do adhere to Forany claricaton contact your evaluator. Rubries- Total marks 20, Python Code appropriate use of concepts ~ 6 marks each question (646=12Marks) Test inputs I mare each (5¥3-Bmarks) 1MCA-B PYTHON Programming 25-08-2022(Tuesday 11AM-1PM) Q5- Classes and Object Instructions: Answer ALL questions. These exercises are mandatory to submit within 01:00PM. You need to upload your py file and output with all test cases as a xt file. You are discouraged from using search engines for obtaining code. Alternating can use any cheat sheet for developing your code. ‘You are crazy about various automobiles. Today is The Day you can write python program on automobiles!!! Create a class called “Vehicle” which has attributes brand, model, type, fuel_tank_size, fuel level. Initialize the variables in the” init_" method and write the following methods Fulltank()- which fills the entire tank and prints “Tank Is Full” Update_fuel_tank()- which updates the amount of fuel which is in the tank. You can pass avariable called “new level” and assign that to fuel level. Print a warning ifthe fuel_level is <=3liters. Got_fuel() - which takes in a variable “amount” and add it to fuel level. Print warning if the fuel_level is exceeding the capacity of the tank. Drive() - which prints a message saying “WOW! I am Driving {model}". The model is the vehicle should be inserted instead of “{model}” Create two objects of vehicles and call the functions. . Implement the concept of Inheritance and Polymorphism. 1MCA-B PYTHON Programming 26-08-2022(Friday 2PM-4PM) Q6- Exceptional Handling & re Module Instructions: Answer ALL questions. These exercises are mandatory to submit within 01:00PM. You need to upload your .py file and output with all test cases as a .txt file. You are discouraged from using search engines for obtaining code. Alternating can use any cheat sheet for developing your code. Write a program which accepts as input a DOB in the format “dd/mm/yyyy “and prints AGE of the person. Validate the input using Exceptional Handling ‘+ Ifno inputs given, prompt user to enter input ‘+ If"?" is typed help the user by telling him/her to enter Data of Birth in the required format If date is entered validate the correctness of the date and print AGE fq” or “Q’ is entered invoke a user defined exception which quits the program after printing “Bye! Hope you run this program again’ Note: Mandatory to use “re” module in following questions. 1. Write a function “MyScottishAccent” which takes in a string and replaces every ‘occurrence of “0” with “u", Example: MyScottishAccent(“hello python coders")->"hellu pythun cuders” MyScottishAccent("“computer nerd”)->"cumputer nerd” 2. Write a function called “LonelyOne” which returns the number of “1's" which are lonely. Lis lonely if it is not immediately followed by another 1.See the example for better understanding of “lonely”. Example: LonelyOne(101)-> 2 (*1" is lonely twice) LonelyOne(1111)->0 LonelyOne(444}->0 ‘ou can take the input as a string also 1MCA-B PYTHON Programming 30-08-2022(Tuesday 11PM-1PM) Q7-NumPy-Basic Instructions: Answer ALL questions. These exercises are mandatory to submit within 01:00PM. You need to upload your .py file and output with all test cases as a .txt file. You are discouraged from using search engines for obtaining code. Alternating can use any cheat sheet for developing your code. 2 Consider two matrices A and Bas 21 34 4 [ 1 Bs [ | 9 Bana - Find (DA‘B (li) A-B (i) 34 (iv) -28 Construct a null matrix of order 3*3. Construct an identity matrix of order 3°3. Write a Python Script to create a structured array from the given details. Name = (‘namet’, ‘name2’, ‘name3', ‘name’, ‘name5") Score = (10, 20, 30, 40, 50) Attempts: Qualify = (‘yes’, ‘no’, ‘y Find Structure of the created array Extract column2 and 3 and assign as array Extract some data using Fancy Indexing and assign as array Find the any 10 statistical summary of score using aggregated functions. 1MCA-B PYTHON Programming 06-09-2022(Tuesday 11PM-1PM) Q8- NumPy-Part2 Instructions: Answer ALL questions. These exercises are mandatory to submit within 01:00PM. You need to upload your .py file and output with all test cases as a xt file. You are discouraged from using search engines for obtaining code. Alternating can use any cheat sheet for developing your code. Write a Python code and give your interpretation with respect to given question and corresponding output. 1 Import the given "Mortality.csv" file using panda and do the following using NumPy a) Create Structured Array of Mortality b) How many variables and observation does the dataset have? ©) select the following A. Allows and first three columns B. First 10 rows and all columns C. 10to15 rows of first and 4th column D. Observation of Sth row 2nd column d) Find Structure of the created array e) Extract column? and 3 and assign as array 1) Find any 10 statistical summary using aggregation functions ) How many different Blood groups are there in dataset? h) List the unique SMOKE categories. i) How many had cholesterol level above 300? {) What is the mean height value for mortality is alive? k) Find the age of tallest 0-Blood Group person. 1) How many nonsmokers are alive who are below 40 years 1MCA-B PYTHON Programming 09-09-2022(Friday 2PM-4PM) Q9- Panda & matplotlib Instructions: Answer ALL questions. These exercises are mandatory to submit within 04:00PM. You need to upload your .py file and output with all test cases as a .txt file. You are discouraged from using search engines for obtaining code. Alternating can use any cheat sheet for developing your code. 1 Import the given "Mortality.csv" file as a dataframe and do the following using panda a) How many variables and observation does the dataset have? b) select the following A. Allows and first three columns B. First 10 rows and all columns C. 10 to 15 rows of first and 4th column D. Observation of Sth row 2nd column ©) Find Structure of the created data frame d) Extract column? and 3 and assign as data frame ¢) Find the any 10 statistical summary using aggregated functions ) How many different Blood groups are there in dataset? g) List the unique SMOKE categories. h) How many had cholesterol level above 300? i) What is the mean height value for mortality is alive? ) Find the age of tallest 0-Blood Group person. k) How many nonsmokers are alive who are below 40 years 2. Draw any 4 graph (Line, Pie, Scatter, Bar, Histogram, violin, etc.) using suitable variables and give your inferences with respect to dataset. 1MCA-B PYTHON Programming 20-09-2022(Tuesday 11AM-1PM) 10- GUI using TKinter Instructions: Answer ALL questions. This exercise is mandatory to submit within 01:00PM. You need to upload your .py file and output screenshot of all Ul test cases as a doc file. You are discouraged from using search engines for obtaining code. Alternating can use any cheat sheet for developing your code. Create an app using TKinter and Python for Shopping Mall Authority to collect parking fee. The Fee collector standing in the parking exit and uses this application. For each type of vehicle, the amount to be collected is fixed by the Authority. Based on the vehicle type and number of Hours parked entered by the fee collector the paid amount will be calculated. Extra Credit: Help the fee collector to know the total money collected in the parking by displaying on the down right comer or in message box. ‘Two Wheeler - Rs 100/- per Hour Four Wheeler - Rs 200/- per Hour

You might also like