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 |
|---|---|---|---|---|---|---|
8fffbe67221317c9fb1a32e1a418f65e4d105792 | xhemilefr/ventureup-python | /dictionary.py | 194 | 3.734375 | 4 | def remove_even(numbers):
counter = 0
for num in numbers:
if num % 2 == 0:
counter += 1
return counter
list1 = [10, 21, 4, 45, 66, 92]
print(remove_even(list1))
|
ab8dd32a23a2284d05ee9e2caf7d12be83e620e1 | xhemilefr/ventureup-python | /exercise2.py | 129 | 3.90625 | 4 | a=[2,3,4,5]
b=[3, 5, 7, 9, 4]
def common(a,b):
c = [value for value in a if value in b]
return c
d=common(a,b)
print(d) |
218275d05a30d062ce99d9dd2f4cb2dea08523ca | xhemilefr/ventureup-python | /exercis5.1.py | 314 | 4.21875 | 4 | def reverse_string(string):
reversed_string = ""
for x in string:
reversed_string = x + reversed_string
return reversed_string
def check_palindrome(string):
temp = string.lower()
if temp == reverse_string(temp):
return True
return False
print(check_palindrome("Pasddsap")) |
88c392c1734a3049ae314a87c03114c6cd343860 | nextco/exploit | /examen-level-6/exploit-6.py | 849 | 3.78125 | 4 | # Python 2.7 x86
# Solution for auto evaluation: Level 6
# Curso IDA Pro de Ricardo Narvaja.
# by @rextco
import string
import random
import struct
import sys
def read_file(file_name):
with open(file_name, "rb") as f:
content = f.read()
return bytearray(content)
def write_file(file_name, content):
... |
c801115885c37a336579922846a8e1c9d0cdbfed | rheehot/Python_Algorithm-1 | /Ch4_Singly_Linked_List/Section02/4_code04-02.py | 975 | 3.828125 | 4 | # 데이터가 5개인 단순 연결 리스트 생성(개선 버전)
class Node():
def __init__(self):
self.data = None
self.link = None
node1 = Node() # 첫 번째 노드 생성
node1.data = "다현" # 다현 입력
node2 = Node() # 두 번째 노드 생성
node2.data = "정연" # 정연 입력
node1.link = node2 # 첫 번째 노드의 링크에 두 번째 노드 입력하여 두 노드 연결
nod... |
0dbfb52158d75aba6a708ddd3015d538e59970be | Hanzala18/Python-projects | /ATM.py | 1,208 | 3.9375 | 4 | def balance(i):
print(i)
def deposit(i):
x = int(input("Enter the amount you want to deposit :\n "))
print("your amount after deposit is :")
print(int(i) + int(x))
def transaction(i):
y = int(input("Enter the amount you want to transact :\n"))
print("your amount after transaction... |
4ad008fe3eabe96a88da6ef421061ecf7fb69693 | Hanzala18/Python-projects | /order.py | 695 | 4.0625 | 4 | print("Place your order")
print("Burger = 300 ")
print("fries = 100 ")
print("Pizza = 500 ")
# order = 0
b = 300
f = 100
p = 500
x = input("choose your food\n")
y = input("Enter your quantity\n")
def order(x, y):
# print()
if x == "burger":
print("your amount is :")
print(i... |
8f07e0ac9d7b5da856ef3a239de98cb75120418b | Hanzala18/Python-projects | /lldays.py | 571 | 3.859375 | 4 | class Node:
def __init__(self, data=None, next=None):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def listprint(self):
printval = self.head
while printval is not None:
print(printval.data)
... |
ade165fffabd1d77c2ca143a872bb47e61ac9ef2 | s4CD/Sherrod-s-Repo | /python_file.py | 476 | 3.53125 | 4 | #! /usr/bin/python
import xml.etree.ElementTree as EL
file = EL.parse('data.xml')
root = file.getroot()
#I'm just playing around with Python
company_name = root.tag
boss_position = root[0].tag
director_first_name = root[0][0].text
director_last_name = root[0][1].text
for full_name i... |
9f3d91511242fd4afd16c64763ee6ddc1dd4a6f2 | scurrent/PythonClass | /milage.py | 530 | 4.03125 | 4 | # This is a sample Python script.
# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows,
# actions, and settings.
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print("Hom many k did you run today?")
... |
e4518cfdbcb296fd57a071c2634a48515e47378f | jack96harrison/PythonBeginner | /PythonPractice_Exercise7.py | 225 | 4.03125 | 4 | """
Take a variable of a list e.g a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Write one line of python that makes a new list with only the even elements
"""
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
b = a[1::2]
print(a)
print(b) |
00a25b8fe86587f23e71bec97c6577cc41402ab4 | Shashi-Chaurasia/Python_Code_Tutorials | /01_dictonory_syntax.py | 314 | 3.890625 | 4 | myDict = {"Name":"Shashi " ,
"colage" : "MIT academy of engineering" ,
"state" : "Pune" , "Rollno" : 437
}
# print(myDict["Name"])
# print(myDict["colage"])
# print(myDict["Rollno"])
# print(myDict.keys())
# print(list(myDict.values()))
updatDict = {"village" : "Balli"}
myDict.update(updatDict)
print(myDict) |
ab9a199272a477e0c2fc3527cb96b27964e1477d | Shashi-Chaurasia/Python_Code_Tutorials | /06_pr_01.py | 485 | 3.765625 | 4 | def max(num1 , num2 , num3 , num4):
if(num1 > num2):
if(num1>num3):
if(num1>num4):
print("gretaest number is :" + str(num1))
elif(num2 > num3):
if(num2>num4):
if(num2>num1):
print ("gretaest number is :" + str(num2))
elif(num3 > num4):
... |
86f5d9cf95545e24e9ded09d6214499ade3dbeb3 | LiuJie6/FirstTest | /loop/while.py | 231 | 3.765625 | 4 | number = 20
running = True
while running:
guess = int(input('Enter an integer:'))
if guess == number:
print('猜对了')
running = False
else:
print('猜错了')
else:
print('执行完成')
|
4baf2598509cec7635744b8ffa9963263f20d285 | RaulAstudillo06/BOQN | /boqn/group_testing/src/individual_interaction_population.py | 7,488 | 3.796875 | 4 | from base_population import BasePopulation
import numpy as np
import random
"""
Implements the population dynamics for the individual-interaction population model
which models stochastic day-by-day interactions between individuals in the population
In addition to the methods and attributes inherited from BasePopulati... |
3935ea0a78c7b1a43761d42d0872fa8c3e927405 | Vaakoo29/timetable | /main.py | 2,172 | 3.65625 | 4 | from timetable import Day, Table
timetable_18704 = 'timetable.csv'
def answer_check(checking):
if checking == '1' or checking == '2':
return True
else:
return False
while True:
print('Программа позволяет вывести расписание по дням.\nЕсть возможность вывести все расписание... |
50eb05493a372061afb1bdcfc3c6898133537f80 | gaganrajn/Data-Conversion | /SimpleFileConversion/Primary.py | 538 | 3.515625 | 4 | import csv
import pprint
from timeit import default_timer as timer
read_file = input("Enter the file path: ")
start = timer()
with open(read_file) as csvfile:
reader = csv. DictReader(csvfile)
field = reader.fieldnames
csv_rows = []
for row in reader:
csv_rows.append({field[i]... |
f127e5429ab24bb11e37e8f3e8b70e99a9a77f07 | AlizaminJ/machine-learning-course | /code/overview/linear_regression/linear_regression_cost.py | 1,456 | 3.65625 | 4 | import matplotlib.pyplot as plt
import seaborn as sns
from sklearn import datasets, linear_model
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
# Create a data set for analysis
x, y = make_regression(n_samples=500, n_features = 1, noise=25, random_state=0)
#... |
d1a4f6386eedb436c1c0c8eb67fb3a32cc5c1fcb | devtecx/time-manage-py | /TimeManage.py | 1,203 | 3.65625 | 4 |
# Test: python3 -c "from app.TimeManage import TimeManage; ...
class TimeManage:
# Test: "... print(TimeManage.format('01:00', '01:20'))"
def format(stime, etime):
t = TimeManage.split(stime)
start = t[0]*3600 + t[1]*60 + t[2]
stime = '{:02d}:{:02d}:{:02d}.0'.format(t[0], t[1], t[2])
t = TimeManage... |
bf90d87cdc75a5252286ec4d2ef75b4f3683fb93 | mariapazvega/VegaM_DatabaseHW | /data/charts.py | 393 | 3.609375 | 4 | import matplotlib.pyplot as plt
years=[1900,1950,1955,1960,1965,1970,1975,1980,1985,1990,1995,2000]
pops=[1.6,2.5,2.6,3.0,3.3,3.6,4.2,4.4,4.8,5.3,5.7,6.1]
plt.plot (years,pops,color=(255/255,100/255,100/255),linewidth=6.0)
plt.ylabel("World Population by Billions")
plt.xlabel("Population Growth by year")
plt.title(... |
c080ee34cb69e8bd9cd55aa790e95324142c3013 | abhisheks008/Data-Structure-and-Algorithm-Lab-Pre-Puja | /Week 11/Balanced Brackets.py | 499 | 4.09375 | 4 | def is_matched(expression):
s = []
for e in expression:
if (e == '{'):
s.append('}')
elif (e == '['):
s.append(']')
elif (e == '('):
s.append(')')
else:
if (s == [] or e != s[-1]):
return False
s.pop();
... |
0b8a3bfb2f1514d77b83bf94c59fefb20f1b5bd8 | mabbott2011/PythonCrash | /conditionals.py | 536 | 4.125 | 4 | # Conditionals
x = 4
#basic if
if x < 6:
print('This is true')
#basic If Else
y = 1
if y > 6:
print("This is true")
else:
print("This is false")
# Elif
color = 'red'
#color = 'blue'
#color = 'purple'
if color == 'red':
print('Color is red')
elif color == 'blue':
print('Color is blue')
else:
... |
54a8c65ace8a48ecfe2201dd7cb55b80c7826007 | Jhongesell/curso-python-igp | /ejemplos-basicos/area_triangulo.py | 271 | 3.890625 | 4 | #!/usr/bin/env python
# -*- coding: utf8 -*-
titulo = "Area del triángulo"
print titulo
print '=' * len(titulo)
print
base = float(raw_input("Ingrese la base: "))
altura = float(raw_input("Ingrese la altura: "))
area = base * altura / 2.0
print "Area: %.2f" % area |
f5177c7bbe50446fa8d39eeb822bd79595fc65d6 | Jhongesell/curso-python-igp | /protocolos/generadores.py | 531 | 4 | 4 | #!/usr/bin/env python
# -*- coding: utf8 -*-
# El comando "yield" es un "return" que recuerda donde se quedó
# en la llamada anterior. La función no devuelve directamente el
# valor como con "return" sino que devuelve un objeto iterable que
# se llama "generador"
def del_uno_al_tres():
yield 1
yield 2
yie... |
3c324fab5d5eccbb030aafd6c7242e7a7789363e | divshekhar/OpenCV | /basic_lane_assist.py | 3,119 | 3.671875 | 4 | import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt
def lanesDetectionNew(img):
# Get the height and width of the provided video frame
height = img.shape[0]
width = img.shape[1]
# Set the image region on witch the lane detection should work
#ToDo: Make this configurable
re... |
50c113936696daa65bd93b356d390993686cc48c | spnow/HackThisSite-2 | /Mission3_ReverseEngineerEncryption/ReverseEngineer.py | 6,378 | 4 | 4 | # solution to the programming mission 3 where you have to decrypt an encoded text
# by reverse engineering the encoding algorithm.
#
# Author : Alican Salor
# date : 27.09.2015
import hashlib
def md5Hash(string):
md5 = hashlib.md5();
md5.update(string);
return md5.hexdigest();
def evalCrossTotal(strMD5):
intT... |
312d0ffc87e4965dc00845852c52a8b75fd33edc | mlusby/PythonStuff | /csvexercise2.py | 280 | 3.703125 | 4 | #!/usr/bin/env python
import csv
with open('csvfile.csv','rb') as csvfile:
csvreader = csv.reader(csvfile, delimiter=",", quotechar="'")
for row in csvreader:
print ",".join(row)
total = 0
for val in row:
total = total + int(val)
print "Total: {0}".format(total)
|
63b4bdc7b80b17cd676b6c404c15a9ccb27f6d7e | ADcadia/py-calc | /coin-toss-calculator.py | 474 | 4.125 | 4 | # Enter the number of times you will toss the coin.
import random
def tossCoin():
num = random.randint(0, 1)
if num == 0:
return "Heads"
else:
return "Tails"
timesToToss = int(input("How many times will you toss the coin? \n"))
headsCounter = 0
tailsCounter = 0
for i in range(timesToToss):
if tossC... |
2736b2f90577c6809f475e34c152c98617ec2dc3 | SeMin4/OSP-20201 | /py_lab2/myprog_pkg.py | 1,322 | 3.875 | 4 | #!/usr/bin/python
import my_pkg
import sys
if __name__ == '__main__':
while True :
select_menu = int(input("Select menu: 1) conversion 2) union/intersection 3)exit ? "))
if (select_menu == 3):
print("exit the program...")
sys.exit()
elif(select_menu == 1):
... |
e2cc7c314411586dca66c30839a0bd8db9123684 | Blyznyuk/HomeWork3 | /ex5.py | 190 | 3.625 | 4 | #ex5
a = input("Введите значение 1: ")
b = input("Введите значение 2: ")
try:
c = float(a) + float(b)
print(c)
except ValueError:
print(a + b)
|
a61d3b69c03c452011ed50b912a165b245195a11 | Hook12aaa/Small_Project_Showcase | /CodeBreaker/CodeBreaker.py | 2,461 | 3.515625 | 4 | import requests,re
from bs4 import BeautifulSoup
class Validator():
"""Dictionary Validator. Just parse the keyword into the IsINDictionary Methood and it will return true or false.
**Warning this needs internet connection!**
"""
def get_soup_object(url):
return BeautifulSoup(requests.get(url).text,features="ht... |
e22a1a23f49ff3dfc2aa80201bb8488fb96626f5 | Sandesh02/Number-to-word | /int to text.py | 1,918 | 3.765625 | 4 | a = float(input('enter no.'))
b = str(a) #for ierating throgh number
c=int(a) #taking only integer part
d=str(c) #iterating through integer part
l = [] #list of separated digits
nu=['Zero','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'] #list for handaling number
final=[]#list of numbers conve... |
8c396abb6742f4e88cd68d47c057420fb5f3f253 | stoneboyindc/udacity | /P1/problem_2.py | 1,862 | 4.4375 | 4 | import os
def find_files(suffix, path):
"""
Find all files beneath path with file name suffix.
Note that a path may contain further subdirectories
and those subdirectories may also contain further subdirectories.
There are no limit to the depth of the subdirectories can be.
Args:
... |
5de2ce92d74e60458107b6d03642938f041af584 | Rohitthapliyal/Python | /Conditional sta/twofor.py | 82 | 3.84375 | 4 | n=int(input("enter any number:\n"))
for i in range(n,1,-1):
print(i)
|
5b56537d6160b058d5d1fe4c176a1cba432506ab | Rohitthapliyal/Python | /Python_basics/6.py | 469 | 3.859375 | 4 | class Arith:
a=int(input("enter first number:\n"))
b=int(input("enter second number:\n"))
def opr(obj):
obj.add=obj.a+obj.b
obj.subtract=obj.a-obj.b
obj.divide=obj.a/obj.b
obj.multiply=obj.a*obj.b
def output(obj):
print("addition=",obj.add)
print... |
b1562cd790de07deaec97f593a6a48ec057e6214 | Rohitthapliyal/Python | /Decision statements/12.py | 328 | 4.125 | 4 | week=int(input("enter week number:\n"))
if week==1:
print("sunday")
elif week==2:
print("monday")
elif week==3:
print("tuesday")
elif week==4:
print("wednesday")
elif week==5:
print("thursday")
elif week==6:
print("friday")
elif week==7:
print("saturday")
else:
print("inv... |
446127a4dd196e5f0eb7c02323b4a63a4d4a7597 | Rohitthapliyal/Python | /Decision statements/ten.py | 192 | 4.28125 | 4 | c=input("enter any character:\n")
if c>='A' and c<='Z' or c>='a' and c<='z':
print("it is character")
elif c>='0' or c<='9':
print("digit")
else:
print("special character")
|
57e97b6780d6de9bbe5b18e56e2776b3d272ee7d | Rohitthapliyal/Python | /Conditional sta/11.py | 103 | 3.9375 | 4 | n=int(input("enter any number:\n"))
i=1
sum=0
while i<=n:
sum=sum+n
print(sum)
i+=1
|
db3067775fa5609fc365427343b1f9c066b14efd | Rohitthapliyal/Python | /Python_basics/5.py | 342 | 4.03125 | 4 | class Average:
a=int(input("enter first number:\n"))
b=int(input("enter second number:\n"))
c=int(input("enter third number:\n"))
av=float()
def avg(obj):
obj.av=(obj.a+obj.b+obj.c)//3
def output(obj):
print("average of three varaibles are=",obj.av)
obj1=Average()
obj1.... |
1e1bc56e17d6d38253aa0c88f292fb661be8753b | Rohitthapliyal/Python | /Dictionary_Questions/10.py | 178 | 3.734375 | 4 | s={"name":"100","city":"200","school":"500"}
sum=0
for i in s.values():
sum=sum+int(i)
print("sum",sum)
#s={"name":"100","city":"200","school":"500"}
#print()
|
c5f60f8b139e4dd181360354df3204d54b29099f | Rohitthapliyal/Python | /Dictionary_Questions/38.py | 134 | 4.1875 | 4 | x={"key1":1,"key2":2,"key3":3}
y={"key1":1,"key2":2}
if "key1":1 in x and y:
print("yes,"key1":1 is present in both x and y")
|
b9d3484d14d0a0148a32d94715c1a30009ce3b3f | Rohitthapliyal/Python | /Python_basics/14.py | 280 | 4.15625 | 4 | import math
class Power:
x=int(input("enter any number:\n"))
y=int(input("enter base:\n"))
def show(ob):
ob.power=math.pow(ob.x*ob.y)
def output(ob):
print("power of the number is=",ob.power)
obj=Power()
obj.show()
obj.output()
|
b2b463baa1c4ba36bda286055ca571af89b1af3a | JoshmiFrijo/SpeechRecognition | /Main.py | 1,030 | 3.59375 | 4 | # Driver code
def main() :
# Training Samples ( m, n ) with their class vector
X = dataset
Y = [ 1 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 0]
m, n = len( X ), len( X[0] )
# weight initialization ( n, c )
weights = []
weights.append( X.pop( 0 ) )
weights.append( X.pop( 1 ) )
... |
d5b327276c333d2e06bc53ac898ae9944cbccd4e | mepujan/IWAcademyAssignment_3_python | /algorithms_and_dataStructure/binary_search.py | 657 | 3.9375 | 4 | def binary_search(data_list,start,end,search_data):
if start > end:
return -1
else:
mid_value = (start + end ) // 2
if data_list[mid_value] == search_data:
return mid_value
elif data_list[mid_value] > search_data:
return binary_search(data_list,start,mid_v... |
fb3d6821b831097d592a05993c5f6d9d24c98706 | mepujan/IWAcademyAssignment_3_python | /algorithms_and_dataStructure/insertion_sort.py | 315 | 4.1875 | 4 | def insertion_sort(data):
for i in range(1,len(data)):
key= data[i]
j=i-1
while j >=0 and key < data[j]:
data[j+1] = data[j]
j -= 1
data[j+1] = key
data =[5,3,2,6,4,1,3,7]
print("Before Sorting = ",data)
insertion_sort(data)
print("After Sorting= ",data) |
73853b2c630c729b2f466d3ccb675274c9ff935b | gptix/cs-module-project-hash-tablesnew | /applications/no_dups/no_dups.py | 620 | 4.0625 | 4 | def no_dups(string_of_words):
#stupid case
if string_of_words == "":
return ""
#not stupid case
words = string_of_words.split()
words_seen = set()
words_in_order = []
for word in words:
if word not in words_seen:
words_seen.add(word)
words_i... |
d8c8086249078d8f4f83d981f4215647cf8d1b58 | PlatformOfTrust/standards | /tools/ontology-validator/validators/structure/json_format.py | 943 | 3.5625 | 4 | """This module has a class that validates that a file is a correct json
file.
"""
import json
from validators.structure.structure import StructureValidator
class JsonFormat(StructureValidator):
"""This class has a validate method that validates that a file is a correct
json file.
"""
def __init__(s... |
65f0061aa059b25d99e5f983d1a93c1408ce0714 | Rogaldoron/CS-Class-Y9 | /Python/Times Table Calculator.py | 766 | 3.921875 | 4 | import time
def Printy():
print("\n"*100)
def TimesTables():
print("Hello! I'm Jeeves, the Times Table Bot!")
time.sleep(2)
print("LOOK AT ME!")
time.sleep(1)
print(""" /:""|
|: 66|_
C _)
\ ._|
) /
/`\\
|| |Y|
... |
d817a2ecfbc001ec2ebc20fed1486c885a21727a | devamcodes/Python_Tutorials | /mixed loops/practice3.py | 1,479 | 4.09375 | 4 | """
Project:
Author:Devam A
Discripition:i can use import function insted but just wanted to practice the use of lambda function but should try decorator if they can do the work
"""
"""name = input("PLEASE ENTER YOUR NAME:")
print(f"Hello, {name.title()}")
year = int(input("PLEASE ENTER YOUR AGE:"))
age = year * 12
p... |
4fccb97e95c729498ab0e446b7558cdf364235c8 | BadrChoujai/hacker-rank-solutions | /Python/07_Collections/collections.Counter().py | 495 | 3.5625 | 4 | # Problem Link: https://www.hackerrank.com/challenges/collections-counter/problem
# -------------------------------------------------------------------------------
from collections import Counter
n_shoes = int(input())
sample_size = Counter(map(int, input().split()))
n_customers = int(input())
money_earned = 0
for ... |
11c9782268f183ea4480abaa694e7391335353fc | BadrChoujai/hacker-rank-solutions | /30 Days of Code/Day 08 Dictionaries and Maps.py | 523 | 3.921875 | 4 | # Problem Link: https://www.hackerrank.com/challenges/30-dictionaries-and-maps/problem
# ------------------------------------------------------------------------------------
n = int(input())
phoneBook = {}
for i in range(n):
name, phoneNumber = input().split(' ')
phoneBook[name] = phoneNumber
while(True... |
fdad51c1be549b795f407f9547aca8b5011a974d | BadrChoujai/hacker-rank-solutions | /Python/16_Numpy/Mean, Var, and Std.py | 469 | 3.5 | 4 | # Problem Link: https://www.hackerrank.com/challenges/np-mean-var-and-std/problem
# -------------------------------------------------------------------------------
import numpy as np
n, m = map(int, input().split())
array = []
for i in range(m):
arr = list(map(int, input().split()))
array.append(arr)
my_arr... |
b11555d8ac34ca4c3fecb5582d4181a9160bd427 | BadrChoujai/hacker-rank-solutions | /Python/04_Sets/Introduction to Sets.py | 252 | 3.640625 | 4 | # Problem Link: https://www.hackerrank.com/challenges/py-introduction-to-sets/problem
# -----------------------------------------------------------------------------------
def average(array):
ans = sum(set(array))/ len(set(array))
return ans |
c2c4f82acaa1cfa7cc082ddcdf5819a21d64f3fd | BadrChoujai/hacker-rank-solutions | /Python/13_Regex and Parsing/Re.findall() & Re.finditer().py | 1,211 | 4.125 | 4 | # Problem Link: https://www.hackerrank.com/challenges/re-findall-re-finditer/problem
# ----------------------------------------------------------------------------------
import re
m = re.findall(r'(?i)(?<=[^aeiou])[aeiou]{2,}(?=[^aeiou])', input())
if len(m) > 0:
print(*m, sep = '\n')
else:
print('-1')
... |
629a0cf9cd05ee6598f3fb0fc1857325d14d41fe | BadrChoujai/hacker-rank-solutions | /Python/06_Itertools/itertools.combinations().py | 392 | 3.546875 | 4 | # Problem Link: https://www.hackerrank.com/challenges/itertools-combinations/problem
# ----------------------------------------------------------------------------------
from itertools import combinations
u_input = list(map(str, input().split()))
s = sorted(u_input[0])
n = int(u_input[1])
for i in range(1, n+1):
... |
f9d5a44f2aff65e805a3dc92e55856138f71c5b4 | BadrChoujai/hacker-rank-solutions | /Python/16_Numpy/Min and Max.py | 377 | 3.515625 | 4 | # Problem Link: https://www.hackerrank.com/challenges/np-min-and-max/problem
# --------------------------------------------------------------------------
import numpy
A = []
n, m = map(int, input().split())
for i in range(n):
a = list(map(int, input().split()))
A.append(a)
A = numpy.reshape(A, (n, m))
min_1 =... |
5f116df649afa5c6cda96e56ae23543707ec5a8c | BadrChoujai/hacker-rank-solutions | /Python/13_Regex and Parsing/Re.start() & Re.end().py | 406 | 3.78125 | 4 | # Problem Link: https://www.hackerrank.com/challenges/re-start-re-end/problem
# ---------------------------------------------------------------------------
import re
s, k = input(), input()
i = 0
m = re.search(k, s)
if m:
while m != None:
print('({}, {})'.format(m.start() + i, m.end() + i - 1))
i... |
e605c5825de0399c8b8836144643ef7da7eb51c3 | kousu/primes | /dbgsieve.py | 6,728 | 3.640625 | 4 | #dbgsieve.py
"this is the file that generates fancyfresh"
#other idea:
#ragged-edged algorithm
#multiply all the primes known so far up
#2
#2,3 -> [p,p,2,0,2*3] this tells us that 5 is prime.
#2,3,5 -> [p,p,2,p, 2*3, 0, 0, 0, 0, 0, 0, 0, 0, 3*5] -> [p,p,2,p, 2*3, 0, 2, 0, 2, 0, 2, 0, 2, 3*5]
# -> [p,p,2,p, 2*... |
9b7bed77e42cdf3bf5a22800ce3c541f684ee3fa | cccooot/chat | /dxlb.py | 2,672 | 3.796875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/9/24 15:39
# @Author : Zhangmi
# @Site :
# @File : dxlb.py
# @Software: PyCharm
class SingleListNode(object):
"""单节点类"""
def __init__(self, _item, _next=None):
self.item = _item
self.next = _next
class SingleLinkedList(object):
... |
86d0871eb25cd3150a0a3377d294c074dcbc8f04 | v82695477/180101064 | /lab5/example1.py | 89 | 3.90625 | 4 | x = int(input("Enter an integer: "))
for i in range(1,11):
print(x, "x",i,"=", i * x ) |
a2a3e0e22f8821c1b0b2f488d562998f26971207 | v82695477/180101064 | /lab3/example2.py | 178 | 4.09375 | 4 | x1 = input("number 1 : ")
x2 = input("number 2 : ")
x3 = input("number 3 : ")
if x1 <= x2 :
min_num = x1
else:
min_num = x2
if x3 <= min_num:
min_num = x3
print(min_num)
|
ad2158d299d1272977da896dd0aabe9d4e4f80e8 | Qwakalicous/TurnBots | /game.py | 2,420 | 3.703125 | 4 | '''
The Game class is responsible for:
-Controlling the game
-Rendering all entities
-Handeling user inputs
'''
import random
import pygame
import math
from generation import GenerationManager
from food import Food
from unit import Unit
from game_math import Matrix
class Game:
def __init__(self):
self.grid_siz... |
ff60ac696ba8b1267e4412f4263ae9aba258918c | againer/hackerrank | /domains/algorithms/dynamic_programming/fibonacci_modified.py | 267 | 3.703125 | 4 |
#b => t n+1 , a => t
def fibonacci(tzero, tone):
ttwo = tone ** 2 + tzero
return ttwo, tone
if __name__ == '__main__':
abn = raw_input().split(' ')
a, b, n = int(abn[0]), int(abn[1]), int(abn[2])
for i in range(n-2):
b, a = fibonacci(a, b)
print b
|
76242be619785040dbfae00b777affcdd8708c91 | againer/hackerrank | /domains/algorithms/string/pangrams.py | 265 | 3.703125 | 4 |
_ALPHABEES = 'abcdefghijklmnopqrstuvwxyz'
def is_pangram(sentence):
return not(False in [letter in sentence.lower() for letter in _ALPHABEES])
if __name__ == '__main__':
sentence = str(raw_input())
print 'pangram' if is_pangram(sentence) else 'not pangram' |
6768552dacee36ce30df6c4696cef0fbd8eec9fb | yuto-moriizumi/AtCoder | /JAG Practice Contest for ACM-ICPC Asia Regional 2017/c.py | 543 | 3.515625 | 4 | l, r = map(int, input().split())
isPrime = [0]*(r+1)
def prime_numbers(right):
pn = [2]
for L in range(3, right):
chk = True
for L2 in pn:
if L % L2 == 0:
chk = False
if chk == True:
pn.append(L)
isPrime[L] = 1
prime_numbers(r+1)
is... |
034703664ec7016de77320ba332260c15bf3412f | yuto-moriizumi/AtCoder | /天下一プログラマーコンテスト2012 予選C/a.py | 309 | 3.703125 | 4 |
def prime_numbers(right):
if right <= 2:
return []
pn = [2]
for L in range(3, right):
chk = True
for L2 in pn:
if L % L2 == 0:
chk = False
if chk == True:
pn.append(L)
return pn
print(len(prime_numbers(int(input()))))
|
de88f9d035711e6221347201efbb78af94109cda | yuto-moriizumi/AtCoder | /ATC001/ATC001b.py | 588 | 3.65625 | 4 | #Union-Find木
import sys
input = sys.stdin.readline
n,q=map(int,input().split())
tree=[]
for i in range(n):
tree.append(i)
def root(x):
if(tree[x]==x):
return x
tree[x]=root(tree[x])
return tree[x] #経路圧縮
def same(x,y): #xとyが同じ木に属するか
return root(x)==root(y)
def unite(x,y):
x=root(x)
... |
7d0e9f7f3800e1cd2ffc77b8e0410b1f768743e6 | schumanzhang/date_calculator_python | /datecalculator.py | 4,548 | 3.75 | 4 | def calculateDays(date1, date2):
normalYear = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
leapYear = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
dd1 = int(date1[:2])
mm1 = int(date1[3:-5])
yyyy1 = int(date1[6:])
dd2 = int(date2[:2])
mm2 = int(date2[3:-5])
yyyy2 = in... |
29a786333072cf94307d0ef38a55799eaff3ddb1 | JelenaGaric/NTRI | /utils.py | 1,489 | 3.53125 | 4 | # from https://github.com/philtabor implementation
import numpy as np
import matplotlib.pyplot as plt
def plot_learning_curve(x, scores, figure_file):
running_avg = np.zeros(len(scores))
for i in range(len(running_avg)):
running_avg[i] = np.mean(scores[max(0, i - 100):(i + 1)])
plt.plot(x, runnin... |
4c5be04c6da394b2b18351a8c0e2e09c6558191f | filipHartman/python_chechpoint_1_home | /short_algoritmic_task.py | 3,678 | 4.0625 | 4 | def print_three_digit_numbers():
for number in range(100, 1000):
if number % 7 == 0 or number % 9 == 0:
print(number)
def compare_words(*word):
index = 0
max_lenght = 0
for i in word:
if max_lenght < len(i):
max_lenght = len(i)
index = word.index(i)
... |
b01b2f37ee3268be9962b26b0ac2aabfb10cb777 | j1nge/Turtle-Race | /main.py | 6,063 | 4 | 4 | import turtle
from tkinter import *
import time
import random
tk = Tk()
Bank_account = 50
class turtle_s:
def __init__(self, color):
self.color = color
self.turt = turtle.Pen()
self.turt.shape('turtle')
self.turt.color(color)
red_turtle = turtle_s('red')
blue_turtle = turtle_s... |
7d9b24c478b532f58469ae1a43b8c4fcd45f0d66 | MichaelTumbelaka/Python | /agecalc.py | 648 | 3.84375 | 4 | from datetime import date
hari = date.today()
tanggal = [hari.year, hari.month, hari.day]
print (hari)
year = tanggal[0]
#print (year)
while True:
b = input("Mau menggunakan age kalk?(y/n) = ")
if b == "y":
x = int(input("Tanggal lahir(yyyy) = "))
y = int(input("Tanggal lahir(mm) = "))
... |
179a9e0dcd903ef7c7fed2c57f76a605aacfd55a | MichaelTumbelaka/Python | /class.py | 519 | 4.03125 | 4 | class Flower:
def __init__(self, name, petal, price):
self.name = name
self.petal = petal
self.price = price
print(f'Nama bunga = {self.name}')
print(f'Jumlah petal = {self.petal}')
print(f'Harga per piece = Rp {self.price}')
def vary(self):
harga = (self.... |
c5e01d0f76461d42989ffd5ea2e0925a86da8023 | cagilleland/myTimeRelearningPython | /RPSA.py | 1,919 | 4.09375 | 4 | #Rock, Paper, Scissors App
import random
print("Welcome to Rock, Paper, Scissors! ")
total_rounds = int(input("\nHow many rounds would you like to play? "))
moves = ['rock','paper','scissors']
player_score = 0
computer_score = 0
for round_number in list(range(1,total_rounds+1)):
print("Round " + str(r... |
b16e29a1cff5d85c8fec70e11b0a210a8171445b | poklj/Python | /Full_Project/Deadliest_Warrior/Sword.py | 1,278 | 3.984375 | 4 | class Sword:
def __init__(self, str_: int, def_:int, name="Sword"):
"""
Sword is a Weapon Class used by Person
CONSTRAINT: Str_ + def_ <= 7
:param str_: Initial Strength of the weapon
:param def_: Initial Defense of the weapon
"""
self.str_:int = str_
... |
6daf68007a7ac82e7d878a2a50b1c52ead07972c | poklj/Python | /Full_Project/MongoDB/Q3 - Not the Answer.py | 644 | 3.6875 | 4 | import MongoDB.Mongo as mong
# [40%] Do not watch these!
# Find the "worst movies" and print their titles.
# (First state, and then use your criteria on what constitutes "the worst")
# The worst movies are ones who's ratings have one person who dislikes the movie
if __name__ == '__main__':
Data = mong.Data() #C... |
6e605e850a0aa062e36f3f54e062f732a2beb62f | koblanm/infa_2020_koblan | /LAB2.turtle1/LAB2_p7.py | 245 | 3.703125 | 4 | import turtle as t
import math as m
t.shape('turtle')
t.speed(100)
Y = 0
dY = m.pi / 180
k = 20
N = 10 #обороты
A = N * (2 * m.pi)
while Y < A:
y = k * Y * m.sin(Y)
x = k * Y * m.cos(Y)
t.goto(x , y)
Y += dY
|
1bdeae5832791cbed1bec03380bdc2c930428400 | koblanm/infa_2020_koblan | /LAB2.turtle1/LAB2_p6.py | 211 | 3.609375 | 4 | import turtle as tr
tr.shape('turtle')
tr.speed(1000)
n = 12
R = 80
k = 0
while k < n:
tr.forward(R)
tr.stamp()
tr.right(180)
tr.forward(R)
tr.left(180 - 360/n)
k += 1
|
daa330f76c8cdca4e384a7058d1df8009f7105c0 | dspen/pyhard | /ctci1_2.py | 257 | 3.65625 | 4 | # Check permutation of 2 strings
# Hints 1, 84, 122, 131
from sys import argv
script, string1, string2 = argv;
def isPerm(string1, string2):
if sorted(string1) == sorted(string2):
return True
return False
print(isPerm(string1, string2));
|
80d6b89657bef8e1198450b623c0270058017aa2 | Kirilodius/interview_tasks | /deijkstra.py | 1,189 | 3.6875 | 4 | def dijkstras(graph, S):
distance = [float("inf") for g in graph]
distance[S] = 0
parents = [None for g in graph]
path = set()
sptSet = [False for g in graph]
notVisited = [i for i in range(len(graph))]
while len(notVisited) > 0:
minIndx = getMinDist(distance, notVisit... |
a97ff00be73f325b470228b001c2eb3c568c53fd | rodneyj3214/Python | /PZ-CursoDePython/BasicoDePython/VariablesExpresiones/main.py | 277 | 4 | 4 | # Programa para recibir un dato por teclado y almacenarlo enuna variable
# Implementar esta linea cuando Python no reconoce los caracteres especiales: # -*- coding: utf-8 -*-
nombre = str(input('Cuál es tu nombre: '))
print('Hola, ' + nombre + '!!')
print('Hola, ' *3 + '!!')
|
56c42f3aadfc1fc0a672d5c87ce1a1ca885ffb3b | JdoubleW/Opdrachten_programmeren | /Week 4/pe8_2.py | 708 | 3.65625 | 4 | import random
def monopolyworp():
""""Pakt 2 willekeurige getallen tussen de 1 en 6 en controleer of het dubbele waardes zijn."""
getal1 = random.randrange(1, 7)
getal2 = random.randrange(1, 7)
totaal1 = getal1 + getal2
counter = 0
while getal1 == getal2:
print(getal1, '+', getal... |
fac1d7a4b2497b9a2cfa119c76a900ee0bd8f1e0 | JdoubleW/Opdrachten_programmeren | /Week 2/pe4_3.py | 297 | 3.703125 | 4 | def lang_genoeg(length):
""""Kijkt of de waarde onder 120 zit."""
res = length >= 120
return res
length = eval(input("Hoe lang ben jij in centimeters?"))
if lang_genoeg(length):
print("Je bent lang genoeg voor de attractie!")
else:
print("Sorry, je bent te klein.") |
ec45bb5ab5f0dc0c1d56e349ed7ea43b25cd7037 | ReijoJaakkola/Pygame-Tetris | /tetris_v3/pygame_enums.py | 405 | 3.625 | 4 | from enum import Enum
# Enum for the possible directions for the current piece.
class Direction(Enum):
RIGHT = 0
LEFT = 1
DOWN = 2
# Enum for the possible colors.
class Color(Enum):
GREEN = 0
RED = 1
BLUE = 2
YELLOW = 3
VIOLET = 4
# Enum for the possible shapes for the current piece.... |
2ecded57167e4ff843aea14dcc97e141de899a38 | Sunil-Archive-Projects/Python-Experiments | /Python_Basics/classes.py | 370 | 4.1875 | 4 | #defining classes
class myClass():
def firstMethod(self):
#self refers to itself
print("First Method")
def secondMethod(self,str):
#self refers to itself
print "Second Method",str
#defining subclasses
# subClass inherits superClass myClass
class subClass(myClass):
x=0
def main():
obj=subClass()
obj.... |
fa3d0f4d2408a8bc7cb7d4861298448c971f5ba6 | kemikon/SPL2 | /grundlagen-python.py | 1,358 | 3.828125 | 4 | # Grundlagen-python.py
import random
# Kommentare erfolgen mit hashtag
# Ausgabe von Daten
print("Hallo World")
# Variable definieren(kann ohne typ erfolgen)
heimat = "Erde"
# Mehrere Variable werden mit , getrennt
print(heimat, "an World: ", "Hallo")
#Eingabe/ liest Text von der Console ein
wer = input("Und wer ... |
b038e7ea68a33ea0ee32ab368ff9989e156fa71b | Namrata96/Lunch-time-Machine-Learning-Projects | /digit_recogniser_nn.py | 3,445 | 3.78125 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 3 22:57:34 2017
@author: nam
"""
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
# Getting inputs, and outputs(in one-hot vector form)
mnist = input_data.read_data_sets("/tmp/data/", one_hot = True)
# Defining... |
063d16a81a5348f33bc809d857d7ad71d16ee58c | elmasria/mini-flow | /src/linear.py | 689 | 4.25 | 4 | from neuron import Neuron
class Linear(Neuron):
def __init__(self, inputs, weights, bias):
Neuron.__init__(self, inputs)
# NOTE: The weights and bias properties here are not
# numbers, but rather references to other neurons.
# The weight and bias values are stored within the
... |
a399244d188577808dcb9ec5c75e10390cfd569e | Ajinkya-Nawarkar/Decision-Tree-Classifier | /dtClassifier.py | 13,095 | 3.75 | 4 | #####################################################################
# #
# Name: Ajinkya Nawarkar #
# CSE 4633 AI Final Project #
# Net-Id: an839 ... |
d83e35aeca831b6aa447f2bac7286f2bcc1b0889 | codio-gcse-2014/teacher-python-4 | /02-orr/task-1.py | 637 | 3.5 | 4 | # Task 1
# Press the 'Run File' menu button to execute
#
class customer:
name=""
appt=""
Jess=customer()
Jess.name="Jessica"
Jess.appt="Monday, 12pm"
print(Jess.name+" is expected "+Jess.appt)
#ext 1
that_office_girl=customer()
that_office_girl .name="Sheila"
that_office_girl .appt="Wednesday, 2pm"
print( tha... |
4c569f0e9b808e8c3c670bd95b9d9d3c0bba7d87 | coolcoder13/coders | /Doubly Linked List/DLL_delete_at_pos.py | 1,736 | 3.90625 | 4 | # making of node of doubly linked list
class Node:
def __int__(self,data):
self.data=data
self.prev=None
self.next=None
#creating class with meathods to perform different tasks
class DoublyLinkedList:
def __init__(self):
self.head=None
# how to insert node in a dou... |
ddd19ba34b8fbb82d9865bc96d20ca6fd28339be | zhaoxiaojun/StudyPython | /DataStructure-Algorithms/Sort.py | 3,848 | 3.890625 | 4 | #coding=utf8
def BubbleSort(L):
'''
冒泡排序
'''
n = len(L)
flag = True
while flag and n>0:
flag = False
for i in xrange(1,n):
for j in xrange(0,n-i):
if L[j] > L[j+1]:
flag = True
L[j], L[j+1] = L[j+1], L[j]
def S... |
51476bd0fb52d616d52d9d98ad249c44123da86e | JaviCodx/cs50x | /pset6/cash/cash.py | 383 | 3.640625 | 4 | from cs50 import get_float
while True:
owed = get_float("Cash owed ")
if owed >= 0:
break
cents = round(owed*100)
coins = 0
while(cents >= 25):
coins += 1
cents -= 25
while(cents >= 10):
coins += 1
cents -= 10
while(cents >= 5):
coins += 1
cents -= 5
while(ce... |
3418f9639060fed70d9bade27751cd7619fe4f01 | sowjanya87/Credit-Risk-Analysis | /APEX | 4,733 | 3.828125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri May 24 16:50:15 2019
@author: sowjanyamattaparthi
"""
#DATA PREPROCESSING
#Load the librarys
import pandas as pd #To work with dataset
import numpy as np #Math library
import seaborn as sns #Graph library that use matplot in background
import matplotl... |
0e0a203a57fb8be7ff61431875bd940fdb5a0763 | john-odonnell/tetris | /tetris.py | 9,671 | 3.765625 | 4 | import pygame
import board as bd
import piece as pc
import random as rand
BLOCK_SIZE = 25
""" Initialize Pygame, constant screen and surfaces """
pygame.init()
# (0,0) is the top left corner of the screen
screen = pygame.display.set_mode((10*BLOCK_SIZE, 21*BLOCK_SIZE))
# board and piece surface are responsible for dr... |
f1f8f371a148c414328c7500bbfe7a97a5f43e60 | simonljus/sandbox | /cake.py | 2,204 | 4 | 4 | import numpy as np
import matplotlib.pyplot as plt
'''
A simple interactive tool for plotting how Swedes eat cake
'''
def cakeGraph(original_size_of_cake,n_bits):
vfun = np.vectorize(cakeLeft,otypes=[np.float])
x = range(n_bits +1)
y=vfun(original_size_of_cake,x)
fig,ax = plt.subplots()
xy = zip(x,... |
b874809082e626a86a44e723378f2de5d59bfa63 | AgrawalNeha25/Flask | /create_table.py | 380 | 3.765625 | 4 | import sqlite3
connection = sqlite3.connect("data.db")
cursor = connection.cursor()
user_query = "CREATE TABLE IF NOT EXISTS Users (id INTEGER PRIMARY KEY , username text, password text)"
cursor.execute(user_query)
item_query = "CREATE TABLE IF NOT EXISTS Items(id INTEGER PRIMARY KEY, name text, price real)"
cursor... |
5ca43f5223b69d0940bc228d8670d551504acd90 | dinvince/creditcalc | /creditcalc.py | 5,095 | 3.890625 | 4 | import argparse
import math
parser = argparse.ArgumentParser()
parser.add_argument('--type', type=str,
help='What type of the calc? Can choose annuity or diff')
parser.add_argument('--principal', type=int,
help='What is the credit principal?')
parser.add_argument('--payment', t... |
bac53da6089ab51d4d094411fdcbc2a9741a50c4 | schnitzlMan/ProjectEuler | /Problem19/Problem19.py | 1,400 | 4.125 | 4 | # strategy -
#count all the days - approximately 100 * 365.25 - not too large.
#keep track of the month to add correctly
#devide the day by %7 - if no rest, sunday if you counted correctly
#count the numbers of sundays
#months = {"jan": 31, "feb": 28, "mar":31, "apr":30, "may":31, "jun":30,
# "jul": 31, "aug... |
a3afdae879b54746b45afd63df4706c8ca9af83a | schnitzlMan/ProjectEuler | /Problem587/Problem587.py | 707 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Mar 5 22:00:43 2017
@author: Peter
"""
import math
def deltaToTheLeftOfBottom(n):
x = (n*n + n - n*math.sqrt(2*n))/ (n*n+1)
return 1-x
def heightAtN(inVal):
return (1-deltaToTheLeftOfBottom(inVal))/inVal
def IntegralTriangle(inVal):
delta = deltaToTheLef... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.