blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
0b240efcf6056322b8f4768da1f33690adf52686 | PY309-2353/eight_homework | /task_5.py | 1,137 | 3.640625 | 4 | class Deck:
deck = []
def push_front(self, n):
self.deck.insert(-1, n)
print('ok')
def push_back(self, n):
self.deck.insert(0, n)
print('ok')
def pop_front(self):
out_elem = self.deck[-1]
self.deck.pop()
print(out_elem)
def pop_b... |
86365d3c2672ca4ef6e627cc8c9c072ee3c22f05 | ISHARRR/hackerrank | /Python/sorting-BubbleSort.py | 360 | 3.6875 | 4 | def countSwaps(a):
count = 0
print (a)
for i in range(len(a)-1):
for j in range(len(a)-1):
if a[j] > a[j+1]:
a[j], a[j+1] = a[j+1], a[j]
count = count + 1
print ('Array is sorted in', count, 'swaps.')
print ('First Element:', a[0])
print ('Last... |
49dbae624f7695959e79f62a34837ed32fa6041a | vandlaw7/piro12 | /2주차 금요일 과제/3.py | 1,177 | 3.625 | 4 | n = int(input())
def arrange(ps):
newps = [value for index, value in enumerate(ps) if
not ((ps[index] == '(' and ps[index + 1] == ')') or (ps[index - 1] == '(' and ps[index] == ')'))]
return newps
def if_vps(ps):
# initial screen
if len (ps) == 0:
print("YES")
r... |
11611feeaa8586728e69cd3d902fb1c67fa35317 | Marist-CMPT120-FA19/Nathan-Raia-Lab-12 | /atm.py | 4,965 | 3.78125 | 4 | #Nathan Raia
class Account:
def __init__(self , id , pin , savings , checking):
self.ID = id
self.PIN = pin
self.savings = int(savings)
self.checking = int(checking)
def getID(self):
return self.ID
def getPIN(self):
return self.PIN
... |
7ac0a41699aad4c673e83b4d5ce6d3b3ff1beb86 | JoaoLeal92/registro-transacoes-financeiras | /db_access/conexao_db.py | 4,320 | 3.640625 | 4 | import psycopg2
class BancoDeDados:
"""
Arquivo definindo rotinas para fazer a conexão e queries de select, imports e deletes de dados no banco de dados
Atributos:
user: nome do usuário de acesso ao banco de dados
password: senha de acesso ao banco de dados
database: nome do banco... |
16e225e621786b9a40ef1834465d4bdf0964b9e3 | aisu-programming/Numerical-Method | /Homework_02_Bisection.py | 852 | 3.59375 | 4 | import math
def bisection(function, interval, precise=None):
start = interval[0]
end = interval[1]
for i in range(100):
middle = (start + end) / 2.0
print(f'{i+1:3d}: {middle}')
if precise is not None:
if (end - start) < precise: return middle
if function(middle) < 0:
start = middle
continue
else... |
f0eb2a695f110c0f81777d0d6c64b60a003fcc51 | chetan113/python | /moreprograms/rightangletriangle.py | 270 | 4.21875 | 4 | """" n = int(input("enter a number of rows:"))
for i in range(1,n+1):
for j in range(1,i+1):
print(" * ",end ="")
print()"""
"""one for loop statement"""
n =int(input("enter the number of rows:"))
for i in range(1,n+1):
print(" $ "*i)
|
3dfcb3368a60024ff4a3ae96b61e343d7ac0b10c | chetan113/python | /moreprograms/stringreversal.py | 344 | 3.796875 | 4 | """s =input("enter a string:")
print(s[::-1])
"""
"""palendrom"""
"""
s= input("enter a string:")
i= len(s)-1
result = ''
while i>=0:
result =result+s[i]
i=i-1
print(result)
"""
""" join the string use reverse"""
s='---'.join(['a','b','c'])
print(s)
s1=input("enter a string:")
print('... |
c93da5b5ba3c3d87755ad07fc880704da4278c92 | leomrocha/legi.py | /legi/roman.py | 764 | 3.703125 | 4 | """
Conversion functions for roman numbers
"""
from __future__ import division, print_function, unicode_literals
ROMAN_NUMERALS = (
('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100),
('XC', 90), ('L', 50), ('XL', 40), ('X', 10), ('IX', 9), ('V', 5),
('IV', 4), ('I', 1)
)
def decimal_to_roma... |
34153f219c89f9f2b926fcc9ded5e62f28b23f74 | 26prajval98/OOP-in-python | /OOP in Python/4_multiple-inheritance.py | 522 | 3.6875 | 4 | class A:
def __init__(self):
print('A')
super().__init__()
class B(A):
def __init__(self,first, **k):
self.first = first
print('B: {}'.format(self.first))
super().__init__(**k)
class C(A):
def __init__(self,last, **k):
self.last = last
print('C: {}'.... |
93b9eb93bbf23b5cd5de05e8b693703d1c8d747e | 26prajval98/OOP-in-python | /OOP in Python/8_metaclasses_1.py | 351 | 3.65625 | 4 | required = input('y or n\n')
isTrue = True if required == 'y' else False
# Similar to meta classes decorator for that class
def classDecorator(cls):
if isTrue:
cls.Hallo = 'Hello'
print('Hello')
return cls
@classDecorator
class A:
def __init__(self):
print('initialised')
... |
9a9fe0973e853ab8c5c9e80c217890ce00e3d881 | ratansingh98/100_Days_of_ML_Code | /days/Day 20 : Understanding NLTK/lemmatization.py | 674 | 3.578125 | 4 | from nltk.stem import WordNetLemmatizer
input_words = ['writing','calves','be','branded','horse','randomize',
'possibly','provision','hospital','kept','scratchy','code']
# Create lemmatizer object
lemmatizer = WordNetLemmatizer()
# Create a List of lemmatizer names for display
lemmatizer_names = ['NOUN LEMMATIZER',"... |
6d3fd57f669b763a4a72d04a429f5f18bab9bfa0 | ratansingh98/100_Days_of_ML_Code | /days/Day 25 : Tic-Tac-Toe Bot/TreePlot.py | 3,425 | 3.5 | 4 | import pydot
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import pylab as pl
import Config
class TreePlot:
"""
This class creates tree plot for search tree
"""
def __init__(self):
"""
Constructor
"""
# create graph object
... |
eebd301ffac344f8fe7bdf16a8cf9677bb542d3a | G00398275/PandS | /Week 05 - Datastructures/prime.py | 566 | 4.28125 | 4 | # This program lists out the prime numbers between 2 and 100
# Week 05, Tutorial
# Author: Ross Downey
primes = []
upto = 100000
for candidate in range (2, upto):
isPrime = True # Required only to check if divisible by prime number
for divisor in primes: # If it is divisible by an integer it isn't a prime num... |
75a5d8161498d62cbdce415742715a9baac22543 | G00398275/PandS | /Week 02/hello3.py | 235 | 4.21875 | 4 | # Week 02 ; hello3.py, Lab 2.2 First Programs
# This program reads in a person's name and prints out that persons name using format
# Author: Ross Downey
name = input ("Enter your name")
print ('Hello {} \nNice to meet you'.format (name)) |
8cc33ccb44add40fb374f791f9e819049cc47af1 | G00398275/PandS | /Week 03/Lab 3.2.1-round.py | 277 | 3.96875 | 4 | # Week 03: Lab 3.2.1 Fun with numbers
# This program takes in a float and outputs an integer
# Author: Ross Downey
numberToRound = float (input("Please enter a float number: "))
roundedNumber = round(numberToRound)
print ( '{} rounded is {}' .format(numberToRound, roundedNumber)) |
a0986698fa2430008eb4d33ebf02b50e933fc09c | G00398275/PandS | /Week 03/Lab 3.3.1-len.py | 270 | 4.15625 | 4 | # Week 03: Lab 3.3.1 Strings
# This program reads in a strings and outputs how long it is
# Author: Ross Downey
inputString = input ('Please enter a string: ')
lengthOfString = len(inputString)
print('The length of {} is {} characters' .format(inputString, lengthOfString)) |
8ff8959b62adcc0f3455ca00c1e9108a16fbf97e | G00398275/PandS | /Week 03/Lab 3.3.3 normalize.py | 575 | 4.46875 | 4 | # Week 03: Lab 3.3.2 Strings
# This program reads in a string and removes any leading or trailing spaces
# It also converts all letters to lower case
# This program also outputs the length of the original string
# Author: Ross Downey
rawString = input("Please enter a string: ")
normalisedString = rawString.strip().low... |
661c5df851bebf8a40806b42288f068885a4200f | G00398275/PandS | /Week 02/Simple Arithmetic 02.py | 158 | 3.671875 | 4 | # Week 02: Simple Arithmetic 02.py, Lab 2.2 First Programs - Extra
# This program outputs whether 2 is equal to 3
# Author: Ross Downey
import math
print (2 == 3) |
59fc57e8d10d9f71c59999d297edfaf310676efd | G00398275/PandS | /Week 04-flow/w3Schools-ifElse.py | 1,257 | 4.40625 | 4 | # Practicing ifElse loops, examples in https://www.w3schools.com/python/python_conditions.asp
# Author: Ross Downey
a = 33
b = 200
if b > a: # condition is IF b is greater than a
print("b is greater than a") # Ensure indentation is present for print, i.e. indent for condition code
a = 33
b = 33
if b > a:
print("b... |
3894d02f1d98a3cab86988ae48c164b300882603 | G00398275/PandS | /Week 08/Lab-8.1-8.4_salaries.py | 774 | 4.09375 | 4 | # Lab 8.1 - 8.4 plotting; salaries.py
# This program generated 10 random salaries that are modified as requested
# Author: Ross Downey
import numpy as np
minSalary = 20000
maxSalary = 80000
numberOfEntries = 10 # specifying min, max and how many numbers needed
np.random.seed(1) # ensures "random" array called is the... |
c680ffcb0cb897828bb5345cca25dca196d87882 | xiaomiaoright/Credit-Risk-Analysis | /BuildingClassificationModel_3_FeatureSelection.py | 6,840 | 3.8125 | 4 | # Feature selection
# including features in a model which do not provide information on the label is useless at best and may prevent generalization at worst.
"""
1. Eliminating features with low variance and zero variance.
2. Training machine learning models with features that are uninformative can create a variety of... |
472fca79ecd452858dbfe9a8fee77630b02e4b8b | ChloeChepigin/HPM573S18_CHEPIGIN_HW1 | /Question 1.py | 308 | 3.75 | 4 |
x = 17
print ('Setting x =', x)
# integer
y1 = x
print (type(y1))
print ('y1 is a', type(y1))
# float
y2 = float(x)
print (type(y2))
print ('y2 is a', type(y2))
# string
y3 = str(x)
print ('y3 is a ', type(y3))
print ('y3 is a', type(y3))
# boolean, 17 > 2
y4 = bool(x > 2)
print ('y4 is a ', type(y4))
|
6c038b46b9e5901c5fd970ca3741c4c65132c140 | mikeyags1016/100DayCodingChallenge | /flash_card.py | 574 | 3.703125 | 4 | import random
flash_cards = {}
def add_flash_card(front, back):
flash_cards.update({front: back})
def trivia_mode(cards):
selected_keys = []
i = 0
while i < len(cards):
current_selection = random.choice(tuple(cards.keys()))
if current_selection not in selected_keys:
gue... |
2e60abd703a5013e8ee5f7d2ce30b066833a7872 | arnavgupta50/BinarySearchTree | /BinaryTreeTraversal.py | 1,155 | 4.3125 | 4 | #Thsi Program traverses the Binary Tree in 3 Ways: In/Post/Pre-Order
class Node:
def __init__ (self, key):
self.left = None
self.right = None
self.val = key
def insert(root, key):
if root is None:
return Node(key)
else:
if root.val==key:
retu... |
4f8d6dd2da113c78ec1a158d423910442a561993 | eri3l/skinks | /apps/home.py | 3,074 | 3.71875 | 4 | import streamlit as st
def app():
st.write("## Welcome to the Skink Search Tool app")
st.write("""
The app filters existing skink data by multiple criteria in order to help with the identification of skinks.
Latest data update: 10 Apr 2020. \n
Use the navigat... |
ee5a5fa8ed15f91074dadc78587bc70671257308 | marleentheyoung/cs_airport | /node.py | 4,187 | 4.0625 | 4 | class Node(object):
def __init__(self, key, value=None):
self.key = key
self.value = value
self.left = None
self.right = None
self.parent = None
self.height = 0
def get_key(self):
"""Return the key of this node."""
return self.key
def... |
4b44a4f293bcf14b0b77d5677159cc5fb90950b5 | walkerwell/algorithm-data_structure | /src/main/python/algorithm/run_LCS.py | 719 | 3.734375 | 4 | def findTheMax(matrix):
index=0
res=matrix[0]
for i in range(len(matrix)):
if matrix[i]>res:
res=matrix[i]
index=i
return res,index
def findDPMatrix(matrix):
dp=[]
for i in range(len(matrix)):
n=1
j=i-1
now_=matrix[i]
while(j>=0):
... |
76e1642a0e8364e876237ca27dad46f1ec982cd6 | walkerwell/algorithm-data_structure | /src/main/python/codeforces/run_131A.py | 353 | 3.953125 | 4 | s=raw_input()
allUp=1
otherUp=1
for i in range(len(s)):
if(s[i].islower()):
allUp=0
if(i<>0 and s[i].islower()):
otherUp=0
res=""
for i in range(len(s)):
if(allUp or otherUp):
if(s[i].isupper()):
res+=s[i].lower()
else:
res+=s[i].upper()
else:
... |
8fa847e2f205c9afb06672ac2bd679810af16e64 | walkerwell/algorithm-data_structure | /src/main/python/codeforces/run_41A.py | 245 | 3.609375 | 4 | a=raw_input()
b=raw_input()
if(len(a)<>len(b)):
print "NO"
exit(0)
else:
index=len(a)-1
i=0
while(index>=0):
if(a[i]<>b[index]):
print "NO"
exit(0)
index-=1
i+=1
print "YES" |
c09e3727d8ad74bdd459a9f4109a282ff5bc636e | walkerwell/algorithm-data_structure | /src/main/python/codeforces/run_69A.py | 168 | 3.546875 | 4 | n=input()
x=0
y=0
z=0
for i in range(n):
x1,y1,z1=(map(int,raw_input().split()))
x+=x1
y+=y1
z+=z1
if((x|y|z)==0):
print "YES"
else:
print "NO"
|
6fafa89090f526c6b7cb9f9b528d0b31eba4e03f | walkerwell/algorithm-data_structure | /src/main/python/codeforces/run_118A.py | 156 | 3.65625 | 4 | s=raw_input().lower()
res=''
for i in range(len(s)):
if s[i] not in ['A','a','O','o','Y','y','E','e','U','u','I','i']:
res+='.'+s[i]
print(res)
|
c2043f1e650a2a770680d1514493c95dd011e3e1 | walkerwell/algorithm-data_structure | /src/main/python/codeforces/run_443A.py | 132 | 3.546875 | 4 | s=raw_input()
m={}
n=len(s)
ignore=['{',',',' ','}']
for i in range(n):
if s[i] not in ignore:
m[s[i]]=s[i]
print len(m) |
eaf45a8f38bcbf4d14bc29d05eff3d9b0fc6cc04 | autumind/huffman_code | /Utils.py | 2,176 | 3.859375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on Jul 22, 2015
@author: shenzb
'''
from Node import Node
def stringToPriorityQueue(text):
'''
Transfer every character of a string to priority queue.
Priority order is according to character's count of the string.
'''
chars = list(text)
... |
1ad84fc6335ea62b64fa8370c918c136f55ebf52 | liufengyuqing/PythonPractice | /demo.py | 266 | 3.765625 | 4 |
print("I\'m liuzhiwei\nhello world!")
# 字符串和编码 unicode utf-8
print(ord("A"))
print(chr(66))
print(b"ABC") # 字节
print("ABC") # 字符串 str
print(sum(range(101)))
for i in range(1,101):
print(i,end='\n') if i % 10 == 0 else print(i,end=' ')
|
09df092b48e2059def51ecc22a0bca8ab99befe1 | liufengyuqing/PythonPractice | /DemoPractice.py | 3,439 | 3.671875 | 4 | # coding=utf-8
'''python一个.py文件就是一个包,一个模块
sys 模块是和系统相关的一些对象
os与sys模块的官方解释如下:
os: This module provides a portable way of using operating system dependent functionality.
这个模块提供了一种方便的使用操作系统函数的方法。
sys: This module provides access to some variables used or maintained by the interpreter and to functions that interact strongl... |
0838fcd3cd4ab10f7dffb318fdf9534e7db0e079 | rongduan-zhu/codejam2016 | /1a/c/c.py | 2,061 | 3.578125 | 4 | #!/usr/bin/env python
import sys
class Node:
def __init__(self, outgoing, incoming):
self.outgoing = outgoing
self.incoming = incoming
def solve(fname):
with open(fname) as f:
tests = int(f.readline())
for i in xrange(tests):
f.readline()
deps = map(int, f.readline().split(' '))
... |
e6657c32a76d198d60ad812ef1fc5587e8a74465 | subham-paul/Python-Programming | /Swap_Value.py | 291 | 4.1875 | 4 | x = int(input("Enter value x="))
y = int(input("Enter value y="))
print("The value are",x,"and",y)
x = x^y
y = x^y
x = x^y
print("After the swapping value are",x,"and",y)
"""Enter value x=10
Enter value y=20
The value are 10 and 20
After the swapping value are 20 and 10
"""
|
447135a4daada255fa5639f0f36abeb318d17cad | subham-paul/Python-Programming | /SortAlphabetical_41.py | 373 | 3.9375 | 4 | """str=input("Enter Your Word = ")
x=str.split()
print(x)
x.sort()
print(x)
for i in x:
print(i, end=" ")"""
"""
Enter Your Word = i am subham
['i', 'am', 'subham']
['am', 'i', 'subham']
am i subham"""
str=input("Enter Your Word = ")
x=str.split()
x.sort()
for i in x:
print(i, end=" ")
""... |
e842bcc485fa3a6a7be041b39f5265960a5a0cf0 | subham-paul/Python-Programming | /N_27(b).py | 142 | 3.53125 | 4 | n=int (input("Enter Limit= "))
a=100
b=5
while a>=n:
print(a)
a=a-b
b=b*2
"""
Enter Limit= 5
100
95
85
65
25
"""
|
d1e6842ea9c8182590d29e76c0bb9b1ca2ca0b42 | subham-paul/Python-Programming | /N_27(d).py | 168 | 4.03125 | 4 | n=int (input("Enter number of term= "))
a=5
b=7
for i in range(1,n+1):
print(a)
a=a+b
b=b*2
"""
Enter number of term= 5
5
12
26
54
110
"""
|
41ffd54d227e0e6ccfa31cf3f4bc878c3a7060e4 | subham-paul/Python-Programming | /MaxNo_30.py | 403 | 3.625 | 4 | list=[10,20,30,40,50,60]
print("Max no in the list = ", max(list))
print("Min no in the list = ", min(list))
x = max(list)
y = min(list)
list.remove(x)
list.remove(y)
print()
print("2nd max no in the list = ", max(list))
print("2nd min no in the list = ", min(list))
"""
Max no in the list = 60
Min no in ... |
772795bb1447e113ef80b22c40d4c35dc38b426b | Alfredo-Diaz-Gomez-2015090154/Compiladores2021B | /Prácticas/P3_AFN_a_AFD_Subconjuntos/AFD.py | 1,429 | 3.609375 | 4 | import copy
class AFD:
def __init__(self, alfabeto):
self.alfabeto = copy.copy(alfabeto)
self.transiciones = {}
def copiar_estados(self, estados_generados):
self.estados = estados_generados.copy()
def copiar_estado_inicial(self, estado_inicial):
self.estado_inicial = esta... |
6a357090cf6171ce46b4c2fdfc871e731335449a | Alfredo-Diaz-Gomez-2015090154/Compiladores2021B | /Prácticas/P7_Descenso_recursivo/descenso_recursivo_3.py | 971 | 3.609375 | 4 | #cadena = input('Ingresa la cadena a probar: ')
#cadena = "afdea"
#cadena = "bcafdeadfdea"
#cadena = "acafdeadea"
cadena = "afcafdeadea"
longitud_cadena = len(cadena)
indice_actual = 0
def consumir(caracter):
global indice_actual
if indice_actual < longitud_cadena:
if cadena[indice_actual] == caracter... |
a83aa31e172236de84390d0031488085aac50120 | JT-Wong/course_homework | /高等数理逻辑/大作业1/code/python/pro_logic.py | 16,604 | 3.5625 | 4 | # -*- coding: utf-8 -*-
import math
import traceback
import sys
def arg_check(pro_logic, i):
temp = ''
while i < len(pro_logic):
if pro_logic[i].isalpha() or pro_logic[i].isdigit():
temp += pro_logic[i]
i += 1
else:
break
return [i - 1, temp]
def synta... |
9b25d5790a8f26477bf55a453a0fced4653a74a8 | EoinDavey/Competitive | /Codeforces/NCPC2018/b.py | 215 | 3.609375 | 4 | N = input()
xs = raw_input().split()
ind = 1
b = False
for x in xs:
if x != "mumble" and int(x)!=ind:
b = True
break
ind+=1
if b:
print "something is fishy"
else:
print "makes sense"
|
fd011effa4b26145b463eeff422ff932f2fe4a8a | EoinDavey/Competitive | /ProjectEuler/p57.py | 495 | 3.5 | 4 | two = (2,1)
one = (1,1)
half = (1,2)
def oneover((x,y)):
return (y,x)
def red((t,b)):
g = gcd(t,b)
return (t/g,b/g)
def gcd(a,b):
while b!=0:
a,b = b,a%b
return a
def add((x1,y1),(x2,y2)):
t = x1*y2 + x2*y1
b = y1*y2
return (t,b)
def check((t,b)):
return len(str(t)) > le... |
0e4afa54ef2d958f9cd1536f46d2fcef75e606ee | EoinDavey/Competitive | /IrlCPC_2019/8.py | 418 | 3.578125 | 4 | def bsub(n):
if n[0] != 'B':
return "bo-b"+n[1:]
return "bo-"+n[1:]
def fsub(n):
if n[0] != 'F':
return "fo-f"+n[1:]
return "fo-"+n[1:]
def msub(n):
if n[0] != 'M':
return "mo-m"+n[1:]
return "mo-"+n[1:]
name = input()
print(', '.join([name, name, bsub(name)]))
print(',... |
dd4bbc6f0daf8c6dcb588595d7cfd1644e6d54b0 | EoinDavey/Competitive | /IrlCPC_2019/3.py | 736 | 3.671875 | 4 | def anagram(s):
freqs = {}
for i in s:
if i not in freqs:
freqs[i] = 1
else:
freqs[i] += 1
odd = 0
for k, v in freqs.items():
if v % 2 != 0:
odd += 1
if odd > 1:
return False
return True
def tolower(i):
if (... |
8edf258a0f792d00fd8ee454206b27eb28e7c9fb | EoinDavey/Competitive | /AdventOfCode2020/d3.py | 593 | 3.515625 | 4 | import sys
from functools import reduce
def lines():
return [line.strip() for line in sys.stdin]
board = lines()
assert(all(map(lambda x: len(x) == len(board[0]), board)))
def get(x, y):
return board[x][y % len(board[0])]
def slopeHits(dx, dy):
x, y = 0, 0
cnt = 0
while x < len(board):
if get(x, y) =... |
306114d6906e93e154cf9179154ff76dc95ef316 | EoinDavey/Competitive | /IEEEPractice/Food_Truck.py | 1,040 | 3.515625 | 4 | import sys
from math import asin, sqrt
import math
def sin(x):
return math.sin(math.radians(x))
def cos(x):
return math.cos(math.radians(x))
R = 6378.137
def toD(inp):
d = inp[0]
date, time = d.split(' ')
MM, dd, yy = date.split('/')
hh, mm = time.split(':')
return ':'.join([yy,MM,dd,hh,... |
5397d98bcd790bfdb458805e8a65ef7ef5e1412f | EoinDavey/Competitive | /Kattis/Ascii_Figure.py | 493 | 3.640625 | 4 | def rep(x):
if x=='-':
return '|'
if x=='|':
return '-'
return x
def rotate(lines):
mxlen = max(map(len,lines))
lines = map(lambda x: x+"".join([" "]*(mxlen-len(x))),lines)
rot = map(lambda x: map(rep,list(x)[::-1]),zip(*lines))
print "\n".join(map(lambda x:"".join(x).rstrip... |
972ffdb7d618ea6487bbb12255efead9da55b5e0 | gr4yh4t-0/XRF-dev | /XRF-dev/play-using-import/importASCII_shrink.py | 1,434 | 3.671875 | 4 | import pandas as pd
path_to_ASCIIs = input("Enter path to ASCIIs here: ")
#notes:
# local file does not have global list EOI = [Cd_L, Cu, ...]. prompt for input?
#MAPS saves column headers with whitespace, this function is used to remove that whitespace
def noColNameSpaces(pd_csv_df):
old_colname... |
718b0686abd46dcdb548c456635035929c52d355 | rheehot/baekjoon-4 | /5397 키로거.py | 451 | 3.53125 | 4 | n = int(input())
for i in range(n):
L=input()
stack1 = []
stack2 = []
for x in L:
if x=='<':
if stack1:
stack2.append(stack1.pop())
elif x=='>':
if stack2:
stack1.append(stack2.pop())
elif x=='-':
if stack1:
... |
dc85f7b9c68a142939a54c207665a87fab4947f3 | mzaira/brightNetwork | /python/src/video_player.py | 14,258 | 3.703125 | 4 | """A video player class."""
import random
from .video_library import VideoLibrary
class VideoPlayer:
"""A class used to represent a Video Player."""
cnt_video = None
state = None
playlist = {}
flagged = {}
def __init__(self):
self._video_library = VideoLibrary()
... |
fa6d1b896e49611c68e011d7caebebffafac604e | Gressia/T07_ChambergoG.VilchezA | /Chambergo/Ejercicio_para3.py | 109 | 3.765625 | 4 | #Ejercicio_03
a=5
max=450
while(a <= max):
print("a",a)
a=a+5
#fin_while
print("programa culminado")
|
35b1ebc683ad9eef39240550cbd39033afd69168 | Gressia/T07_ChambergoG.VilchezA | /Vilchez/ejercicio.mientras05.py | 254 | 3.796875 | 4 | # Programa 05
rpta=""
rpta_invalida=(rpta!="gano" and rpta!="sigue intentando")
while(rpta_invalida):
rpta=input("Ingrese rpta(gano o sigue intentando):")
rpta_invalida=(rpta!="gano" and rpta!="sigue intentando")
#fin_while
print("rpta:",rpta)
|
eafda40ba1154d3f8d02c01d9b827f93f3d7edc6 | audflexbutok/Python-Lab-Source-Codes | /audrey_cooper_501_2.py | 1,788 | 4.3125 | 4 | # Programmer: Audrey Cooper
# Lab Section: 502
# Lab 3, assignment 2
# Purpose: To create a menu driven calculator
# set calc equal to true so it runs continuously
calc = True
while calc == True:
# adds two numbers
def add(x, y):
return x + y
# subtracts two numbers
def subtract... |
71c813eeaea12d9f0b3791bbbf7c2c92fcaf391f | dedx/PHYS200 | /Ch7-Ex7.4.py | 797 | 4.46875 | 4 | #################################
#
# ThinkPython Exercise 7.4
#
# J.L. Klay
# 30-Apr-2012
#
# Exercise 7.4 The built-in function eval takes a string and evaluates
# it using the Python interpreter. For example:
# >>> eval('1 + 2 * 3')
# 7
# >>> import math
# >>> eval('math.sqrt(5)')
# 2.2360679774997898
# >>> eval('t... |
1610e07843f5ea10192ceaf02101e9667c5bb934 | stuffyUdaya/Python | /1-9-17/looping.py | 392 | 3.78125 | 4 | # for x in range(1,20):
# print "I am good at coding",x
# my_list = [2,5,9,['carrot','lettuce'],78,90]
# for element in my_list:
# print element
# WHILE LOOP
# count = 0
# while(count<10):
# print "I love to code", count
# count= count+1
# BREAK AND CONTINUE
for val in "Hell... |
d91dcff8fa9263c1c31e2b755001808fe041caa3 | stuffyUdaya/Python | /1-9-17/getandprintavg.py | 120 | 3.59375 | 4 | arr = [5,7,9,65,45]
sum =0
for x in range(0,len(arr)):
sum = sum+arr[x]
avg = sum/len(arr)
print sum
print avg
|
e5ed52cb751dad2071aa88dee39ee68fa02b4f44 | stuffyUdaya/Python | /1-9-17/swapstringfornegval.py | 115 | 3.5 | 4 | arr = [35,40,2,1,-8,7,-30]
for x in range(0,len(arr)):
if(arr[x]<0):
arr[x] = "Dojo"
print arr
|
2f319d09ef1183f75623fdc10fe226c371eba85f | stuffyUdaya/Python | /1-9-17/strings.py | 305 | 4.15625 | 4 | name = "hello world!"
lname = "This is Udaya"
print "Welcome",lname
print "Welcome"+lname
print "Hi {} {}".format(name,lname)
print name.capitalize()
print name.lower()
print name.upper()
print name.swapcase()
print name.find("l")
print lname.replace("Udaya","UdayaTummala")
print name.replace("o","0",1)
|
81e67608971d0d9f305a8fc15791880534e92891 | harshmalani007/python | /vowels.py | 224 | 4.0625 | 4 | ha = input ("Enter a char: ")
if(ha=='A' or ha=='a' or ha=='E' or ha =='e' or ha=='I'
or ha=='i' or ha=='O' or ha=='o' or ha=='U' or ha=='u'):
print(ha, "is a Vowels")
else:
print(ha, "is a Consonants")
|
f1ddf4f31c1f8a99a6a0d81dd68c9bd050a03f49 | ParkJH1/ML-Example | /lab-09.py | 690 | 3.6875 | 4 | import numpy as np
import matplotlib.pyplot as plt
def minumum_mean_square_error(y_predict, y_data):
ret = 0
for i in range(len(y_predict)):
ret += (y_data[i] - y_predict[i]) ** 2
ret /= len(y_predict)
return ret
x_data = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
y_data = np.array([8, 24, 28... |
1889f8c01638353f958f9e7c838ca30d30148c4d | eshu-bade/Data-Structures-and-Algorithms | /BinarySearchTree.py | 3,384 | 4.34375 | 4 | """
Binary search tree has left and right subtrees.
If the new child is smaller than node, it must go left side
If the new child is greater than node, it must go right side
It has 3 types of sortings
- In-order traversal method: returns list of elements in a binary tree in a specific order(first visits leftsubt... |
3c563a9a759b7c3fabf6df0a58e7d55ccd34c23f | lhc0506/leetcode | /210323_leetcode.py | 450 | 3.546875 | 4 | class Solution:
def threeSumMulti(self, arr: List[int], target: int) -> int:
n = len(arr)
count = 0
for i in range(n-2):
for j in range(i+1,n-1):
if arr[i] + arr[j] > target:
continue
else:
for k in range(j+1... |
80fcbc62352da0272aa57cba930766812939e861 | sathishmepco/Python-Basics | /basic-programs/prime_nos.py | 428 | 3.671875 | 4 | def main():
start = int(input('Enter the start value : '))
end = int(input('Enter the end value : '))
primeNos = []
for value in range(start,end+1):
flag = True
for j in range(2,int(value/2)):
if value % j == 0:
flag = False
break
if flag is True:
primeNos.append(value)
for i in range(len(prim... |
1b3694daf743bcdb5e7c9835a5f8caa28e30c132 | sathishmepco/Python-Basics | /techgig/average_score.py | 410 | 3.515625 | 4 | def main():
n = int(input().strip())
names = {}
for i in range(n):
s = input().strip().split()
a = int(s[1])
b = int(s[2])
c = int(s[3])
avg = (a+b+c)/3
names[s[0]] = avg
name = input().strip()
print('{0:.2f}'.format(names[name]))
main()
'''
Test Case... |
e4a205127460b9e4f0688049e723dd8fb16ea8d9 | sathishmepco/Python-Basics | /basic-concepts/modules/calculator.py | 122 | 3.609375 | 4 | def add(a,b):
return a+b
def sub(a,b):
return a-b
def isEven(a):
if a % 2 == 0:
return True
else:
return False
|
676895da9e1eff2fc1b778059b14741eac5a1d55 | sathishmepco/Python-Basics | /basic-concepts/del_statement.py | 540 | 3.953125 | 4 | a = [-1, 1, 66.25, 333, 333, 1234.5]
print('The elements in the list are :',a)
del a[0]
print('After deleting 0th index element :',a)
del a[2:4]
print('Deleting elements from index 2 to 4th element')
print('After deletion :',a)
del a[:]
print('Deleting entire list :',a)
'''
OUTPUT
------
The elements in the list are :... |
690805257154a3d610f72d0fa777a0196b9e07fb | sathishmepco/Python-Basics | /basic-concepts/for_loop.py | 1,005 | 4.28125 | 4 | #for loop
print('------Looping through string list')
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x,len(x))
print('------Looping through String')
str = 'Python'
for x in str:
print(x)
print('-----Range() function')
for x in range(10):
print(x)
print('-----Range() function with start and end valu... |
551f096fdf03040494cd2ef3d1df329a81766c86 | sathishmepco/Python-Basics | /basic-concepts/collections/counter.py | 217 | 3.703125 | 4 | from collections import Counter
def main():
s = input()
common = Counter(s).most_common(2)
if len(common) is 1:
print(common[0],end="")
else:
print(common[0],common[1],end="")
main() |
c2740cb3c6b4f838d3b8ff8bd7c54dade977cbe4 | sathishmepco/Python-Basics | /basic-programs/array/intersection.py | 763 | 4.09375 | 4 | def main():
a = int(input('Enter the length of array1 : ').strip())
s1 = input('Enter the values of array1 : ').strip()
b = int(input('Enter the length of array2 : ').strip())
s2 = input('Enter the values of array2 : ').strip()
array1 = s1.split()
array2 = s2.split()
list1 = []
list2 = [... |
8617d6b008e47ed734b1ecaf568ae94dfc7db835 | sathishmepco/Python-Basics | /basic-concepts/collections/dequeue_demo.py | 1,329 | 4.34375 | 4 | from collections import deque
def main():
d = deque('abcd')
print('Queue of : abcd')
for e in d:
print(e)
print('Add a new entry to the right side')
d.append('e')
print(d)
print('Add a new entry to the left side')
d.appendleft('z')
print(d)
print('Return and remove the right side elt')
print(d.pop())
p... |
0000c11753a4882f5e1bf9675a714533b6551259 | sathishmepco/Python-Basics | /basic-programs/array/unique_set.py | 209 | 3.8125 | 4 | #Find unique elements
def main():
s1 = input().strip()
array1 = s1.split()
uniqueset = set(array1)
print(uniqueset)
main()
'''
Input
1 2 3 2 3 1 4 5 3 4 5
Output
{'1', '2', '5', '3', '4'}
''' |
45fba01c9f2649279f241e196e773dff5394f81c | sathishmepco/Python-Basics | /patterns/pattern21.py | 393 | 3.546875 | 4 | def main():
n = int(input().strip())
for i in range(n):
for j in range(i):
print(end=' ')
for j in range(i,n,1):
if j == i:
print(str(n-i),end='')
else:
print(' '+str(n-i),end='')
if i < n-1:
print()
main()
... |
d7b198ce22ade78373e81feea7f1d34547ac686c | sathishmepco/Python-Basics | /techgig/itertools/groupby_demo2.py | 346 | 3.5 | 4 | from itertools import groupby
def main():
s = input().strip()
s = sorted(s)
groups = groupby(s)
result = [(sum(1 for _ in group),label) for label, group in groups]
output = " ".join("({}, \'{}\')".format(label, count) for label, count in result)
print(output)
main()
'''
Input
aabbccc
Output
(2, ... |
b101c2a2a741512026b4829e570923eb3d45267d | duplamatyi/ads | /python/sorting/sorting.py | 4,777 | 4.1875 | 4 | """Sorting algorithms in Python"""
import copy
class Sorter:
@staticmethod
def bubble_sort(lst):
"""The greatest item bubbles to the top in each iteration"""
lst = copy.deepcopy(lst)
for i in range(len(lst) - 1, 0, -1):
ordered = True
for j in range(i):
... |
b27991d36c39d6506daf2c4566203496798cc770 | domoritz/informaticup-2012 | /data/dataDistances.py | 2,895 | 3.875 | 4 | from data.dataMatrix import DataMatrix
class DataDistances(DataMatrix):
"""Data structure containing distances between stores."""
def getDistance(self, i1, i2):
"""Returns the minimum distance between i1 and i2."""
return self.getValue(i1, i2)
def prepare(self):
"""Prepares the data structure for the next... |
fb367242ca13764800e441b677d24563b5ecf109 | stevenhankin/Entertainment_Center | /fresh_tomatoes.py | 2,576 | 3.53125 | 4 | import webbrowser
import os
import re
def get_template_data(template_name):
"""Retrieves specified template
The templates for the Header, content and tiles are
stored in HTML "template" files within a resources
subdirectory and are returned using this helper function
:return: String of the templ... |
5ffa633ffb47b5c83d71b2e17bf016d3f49cfa97 | Pavankalyan0105/Dynamic-Programming | /minCoinsChange.py | 993 | 3.71875 | 4 |
#function that gives the mimimum noof coins required
def minCoins(coins , sum):
rows = len(coins)
cols = sum+1
table = [[0 for j in range(cols)] for i in range(rows)]
for i in range(0 , rows):
table[i][0] = 0
for i in range(1, cols):
table[0][i] = i//coins[0]
for i in rang... |
c5e31c20a1a55cec683250a8d64ebc8836c3f5b6 | JKodner/median | /median.py | 528 | 4.1875 | 4 | def median(lst):
"""Finds the median of a sequence of numbers."""
status = True
for i in lst:
if type(i) != int:
status = False
if status:
lst.sort()
if len(lst) % 2 == 0:
num = len(lst) / 2
num2 = (len(lst) / 2) + 1
avg = float(lst[num - 1] + lst[num2 - 1]) / 2
median = {"median": avg, "positi... |
d42020a99ba634ce329ec2498d60f5f3594c198c | BramKineman/331-cc-queue | /CC6/solution.py | 2,688 | 3.859375 | 4 | """
CC6 - It's As Easy As 01-10-11
Name:
"""
from typing import Generator, Any
class Node:
"""
Node Class
:value: stored value
:next: reference to next node
"""
def __init__(self, value) -> None:
"""
Initializes the Node class
"""
self.valu... |
33487b5cd6e069e72cbe686724143ba1eb16979e | Tayuba/AI_Engineering | /AI Study Note/List.py | 1,895 | 4.21875 | 4 | # original list
a = [1, 2, 3, 4, "m", 6]
b = ["a", "b", "c", "d", 2, 9, 10]
# append(), add an item to the end of already existing list
c = 8
a.append(c) # interger append
print(a) # [1, 2, 3, 4, 'm', 6, 8]
d = "Ayuba"
b.append(d)
print(b) # ['a', 'b', 'c', 'd', 2, 9, 10, 'Ayuba']
# extend(), add all items to the t... |
9793d0c61424787630040790531af6f165f99e5d | Tayuba/AI_Engineering | /Solutions_of_Exercises/Nump_Ex_Solutions/ex_34_42.py | 1,993 | 3.65625 | 4 | import numpy as np
import time
# How to get all the dates corresponding to the month of July 2016?
print(np.arange('2016-07', '2016-08', dtype='datetime64[D]'))
# How to compute ((A+B)*(-A/2)) in place (without copy)?
A = np.ones(3) * 1
B = np.ones(3) * 2
np.add(A, B, out=B)
np.divide(A, 2, out=A)
np.negative(A, out=... |
4f340717ec34d4d1ee5dc79b1bcac29c8be02600 | OliverMathias/University_Class_Assignments | /Python-Projects-master/Assignments/Celsius.py | 367 | 4.3125 | 4 | '''
A script that converts a user's celsius input into farenheight by using
the formula and prints out an temp in farenheight
'''
#gets user's temp Input
temp_c = float(input("Please enter the current temperature in celsius: "))
# turns it into farenheight
temp_f = temp_c*(9/5) + 32
#prints out farenheight
print("The... |
6bef25b006ecf686bb576d382cbdd711ff7faa11 | N02994498/ELSpring2015 | /code/logTemperature.py | 822 | 3.625 | 4 | #!/usr/bin/python
import sqlite3 as myDataBase
import sys
import time
import os
date = " "
tempC = 0
tempF = 0
""" Log Current Time, Temperature in Celsius and Fahrenheit
Returns a list [time, tempC, tempF] """
def readTemp():
tempfile = open("/sys/bus/w1/devices/28-0000069743ce/w1_slave")
tempfile... |
dd0b8328fbb3617d8f083904fe3d812230f35208 | pajakpawel/AdventOfCode_2020 | /Day_4/Puzzle_1.py | 641 | 3.90625 | 4 | def count_valid_passports(filepath: str) -> int:
valid_passports_number = 0
required_passport_fields = {"byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"}
with open(filepath) as bach_file:
passports_list = bach_file.read().split('\n\n')
for passport in passports_list:
if all(field in pas... |
33084ea3b0540cb423e7f4f546ca0c9a0a6a656f | pajakpawel/AdventOfCode_2020 | /Day_6/Puzzle_1.py | 857 | 3.953125 | 4 | def count_positive_answers(group_answers: str) -> int:
positive_answers = 0
counted_questions = set()
group_answers = ''.join(group_answers.split())
for answer in group_answers:
if answer not in counted_questions:
counted_questions.add(answer)
positive_answers += 1
... |
dfedefb05689f6278d9504e14f701cec7eae7a3b | camilocruz07/esport | /sport.py | 511 | 3.859375 | 4 | numero1= 45
numero2= 34
operacion = input("ELIJA UNA OPCIION: ")
if operacion =="a":
suma = numero1 + numero2
print ("el resultado es: ", suma)
elif operacion =="b":
suma = numero1 + numero2
print ("el resultado es: ", suma)
elif operacion =="c":
suma = numero1 + numero2
print ("el resultado... |
a0393bda25d0b27316eecbac32387507c079ad26 | zih123/assignment-1-zih123-master | /assignment1.py | 9,098 | 3.515625 | 4 | # This is the file you will need to edit in order to complete assignment 1
# You may create additional functions, but all code must be contained within this file
# Some starting imports are provided, these will be accessible by all functions.
# You may need to import additional items
import math
import os
import re
... |
53f51d2d0bcf61dd52f1a1eaa09d5a16f4a0edfc | shun-999/studey_04.kadai | /pos-system.py | 3,571 | 4.15625 | 4 | ### 商品クラス
import pandas as pd
import datetime
class Item:
def __init__(self,item_code,item_name,price):
self.item_code=item_code
self.item_name=item_name
self.price=price
def get_price(self):
return self.price
### オーダークラス
class Order:
def __init__(self,item_master):
... |
7a1ec8cc30caf9b4fd0f586c53bc4189999c3cf4 | ChandanB/Tweet-Generator | /Before Template/bf_stoch_samp.py | 1,488 | 3.703125 | 4 | import sys
import string
import re
import random
outcome_for = {}
user_input = sys.argv[1]
sentence = []
dict = open('Bible.txt', 'r')
text = dict.read()
dict.close()
def histogram(source_text):
histogram = {}
for word in source_text.split():
word = word.translate(None, string.punctuation)
... |
e6e42e07e0a08a8fa3c6e3b7ce67a14fcc97eb21 | GateNLP/python-gatenlp | /gatenlp/processing/pipeline.py | 9,529 | 3.5 | 4 | """
Module that provides the Pipeline class. A Pipeline is an annotator which is configured to contain several annotators
which get executed in sequence. The result of each annotator is passed on to the next anotator.
Each annotator can return a single document, None, or list of documents. If no document is returned, s... |
33e2d191343b8e41cb60a3f79d2742e408e13f7f | jwalters006/blackjack | /handsplit.py | 843 | 3.984375 | 4 | # Start by placing the player_hand in a container interable, then put all of the
# ensuing logic in a "for x in container", so that either one or multiple hands
# can be processed by the ensuing logic. If the initial hand is split,
# additional hands are put into additional places in the container, and a
# continue co... |
31dfc6f78ac61e9cd4e39d33175a825542535592 | bpruitt63/python-and-flask | /python-ds-practice/27_titleize/titleize.py | 364 | 3.921875 | 4 | def titleize(phrase):
"""Return phrase in title case (each word capitalized).
>>> titleize('this is awesome')
'This Is Awesome'
>>> titleize('oNLy cAPITALIZe fIRSt')
'Only Capitalize First'
"""
lst = phrase.split(' ')
nlst = []
for word in lst:
nlst.append(w... |
ca21870eede88503c013ed741eac2d1581d68554 | SachinSPawar/wordmatch-backend | /checkword.py | 1,206 | 3.84375 | 4 | import string
import random
from random import seed
from random import randint
vowels="aeiou"
consonants="abcdefghijklmnopqrstuvwxyz"
def checkword(word,characters):
word= word.upper()
characters=characters.upper()
letters = {}
for c in word:
letters[c]=1
for c in characters:
... |
10ea306fedbee3cff2ce63c97add2561c9f2b54a | mbkhan721/PycharmProjects | /RecursionFolder/Practice6.py | 2,445 | 4.40625 | 4 | """ Muhammad Khan
1. Write a program that recursively counts down from n.
a) Create a recursive function named countdown that accepts an
integer n, and progressively decrements and outputs the value of n.
b) Test your function with a few values for n."""
def countdown(n): # def recursive_function(parameters)
if n... |
b4649ad4164529beddc033f4e141fce74d56b637 | mbkhan721/PycharmProjects | /pythonProject/Functions.py | 3,765 | 4.125 | 4 | # star* means unlimited args
def my_function(*kids):
#for name in kids:
#print(name)
#print(kids)
print("The youngest child is " + kids[4])
my_function("Emil", "Tobias", "Linus", "John", "Khan")
print()
print("------------- Exercise 12 -------------")
print()
import random
from random import randr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.