# CODE FOR ASSIGNMENTS 1 AND 2 BELOW! import pandas as pdASSIG.pdf

S

CODE FOR ASSIGNMENTS 1 AND 2 BELOW! import pandas as pd ASSIGNMENT 1: # perform the set difference of the two tables diff = pd.merge(A, B, on='Country', how='outer', indicator=True) diff = diff[diff['_merge'] == 'left_only'].drop('_merge', axis=1) # output the set difference table and the cardinality of the operation print(diff) print(f"Cardinality of A-B: {len(diff)}") import pandas as pd # perform the intersection of the two tables intersection = pd.merge(A, B, on='Founded') # output the intersection table and the cardinality of the operation print(intersection) print(f"Cardinality of AB: {len(intersection)}") import pandas as pd # filter the rows based on the condition C = A[A['Country'] == 'United States of America'] # write the filtered table to a new CSV file C.to_csv('organizations-C.csv', index=False) # output the filtered table and the cardinality of the operation print(C) print(f"Cardinality of the condition: {len(C)}") import pandas as pd # perform the union of the two tables union = pd.concat([A, B], axis=1) # output the union table and the cardinality of the operation print(union) print(f"Cardinality of AB: {len(union)}") ASSIGNMENT 2: import random # Generate two sets of five unique random integers between 11 and 99 X = set(random.sample(range(11, 100), 5)) Y = set(random.sample(range(11, 100), 5)) # Compute the product of X and Y product = set(x * y for x in X for y in Y) # Compute the absolute value of the product abs_product = abs(sum(product)) print("X:", X) print("Y:", Y) print("X*Y:", product) print("|X*Y|:", abs_product) def fibonacci(n): if n <= 1: return n else: return fibonacci(n-1) + fibonacci(n-2) #generate the sequence of fibonacci numbers starting with f5 to f10 for i in range(5, 11): print("f" + str(i) + ":", fibonacci(i)) import math def sinc(x): if x == 0: return 1 else: return math.sin(x) / x #to determine if the function is one-to-one, we can take the derivative of 'sinc(x)': def d_sinc(x): if x == 0: return 0 else: return (x * math.cos(x) - math.sin(x)) / (x**2) is_one_to_one = True for x in range(-5, 6): if d_sinc(x) == 0: is_one_to_one = False break elif d_sinc(x) < 0: is_one_to_one = False break if is_one_to_one: print("sinc(x) is one-to-one on [-5, 5]") else: print("sinc(x) is not one-to-one on [-5, 5]") #to determine if the function is increasing is_increasing = True for x in range(-5, 6): if d_sinc(x) < 0: is_increasing = False break if is_increasing: print("sinc(x) is increasing on [-5, 5]") else: print("sinc(x) is not increasing on [-5, 5]") #to determine if the function is onto sinc_values = set() for x in range(-5, 6): sinc_values.add(sinc(x)) if len(sinc_values) == 11: print("sinc(x) is onto on [-5, 5]") else: print("sinc(x) is not onto on [-5, 5]") #to determine if the is bijective is_one_to_one = True is_increasing = True sinc_values = set() for x in range(-5, 6): if d_sinc(x) == 0: print 1. Verify the programs you wrote for Assignment01 (the one with the files) \& Assignment02 and calculate thei.

## Recommandé

Python Programming par
Python Programming Sreedhar Chowdam
901 vues43 diapositives
Practicle 1.docx par
Practicle 1.docxGaneshPawar819187
82 vues22 diapositives
calculator_new (1).pdf par
calculator_new (1).pdfni30ji
8 vues28 diapositives
PRACTICAL FILE(COMP SC).pptx par
PRACTICAL FILE(COMP SC).pptxAbhinavGupta257043
9 vues12 diapositives
Programs.doc par
Programs.docArnabNath30
28 vues27 diapositives
AI-Programs.pdf par
AI-Programs.pdfArnabNath30
16 vues33 diapositives

## Similaire à CODE FOR ASSIGNMENTS 1 AND 2 BELOW! import pandas as pdASSIG.pdf

fds Practicle 1to 6 program.pdf par
fds Practicle 1to 6 program.pdfGaneshPawar819187
150 vues22 diapositives
Python programming workshop par
Python programming workshopBAINIDA
3.2K vues24 diapositives
#include iostream #include math.h using namespace std; flo.docx par
#include iostream #include math.h using namespace std; flo.docxajoy21
2 vues4 diapositives
D) What is the time complexity of the below program justify.pdf par
D) What is the time complexity of the below program justify.pdffairdeal00001
3 vues1 diapositive
PYTHON_PROGRAM(1-34).pdf par
PYTHON_PROGRAM(1-34).pdfNeeraj381934
18 vues12 diapositives
Practical File waale code.pdf par
Practical File waale code.pdfFriendsStationary
5 vues8 diapositives

