code stringlengths 1 1.72M | language stringclasses 1
value |
|---|---|
x = (1,3)
print {x:'OK'}[x]
| Python |
import sys
print [x.replace("\\", "/") for x in sys.argv]
| Python |
# Test behaviour of min() and max() on lists and tuples
l = ['b','a','d','c']
m = ['1','0','4','3']
print l
print m
print min(l), max(l)
print min(m), max(m)
print min(l,m), max(l,m)
t = tuple(l)
u = tuple(m)
print t
print min(t), max(t)
print min(u), max(u)
print min(t,u), max(t,u)
| Python |
a = [1,2,3,4,5,6]
b = [9,10,11]
a[::2] = b
print a
| Python |
def loc(): pass
def gbl(): pass
def free(): pass
def cell(): pass
def gen(): pass
def true(): pass
def var(): pass
def volatile(): pass
def package():
loc = 4
gbl = 42
cell = 19
instanceof = gbl * cell
static = instanceof
print loc, gbl, cell, instanceof, static
print true == var
print ... | Python |
print "aa..bbb...ccc".replace("..", "X")
| Python |
class X:
def __init__(self):
print "wee"
x = X()
print repr(x)
| Python |
a = [1,2,3,4,5]
print a[::-1]
| Python |
s = set([1,2,3])
t = set([3,4,5])
s.symmetric_difference_update(t)
t.symmetric_difference_update(s)
print s
print s == t
print s == set([1,2,4,5])
print s == set([1,2,3])
| Python |
x = {"hi": "there", "yo": "I'm a dawg"}
print x.items()
print x.keys()
print x.values()
| Python |
def x():
y = lambda x,y,z: x*y+z
print y(5, 10, 15)
x()
| Python |
print [y for x in range(10) for y in range(x)]
| Python |
def f():
a = "dog"
print "f", a
def g():
a = "cat"
print "g", a
g()
print "f2", a
def h():
print "h",a
h()
f()
| Python |
v = [3,2,1]
v.sort()
print v[0]
| Python |
def yrange(n):
for i in range(n):
yield i
def zrange(n):
for y in yrange(n):
yield y
print list(zrange(5))
| Python |
def test(): pass
x = 1
print test()
| Python |
# Test the comparison of sets
l = [1,2,3,4,1,1]
print l
s = set(l)
print s
print '# equal'
eq = set(l)
print eq
print '# forwards'
print s.isdisjoint(eq)
print s > eq
print s.issuperset(eq)
print s >= eq
print s == eq
print s != eq
print s.issubset(eq)
print s <= eq
print s < eq
print '# backwards'
print eq.isdisjoi... | Python |
def xyz(): pass
print xyz
class X:
def abc(self): pass
print X.abc
print X().abc
| Python |
X = "OK"
def test(): print(X)
test()
| Python |
print {'a':[1,2,3], 'b':(5,6,7), 999: {'ok':1, 'stuff':2}}
| Python |
x = [1,2,]
print x[1]
| Python |
print max(3,8,2,6)
| Python |
x = (1,3)
y = (1,3)
print {x:'OK'}[y]
| Python |
print 2**3
| Python |
x = [10] * 5
x[:3] += 100,100
print x
| Python |
print str(range(4))[:5]
print len(range(4))
print range(4)[0]
print range(4)[1]
print range(4)[-1]
| Python |
# Test that min & max work on sets
s = set([1,2,3])
print s
print min(s)
print max(s)
| Python |
print 1 in {1:2}
| Python |
a = [1,2,3,4,5,6]
b = [9,9,9]
a[1:5] = b
print a
| Python |
def wee(waa, woo=False, wii=True):
print "OK", waa, woo, wii
wee("stuff")
wee("stuff", "dog")
wee("stuff", "dog", "cat")
wee("stuff", wii="lamma")
wee(wii="lamma", waa="pocky")
wee(wii="lamma", waa="pocky", woo="blorp")
| Python |
z = 0
for x in [1,2,3]:
z += x
print z
| Python |
def f():
for i in 1,2,3,4,5:
if i == 4: return
yield i
print list(f())
| Python |
def mygen(upto):
for i in range(0, upto):
print 'i',i
got = yield i
print 'got',got
handle = mygen(3)
first = True
for num in handle:
print 'num',num
if first:
print 'signalling'
foo = handle.send('sig')
print 'foo', foo
first = False
| Python |
x = [1]
x.extend([2,3])
print(x[1])
| Python |
print 2^7
| Python |
def f(l):
for i in 1,2,3,4,5:
yield l, i
a, b = f("a"), f("b")
print a.next()
print a.next()
print b.next()
print b.next()
print b.next()
print a.next()
print b.next()
print a.next()
| Python |
print 7^2&2
| Python |
x = 4
print 1 != x < 9
print 1 != x > 9
print 4 != x < 9
print 4 == x > 9
print 4 == x < 9
print 4 == x < 9 < 14
print 4 == x < 9 < 14 > 10
print 4 == x < 9 < 14 < 10
| Python |
print [c for c in "asdf"]
| Python |
print "1234"[1:3]
| Python |
print " hello ".partition("x")
print " hello ".rpartition("x")
| Python |
print True and True
| Python |
print [x for x in range(1,10) if False] or ["hello" for x in range(1,10) if True]
| Python |
s = 'abcd'
print s[::-1]
| Python |
print int(3)
print int(3.2)
print int(3.8)
print int(-3.2)
print int(-3.8)
print int(013)
print int(0x13)
print "------"
print int("3")
print int("013")
print "------"
print int("13", 8)
print int("013", 8)
print "------"
print int("13", 0)
print int("013", 0)
print int("0x13", 0)
print "------"
print int("13", 16)
pri... | Python |
print "".join(["O"]+["K"])
| Python |
print "-".join(["O","K"])
| Python |
for const in (1,2,3):
print const
def f():
for const in (1,2,3):
print const
for object in (1,2,3):
print object
instanceof = 5
void = 6
var = 7
delete = 8
switch = 9
default = 10
catch = 11
print instanceof, void, var, delete, switch, default, catch
f()
| Python |
def f(n):
for i in range(n):
yield i
g = f(5)
print g.next()
print g.next()
print g.next()
print g.next()
| Python |
print slice(1,2)
| Python |
class Base(object):
def myfunc(self):
print "Base.myfunc"
def stuff(self):
print "Base.stuff"
self.myfunc()
class Derived(Base):
def myfunc(self):
Base.myfunc(self)
print "Derived.myfunc"
d = Derived()
d.myfunc()
b = Derived()
b.stuff()
| Python |
x=2
x+=3
print x
| Python |
print str(range(-4))[:5]
print len(range(-4))
| Python |
# free and cell vars in y
c = "squirrel"
def x():
b = "dog"
print b, c
def y():
a = "cat"
print a,b
def z():
return a,b,c
return z
return y()
print x()()
| Python |
print float('inf')
print float('-inf')
| Python |
def f():
for i in 1,2,3,4,5:
if i % 2 == 0: continue
yield i
print list(f())
| Python |
for i in (i*2 for i in range(3)):
print i
| Python |
s = set([2,3,4])
t = set([3,4,5])
u = set([1,3,5])
a = s.difference(t)
b = u.difference(s)
c = u.difference(t)
print a
print b
print c
print a == set([2])
print b == set([1,5])
print c == set([1])
d = s.difference(t, u)
print d
print d == set([2])
| Python |
print False == 0
print True == 1
print True == 2
| Python |
def do(fmt, val):
print fmt % val
# Some small ints
do("%d", 42)
do("%d", -42)
do("%d", 42L)
do("%d", -42L)
do("%d", 42.0)
do("%#x", 1)
do("%#x", 1L)
do("%#X", 1)
do("%#X", 1L)
do("%#x", 1.0)
do("%#o", 1)
do("%#o", 1L)
do("%#o", 0)
do("%#o", 0L)
do("%o", 0)
do("%o", 0L)
do("%d", 0)
do("%d", 0L)
do("%#x", 0)
do("%#x... | Python |
print 7^2|4
| Python |
z = 0
for x in range(1,4):
z += x
print z
| Python |
class X:
def __init__(self):
self.px = 3
def y(self):
l = "xyz"
if len(l) == self.px:
print "OK"
x = X()
x.y()
| Python |
x = {1:2}
del x[1]
print len(x)
| Python |
a = 4
def test(z):
for i in range(0,a):
z += i
return z
print test(1)
| Python |
c = "squirrel"
time = 0
def x():
global time
time += 1
if time == 1:
b = "dog"
else:
b = "banana"
print b, c
def y(d):
a = "cat"
print a,b,d
def z():
for i in range(10*time):
yield i,a,b,c,d
return z
return y("blorp"... | Python |
a = [1,2,3,4,5,6]
b = [9,9,9]
a[1:2] = b
print a
| Python |
import this
| Python |
class X:
def stuff(self):
pass
x = X()
f = getattr(x, "stuff")
print f
fu = getattr(X, "stuff")
print fu
| Python |
def test(x):
return x
y = test(1)*2 + test(3)*4 + test(5)*6
print y
| Python |
print ~True
print ~False
| Python |
print " hello ".strip()
print " hello ".lstrip()
print " hello ".rstrip()
print " hello ".partition("l")
print " hello ".rpartition("l")
print " HELlo ".lower()
print " heLLO ".upper()
print "hi there".split(" ")
| Python |
# test list comparisons
l = [1,2,3,1]
print l
print l > l
print l >= l
print l == l
print l != l
print l <= l
print l < l
| Python |
class X: pass
def test(): y = X()
test()
print "OK"
| Python |
a,b = 1,2
print a+b
| Python |
x=4
x=x*3
print x
| Python |
def f(a, b):
print a, b
f(1, 2)
f(*[1, 2])
f(*(1, 2))
def g(a, b, *c):
print a, b, c
g(1, 2, 3)
g(1, 2, 3, 4, 5, 6)
g(*[1, 2])
g(*[1, 2, 3, 4])
g(*[1, 2, 3, 4, 5, 6, 7])
g(*(1, 2, 3, 4, 5, 6, 7))
g(1, *[7])
g(1, *[7, 8, 9])
g(1, 2, *(7,))
g(1, 2, 3, *(7, 8, 9))
| Python |
a = [100,101,102,103,104,105,106,107]
del a[2:6]
print a
| Python |
print(abs(-5))
| Python |
print str((1,2,3))
print str([1,2,3])
print str({1:'ok', 2:'stuff'})
print str("weewaa")
| Python |
x = []
x.append(x)
print x<x
| Python |
print "a"*15
print "dog"*19
print 40*"weee"
| Python |
print "..bbb..".replace("..", "X")
| Python |
print 4-1
| Python |
x = 2,'OK',
print len(x)
| Python |
print({1:"OK"}[1])
| Python |
def f(n):
i = 0
yield i
i += 1
j = i
yield i
yield j
j *= 100
i += j
yield j
yield i
yield n + i
for i in f(10): # i to conflict with body
j = 999
print i
| Python |
print str(range(5,0,-3))[:5]
print len(range(5,0,-3))
print range(5,0,-3)[0]
print range(5,0,-3)[1]
print range(5,0,-3)[-1]
| Python |
print "Yes" if True else "No"
print "Yes" if False else "No"
| Python |
a = ()
print a
| Python |
print "%x" % 10
print "%x" % 10L
print "%x" % 100000000000L
print "%o" % 10
print "%o" % 10L
print "%o" % 100000000000L
print "%d" % 10
print "%d" % 10L
print "%d" % 100000000000L
| Python |
# nl continuation
x = "stuff \
and \
things"
print x
| Python |
print range(10)[slice(0, 5, 2)]
| Python |
def f():
if 1 == 2:
yield -1
elif 1 == 1:
yield 3
else:
yield -1
print list(f())
| Python |
print False == None
if not None:
print "This statement evaluates to True."
if None:
print "This statement evaluates to False."
| Python |
# empty set creation
print set()
| Python |
def f(a, b, c):
print a, b, c
args = [5, 6, 7]
f(*args)
| Python |
print "1,2,3".split(",").index("3")
| Python |
longvalue = 9999999999999L
print "%3ld" % 42
print "%d" % 42
print "%d" % 42.0
print "%d" % longvalue
print "%07.2f" % 42
print "%07.2F" % 42
print "%(foo)s" % { 'foo': 'bar' }
#print "%((foo))s" % { '(foo)': 'bar' }
print "%sx" % (103*'a')
| Python |
print 7 in [1,2,3]
| Python |
Subsets and Splits
SQL Console for ajibawa-2023/Python-Code-Large
Provides a useful breakdown of language distribution in the training data, showing which languages have the most samples and helping identify potential imbalances across different language groups.