blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
c9a93fcb2a616d77b83eaa45f84cbcb9b9721de7 | SAINTpsycho/lerninpython | /PythonLearning/goaltwo.py | 348 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jul 23 15:10:30 2020
@author: varta
"""
import string
alpha_string = string.ascii_lowercase
alpha_list = list(alpha_string)
vowels = ['a', 'e', 'i', 'o', 'u']
name = 'mason grosko'
for x in alpha_list:
if x in name:
print(x.upper())
else:
if x in vo... |
951f01b0e8979e1974b39fc5e54d88fbb8a53601 | rajat503/Data-Structures-and-Algorithms | /python/sort/insertionsort.py | 208 | 3.8125 | 4 | def INSERTION_SORT(A):
n = len(A)
for i in range(1, n):
x = A[i]
j = i-1
while j >= 0 and x < A[j]:
A[j+1] = A[j]
j -= 1
A[j+1] = x
return A |
9fff1292d1e3688a3851e3ed670e9ce2b6c3f886 | annasw/HackerRank | /CtCI/Arrays-Left-Rotation.py | 622 | 3.8125 | 4 | # sort of badly explained (why are the variable names different here and in the problem description??)
# but i'm pretty sure n is the number of integers, k is the number of rotations, a is the list/array
# i tried a failed version with actual rotations before I figured out you can just do it all at once (also modulo)
d... |
e8a3698ef220f29a22bafffdfb7f477b68f26a41 | annasw/HackerRank | /Algorithms/Implementation/Encryption.py | 871 | 3.796875 | 4 | #!/bin/python
import sys
import math
s = ''.join(raw_input().strip().split(' '))
# first we determine the number of rows and columns
L = len(s)
f,c = map(int, (math.floor(math.sqrt(L)), math.ceil(math.sqrt(L))))
rows,columns = 0,0
if f*f>=L:
rows,columns = f,f
elif f*c>=L:
rows,columns = f,c
else:
rows,c... |
01eff00c37b7cd9083b5a3439aab160accfa6c15 | annasw/HackerRank | /30DoC/Day-26-Nested-Logic.py | 573 | 3.78125 | 4 | actualDay, actualMonth, actualYear = map(int, input().split())
dueDay, dueMonth, dueYear = map(int, input().split())
fine = 0
if actualYear > dueYear: # more than a year late
fine = 10000
elif actualYear < dueYear:
fine = 0
else: # year is the same
if actualMonth > dueMonth: # at least one month late
... |
9c839ced81eb51fc86013cd0033ee59534805596 | annasw/HackerRank | /Algorithms/Dynamic-Programming/Coin-Change-Problem-[NOTDONE].py | 909 | 3.640625 | 4 | # this isn't even at the testing stage yet
# i'm just saving it here so it doesn't get deleted from hackerrank
d = {}
# takes a goal number and a list of coins,
# returns number of ways to make change for goal with coins
def makeChange(goal, ls):
if goal==0:
return 1
elif goal<ls[0]:
d[goal] =... |
0404cc777fe456dac49f11713c5655b5606cf3df | annasw/HackerRank | /Algorithms/Search/KnightL-on-Chessboard-NOTWORKING.py | 2,181 | 3.625 | 4 | '''
Doesn't work yet.
Didn't finish implementing it.
'''
class MyQueue(object):
def __init__(self):
self.inbox = []
self.outbox = []
def fillOutbox(self):
if not self.inbox:
raise IndexError('Tried to fill outbox without anything in inbox')
else:
whi... |
9f7d6483a7f6661e78fb79fce1269efa839b18de | nirajkmr007/Python | /prac/Bombard.py | 1,261 | 3.515625 | 4 | '''
Created on Oct 24, 2017
@author: Niraj.Kumar
'''
'from given string remove same char if they are together till there are no such.'
class Bomb(object):
def bombard(self,lst):
start = 0
end = 0
i = 0
flag = True;
while flag:
flag = False
... |
66af55819c15092e3431065410c26c302cf2e279 | Tayyab-Ilahi12/Python-Programs-for-practice | /FlashCard Game.py | 1,900 | 4.46875 | 4 |
"""
This flashcard program allows the user to ask for a glossary entry.
In response,if user select show flash card
the program randomly picks an entry from all glossary
entries. It shows the entry. After the user presses return, the
program shows the definition of that particular entry.
If user select show_defi... |
4f58cdbfa6c6e24a07ad1305632cca0e50dfb70b | Ananya31-tkm/PROGRAMMING_LAB_PYTHON | /CO2/CO2-Q1.py | 213 | 4.1875 | 4 | n=int(input("enter number:"))
fact=1
if n<0:
print("cannot find factorial")
elif n==0:
print("Factorial is 0")
else:
for i in range(1,n+1):
fact=fact*i
print("Fctorial of ",n," is",fact)
|
401d20218b09da5be3ce0eaa054310ef939e7486 | Skinkeve/Prototype-door-sensor | /Prototype file.py | 1,051 | 3.5 | 4 | people = 0 #hvor mange mennesker der aktuelt er i rummet
maxpeople = 50 #max antallet af mennesker der må være i rummet
entering = False #bool der er sand hvis der er en på vej ind af døren
exiting = False #bool der er sand hvis der er en der er på vej ud af døren
redlight = False #bool der er sand hvis lyset skal lyse... |
2512358d04a1f4760e96ed1ca846d1ccb2e8af8a | vamsigontla7/MyLearningRepo | /Python_Practice/draw_shape.py | 628 | 3.765625 | 4 | import turtle
def draw_shape() :
window = turtle.Screen()
window.bgcolor("pink")
turtle.shape('turtle')
turtle.color('yellow')
turtle.speed(0)
brad = turtle.Turtle()
brad.color('red')
i=0
while i<4 :
brad.forward(100)
brad.right(90)
i = i+1
a... |
a22fca2b62384a297e2feea5dbfa57a3dc509313 | ArtHouse5/python_progs | /simple_tasks.py | 2,303 | 4.21875 | 4 | #1
print('Create list of 6 numbers and sort it in ascending order')
l=[4,23,15,42,16,8]
print('The initial list is ',l)
l.sort()
print(l)
print()
#2
print('Create dictionary with 5 items int:str and print it pairwise')
d = {1 : 'one', 2 : 'two', 3 : 'three', 4 : 'four', 5 : 'five'}
print('The initial dictionaty is ',d... |
d00a6588566a6bac5d73f62d77761f110417288a | eshanim/python | /haiku.py | 1,327 | 4.03125 | 4 | from random import randint
syl5 = ["Flying in the sky",
"Laptop keys clicking",
"Stars shining at night",
"The sunshine is bright",
"An old silent pond",
"Long walk to water",
"Long snakes slithering",
"A cricket chirping",
"Loud ducks are quacking",
"Small cows are mooing",
"A fat bee stings me"]
... |
161fcaf1ad64be1d6942a278478974a879d0026b | eshanim/python | /hangman.py | 1,260 | 4.0625 | 4 | from random import randint
hangman = ["jazz",
"boutique",
"computer",
"whiteboard",
"projector",
"notebook",
"window",
"carpet",
"elephant"]
correct_letters = []
letters_left = ["a","b","c","d","e","f","g","h","i","j","k","l","m","... |
84eb3ee863968a88040bc340e045394ae31567e0 | eshanim/python | /functions.py | 795 | 4.0625 | 4 | def add(num1, num2):
print ("The sum is " + str(num1 + num2) + ".")
return
def sub(num1, num2):
print ("The difference is " + str(num1 - num2) + ".")
return
def mul(num1, num2):
print ("The product is " + str(num1 * num2) + ".")
return
def div(num1, num2):
print ("The quotient is " + str(num1 / num2) + ".")
... |
f3407d2e6fba29be8a767e14f58369da5d4c962b | pratham-99/programs | /smallest no in list.py | 237 | 3.71875 | 4 | '''lst= [34,56,78,34,45,2,67]
minimum=lst[0]
for x in lst:
if x<minimum:
minimum=x
print(minimum)
print(min(lst))'''
lst=[]
num=10
for i in range(1, num+1):
ele = int(input("Enter no: "))
lst.append(ele)
print(lst) |
ff081fe7819acddfeb9652e1912e226734d948ab | pratham-99/programs | /find n largest no.py | 295 | 3.640625 | 4 | lst = [6, 8, 5, 4, 7, 22, 65, 34, 84, 74]
n = 3
final_list = []
for i in range(0, n):
max1 = 0
for j in range(len(lst)):
if lst[j] > max1:
max1 = lst[j]
lst.remove(max1)
final_list.append(max1)
print(final_list)
# second largest element
print(final_list[1])
|
6da2db7306c261a31f98f156591f8b6e8d3c9eef | FernandoJunior16/FATEC-MECATRONICA-RA1600792021040-FERNANDO | /LTP1-2020-2/Pratica03/programa04.py | 164 | 3.953125 | 4 | # Pede um valor em cm e converte para metros
valor_cm = float(input("Informe um valor em cm: "))
valor_m = valor_cm / 100
print("Valor convertido em m: ", valor_m)
|
4067855aa4a4407331f3292622029f5a1fc8a0be | annamaryjacob/Python | /RegularExpression/quantifier.py | 216 | 3.578125 | 4 | import re
#x='a+'
#x='a*'
#x='a?'
#x='a{2}'
#x='a{2,3}'
#x='^a'
x='a$'
matcher=re.finditer(x,'abaabaaaacaab')
for match in matcher:
print("Match is available at",match.start())
print("Group = ",match.group()) |
37c11335a630da8d6d51ed41c138c592067b0456 | annamaryjacob/Python | /Collections/set/set.py | 301 | 3.828125 | 4 | lst=[10,10,20,30,40]
d=set(lst)
print(d)
# to remove duplicates from the list convert the list into set
st1={10,20,30,40}
st2={50,60,4,45}
#st1.union(st2)
#OR
#un=st1|st2
print("union of 2 sets=",un)
#TO FIND UNION OF 2 SETS
com=st1.intersection(st2)
print(com)
dif=st1.difference(st2)
print(dif)
|
26c5fccbb5195fa4eaccef23c321e72e1760e3bc | annamaryjacob/Python | /Flowcontrols/Decisionmaking/clothtype.py | 957 | 4 | 4 | cloth=int(input("Enter 1 for Cotton, 2 for Silk and 3 for Linen"))
price=int(input("Enter price of cloth"))
if(cloth==1):
if(price>20000):
disc=(10/100)*price
elif((price>15000)&(price<=20000)):
disc=(9/100)*price
elif((price>14000)&(price<=15000)):
disc=(7/100)*price
elif((price... |
ad01aa245f675d4f11fd3ad1b39de32ab73a6d61 | annamaryjacob/Python | /OOP/Polymorphism/po1.py | 714 | 4.09375 | 4 | def add(no1):
no2=20
print(no1+no2)
def add(no1,no2,no3):
res=no1+no2+no3
print(res)
def add(no1,no2,no3,no4):
res=no1+no2+no3+no4
print(res)
#Function over loading
#same function but different number of arguments
#only the most rescently implememted function can be invoked
#ie, only add(1,2,... |
ccc89332401175b9730f27f076440aa1e37b43a0 | annamaryjacob/Python | /Functions/cubefnc.py | 86 | 3.65625 | 4 | def cube():
no1=int(input("Enter a value"))
res=no1**3
print(res)
cube()
|
d16fca91d7550b7a22417b6730d2d92cde1b217b | annamaryjacob/Python | /OOP/Polymorphism/2str.py | 508 | 4.25 | 4 | class Person():
def setPerson(self,age,name):
self.age=age
self.name=name
def __str__(self):
return self.name+str(self.age)
ob=Person()
ob.setPerson(25,"name")
print(ob)
#When we give print(ob) we get '<__main__.Person object at 0x7f92fee45ba8>'. This is the method called 2string met... |
5ed0c47a4ca42b42ba9ab6b39efb418cabd3c372 | MohamadHajjRabee/100-Days-python-challenge | /Day-005/password-generator.py | 1,451 | 3.890625 | 4 | import random
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
numbers = ['0', '1', '2'... |
2ed480da86d3120c9df6e1688898e0c530f9a71d | MohamadHajjRabee/100-Days-python-challenge | /Day-009/main.py | 637 | 3.609375 | 4 | from logo import logo
import os
def clear():
return os.system('cls')
print(logo)
Infos = {}
continue_bidding = True
while continue_bidding:
username = input("What is your name?: ")
userbid = int(input("What is your bid?: $"))
Infos[username] = userbid
more_bidders = input("Are there any other ... |
a9354007401e1ece7511b4f898b3d3bb203848b0 | rubiruchi/artificial-intelligence | /misc/heapsort.py | 1,873 | 3.640625 | 4 | class minHeap:
def __init__(self, size):
self.size = size
self.mH = [0]*10
self.position = 0
def createHeap(self, arrA):
if len(arrA) > 0:
for num in range(len(arrA)):
self.insert(arrA[num])
def display(self):
for i in range(1, se... |
46bc9352a1e7911bfb472ed12ad173517653effb | rubiruchi/artificial-intelligence | /Sudoku/sudoku_v2.py | 5,803 | 3.625 | 4 | # Name: Jason Liu
# Block: 7
# Email: 2017jliu@tjhsst.edu
import time
import math
import heapq
from collections import deque
import copy
import random
from random import shuffle
class nQueens:
def __init__(self, state=None, choices=None, n=None, parent=None):
""" creates an nQueens board where state is... |
c4b24f9e0d2da0c06f896d8cb8448c3d798c9d80 | rubiruchi/artificial-intelligence | /entropytree/entropy.py | 629 | 3.796875 | 4 | import math
def entropy(list):
total = 0
listSum = sum(list)
for val in list:
if val is 0:
total += 0
else:
total += (val/listSum) * math.log(val/listSum, 2)
return -1 * total
def avg_entropy(list):
total = 0
listSum = 0
# gets total values in list
... |
29c6c3e91b451c36c9c378cd9c2cc8311ea27bd7 | zhouanqi/python-algorithm | /permuteUnique.py | 744 | 3.609375 | 4 | import itertools
def permuteUnique(nums):
# write your code here
a = []
if len(nums) == 0:
return [a]
for i in itertools.permutations(nums):
if list(i) not in a:
a.append(list(i))
return a
assert permuteUnique([1,2,2])==[[... |
be634801a153e56f5726de22f219cf16d127a8d0 | zhouanqi/python-algorithm | /searchMatrix.py | 769 | 3.875 | 4 | def searchMatrix(matrix, target):
# write your code here
end=len(matrix)-1
begin=0
mid=0
if target in matrix[begin]:return True
if target in matrix[end-1]:return True
while begin<end:
mid=(begin+(end-begin))//2
if target in matrix[mid]:
return True
elif target>matrix[begin][0]:
begin=begin+1
... |
6f9f2c0cf2d19cb2661026d9fb32b35993f4a824 | NoctemLeges/School-Project | /prog7.py | 520 | 3.859375 | 4 | s = input("Enter a sentence")
len_dict = {}
l = s.split()
count = 0
result = ""
#Arranging
for w in l:
len_dict[w] = len(w)
l_sorted = list(len_dict.values())
l_sorted.sort()
for i in l_sorted:
for w in len_dict:
if len_dict[w] ==i:
result+=w + " "
print(result)
#___________________________... |
6c048cc77e200c6e6a379addf34afc63bf910e5a | mherr77m/pg2014_herrera | /HW2/HW2_q1.py | 1,280 | 4.3125 | 4 | # !env python
# Michael Herrera
# 10/18/14
# HW2, Problem 1
# Pass the function two arrays of x,y points and returns
# the distance between all the points between the two arrays.
import numpy as np
def distance(array1,array2):
"""
Calculates the distance between all points in two
arrays. The arrays don't... |
00af83076665a8106b05159db475e748d0db3434 | mherr77m/pg2014_herrera | /HW2/HW2_q3.py | 1,028 | 3.765625 | 4 | # !env Python
# Michael Herrera
# 10/18/14
# HW2, Problem 3
# Passes the function the data to a high pass filter
# that removes the trend with a given order polynomial.
import numpy as np
import matplotlib.pyplot as plt
def high_pass(x, y, n = 1):
"""
High pass filter. Takes x,y data as input and removes
... |
f85871d7a38dfbc96d4bacb6369d9df9b1ec3373 | stevemendozajr/python-challenge | /PyPoll/main.py | 3,940 | 3.625 | 4 | import os
import csv
# creating variable name of incomingCSV to collect the budget data csv file
incomingCSV = os.path.join( "election_data.csv")
#define lists to hold data we will extract from the csv file
#VoterID to put each voter id into a list
#County to put each county into a list
#Candiate to put each canida... |
e0e2edb11476685b87d157d1dfeda17654b5333c | anstones/py-collection | /interface_algo.py | 6,586 | 3.671875 | 4 | def binry_search(lists, item):
""" 二分法查找:循环 """
num_list = sorted(lists)
left, right = 0, len(num_list)
while left < right:
middle = (left + right) // 2
if lists[middle] < item:
left = middle +1
elif lists[middle] > item:
right = middle
else:
return "待查元素{}在列表中下标为{}".format(item, middle)
return... |
ac8d4d04a1118995b2aba680aa09472a85a7d92d | nikhitha1997/studentproctor | /proct.py | 1,817 | 4.25 | 4 |
#Student procter
class Student():
def studentdetails(self): #adding the student details
"""
Attributes:
self.student_name --- name of the student
self.usn ---- usn of that perticutar student
self.ph_no
self.branch----branch of the student_details
self.marks---student internal and exte... |
ca7c7c91bf638b4e18660677fe8fb4f7630c4c01 | Neenu1995/CHPC-PYTHON | /bisection_cuberoot.py | 322 | 4.125 | 4 | number = input('Enter the number : ' )
number = float(number)
change = 0.00001
low =0.0
high = max(1.0,number)
mid = (low+high)/2.0
while (abs(mid**3-number)>=change):
if mid**3<number:
low = mid
else:
high = mid
mid =(low+high)/2.0
print 'The cube root of ', number ,' is ', mid... |
7740b01b59b860367ca6b99f7372e384b5b01cf8 | adeept/Adeept_Ultimate_Starter_Kit_for_RPi | /Lesson08_PIR_Movement_Sensor/code/python/Lesson08_PIR_Movement_Sensor.py | 646 | 3.640625 | 4 | import RPi.GPIO as GPIO
import time
PIR_OUT_PIN = 11 # pin11
def setup():
GPIO.setmode(GPIO.BOARD) # Numbers GPIOs by physical location
GPIO.setup(PIR_OUT_PIN, GPIO.IN) # Set BtnPin's mode is input
def loop():
while True:
if GPIO.input(PIR_OUT_PIN) == GPIO.LOW:
print('...Movement not detected!')
... |
b7ce59d44d6c85d447868d6682eddf5181a65554 | vcslav-v/python-project-lvl1 | /brain_games/games/even.py | 438 | 3.609375 | 4 | """Even or not game."""
from random import randint
MIN_NUMBER = -100
MAX_NUMBER = 100
INSTRUCTION = 'Answer "yes" if number even otherwise answer "no".'
def get_round_data() -> tuple:
"""Generate quest/answer for even or not game.
Returns:
(quest, right answer)
"""
quest = randint(MIN_NUMBE... |
8f9ccee81196907bbbcb3202e901f6a919876f8d | Manandkumar/MyProjects | /Python/do_while.py | 131 | 3.78125 | 4 | for i in [0,1,2,3,4]:
print ("Hello" + str(i))
counter =0
while counter <5:
print ("Hello" + str(counter))
counter = counter+1
|
a1f50b863716f6b0c6b304058a9fc3ff963e4011 | Manandkumar/MyProjects | /Python/ifstatement.py | 209 | 3.8125 | 4 | myvar=50
if myvar<=50:
print("Yes, your number is less than or equal to 50")
print("Good")
else:
print("No, your number is greater than 50")
print("Bye!!")
|
0a25bb8043c6826d15d75af121775efbaf73ed9f | HMinhP/BoSTEMproject-MinhP | /mountainPaths (1).py | 8,410 | 4.25 | 4 | import matplotlib.pyplot
import copy
import random
def data_to_2d(data, rows, columns):
"""
Convert input 1D data list into a 2D list.
Data should be indexed by row number, column number
For example, l[0] = the first row, l[0][0] is the element in the first column of the first row
Return the ... |
951a2b36fee6d575913ee14ca21b9dcb7e0fda35 | bariserdogan/PythonStartUp | /eight.py | 982 | 3.625 | 4 | #-*- coding:utf-8 -*-
# Search in dictionary
import string
import sys
import time
def main():
sozluk = { "kitap":"book",
"bilgisayar":"computer",
"masa":"table",
"programlama":"programming",
"envanter":"inventory"}
sozcukler=[]
counter=0
... |
9ae156fcad498de7d2c65316beed29dbb7ca994d | bariserdogan/PythonStartUp | /classes1.py | 418 | 3.609375 | 4 | #-*- coding:utf-8 -*-
import string
import sys
import time
from os import*
sesli_harfler="aeıioöuü"
katar = raw_input("Bir şeyler yazın:")
yeni_list=[]
sayac=0
for k in katar:
if k in sesli_harfler:
if k not in yeni_list:
yeni_list.append(k)
sayac+=1
mesaj = "{} kelimesinde {} ade... |
a64c3a30e292139bf9532c1589de9abe904803b8 | guspihl/aoc20 | /day11/day11_1.py | 1,619 | 3.53125 | 4 | #Advent of Code 2020 - Day 11
import itertools
def check_empty_adjacents(i,j):
permutations = itertools.product([i-1,i,i+1],[j-1,j,j+1])
for x,y in permutations:
if x < 0 or x >= len(l) or y < 0 or y >= len(l[x]) or (x==i and j==y):
continue
if l[x][y] == '#':
return Fa... |
643b88cbe2c71aab3228987dda2d934d3dbbfb59 | ChuckData/Coding_the_Matrix | /0525.py | 1,444 | 3.96875 | 4 | import math
import math
def digits(number, base): #this calculates how many digits are required to represent a number in a given base
if number == 0:
return 1
else:
logarithm = math.log(number, base)
if logarithm >= int(logarithm):
return int(logarithm) + 1
else:
return int(logarithm)
b... |
3cdfa31d4066b962a65d9a405332a9d271e36a74 | ChuckData/Coding_the_Matrix | /0511.py | 111 | 3.59375 | 4 | List_A = ['A', 'B', 'C']
List_1 = [1, 2, 3]
List_A1 = [[x,y] for x in List_A for y in List_1]
print(List_A1) |
2523b5db863d191a31fb2a9a255b2833654fc4d5 | iglpdc/dmrg_helpers | /dmrg_helpers/extract/tuple_to_key.py | 568 | 4.0625 | 4 | '''A function to build keys for the database.
'''
def tuple_to_key(t, delimiter=u':'):
'''Joins the elements of a tuple into a string using delimiter.
Parameters
----------
t: a tuple
You want to join this.
delimiter: a string
You want to join usig this as a delimiter.
Returns... |
a501023954f891113887b20f51834a055e565819 | iglpdc/dmrg_helpers | /dmrg_helpers/view/separate_plots.py | 9,992 | 3.890625 | 4 | """Functions to remove some of the plots.
Usually you have a bunch of plots and you may want to remove some to them to
keep only those separated by a certain distance, so the graph is not
cluttered with tens of lines.
"""
from dmrg_helpers.core.dmrg_logging import logger
import numpy as np
import operator
from itertoo... |
1b4471df0af7a575d8798a5aa195e59406b6b4e8 | vikorbit/othertasks | /task_2.py | 2,629 | 3.671875 | 4 | #!/usr/bin/python
import sys
import unittest
def get_split_index(n, m):
if type(n) is not int:
raise ValueError('type(n) is not int')
if type(m) is not int:
raise ValueError('type(m) is not int')
if n <= 0:
raise ValueError('n can not to be less or equal 0 (n={})'.format(n))
... |
9874bee48606b2858389e9f8c2677503adf08f23 | ebellau-uno/AgileUnoModule3 | /Assignment1.py | 156 | 3.578125 | 4 | # Module 3 Assignment
#Eugene Bellau
file = open("question.txt","r+")
question = file.read()
response = input(question)
file.write(response)
file.close()
|
32a832b5c8e40dc151030bde56c07e024eca2ea5 | ionutmarghidanu/liga-ac-labs-2021 | /Andrei/Xand0/Game.py | 5,043 | 3.75 | 4 | from Player import Player
import random
class Game:
def __init__(self, player1_name, player2_name):
self.player1 = Player(player1_name, ' ')
self.player2 = Player(player2_name, ' ')
self.moves = [1, 2, 3, 4, 5, 6, 7, 8, 9]
self.current_player = None
self.points = [0, 0]
... |
88e897d83ac29ca2761ee12587c3f4a7a135cc98 | ionutmarghidanu/liga-ac-labs-2021 | /lab4/ex2.py | 529 | 3.515625 | 4 | def read_lines(file_path):
with open(file_path, 'r') as f:
for line in f:
print(line)
def read_lines_generator_function(file_path):
with open(file_path, 'r') as f:
for line in f:
yield line
if __name__ == '__main__':
#read_lines('pg100.txt')
lines = read_lines_g... |
236a2cea8c179cb2ce1d4a8c9fe1c53c22ff1226 | ggoolsby/CS-101-HW | /graysongoolsby_HW5.py | 1,496 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Mar 14 09:44:07 2017
@author: graygoolsby
Name: Grayson Goolsby
Date: 03-22-17
Lab: X
"""
import turtle
def binary2decimal(bs):
"""converts a binary string to a decimal number"""
if bs=='':
return 0
else:
return binary2decimal(bs[:-1])*2+(int... |
ae9c50436d02ef8a17bef261fc1a68a556a01ac5 | harshitpoddar09/CodeChef-Solutions | /Beginner/Grade The Steel.py | 441 | 3.546875 | 4 | # cook your dish here
t=int(input())
for i in range(t):
[hard,carbon,tensile]=list(map(float,input().split()))
grade=5
if hard>50 and carbon<0.7 and tensile>5600:
grade=10
elif hard>50 and carbon<0.7:
grade=9
elif carbon<0.7 and tensile>5600:
grade=8
elif hard>... |
b929bf36fef63b96799bed006821e64959da2d9c | harshitpoddar09/CodeChef-Solutions | /Beginner/Chef and Interactive Contests.py | 169 | 3.515625 | 4 | # cook your dish here
N,r=map(int,input().split())
for i in range(N):
R=int(input())
if R>=r:
print('Good boi')
else:
print('Bad boi') |
e24d10aef4f22f59ebe3444b974940b679db0fd7 | stiero/supreme-octo-computing-machine | /02_02_begin/read_maze.py | 885 | 4.0625 | 4 | """
Python Data Structures - A Game-Based Approach
Reading a maze from a text file
Robin Andrews - https://compucademy.net/
"""
def read_maze(file_name):
"""
Reads a maze stored in a text file and returns a 2d list containing the maze representation.
"""
try:
with open(file_name) a... |
41c85076f8b712dc6700f73bb4ec7a515b8afc0c | NiketPatel9/ProBowlPrediction | /retrieve_csv.py | 3,162 | 3.765625 | 4 | """
This module is responsible for extracting CSVs as well as cleaning them up and combining them.
"""
import requests
import pandas as pd
from bs4 import BeautifulSoup
def create_csvs():
"""
This function is responsible for web scraping various years from the Pro Football Database as well
as cleaning up ... |
bcb3abe0c7943a167f487d0cf4d962a4dc14812d | mchrupcala/Computer-Architecture | /ls8/cpu.py | 3,124 | 3.984375 | 4 | """CPU functionality."""
import sys
class CPU:
"""Main CPU class."""
def __init__(self):
"""Construct a new CPU."""
#hold 256 bytes of memory
self.ram = [0] * 256
# 8 general-purpose registers
self.r0, self.r1, self.r2, self.r3, self.r4, self.r5, self.r6, self.r7 = 0, ... |
4da697ef31f35dfd110f71a953539a453f78aba9 | chefpiester/python-challenge | /pybank/PyBank.py | 1,976 | 4.09375 | 4 | import pandas as pd
csvfile = input("csv file you want to get analyzed : ")
# budget_data_1.csv
data = pd.read_csv(csvfile)
countmonth = data["Date"].count()-1
total_rev = data["Revenue"].sum()
print("Financial Analysis")
print("----------------------------")
print("Total Months: " + str(countmonth) )
prin... |
37002a9d4b49fff6b781b83d2d02a777b1362bb7 | Jeyabalajips/Hacktoberfest2021-2 | /Python/Acronyms.py | 273 | 3.78125 | 4 | class Solution:
def solve(self, s):
tokens=s.split()
string=""
for word in tokens:
if word != "and":
string += str(word[0])
return string.upper()
ob = Solution()
print(ob.solve("Indian Space Research Organisation"))
|
544b89a63c6449cf7612f7a4990c5f6e972e40d8 | WANQITANG/COMP9418 | /comp9418_ass21.py | 18,046 | 3.515625 | 4 |
# coding: utf-8
# # Assignment 2 (Practical)
#
# **COMP9418 - Advanced Topics in Statistical Machine Learning**
#
# **Louis Tiao** (TA), **Edwin V. Bonilla** (Instructor)
#
# *School of Computer Science and Engineering, UNSW Sydney*
#
# ---
#
# In the practical component of this assignment you will build a *clas... |
185abd0b12115a2cf3f91ac799fccc664c403a14 | LessonsWithAri/textadv | /next.py | 1,803 | 4.15625 | 4 | #!/usr/bin/env python3
INVENTORY = []
room_learning_took_soda = False
def room_learning():
global room_learning_took_soda
print("You are in room #312. You see a Kellan, a Maria, and a Brooke.")
if not room_learning_took_soda: print("There is a can of soda on the table.")
print("Exits: DOOR")
comma... |
6a8b4dab5c7639a003dc530cb9d4bf6c5fb5c552 | Michaeloye/python-journey | /simp-py-code/Password_Validation_sololearn.py | 1,044 | 4.40625 | 4 | # Password Validation : You are interviewing to join a security team. They want to see you build a password evaluator for your technical interview to validate
#the input.
#task: Write a program that takes in a string as input and evaluates it as a valid password. The password is valid if it has a minimum 2 numbers, 2 ... |
9940f0e66b71ed701e9ee4440772a39b4f0d8726 | Michaeloye/python-journey | /simp-py-code/Tkinter_trial_DL.py | 2,046 | 4.5625 | 5 | from tkinter import * # Import all definitions from tkinter
window = Tk() # Create a window
label = Label(window, text = "Welcome to Python") # Create a label
button = Button(window, text = "Click Me") # Create a button
label.pack() # Place the label in the window
button.pack() # Place the button in the window
window... |
338d446f53b76308220122fdd2b1115eaf3906db | Michaeloye/python-journey | /simp-py-code/raise_to_power.py | 588 | 4.40625 | 4 | #raise to power
base_num = int(input("Enter the base number: "))
pow_num = int(input("Enter the power number: "))
def raise_to_power(base_num, pow_num):
result = 1
for num in range(pow_num):
'''since the pow_num is what the base_num will multiply itself by.
so pow_num if 3 will cause the code lo... |
a68f609d435c84d30dc569699894df16d8db9354 | Michaeloye/python-journey | /simp-py-code/New_driver's_license_sololearn.py | 1,372 | 4.1875 | 4 | # New Driver's License
#You have to get a new driver's license and you show up at the office at the same time as 4 other people. The office says that they will see everyone in
#alphabetical order and it takes 20 minutes for them to process each new license. All of the agents are available now and they can each see one... |
00938a96d81fc7a5746091eec52b37eddea053ff | Michaeloye/python-journey | /simp-py-code/File_editor.py | 2,647 | 3.828125 | 4 | from tkinter import *
from tkinter.filedialog import askopenfilename
from tkinter.filedialog import asksaveasfilename
class FileEditor:
def __init__(self):
window = Tk()
menu_bar = Menu(window)
window.config(menu = menu_bar) # Display menu bar
# create a pulldown menu and ad... |
9e557bdb4659f1d6b376f52b956f3f0a547db307 | Michaeloye/python-journey | /simp-py-code/DL_9.7ex_LoanCalcutor.py | 2,436 | 4.09375 | 4 | from tkinter import *
class Loan_Calculator:
def __init__(self):
window = Tk()
label_1 = Label(window, text = "Annual Interest Rate")
self.Annual_Interest_Rate = DoubleVar()
entry_1 = Entry(window, textvariable = self.Annual_Interest_Rate, justify = RIGHT)
... |
24f8a43e73503662cd2a930ad44a5fe1cb29e16f | Michaeloye/python-journey | /simp-py-code/task21.py | 658 | 4.125 | 4 | # Bob has a strange counter. At the first second t=1, it displays the number 3. At each subsequent second, the number displayed by the counter decrements by 1.
# the counter counts down in cycles. In the second after the counter counts down to 1, the number becomes 2 times the initial number for that countdown cycle
# ... |
a6045032dc4ddfc34b6d92bd84a24fa2fe552e0c | Michaeloye/python-journey | /simp-py-code/DL_13.4_Counting_each_letter_in_a_file.py | 3,287 | 3.671875 | 4 | from tkinter.filedialog import askopenfilename
def counting_letter():
file_name = askopenfilename()
infile = open(file_name, "r")
file_read = infile.read()
count_for_a = 0
count_for_b = 0
count_for_c = 0
count_for_d = 0
count_for_e = 0
count_for_f = 0
count_for_g = 0
cou... |
25b83260765a26cab0ba821ad5b69b5161ffc171 | Michaeloye/python-journey | /simp-py-code/task7.py | 672 | 4.1875 | 4 | # Given a string input count all lower case, upper case, digits, and special symbols
def findingchars(string):
ucharcount = 0
lcharcount = 0
intcount = 0
symcount = 0
for char in string:
if char.isupper():
ucharcount+=1
elif char.islower():
lcharcount+=1
... |
27924b2a468c28dbb2ef6be1686bc647fd7917d5 | npelletier/EECS448_projectGroup | /Board.py | 2,339 | 3.875 | 4 | import random
class Cell:
"""
Store data for each cell in the grid. Upon initiation, a Cell is not a bomb,
not revealed, not flagged, and adjacent to no bombs.
"""
def __init__(self):
self.isBomb = False
self.isRevealed = False
self.isFlagged = False
self.adj = 0
... |
86cb44421908e795da7c76e22956b6717622c65a | markajino/Python_September | /2020-09-18/task_1/sos.py | 1,696 | 3.6875 | 4 | import random
def main():
table = []
# create the 10x10 table of random S and O
for i in range(10):
table.append([])
for j in range(10):
if random.random() > .5:
table[i].append("S")
else:
table[i].append("O")
# display the ... |
ef90fe364d42f188838ac70aa5dd0a1d2ffe2cea | amukiza/Python_FizzBuzz | /test_fizz_buzz.py | 1,303 | 3.640625 | 4 | import unittest
from fizz_buzz import FizzBuzzGame
class TestFizzBuzz(unittest.TestCase):
def setUp(self):
self.game = FizzBuzzGame()
def test_returns_a_one_when_given_one(self):
self.assertEqual("1", self.game.play(1))
def test_returns_Fizz_when_given_two(self):
self.assertEqua... |
860182b6aba242eff68e27fc8d8ed124133a9c28 | eareyan/gamelearning | /util_random.py | 1,434 | 3.5625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed May 2 14:00:15 2018
@author: enriqueareyan
Centralized file for all operations involving randomness.
"""
import numpy as np
import itertools
import game
import player
import random
import string
noise_c = 5
#noise_c = 2
random_game_noise_c = 100
... |
3f883f5768caeccbdc589a148fd7722265d0c40b | Redwiat/One_month | /math.py | 516 | 4.0625 | 4 | #Python math functions
#Python is famous for it's ability to do amazing things with numbers and math.
# + plus
# - minus
# / divide
# * times
# ** exponentiation
# % modulo
# < less then
# < greater then
print("what is the answer to life, the universe, and everything?", int((467 + 318 - 31) *67 / 12) )
... |
a802e0447e69c9e42b353305575d0762fcbc3f86 | fish-py/PythonImpl | /collections/dict.py | 237 | 4.125 | 4 | dict1 = {
"firstName": "Jon",
"lastName": "Snow",
"age": 33
}
"""
遍历dict
"""
for key in dict1.keys():
print(key)
for value in dict1.values():
print(value)
for key, value in dict1.items():
print(key, value)
|
59f4a4d3545ed9a75643aad61af21efbbba026bd | fish-py/PythonImpl | /oop/magic/math.py | 679 | 4.0625 | 4 | from math import hypot
# Return the Euclidean distance, sqrt(x*x + y*y).
class Vector:
def __init__(self, x = 0, y = 0):
self.x = x
self.y = y
def __str__(self):
return 'Vector(%r, %r)' % (self.x, self.y)
# 返回当前向量的摸
def __abs__(self):
return hypot(self.x, self.y)
... |
45df33b916bb8d19ac17790fb182f14166480437 | fish-py/PythonImpl | /collections/sorted_list.py | 449 | 4.1875 | 4 | """
sorted函数可以将一个iterable进行排序
使用的时候我们需要传递一个函数作为排序规则
https://www.runoob.com/python/python-func-sorted.html
"""
# 自定义排序规则: 按照字符串的长度来排序
def key(item):
return len(item)
if __name__ == "__main__":
list1 = ["Java", "Python", "C", "Go", "C++"]
list2 = sorted(list1, key=key)
print(list2)
# ['C', 'Go',... |
99897c0894c49f1cc4b276f475502b9e52f74281 | LearningNaveen1/PythonCodeExamples | /Strings/Anagram.py | 409 | 3.953125 | 4 | def checkAnagram(str1, str2):
len1 = len(str1)
len2 = len(str2)
if(len1 != len2):
return 0
str1 = sorted(str1)
str2 = sorted(str2)
# Return 0 - Return false and Return 1 - True
for i in range(0,len1):
if(str1[i] != str2[i]):
return 0
return 1
# Taking inp... |
3afb5424f347776d25b9e19080c948169fbc31a7 | BENSONCHIEN/10-real-application | /venv/app 1 with mysql database.py | 551 | 3.53125 | 4 | import mysql.connector
con = mysql.connector.connect(
user = "ardit700_student",
password = "ardit_student",
host = "108.167.140.122",
database = ""
)
cursor = con.cursor() #cursor object to navigate through the table
word = input("Enter a word: ")
#
query = cursor.execute("SELECT * FORM Dictionary WHERE Expression... |
5909b6d3d62868e5e661c07705827f954ef34a4a | aswna/GameOfLife | /game_of_life_test.py | 6,645 | 3.625 | 4 | #!/usr/bin/env python
# encoding: utf-8
from sets import Set
import unittest
from game_of_life import GameOfLife
class TestGameOfLife(unittest.TestCase):
def setUp(self):
self.game_of_life = GameOfLife()
self._cells_alive = None
def tearDown(self):
self._cells_alive = None
... |
1bb3957a914ec6deb2419cc85a4d3a8064a17c68 | keviv202/CTCI-Solutions | /Binary Tree Implementation.py | 219 | 3.578125 | 4 | class Node:
def __init__(self,n):
val = n
self.left = None
self.right = None
class Bst:
root = None
def insert(self,n):
if self.root is None:
self.root = Node(n)
|
0418888eb47bb6741b58a10969bc571dce963ccf | keviv202/CTCI-Solutions | /Ch2 Q1.py | 896 | 3.90625 | 4 | class Node:
def __init__(self,n):
self.val=n
self.next=None
class linkedlist:
head=None
def insert(self,n):
if self.head is None:
self.head = Node(n)
elif self.head is not None:
temp = self.head
while(temp.next != None):
temp = temp.next
temp.next = Node(n)
def __str__(self):
temp =... |
376948215d3a318897c6f836e31ef5b75a7a87e3 | kangic/study | /ds_algo/sorting/insertion.py | 374 | 4.1875 | 4 | # -*- coding: utf-8 -*-
def insertion_sort(ar):
for i in range(1, len(ar)):
idx = i - 1
value = ar[i]
while (idx >= 0 and ar[idx] > value):
ar[idx + 1] = ar[idx]
idx = idx - 1
ar[idx + 1] = value
return ar
if __name__ == "__main__":
changed_ar = inse... |
a9ff2d8d80515fa4eb736754978ab79c56f48d49 | Chong1455/Data-structure-and-algorithm | /Sorting/insertion sort.py | 399 | 4.03125 | 4 | def insertion_sort(nums):
for i in range(len(nums)):
j = i
while j>0 and nums[j-1] > nums[j]:
swap(nums, j, j-1)
j -= 1
return nums
def swap(nums, i ,j):
temp = nums[i]
nums[i] = nums[j]
nums[j] = temp
if __name__ ==... |
42c945d1dd85172ec88e62b98a279e475abb8992 | messi10goat/student-prof-dept-course-database-management | /mydatabasecode1.py | 3,620 | 3.9375 | 4 | import sqlite3
import numpy as np
conn = sqlite3.connect('mydatabase2.sqlite')
cur = conn.cursor()
cur.executescript('''
DROP TABLE IF EXISTS Student;
DROP TABLE IF EXISTS Professor;
DROP TABLE IF EXISTS Course;
DROP TABLE IF EXISTS Department;
DROP TABLE IF EXISTS MemberSC;
DROP TABLE IF EXISTS MemberPC;... |
3d37104ef6582fb0aaf8828fe82b3f33c30b2cd3 | AHartNtkn/Hash-Tables | /hashtable/hashtable.py | 4,914 | 3.734375 | 4 | class HashTableEntry:
"""
Hash Table entry, as a linked list node.
"""
def __init__(self, key, value):
self.key = key
self.value = value
self.next = None
def hte_insert(lp, key, value):
if lp.key == key:
lp.value = value
elif lp.next is None:
lp.next = H... |
783c9d8f752320c688c667fce0f956c37a75b0d1 | finstalex/blackjack---python | /game.py | 1,001 | 3.75 | 4 | koloda = [6,7,8,9,10,2,3,4,11] * 4
import random
random.shuffle(koloda)
name=input(str("Введите Ваше имя : "))
print("Поиграем в Блекджек "+name+"?")
print ("Правила игры: Нужно набрать 21 очко")
count = 0
while True:
choice = input("Будете брать карту? да/нет\n")
if choice == "да":
current = koloda.pop... |
9c1c7653e39833ac08702e6052200d279629fdea | wsbiko/Owner_Agent | /Assignment_Problem_example_PyMathProg.py | 1,892 | 3.546875 | 4 | # C:\GitHub\Owner_Agent\Assignment_Problem_example_PyMathProg.py
# Written in pymprog by Yingjie Lan <ylan@umd.edu>
# The assignment problem is one of the fundamental combinatorial
# optimization problems.
# In its most general form, the problem is as follows:
# There are a number of agents and a numbe... |
d60d2543aa44df03dc1c4775086e4ce59a30ed23 | evgenyarmusevich/HM | /HM 7.py | 615 | 3.90625 | 4 | def func_1():
a = int(input("Введите значение 'A' "))
b = int(input("Введите значение 'B' "))
c = int(input("Введите значение 'C' "))
while a < b:
print("Число " + str(a) + " меньше " + str(b))
a += c
if a == b:
print("Поздравляем, цикл завершен. Число " + str(a) + " ... |
900a27654292016388d586aef6c778d94814eec1 | StiliyanDr/neural-machine-translation | /nmt/models/attention.py | 6,591 | 3.5 | 4 | import torch
from nmt.models import utils
class Attention(torch.nn.Module):
"""
Represents an attention module in a sequence-to-sequence
architecture.
Given a context from a target sentence and all the contexts from
the corresponding source sentence, this module:
1. Computes the attention s... |
f2477a62cc1ccf2a190c4ef55a28c17f968f5191 | Zahidsqldba07/CodeFights-9 | /Arcade/Intro/Level 12/digitsProduct/code.py | 800 | 3.78125 | 4 | from math import sqrt
def factor(x):
return sorted(reduce(list.__iadd__, [[n, x / n] for n in range(1, int(sqrt(x)) + 1) if not (x % n)]))
def is_prime(x):
return True if len(factor(x)) == 2 else False
def digitsProduct(product):
# This should be 0 to be consistent with 1, 2, 3, ..., 9.
if product ==... |
8e7d2f3abd934396afb8202bf74aac908df7bd2c | Zahidsqldba07/CodeFights-9 | /Interview Practice/sumOfTwo/sumOfTwo.py | 313 | 3.546875 | 4 | def sumOfTwo(a, b, v):
# Convert a and b to sets for O(1) average case in-operations.
a = set(a)
b = set(b)
# For each number in a, is the difference `in` b?
for number in a:
if v - number in b:
return True
# There were no pairs that added up to v.
return False
|
ae4ee6c73acc9afc5c59f8e3a898ef9faa602121 | Zahidsqldba07/CodeFights-9 | /Arcade/Intro/Level 10/buildPalindrome/code.py | 440 | 4.0625 | 4 | def isPalindrome(string):
return string == string[::-1]
def buildPalindrome(st):
length = len(st)
reversedString = st[::-1]
for index in xrange(1, length):
string = st + reversedString[-index:]
if isPalindrome(string):
return string
# This line should never be reached ... |
3b0155d1df56e0cddd516efd8884722448fa76a5 | herysihn918/indeed-stackoverflow-scraping-with-python | /src/stackoverflow.py | 2,092 | 3.578125 | 4 | # Scrap jobs which includes 'python' from indeed.com
import requests
from bs4 import BeautifulSoup
# this URL sends the list of jobs which includes 'python' and the limit is 50. Please check this URL and see the result page.
STACKOVERFLOW_URL = f"https://stackoverflow.com/jobs?q=python&sort=i"
# the function to extr... |
e58d6c0bc2831729f65f722de7e4bb30b7291a4b | DanielSouzaBertoldi/codewars-solutions | /Python/7kyu/Isograms/solution.py | 508 | 4.15625 | 4 | # Calculates the ocurrence of every letter of the word.
# If it can't find more than one ocurrence for every letter,
# then it's an isogram.
def is_isogram(string):
string = string.lower()
for char in string:
if string.count(char) > 1:
return False
return True
# That was my first try a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.