Skip to main content
deleted 51 characters in body
Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661

Python1 line, 180 173 171 bytes

7 bytes saved thanks to Jonathan Allen

exec("x={}\n"+"if x.get(a:=input('Enter subject: ')[:3].upper(),b:=int(input('Enter marks: ')))<=b:x[a]=b\n"*int(input("Enter number of tuples: "))+"print((*x.items(),))")

Attempt This Online!

Python3 lines, 171 163 160 bytes

8 bytes saved thanks to Jonathan Allen

x,i,e={},input,'Enter '
exec("if x.get(a:=i(e+'subject: ')[:3].upper(),b:=int(i(e+'marks: ')))<=b:x[a]=b\n"*int(i(e+"number of tuples: ")))
print((*x.items(),))

Attempt This Online!

Here's another approach that yields fewer bytes. It can be done in 1, 2 or 3 lines, with more lines enabling shorter overall programs. There's probably still even some improvements to be made here.

Python, 180 173 171 bytes

7 bytes saved thanks to Jonathan Allen

exec("x={}\n"+"if x.get(a:=input('Enter subject: ')[:3].upper(),b:=int(input('Enter marks: ')))<=b:x[a]=b\n"*int(input("Enter number of tuples: "))+"print((*x.items(),))")

Attempt This Online!

Python, 171 163 160 bytes

8 bytes saved thanks to Jonathan Allen

x,i,e={},input,'Enter '
exec("if x.get(a:=i(e+'subject: ')[:3].upper(),b:=int(i(e+'marks: ')))<=b:x[a]=b\n"*int(i(e+"number of tuples: ")))
print((*x.items(),))

Attempt This Online!

Here's another approach that yields fewer bytes. It can be done in 1, 2 or 3 lines, with more lines enabling shorter overall programs. There's probably still even some improvements to be made here.

1 line, 180 173 171 bytes

7 bytes saved thanks to Jonathan Allen

exec("x={}\n"+"if x.get(a:=input('Enter subject: ')[:3].upper(),b:=int(input('Enter marks: ')))<=b:x[a]=b\n"*int(input("Enter number of tuples: "))+"print((*x.items(),))")

Attempt This Online!

3 lines, 171 163 160 bytes

8 bytes saved thanks to Jonathan Allen

x,i,e={},input,'Enter '
exec("if x.get(a:=i(e+'subject: ')[:3].upper(),b:=int(i(e+'marks: ')))<=b:x[a]=b\n"*int(i(e+"number of tuples: ")))
print((*x.items(),))

Attempt This Online!

Here's another approach that yields fewer bytes. It can be done in 1, 2 or 3 lines, with more lines enabling shorter overall programs. There's probably still even some improvements to be made here.

added 541 characters in body
Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661

1 linePython, 180180 173 171 bytes

7 bytes saved thanks to Jonathan Allen

exec("x={};"+"a=input\n"+"if x.get(a:=input('Enter subject: ')[:3].upper();b=int,b:=int(input('Enter marks: '))\nif a not in x or x[a]<b)<=b:x[a]=b\n"*int(input("Enter number of tuples: "))+"print((*x.items(),))")

Attempt This Online!Attempt This Online!

3 linesPython, 171171 163 160 bytes

8 bytes saved thanks to Jonathan Allen

x,i=i,e={},input,'Enter '
exec("a=i('Enter"if subjectx.get(a:=i(e+'subject: ')[:3].upper();b=int,b:=int(i('Enter markse+'marks: '))\nif a not in x or x[a]<b)<=b:x[a]=b\n"*int(i("Enter numbere+"number of tuples: ")))
print((*x.items(),))

Attempt This Online!Attempt This Online!

Here's another approach that yields fewer bytes. It can be done in 1, 2 or 3 lines, with more lines enabling shorter overall programs. There's probably still even some improvements to be made here.

1 line, 180 bytes

exec("x={};"+"a=input('Enter subject: ')[:3].upper();b=int(input('Enter marks: '))\nif a not in x or x[a]<b:x[a]=b\n"*int(input("Enter number of tuples: "))+"print((*x.items(),))")

Attempt This Online!

3 lines, 171 bytes

x,i={},input
exec("a=i('Enter subject: ')[:3].upper();b=int(i('Enter marks: '))\nif a not in x or x[a]<b:x[a]=b\n"*int(i("Enter number of tuples: ")))
print((*x.items(),))

Attempt This Online!

Here's another approach that yields fewer bytes. It can be done in 1, 2 or 3 lines, with more lines enabling shorter overall programs. There's probably still even some improvements to be made here.

Python, 180 173 171 bytes

7 bytes saved thanks to Jonathan Allen

exec("x={}\n"+"if x.get(a:=input('Enter subject: ')[:3].upper(),b:=int(input('Enter marks: ')))<=b:x[a]=b\n"*int(input("Enter number of tuples: "))+"print((*x.items(),))")

Attempt This Online!

Python, 171 163 160 bytes

8 bytes saved thanks to Jonathan Allen

x,i,e={},input,'Enter '
exec("if x.get(a:=i(e+'subject: ')[:3].upper(),b:=int(i(e+'marks: ')))<=b:x[a]=b\n"*int(i(e+"number of tuples: ")))
print((*x.items(),))

Attempt This Online!

Here's another approach that yields fewer bytes. It can be done in 1, 2 or 3 lines, with more lines enabling shorter overall programs. There's probably still even some improvements to be made here.

Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661

1 line, 180 bytes

exec("x={};"+"a=input('Enter subject: ')[:3].upper();b=int(input('Enter marks: '))\nif a not in x or x[a]<b:x[a]=b\n"*int(input("Enter number of tuples: "))+"print((*x.items(),))")

Attempt This Online!

3 lines, 171 bytes

x,i={},input
exec("a=i('Enter subject: ')[:3].upper();b=int(i('Enter marks: '))\nif a not in x or x[a]<b:x[a]=b\n"*int(i("Enter number of tuples: ")))
print((*x.items(),))

Attempt This Online!

Here's another approach that yields fewer bytes. It can be done in 1, 2 or 3 lines, with more lines enabling shorter overall programs. There's probably still even some improvements to be made here.