### Similaire à CODE FOR ASSIGNMENTS 1 AND 2 BELOW! import pandas as pdASSIG.pdf(20)

Python programming workshop par BAINIDA
Python programming workshop
BAINIDA3.2K vues
#include iostream #include math.h using namespace std; flo.docx par ajoy21
#include iostream #include math.h using namespace std; flo.docx
ajoy212 vues
D) What is the time complexity of the below program justify.pdf par fairdeal00001
D) What is the time complexity of the below program justify.pdf
fairdeal000013 vues
Below is the code we used to produce the divided difference table. Ad.pdf par amanaharma262
Below is the code we used to produce the divided difference table. Ad.pdf
amanaharma2622 vues
import os import matplotlib-pyplot as plt import pandas as pd import r.docx par Blake0FxCampbelld
import os import matplotlib-pyplot as plt import pandas as pd import r.docx
Chapter 5 Balagurusamy Programming ANSI in c par BUBT
Chapter 5 Balagurusamy Programming ANSI in c
BUBT10.9K vues
Retos de Programación en Python par Javier Abadía
Retos de Programación en Python
TSP algorithm (Computational Thinking) Dropbox par Seb Sear
TSP algorithm (Computational Thinking) Dropbox
Seb Sear194 vues
Please determine all the bugs that exist in this program. You must a.pdf par amarnathmahajansport
Please determine all the bugs that exist in this program. You must a.pdf
python practicals-solution-2019-20-class-xii.pdf par rajatxyz
python practicals-solution-2019-20-class-xii.pdf
rajatxyz61 vues
Please provide a complete Python code with these provided co.pdf par mukulsingh0025
Please provide a complete Python code with these provided co.pdf
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers par Sheila Sinclair
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Sheila Sinclair13 vues
Scope Graphs: A fresh look at name binding in programming languages par Eelco Visser
Scope Graphs: A fresh look at name binding in programming languages
Eelco Visser779 vues
Scalapeno18 - Thinking Less with Scala par Daniel Sebban
Scalapeno18 - Thinking Less with Scala
Daniel Sebban400 vues
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx par SALU18
error 2.pdf101316, 6(46 PM01_errorPage 1 of 5http.docx
SALU184 vues

Codebaseimport numpy as npimport mathimport cvxpy as cpimpo.pdf par
Codebaseimport numpy as npimport mathimport cvxpy as cpimpo.pdfsecunderbadtirumalgi
15 vues4 diapositives
Como preliminar a la solicitud de estimaciones presupuestarias de ve.pdf par
Como preliminar a la solicitud de estimaciones presupuestarias de ve.pdfsecunderbadtirumalgi
2 vues1 diapositive
Como director general reci�n nombrado de Minnesota Micromotors, Inc..pdf par
3 vues1 diapositive
Como gerente de operaciones de Holz Furniture, debe tomar la decisi�.pdf par
Como gerente de operaciones de Holz Furniture, debe tomar la decisi�.pdfsecunderbadtirumalgi
30 vues1 diapositive
Como l�der de una empresa, desea que su empresa alcance un mayor niv.pdf par
Como l�der de una empresa, desea que su empresa alcance un mayor niv.pdfsecunderbadtirumalgi
2 vues1 diapositive
Como parte de la investigaci�n de su tesis, genera una biblioteca de.pdf par
Como parte de la investigaci�n de su tesis, genera una biblioteca de.pdfsecunderbadtirumalgi
2 vues1 diapositive

Codebaseimport numpy as npimport mathimport cvxpy as cpimpo.pdf par secunderbadtirumalgi
Codebaseimport numpy as npimport mathimport cvxpy as cpimpo.pdf
Como preliminar a la solicitud de estimaciones presupuestarias de ve.pdf par secunderbadtirumalgi
Como preliminar a la solicitud de estimaciones presupuestarias de ve.pdf
Como director general reci�n nombrado de Minnesota Micromotors, Inc..pdf
Como gerente de operaciones de Holz Furniture, debe tomar la decisi�.pdf par secunderbadtirumalgi
Como gerente de operaciones de Holz Furniture, debe tomar la decisi�.pdf
Como l�der de una empresa, desea que su empresa alcance un mayor niv.pdf par secunderbadtirumalgi
Como l�der de una empresa, desea que su empresa alcance un mayor niv.pdf
Como parte de la investigaci�n de su tesis, genera una biblioteca de.pdf par secunderbadtirumalgi
Como parte de la investigaci�n de su tesis, genera una biblioteca de.pdf
Como director ejecutivo de la empresa, su primera orden del d�a es d.pdf par secunderbadtirumalgi
Como director ejecutivo de la empresa, su primera orden del d�a es d.pdf
Como auditor, ha descubierto los siguientes problemas con el sistema.pdf par secunderbadtirumalgi
Como auditor, ha descubierto los siguientes problemas con el sistema.pdf
Como analista de Delta Airlines, se le pide que ayude al personal de.pdf par secunderbadtirumalgi
Como analista de Delta Airlines, se le pide que ayude al personal de.pdf
Como alcalde de Tropical Island, se enfrenta al doble mandato de pre.pdf par secunderbadtirumalgi
Como alcalde de Tropical Island, se enfrenta al doble mandato de pre.pdf
Commentators on the US economy feel the US economy fell into a reces.pdf par secunderbadtirumalgi
Commentators on the US economy feel the US economy fell into a reces.pdf
Comment on Target�s efforts to predict shopper behavior. Do you have.pdf par secunderbadtirumalgi
Comment on Target�s efforts to predict shopper behavior. Do you have.pdf
Coloque los eventos para explicar c�mo un bien p�blico llega a ser d.pdf par secunderbadtirumalgi
Coloque los eventos para explicar c�mo un bien p�blico llega a ser d.pdf
collective bargaining, as practised in contemporary labour relations.pdf par secunderbadtirumalgi
collective bargaining, as practised in contemporary labour relations.pdf
Colbert opera un servicio de catering en el m�todo de acumulaci�n. E.pdf par secunderbadtirumalgi
Colbert opera un servicio de catering en el m�todo de acumulaci�n. E.pdf
Colin est� tratando de decidir si debe hacer su contribuci�n a la cu.pdf par secunderbadtirumalgi
Colin est� tratando de decidir si debe hacer su contribuci�n a la cu.pdf
Coeficiente de variaci�nFabricaci�n de Metales ha aislado cuatro a.pdf
CODE THIS IN C# AND USE VISUAL STUDIOAdditional logic required by .pdf par secunderbadtirumalgi
CODE THIS IN C# AND USE VISUAL STUDIOAdditional logic required by .pdf
Code using Java Programming. Show your code and output.Create a pe.pdf par secunderbadtirumalgi
Code using Java Programming. Show your code and output.Create a pe.pdf

## Dernier

Research Methodology (M. Pharm, IIIrd Sem.)_UNIT_IV_CPCSEA Guidelines for Lab... par
Research Methodology (M. Pharm, IIIrd Sem.)_UNIT_IV_CPCSEA Guidelines for Lab...RAHUL PAL
53 vues26 diapositives
Interaction of microorganisms with vascular plants.pptx par
Interaction of microorganisms with vascular plants.pptxMicrobiologyMicro
77 vues33 diapositives
Gross Anatomy of the Liver par
Gross Anatomy of the Liverobaje godwin sunday
267 vues12 diapositives
JRN 362 - Lecture Twenty-Two par
JRN 362 - Lecture Twenty-TwoRich Hanley
41 vues157 diapositives
Presentation_NC_Future now 2006.pdf par
Presentation_NC_Future now 2006.pdfLora
38 vues74 diapositives
Education of marginalized and socially disadvantages segments.pptx par
Education of marginalized and socially disadvantages segments.pptxGarimaBhati5
59 vues36 diapositives

### Dernier(20)

Research Methodology (M. Pharm, IIIrd Sem.)_UNIT_IV_CPCSEA Guidelines for Lab... par RAHUL PAL
Research Methodology (M. Pharm, IIIrd Sem.)_UNIT_IV_CPCSEA Guidelines for Lab...
RAHUL PAL53 vues
Interaction of microorganisms with vascular plants.pptx par MicrobiologyMicro
Interaction of microorganisms with vascular plants.pptx
JRN 362 - Lecture Twenty-Two par Rich Hanley
JRN 362 - Lecture Twenty-Two
Rich Hanley41 vues
Presentation_NC_Future now 2006.pdf par Lora
Presentation_NC_Future now 2006.pdf
Lora 38 vues
Education of marginalized and socially disadvantages segments.pptx par GarimaBhati5
Education of marginalized and socially disadvantages segments.pptx
GarimaBhati559 vues
UNIT NO 13 ORGANISMS AND POPULATION.pptx par Madhuri Bhande
UNIT NO 13 ORGANISMS AND POPULATION.pptx
Guess Papers ADC 1, Karachi University par Khalid Aziz
Guess Papers ADC 1, Karachi University
Khalid Aziz119 vues
Guidelines & Identification of Early Sepsis DR. NN CHAVAN 02122023.pptx par Niranjan Chavan
Guidelines & Identification of Early Sepsis DR. NN CHAVAN 02122023.pptx
Niranjan Chavan48 vues
Creative Restart 2023: Christophe Wechsler - From the Inside Out: Cultivating... par Taste
Creative Restart 2023: Christophe Wechsler - From the Inside Out: Cultivating...
Taste39 vues
Payment Integration using Braintree Connector | MuleSoft Mysore Meetup #37 par MysoreMuleSoftMeetup
Payment Integration using Braintree Connector | MuleSoft Mysore Meetup #37
What is Digital Transformation? par Mark Brown
What is Digital Transformation?
Mark Brown56 vues
JRN 362 - Lecture Twenty-Three (Epilogue) par Rich Hanley
JRN 362 - Lecture Twenty-Three (Epilogue)
Rich Hanley46 vues
Peripheral artery diseases by Dr. Garvit.pptx par garvitnanecha
Peripheral artery diseases by Dr. Garvit.pptx
garvitnanecha147 vues

### CODE FOR ASSIGNMENTS 1 AND 2 BELOW! import pandas as pdASSIG.pdf

• 1. CODE FOR ASSIGNMENTS 1 AND 2 BELOW! import pandas as pd ASSIGNMENT 1: # perform the set difference of the two tables diff = pd.merge(A, B, on='Country', how='outer', indicator=True) diff = diff[diff['_merge'] == 'left_only'].drop('_merge', axis=1) # output the set difference table and the cardinality of the operation print(diff) print(f"Cardinality of A-B: {len(diff)}") import pandas as pd # perform the intersection of the two tables intersection = pd.merge(A, B, on='Founded') # output the intersection table and the cardinality of the operation print(intersection) print(f"Cardinality of AB: {len(intersection)}") import pandas as pd # filter the rows based on the condition C = A[A['Country'] == 'United States of America'] # write the filtered table to a new CSV file C.to_csv('organizations-C.csv', index=False) # output the filtered table and the cardinality of the operation print(C) print(f"Cardinality of the condition: {len(C)}") import pandas as pd # perform the union of the two tables union = pd.concat([A, B], axis=1) # output the union table and the cardinality of the operation print(union) print(f"Cardinality of AB: {len(union)}") ASSIGNMENT 2: import random # Generate two sets of five unique random integers between 11 and 99
• 2. X = set(random.sample(range(11, 100), 5)) Y = set(random.sample(range(11, 100), 5)) # Compute the product of X and Y product = set(x * y for x in X for y in Y) # Compute the absolute value of the product abs_product = abs(sum(product)) print("X:", X) print("Y:", Y) print("X*Y:", product) print("|X*Y|:", abs_product) def fibonacci(n): if n <= 1: return n else: return fibonacci(n-1) + fibonacci(n-2) #generate the sequence of fibonacci numbers starting with f5 to f10 for i in range(5, 11): print("f" + str(i) + ":", fibonacci(i)) import math def sinc(x): if x == 0: return 1 else: return math.sin(x) / x #to determine if the function is one-to-one, we can take the derivative of 'sinc(x)': def d_sinc(x): if x == 0: return 0 else: return (x * math.cos(x) - math.sin(x)) / (x**2) is_one_to_one = True for x in range(-5, 6): if d_sinc(x) == 0: is_one_to_one = False break
• 3. elif d_sinc(x) < 0: is_one_to_one = False break if is_one_to_one: print("sinc(x) is one-to-one on [-5, 5]") else: print("sinc(x) is not one-to-one on [-5, 5]") #to determine if the function is increasing is_increasing = True for x in range(-5, 6): if d_sinc(x) < 0: is_increasing = False break if is_increasing: print("sinc(x) is increasing on [-5, 5]") else: print("sinc(x) is not increasing on [-5, 5]") #to determine if the function is onto sinc_values = set() for x in range(-5, 6): sinc_values.add(sinc(x)) if len(sinc_values) == 11: print("sinc(x) is onto on [-5, 5]") else: print("sinc(x) is not onto on [-5, 5]") #to determine if the is bijective is_one_to_one = True is_increasing = True sinc_values = set() for x in range(-5, 6): if d_sinc(x) == 0: print 1. Verify the programs you wrote for Assignment01 (the one with the files) & Assignment02 and calculate their O notation in this assignment. Is there any way to improve
• 4. their O notation? How and by how much? (no need to recode them, just explain and provide an O order). Explain your results and your reasoning.
Langue couranteEnglish
Español
Portugues
Français
Deutsche