Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
Python_SEE/debug_exam.py at main · kavyashreeD/Python_SEE · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
kavyashreeD
Python_SEE
Repository navigation
Code
Issues
Pull requests
3
(3)
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
Python_SEE
/
debug_exam.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
114 lines (104 loc) · 3.05 KB
main
Breadcrumbs
Python_SEE
/
debug_exam.py
Copy path
Top
File metadata and controls
Code
Blame
114 lines (104 loc) · 3.05 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
'''
This function takes two arguments,
data1 and data2, which contain
key-value pairs. All key-value
pairs within data1 are unique.
Similarly, all key-value pairs
within data2 are unique. However,
there may be key-value pairs (k, v1)
in data1 and (k, v2) in data2 with a
common key k. In this case, v1 and
v2 may be the same, or v1 and v2 may
be different.
This function should modify only
data1 and return a (possibly empty)
dictionary as follows:
For every key-value pair (k, v2) in
data2, if no key-value pair with key
k exists in data1, then the pair
(k, v2) should be added to data1.
Otherwise, there is a unique pair
(k, v1) already in data1. If v1 and
v2 are different, the pair (k, v1)
should be removed from data1 and the
key-value pair (k, [v1, v2]) should
be added to the (initially empty)
dictionary to be returned.
In this implementation, data1 is a
dictionary and data2 is a list where
each key-value pair in data2 is also
a list [key, value] of length 2.
'''
def
uniqueUpdate
(
data1
,
data2
):
# Initially empty dictionary
dupKeys
=
{}
# Examine every (k, v2) pair in data2
for
[
k
,
v2
]
in
data2
:
# Check if there is a key-value
# pair with key = k in data1
if
k
in
data1
:
v1
=
data1
[
k
]
# (k, v1) in dict1
# Check if v1 != v2
if
v1
!=
v2
:
# Add (k, [v1, v2])
# to dictionary
dupKeys
[
k
]
=
[
v1
,
v2
]
# Remove (k, v1) from data1
del
data1
[
k
]
else
:
# Add (k, v2) to data1
data1
[
k
]
=
v2
# After processing all (k, v2) in
# data2, return the dictionary
return
dupKeys
'''
Visualize this function on an example:
https://tinyurl.com/...
'''
## DO NOT MODIFY BELOW THIS LINE! ##
'''
This part of the code reads input in
the following format:
Line 1: A positive integer n1
representing the number of key value
pairs in data1
Lines 2 to n1+1: Two integers k v
per line representing the key and
value (these n1 key value pairs are
added to data1)
Line n1+2: A positive integer n2
representing the number of key value
pairs in data2
Lines n1+3 to n1+n2+2: Two integers
k and v per line representing the
key and value (these n2 key value
pairs are added to data2)
This also prints the output in the
following format after calling the
uniqueUpdate function:
data1
data2 (should remain the same)
dup (the dictionary returned)
'''
import
sys
if
__name__
==
'__main__'
:
data1
=
{}
n1
=
int
(
input
())
for
_
in
range
(
n1
):
k
,
v
=
map
(
int
,
input
().
split
())
if
k
in
data1
:
sys
.
exit
(
"Illegal: data1"
)
data1
[
k
]
=
v
data2
=
[]
n2
=
int
(
input
())
for
_
in
range
(
n2
):
k
,
v
=
map
(
int
,
input
().
split
())
for
[
k2
,
v2
]
in
data2
:
if
k2
==
k
:
sys
.
exit
(
"Illegal: data2"
)
data2
.
append
([
k
,
v
])
dup
=
uniqueUpdate
(
data1
,
data2
)
print
(
data1
)
print
(
data2
)
print
(
dup
)
You can’t perform that action at this time.