blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
f951dcace25b2c1ef73bd88af26d2974285d2d98 | nileshnegi/hackerrank-python | /day005/ex38.py | 525 | 3.671875 | 4 | """
Mean, Var and Std
You are given a 2-D array of size ```N x M```.
Your task is to find:
The mean along ```axis 1```
The var along ```axis 0```
The std along ```axis None```
"""
import numpy
numpy.set_printoptions(legacy='1.13')
if __name__ == "__main__":
N, M = map(int, input().split())
arr =... |
94b4f692037e4d6e1646968f9be5746f4957fe43 | nileshnegi/hackerrank-python | /day004/ex25.py | 2,003 | 3.6875 | 4 | """
**The Minion Game
Both players are given the same string, ```S```. Both players have to make substrings using the letters of this string.
Stuart has to make words starting with consonants. Kevin has to make words starting with vowels.
The game ends when both players have made all possible substrings.
"""
import re... |
2b08d0e54191c1be5acada2271ffba0718de2885 | nileshnegi/hackerrank-python | /day015/ex91.py | 673 | 3.90625 | 4 | """
Matrix Script
The first line contains space-separated integers `N`(rows) and `M`(columns).
The next `N` lines contain the row elements of the matrix script.
To decode the script, replace symbols or spaces between 2 alphanumeric
characters with a single space for better readability.
"""
import re
first_multiple_i... |
fa88d7cd8267e7e7add2027eec7f6b3c778e41b1 | nileshnegi/hackerrank-python | /day010/ex64.py | 582 | 4.15625 | 4 | """
Re.findall() & Re.finditer()
You are given a string ```S```. It consists of alphanumeric characters,
spaces and symbols(+,-). Your task is to find all the substrings of that
contains or more vowels. Also, these substrings must lie in between consonants
and should contain vowels only.
"""
import re
if __name__ == ... |
c68cad723ff56551ea842aa63695993e427e5496 | nileshnegi/hackerrank-python | /day014/ex90.py | 528 | 3.921875 | 4 | """
Validating Postal Codes
A valid postal code `P` has to fullfil both below requirements:
`P` must be a number in the range from `100000` to `999999` inclusive.
`P` must not contain more than one alternating repetitive digit pair.
"""
regex_integer_in_range = r"^[1-9]{1}[0-9]{5}$" # Do not delete 'r'.
regex_alternat... |
09e47777029530253caee18c7e74580c34fa825c | nileshnegi/hackerrank-python | /day016/ex102.py | 796 | 4.09375 | 4 | """
Exceptions
Given two values `a` and `b`, perform integer division and print `a/b`.
In the case of `ZeroDivisionError` or `ValueError`, print the error code.
"""
if __name__ == '__main__':
for _ in range(int(input())):
a, b = input().rsplit()
try:
a = int(a)
except ValueError... |
67f581e6718e53df0a2e1009f58e8f53dfeafe7f | nileshnegi/hackerrank-python | /day002/ex18.py | 696 | 4.03125 | 4 | """
String Validators
You are given a string ```S```.
Your task is to find out if the string contains: alphanumeric characters, alphabetical characters, digits, lowercase and uppercase characters.
"""
if __name__ == '__main__':
s = input()
results = [False, False, False, False, False]
for char in s:
... |
15c84e305cc9d23af46f2e59989ec90a4ab276f0 | nileshnegi/hackerrank-python | /day001/ex8.py | 295 | 3.625 | 4 | """
Input()
You are given a polynomial of a single indeterminate (or variable), ```x```.
You are also given the values of ```x``` and ```k```. Your task is to verify if ```P(x) == k```.
"""
if __name__ == "__main__":
x, k = map(int, input().split())
P = input()
print(eval(P) == k) |
b5fb0f3ad214764e73b2048a41aaa57d430dfe54 | nileshnegi/hackerrank-python | /day003/ex22.py | 639 | 4.21875 | 4 | """
String Formatting
Given an integer, ```n```, print the following values for each integer ```i``` from 1 to n:
Decimal
Octal
Hexadecimal (capitalized)
Binary
The four values must be printed on a single line in the order specified above.
Each value should be space-padded to match the width of the bi... |
c94b07395b5117ea67948120e5ffb52ae1540221 | nileshnegi/hackerrank-python | /day008/ex51.py | 644 | 4 | 4 | """
Collections.OrderedDict()
You are the manager of a supermarket. You have a list of items together
with their prices that consumers bought on a particular day. Your task
is to print each item_name and net_price in order of its first occurrence.
"""
from collections import OrderedDict
if __name__ == "__main__":
... |
4e44d6c979db45c36bacf986e2505cc47ae5d1b2 | niriddiki/python | /step-1.py | 1,061 | 3.625 | 4 | # Транспонирование матрицы
#var1
matrix =[[0.5,0,0,0,0],
[1,0.5,0,0,0],
[1,1,0.5,0,0],
[1,1,1,0.5,0],
[1,1,1,1,0.5]]
# Транспонирование
matrix_t=list(zip(*matrix))
matrix_t_as_list=list(map(list, zip(*matrix)))
#var2
a=[0.5,0,0,0,0]
b=[1,0.5,0,0,0]
c=[1,1,0.5,0,0]
d=[1,1,1,1,0.5]
matr... |
6a4fd45e892d61adcca6eab4cd09edee2fcfa5d6 | tejesh0/projectEuler | /4problem.py | 325 | 3.578125 | 4 | #check for palindrome
def isPalindrome(num):
num_str = str(num)
if(str(num) == num_str[::-1]):
return True
return False
print isPalindrome(99009)
max = 0
for i in list(range(999,99,-1)):
for j in list(range(990,99,-11)):
if(isPalindrome(i*j)):
print i*j
if(max < i*j):
max = i*j
print max
prin... |
6d9f5ef33a051665ec576abac4f5e6ec47fe8485 | HamzaElshennawy/Aalaa-Designs-Management-System | /aalaa designs/Back_End.py | 2,024 | 3.859375 | 4 | import sqlite3
from tkinter import *
#this is the main database
def aalaa_designs_data():
connect=sqlite3.connect("AD.db")
cur=connect.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS AD(id INTEGER PRIMARY KEY, Name text, Date text, \
cde text, Address text, Mobile text, wight text, length text ... |
7b68ca7bb383a97d2b9a4b5f002f925c4c64cec0 | Daniyal56/Python-Projects | /Vowel.py | 653 | 4.375 | 4 | ## 7. Vowel Tester
### Write a Python program to test whether a passed letter is a vowel or not
#### Program Console Output 1:
##### Enter a character: A
###### Letter A is Vowel
#### Program Console Output 2:
##### Enter a character: e
###### Letter e is Vowel
#### Program Console Output 2:
##### Enter a character: N
... |
fc561fb9bbf8085b10bcfa19d3b1d383aa933c6e | seed-good/mycode | /funif/harrypotter.py | 4,411 | 3.671875 | 4 | #!/usr/bin/env python3
quiz = [{"Pick a Movie": ["The Parent Trap", "The Silence of the Lambs", "Mean Girls", "The Wolf of Wall Street", "Eternal Sunshine of the Spotless Mind", "The King's Speach"]},
{"Which Object do you most desire?": ["The Elder Wand", "The Philosopher's Stone", "The Mirror of Erised", "A ... |
e13d0684aaa31d1cc3565fd7622f898496a06f3b | seed-good/mycode | /forloops/goggles.py | 1,330 | 3.859375 | 4 | #!/ust/bin/env python3
challenge= ["science", "turbo", ["goggles", "eyes"], "nothing"]
trial= ["science", "turbo", {"eyes": "goggles", "goggles": "eyes"}, "nothing"]
nightmare= [{"slappy": "a", "text": "b", "kumquat": "goggles", "user":{"awesome": "c", "name": {"first": "eyes", "last": "toes"}},"banana": 15, "d": "n... |
6c6053a187e469853a4899305dee103521de77ef | maiosama/Python-for-Everybody-py4e | /ex_09_04.py | 658 | 3.875 | 4 | fname = input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
fh = open(fname)
email = dict()
for line in fh:
line=line.rstrip()
if not line.startswith("From") or line.startswith("From:"):
continue
mail_list=line.split()
#for word in mail_list:
name=mail_list[... |
91cbc1a3fea47be184f49487c627d03f754a198d | sangee1234/cv | /AutoEncoder.py | 3,512 | 4.09375 | 4 | '''
AUTOENCODER
-Type of feedforward neural network where the input is same as output
-They compress input to lower dimensional code and reconstruct output from this representation
-To build autoencoder we need 3 components: encoding method, decoding method and loss function to compare output and target
-It is basical... |
346a3e73024f613e3091eb60637e951edff5c8ca | usman-tahir/project-euler-language-agnostic | /problem-1/Solution.py | 101 | 3.53125 | 4 |
multiples_sum = sum([x for x in range(3, 1000) if (x % 3 == 0 or x % 5 == 0)])
print(multiples_sum)
|
fe9e18ab764f36000a03bf9c65a02a7d596ddb2a | xiaoaxe/xiao-python-corelib | /corelib/ch03_thread/sec02_queue.py | 1,203 | 3.59375 | 4 | #!/usr/bin/env python
# encoding: utf-8
"""
@description:
@author: BaoQiang
@time: 2017/7/27 17:44
"""
import threading
from queue import Queue
import time
import random
WORKER_NUM = 10
class Consumer(threading.Thread):
def __init__(self, queue):
super().__init__()
self.queue = queue
def... |
bcc34c212f4b2b52fecced2c69cd60a104a050f0 | rakeshreddy02/100-days-of-code-by-Manish-Beesetti | /Day 1/TheCrunch/pythonbasics.py | 2,214 | 4.3125 | 4 | ##########################################################
# Day 1
#Python Basics
# Manish Beesetti
##########################################################
#Strings
#Declaring a string
string1 = "i am batman\t"
#printing a variable
print(string1)
string2 = ", Where is the Joker."
print(string2)
#string concatin... |
18ede67c4a7b618d83d2eab9ed7183a82b03e2c6 | sssmc/Twitter-Numbers | /Python/regx_testing.py | 191 | 3.984375 | 4 | num = "34325"
print(num)
if num.lstrip('-').isdigit():
print("is Digit")
else:
try:
float(num)
print("is float")
except ValueError:
print("is not number")
|
a3a154434b582457b9123b5adcbacc2806ddf3a6 | sutirtha-gupta/Python-ML-HW1 | /Fibonacci.py | 323 | 3.890625 | 4 | def FibonacciSeries(seriesLength):
x =0
y =1
#z = 0
for i in (range(0,seriesLength)):
if(i==0):
print(x)
elif(i==1):
print(y)
else:
z = x +y
print(z)
x = y
y= z
FibonacciSeries(9)
... |
21a3dd2dfd06ff58ab62244595720cec63935fea | froststein/CVE1113 | /Q2strongNum.py | 610 | 4 | 4 | def findStrongNum(start,end):
arr = []
for num in range(start,end+1):
if(num != 0):
length = len(str(num))
n1 = 0
temp = num
while temp > 0:
digit = temp % 10
n1 += digit ** length
temp //= 10
... |
c459c84832c9af48dc0cc1721b481d2e8309a569 | Emrys-Hong/mamamiya | /intro_to_algo/sort/insert-sort.py | 352 | 3.984375 | 4 | def insert_sort(input_list):
for i in range(len(input_list)):
cur_value = input_list[i]
j = i-1
while input_list[j] > cur_value and j>=0:
input_list[j+1] = input_list[j]
j=j-1
input_list[j+1] = cur_value
return input_list
input_list = [5,4,3,2,1,0,-1,-1]
... |
eecac540113396e726354160577d6dbe91387519 | GEEGABYTE1/InterviewQuestions | /Knapsack/recursive.py | 619 | 3.78125 | 4 | def recursive_knapsack(weight_cap, weights, values, i):
if weight_cap == 0 or i == 0:
return 0
elif weights[i - 1] > weight_cap:
return recursive_knapsack(weight_cap, weights, values, i - 1)
else:
include_item = values[i - 1] + recursive_knapsack(weight_cap - weights[i - 1], weights,... |
4edc8ca67abb0540623794655185e5198941fda3 | hzhcongo/MDP-Simulator-and-Algo | /RPi/Algorithm/Algo/Simulator.py | 9,138 | 4.21875 | 4 | #!/usr/bin/env python
"""Implementation of the Robot class for simulation mode.
"""
import numpy as np
import os
from Constants import MAX_ROWS, MAX_COLS, NORTH, SOUTH, EAST, WEST, RIGHT, LEFT
__author__ = "Utsav Garg"
class Robot:
"""Robot class keeps track of the current location and direction of the robot,
... |
9bc9c514f88275397c853cf045991587177e0fff | hzhcongo/MDP-Simulator-and-Algo | /RPi/Map.py | 2,098 | 3.515625 | 4 | import Constants
import numpy
class Map(object):
def __init__(self):
self._grid = numpy.zeros([Constants.MAP_ROWS, Constants.MAP_COLS])
# Int representations of a cell
# 0 = Initialized and unexplored
# 1 = Explored - walkable
# 2 = Explored - not walkable due to obstacle
... |
35c1db3aad9fae72ff8234ec53c34cfc85cb0345 | Nazar961/OG19PythonShostak | /dictionary.py | 178 | 3.625 | 4 | def dicti (a, b):
d = dict([(a, b)])
print (d)
a = int(input("Введіть значення A = "))
b = int(input("Введіть значення B = "))
dicti (a, b) |
e2927f31b028516badf35363c54ef1aa559da639 | euleryang/PythonLearning | /src/day02/leap.py | 379 | 3.953125 | 4 | """
输入年份 如果是闰年输出True 否则输出False
Version: 0.1
Author: SamYnag
Date: 2019-12-07
"""
year = int(input('请输入年份: '))
# 如果代码太长写成一行不便于阅读 可以使用\或()折行
is_leap = (year % 4 == 0 and year % 100 != 0 or year % 400 == 0)
if is_leap:
print(str(year) + "是闰年")
else:
print(str(year) + "不是闰年") |
1101abbd8aae4faf951c35ca055702fb69de8995 | Lucky0214/machine_learning | /fillna_pd.py | 318 | 3.828125 | 4 |
# use of fillna() function
import pandas as pd
p = pd.read_csv("cricket.csv")
print(p.tail())
print("*********************fillna function use************************")
q=p.fillna(1)
print(q.tail())
print("*************************fillna for particular column***************")
r=(p["5w"].fillna(1))
print(r.tail())
|
7ab046a022387c673938c1d6d67b65808fa9be15 | Lucky0214/machine_learning | /apply_pd.py | 454 | 3.953125 | 4 | #apply function
# when we need to apply a function in each value then we use .apply function
import pandas as pd
p=pd.read_csv("test.csv", squeeze=True)
def classify_per(number):
if number<100:
return "OK"
elif number>=100 and number<500:
return "still OK"
else:
return "bad"
print("***********************... |
586ac565e8a6085107ef5e2911184949cfdb0569 | Lucky0214/machine_learning | /drop_duplicate_pd.py | 858 | 4.3125 | 4 | # use of drop_duplicated() method
## It drops the duplicate value after identify
import pandas as pd
df = pd.read_csv("testing.csv")
print(df)
print(len(df))
#we can find the duplicated value in a single function name as duplicated() function
print("*****************************drop duplicated default command*******... |
7b452319c8b6edad6cca06d650bfec23b0d09c66 | Lucky0214/machine_learning | /math_pd.py | 514 | 3.8125 | 4 | #basic math method which is use in every time
#use of .idxmax() & .idxmin()
import pandas as pd
p= pd.read_csv("test.csv", squeeze = True)
print(p)
print( p.count())
print(p.mean())
print(p.sum())
print(p.std())
print(len(p))
print(p.median())
print(p.max())
print(p.min())
# idxmax()
print("Use of idxmax")
print... |
978800534acb6ca14b16bca68115450bad1f3888 | HeyVoyager/Portfolio-Projects | /d_graph.py | 17,515 | 4.0625 | 4 | # Course: CS261 - Data Structures
# Author: Michael Hilmes
# Assignment: 6
# Description: Directed Graph Implementation
class DirectedGraph:
"""
Class to implement directed weighted graph
- duplicate edges not allowed
- loops not allowed
- only positive edge weights
- vertex names are integers
... |
ca431614e33c7794dad59c0f75cb39662f721fd5 | yevamelikyan/Parking-app-User-Story-Yeva | /main.py | 656 | 4.09375 | 4 | import random #use Python random package to get random numbers
carType = ["sedan", "suv"] #store two possible values for answer
answer=0
while carType[0] != answer and carType[1] != answer:
answer = input("Please choose the type of your car: sedan or suv? ")
if answer == carType[0]:
print("Your parking spot is:... |
9bb318d19d3f0eff4c754fd72f24438a44dd70c7 | elsenorbw/advent-of-code-2015 | /day4/day4.py | 1,942 | 3.890625 | 4 | # --- Day 4: The Ideal Stocking Stuffer ---
# Santa needs help mining some AdventCoins (very similar to bitcoins) to use as gifts for all the economically forward-thinking little girls and boys.
#
# To do this, he needs to find MD5 hashes which, in hexadecimal, start with at least five zeroes.
# The input to the MD5 ha... |
e2eb33387f67b7f8d21cd4ae745f492e0701c01b | elsenorbw/advent-of-code-2015 | /day3/day3_part1.py | 2,581 | 3.953125 | 4 | # --- Day 3: Perfectly Spherical Houses in a Vacuum ---
# Santa is delivering presents to an infinite two-dimensional grid of houses.
#
# He begins by delivering a present to the house at his starting location, and then an elf at the North Pole calls him via radio and tells him where to move next.
# Moves are always ex... |
287baea14a5650990de9fb365ad0e95605360a5b | cedadev/esacci-esgf | /esacci_esgf/input/remove_key.py | 651 | 3.5 | 4 | #!/usr/bin/env python3
"""
Remove a key from the top level of a JSON dictionary, and print the new
dictionary to stdout.
"""
import sys
import argparse
import json
def main():
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter
)
pars... |
6f03141b95b9d8151ecf207b8db33fbc8ced8a7d | kmurphy13/jtk-cs364-finalproject | /ast.py | 15,670 | 3.859375 | 4 | from typing import Union, Optional, List, Dict
import operator
env = {}
types = {}
# Use a class hierarchy to represent types.
class Expr:
"""
Base class for expressions
"""
def eval(self):
pass
class UnaryMinus(Expr):
"""
Adds a unary minus to an expression (-34567)
"""
def... |
47a19ef5e510d63628c979c42a4656aacfb51453 | EmelineGOT/Centrale | /INF/INF tc1/BE1/GOT - BE1 - Prise en main de Python/IV-3-pair-impair.py | 260 | 3.828125 | 4 | a=int(input('Donner un entier:')) #On demande l'entier a
if (a%2==0): #Si le reste de la division euclidienne de a par 2 est nul...
print(a,"est pair.") #...L'entier est pair
else:
print(a,"est impair.") #Sinon l'entier est impair
|
e253048a59b7306c4e2173e85f00f73055d8e092 | EmelineGOT/Centrale | /INF/INF tc1/BE1/GOT - BE1 - Prise en main de Python/XVIII-2 Tri insertion.py | 1,159 | 3.84375 | 4 | def tri_insertion(l):
def insere_a_sa_place(liste,val):
lf=[] #lf est la liste finale obtenue après insertion
copie=liste[:] #On fait une copie de la liste pour ne pas la modifier
while copie!=[] and val>copie[0]: #Tant que la copie n'est pas vide et que la valeur que l'on veut in... |
acf50aebdbd10132f2dbcbf0ae47b4cc43b681f3 | coparker/CST205Proj2 | /A2.py | 1,908 | 3.765625 | 4 | """
work on making a function that will take a black image
and put that into the GPU so that the graphics card can
do the work to make it faster. also make the function input
an image so that it doesnt have to be just a black image.
"""
import sys
import sdl2
import sdl2.ext
import time
import Audio
"""
@Author: Na... |
e5d965556a0f5ce45bf38c6700ac7af84f894cb9 | cortezmb/List-Exercises | /ex9.py | 924 | 4.40625 | 4 | #Lists exercise 9
matrix1 = [[1, 3], [2, 4]]
matrix2 = [[5, 2], [1, 0]]
# Created an empty matrix in order to append (add) the calculated elements
matrix3 = []
# I want mResults = [[6, 5], [3, 4]]]
# mResults.append([6, 5])
# mResults.append([3, 4])
# This is going to locate the element each time it loops
element1 = ... |
68e8154a5ae1eb4743dc152cc657955ff4c64aca | Alikutepa/Password_Locker | /modules/credentials_test.py | 1,817 | 3.71875 | 4 | import unittest
from credentials import Credentials
class TestCredentials(unittest.TestCase):
'''
Test class that defines test cases for the contact class behaviours.
'''
def setUp(self):
'''
Set up method to run before each test cases.
'''
self.new_socials = Credent... |
2e0c685a23065058b119dddac94966b43c390129 | Sayitkamol/Python_darslari1 | /12.07 1.py | 2,110 | 3.6875 | 4 | # # # # a = int(input('a=:'))
# # # # b = int(input('b=:'))
# # # #
# # # #
# # # # def qushish(a, b):
# # # # return a + b
# # # #
# # # #
# # # # def urta_arifmetik():
# # # # return qushish(a, b) / 2 #ikki sonning o'rta arifmetigini chiqarish
# # # #
# # # #
# # # # print(urta_arifmetik())
# # ... |
20d8ef40d25eb036e148891ffb0262fc539c679c | Sayitkamol/Python_darslari1 | /14.py | 260 | 3.90625 | 4 | # 3 o'lchovli matrix berilgan shundan diagonalini chiqaring
a = [[1, 2, 3],[4, 5, 6],[7, 8, 9]]
for i in range(3):
for j in range(3):
if a[i][j]:
a[i][j] = (a[i][j])
elif a[i][j]:
a[i][j] = a[i][j]
print(a)
|
f66ac7f2d9ca31f36c1dbdb20b7f7c07bc2b9202 | Sayitkamol/Python_darslari1 | /date_time.py | 923 | 3.59375 | 4 | import datetime as dt # as qisqacha nom berish buyug'i
from tkinter import *
import time
# while True:
# print(datetime.datetime.now())
# print(dt.datetime.now().year)
import this
#vaqt = dt.datetime.now().second
# print(vaqt.year) # yil
# print(vaqt.month) # oy
# print(vaqt.day) # kun
# print(... |
4b1818b7b86821578982d583422ab3e71bd2e011 | subhayuroy/ComputationalForensics | /Multiprocessing Support/multi.py | 936 | 3.59375 | 4 | import random
import multiprocessing
def list_append(count, id, out_list):
# appends the count of number of processes which takes place at a time
for i in range(count):
out_list.append(random.random())
if __name__ == "__main__":
size = 999
procs = 2
# Create a list of jobs... |
18effbfbf84db705faec12e02b88314d528765c2 | Pixelus/MIT-6.0.0.1-problems | /while_loop.py | 370 | 4.3125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 12 15:12:49 2018
@author: PixelNew
"""
# Replace the comment in the following code with a while loop.
numXs = int(input('How many times should I print the letter X? '))
toPrint = ''
# concatenate X to toPrint numXs times
while (numXs):
toPri... |
b2afdd6dab932798619220bf9e9b4010334f79e7 | jsillman/astr-119-hw-1 | /dictionaries.py | 482 | 4.5 | 4 | #this program explores the dictionary class in python
ex_dict = {
"class" : "Astr 119",
"prof" : "Brant",
"awesomeness" : 10
}
print(type(ex_dict)) #prints datatype of ex_dict (dictionary)
course = ex_dict["class"]
print(course) #prints the value under the key "class" in ex_dict
ex_dict["awesomeness... |
6ee4493bbb98bbc76a84f2c2e762d4da4933e416 | patrickfuller/fomms-2015 | /file_formats/step_1.py | 358 | 3.5625 | 4 | import json
# Pretend we're doing something that's generating data
a = {"conference": "FOMMS",
"year": 2015,
"languages": ["python"],
"names": [{"first": "Patrick", "last": "Fuller"},
{"first": "Chris", "last": "Wilmer"}]}
# Write the output to a file as json
with open("v1.json", "w") as... |
e13b2e13beacd37dc48e6bc6debdc3cae863e9ad | Sophie1218/IE221_L22_CNCL | /myprogram/option1/point.py | 2,740 | 4.21875 | 4 | # import libraries
from math import sqrt
from pygame.draw import circle
from pygame.draw import rect
from myprogram.interface import BLACK, WHITE, COLORS, LIGHT_COLORS
class Point:
"""
A class to represent a two-dimensional data point.
...
Attributes
----------
x : float
... |
8c5f876469161ac990d7f8871125de19ddd37142 | melissanardone/test | /git_exercise/p1-melissanardone/base_convert.py | 517 | 4.0625 | 4 |
def convert(num, b):
"""Recursive function that returns a string representing num in the base b"""
num_list = ['A', 'B', 'C', 'D', 'E', 'F']
if num//b != 0:
if num % b < 10:
return convert(num // b, b) + str(num % b)
else:
return convert(num // b, b) + num_list[(n... |
9d1970e2683f2be74fed12d1ca69267763efad99 | baquinn4/Numerical_Methods | /Numerical Integration/main.py | 2,075 | 3.8125 | 4 |
import math
# This program numerically(integrates) approximates the given integral f(x) = ln(x) on [1,3] with n = 512 using
# both the Trapezoidal Rule and Simpsons Rule
#
# CSC 2262 Programming Project 5
#
# @author Bradley Quinn
# @since 10/28/20
# Given final values
UPPER_BOUND = 3
LOWER_BOUND = 1
SUBINTERVALS =... |
d1ad721ed67d2b988a40cc998c5c27b2abb4ad18 | rez0815/Casion | /CasinoV1/main.py | 8,466 | 3.609375 | 4 |
# name: main.py
# Usage: main file of project 'Casino'
# Created by: rez0815
# Date: 2021-02-01
# input project 'BlackJack' later
import random
import time
games = ["BlackJack", "Other"]
print("Wilkommen im Casion!")
print("Wir freuen uns, sie hier begrüßen zu dürfen.")
knowgame = input("Wissen sie schon, welches ... |
d94b86597944d5d5339ec919d4f3daf359b2106a | elootje98/Rooster | /classes/classroom.py | 440 | 4.15625 | 4 | class Classroom:
def __init__(self, name, capacity):
""" Creates classrooms objects which holds the name and capacity.
Arguments:
name (str): Name of classroom.
capacity (int): Capacity of classroom.
Attributes:
name (str): Name of the classroom.
... |
7f6d61cf99a4f69045df8b1acda5937488c21050 | JBarretoY/proyecto---maria-valentina | /Main.py | 3,762 | 3.640625 | 4 | from Movie import Movie
import sys
from os import system
from time import sleep
class Main:
def main(self):
try:
output = int(self.menu())
if output == 0:
sys.exit()
elif output == 1:
title = input... |
8749e451477dba0af2a7d7c6c8ead51e14b05daa | akshayrana30/Data-Structures-and-Algorithms | /#1 LeetCode/189. Rotate Array.py | 919 | 3.625 | 4 | class Solution:
def rotate(self, nums: List[int], k: int) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
# Timeout Error
## Using O(kn), O(1) Memory
# k = k%len(nums)
# while(k>0):
# prev = nums[-1]
# for i i... |
129b688c3fe72568bebc0480c284425fa27e3abe | akshayrana30/Data-Structures-and-Algorithms | /#2 Cracking the Coding Interview/02 - Linked Lists/linked_list.py | 1,730 | 3.875 | 4 | class Node():
def __init__(self, val):
self.data = str(val)
self.next = None
def __str__(self):
return self.data
class SinglyLinkedList():
def __init__(self, val):
node = Node(val)
self.size = 1
self.tail = node
self.head = node
## Queue - ... |
e8699403cc002021654dae22a9aec3775499b1c3 | akshayrana30/Data-Structures-and-Algorithms | /#1 LeetCode/283. Move Zeroes.py | 473 | 3.78125 | 4 | from typing import List
class Solution:
def moveZeroes(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
size = len(nums)
n = 0
while n < size:
if nums[n] is 0:
nums.pop(n)
... |
4ae65747a9713faea7da3b9fbc99ff50443ea6c9 | akshayrana30/Data-Structures-and-Algorithms | /#1 LeetCode/125. Valid Palindrome.py | 1,330 | 3.875 | 4 | import string
class Solution:
def isPalindrome(self, s: str) -> bool:
# This is 2*O(n) runtime and O(n) memory
# stack = []
# for val in s:
# if val.lower() not in string.punctuation and val!=" ":
# stack.append(val.lower())
# for val in s:
... |
ee021fd6514e687aade1ce171a391f0b87505412 | akshayrana30/Data-Structures-and-Algorithms | /#1 LeetCode/234. Palindrome Linked List.py | 1,052 | 3.921875 | 4 | # Definition for singly-linked list.
# Runtime: 56 ms, faster than 99.18% of Python3 online submissions for Palindrome Linked List.
# Memory Usage: 22.8 MB, less than 100.00% of Python3 online submissions for Palindrome Linked List.
class ListNode:
def __init__(self, x):
self.val = x
self.next = N... |
df87c1873c7b563ac1b4ba61041b1775cfaf7716 | akshayrana30/Data-Structures-and-Algorithms | /#1 LeetCode/344. Reverse String.py | 532 | 3.90625 | 4 | # Runtime: 212 ms, faster than 70.45% of Python3 online submissions for Reverse String.
# Memory Usage: 17 MB, less than 100.00% of Python3 online submissions for Reverse String.
from typing import List
# two pointers and swap
class Solution:
def reverseString(self, s: List[str]) -> None:
"""
Do n... |
8d958872245929cd084f0c269e705de399d8bbee | akshayrana30/Data-Structures-and-Algorithms | /#1 LeetCode/13. Roman to Integer.py | 656 | 3.703125 | 4 |
# Runtime: 44 ms, faster than 94.89% of Python3 online submissions for Roman to Integer.
# Memory Usage: 12.7 MB, less than 100.00% of Python3 online submissions for Roman to Integer.
class Solution:
def romanToInt(self, s: str) -> int:
dic = ((1000,'M'),(900,"CM"),(500,"D"),(400,"CD"),(100,"C"),(90,"XC")... |
f0e494f16bd21db46e04d3df518cdf44e37716d6 | qiaoy9377/python-base | /第二天作业/1.三角形练习.py | 2,717 | 4.03125 | 4 | #一、打印三角形
#1.while实现
#循环变量--行号
j = 1
#循环判断--判断行号小于5
while j <= 5:
#循环体--循环打印单行星号
#循环变量-星号数量
i = 0
str1 = '' #定义一个字符串
#循环判断--判断星号数量
while i < j:
#循环体--用星号拼接字符串
str1 += '*'
#循环变量发生变化
i += 1
#打印拼接好的星号字符串
print(str1)
#循环变量发生变化
j += 1
#用for实现
#行数循环
for... |
d16ef6218697ed9ad1bd14ce0ebead9a546c58cd | qiaoy9377/python-base | /第一天练习代码/3.条件语句.py | 1,050 | 4.125 | 4 | #练习1
if True:
print('条件语句1')
print('条件语句2')
print('无论条件是否成立都打印')
#如果用户年龄大于等于18岁,即成年,输出’已成年,可上网‘
age = 18
if age >= 18:
print('已经成年,可以上网')
age = int(input('请输入年龄:')) #input接受用户输入的数据是字符串类型,这里需要int转换数据类型
if age >= 18:
print(f'你的年龄是{age},已经成年,可以上网')
else:
print(f'你的年龄是{age},未成年,不可上网')
#多重判断练习
age =... |
8529b658a5ad83b8200fc2ddae86d1926b2792d7 | qiaoy9377/python-base | /day2/公共操作.py | 1,560 | 3.890625 | 4 | #+
#1.字符串
str1 = 'aa'
str2 = 'bb'
str3 = str1 + str2
print(str3)
#2.列表
list1 = [1,2]
list2 = [10,20]
list3 = list1+list2
print(list3)
#3.元组
t1 = (1,2)
t2 = (10,20)
t3 = t1+t2
print(t3)
#*
#1.字符串
str4 = str1*3
print(str4)
print('-'*10)
#2.列表
list4 = list1 *4
print(list4)
#3.元组
t4 = t1 * 3
print(t4)
#in\not in
#1.字... |
1e1d46f7fa668fd3393717eb5821f614fb79b9ef | qiaoy9377/python-base | /day1/循环.py | 839 | 3.96875 | 4 | # #循环变量-道歉次数
# n = 0
# #循环条件-道歉次数判断
# while n < 5:
# #循环体-执行道歉
# print('我错了')
# #循环体发生变化-道歉次数发生变化
# n += 1
# #道歉结束
# print('道歉结束')
#循环变量--苹果数量
apple = 1
#循环条件--吃5个
while apple <= 5:
#判断吃到第几个苹果
# if apple == 4:
# #是,吃饱了
# print('吃饱了')
# #跳出循环
# break
# 判断吃到第几个... |
d7602bf69a84553241cf8d26ae97e8100c0fd166 | qiaoy9377/python-base | /day1/字符串.py | 2,054 | 4.21875 | 4 | # print("I'm Tom")
#
# #下标 下标是从0开始的
# name = 'abcdefg'
# print(name[0])
# print(name[3])
#
# #切片
# print(name[2:5:1])
# print(name[2:5])
# print(name[:4])
# print(name[1:])
# print(name[:])
# print(name[:2])
# print(name[:-1])
# print(name[-3:-2])
# print(name[::-1])
# print(name[6:3:-1])
# print(name[2:5:-1]) #没切到,为... |
a92c3d417b676e2ca3302fef27a1269d9ef127a0 | qiaoy9377/python-base | /day2/集合.py | 925 | 3.53125 | 4 | #有数据集合
s1 = {10,20,30,40,50}
print(s1)
s2 = {10,30,20,10,30,40,30,50}
print(s2)
s3 = set('abcdefg')
print(s3)
#空集合
s4 = set()
print(type(s4))
s5 = {}
print(type(s5))
#常见操作方法
#增--add()--追加单个数据
s1.add(10) #追加已有数据,不进行任何操作
print(s1)
s1.add(60)
print(s1)
#update()--追加的是序列
s1.update((100,200))
print(s1)
s1.update([... |
5004f9122b31b530cab52baf6e18911e4120c73e | qiaoy9377/python-base | /第二天作业/7.打印出superTest.py | 501 | 4 | 4 | #有一堆字符串“welcom to super&Test”,打印出superTest,不能查字符串的索引
#定义字符串
str1 = 'welcom to super&Test'
#将字符串用空格切片
list1 = str1.split(' ')
print(list1)
#将列表第3个参数赋值给字符串2
str2 = list1[2]
print(str2)
#将str2进行切片
list2 = str2.split('&')
print(''.join(list2))
#再次切片,判断切片完成后的长度
for i in list1:
list3 = i.split('&')
if len(list3) > 1... |
86c58e61a341302ec697845e4b56b25d120f4300 | PastyPurpleTrolls/game-contest-server | /examples/peggity/test-players/P24.py | 3,112 | 3.59375 | 4 | import random
def winCheck(board,emptyCellsList):
for row in range(11):
for col in range(11):
if board[row][col]==board[row+1][col] and board[row+1][col]==board[row+2][col] and board[row+2][col]==board[row+3][col] and board[row][col]!=0:
if board[row+4][col]==0:
... |
ddb2ab7e7af6d215895453e6064a01e6ed8d2abb | nicolasr120/csv_load | /csv_load/main.py | 1,671 | 3.71875 | 4 | import sys
import csv
import sqlite3
def generar_csv(nombre_archivo):
rows = []
csvfile = open(nombre_archivo, "r")
reader = csv.reader(csvfile, delimiter=',', quotechar='"')
reader.__next__()
for row in reader:
rows.append(row)
csvfile.close()
return rows
def create_table(curs... |
333a2ceee868123cd9c4f4a9314d7fbf13eeb4e0 | GoldenRed/K-TWSTP | /src/app.py | 2,532 | 3.546875 | 4 | from flask import Flask, request, jsonify
import json
app = Flask(__name__)
translations = {} # Will contain nested Python3 dictionaries for each "language"
def checkHeader(headers, headerLabel):
"""
Checks if a header is correct and that it's value is not empty.
"""
if headerLabel not in he... |
689c34eb5f61b08e7a793e2dc3f834c9f53d4c29 | alexmehandzhiyska/Pirple-Academy | /Python-is-easy/project-02.py | 838 | 3.875 | 4 | import random
def main():
words = ['juice', 'badminton', 'marvel', 'textbook', 'choice', 'difference', 'alliance', 'sorting']
word = random.choice(words)
field = list('_' * len(word))
print(' '.join(field))
attempts = 10
while (attempts > 0):
guess = input('\nChoose a letter: ')
... |
c9afb9fd5f66685555879f55b24d1d922fbba7a2 | alexmehandzhiyska/Pirple-Academy | /Python-is-easy/homework-08.py | 845 | 4.34375 | 4 | import os.path
from os import path
def createFile():
file_name = input('Enter file name: ')
if path.exists(file_name):
action = input('Select your action. Write "r" to read, "w" to rewrite the content, and "a" to append text: ')
if action == 'r':
file = open(file_name, 'r')
... |
40547cdf5f343e16a14a01adeaea218ba615d1df | hyeminshin99/codingtest_python | /그래프이론/#2_팀결성.py | 804 | 3.59375 | 4 | # 0~N번까지(N+1개)팀, M번 연산.
# 0 a b : a팀+b팀 합치기 / 1 a b : a,b같은팀?->출력YES/NO
def find_parent(parent, x):
if parent[x] != x:
parent[x] = find_parent(parent, parent[x])
#else: 아님!!! 모든 경우에 return
return parent[x]
def union(parent, a, b):
a = find_parent(parent, a)
b = find_parent(parent, b)
i... |
068fd6f0e99ae9c598945a37240de05d6acdc9d5 | fengshuai1/1805 | /15day/8-函数判断闰年.py | 384 | 3.8125 | 4 | # 定义函数判断闰年
def year(num):
# 判断能否整除400,或者(能整除4但是不能整除100)
if(num % 400 == 0) or ((num % 4 == 0) and (num % 100 !=0)):
print("%s是闰年"%num)
else:
print("%s不是闰年"%num)
while True:
# 获取输入的年份,转为int
year_input = int(input("请输入年份是否是闰年"))
# 调用函数判断
year(year_input)
|
069f91bc716c8d54fca3a8cc055139dd419becc4 | fengshuai1/1805 | /5day/05-注释.py | 280 | 3.765625 | 4 | #这个=是赋值运算符
a = 1
b = 2
c = a+b
print('1-c的值为:',c)
c = a-b
print('2-c的值为:',c)
c = a*b
print('3-c的值为:',c)
c = a/b
print('4-c的值为:',c)
c = a%b
print('5-c的值为:',c)
c = a**b
print('6-c的值为:',c)
c = a//b
print('7-c的值为:',c)
|
6ffc700111755db5a6487215d5e1dd9c479de6ce | fengshuai1/1805 | /08day/03-猜数字.py | 211 | 3.625 | 4 | import random
i = 0
a = random.randint(1,100)#电脑
while i < 11:
b = int(input("请输入数字"))
if b > a:
print("数大了")
elif b < a:
print("数小了")
else:
print("猜对了")
i = 10
i+=1
|
724d49c2506f7c681d16e243d1fab0b2cdcf4b3b | fengshuai1/1805 | /7day/5-法师肉盾.py | 156 | 3.671875 | 4 | a = input("输入位置:")
if a=="ADC"or"肉盾"or"法师"or"刺客":
print("后裔黄忠虞姬"or"亚瑟陈咬金"or"王昭君妲己"or"兰陵王阿珂")
|
cbf55340a3200482e241c2ddef0d27025457ba04 | fengshuai1/1805 | /6day/05-练习.py | 221 | 3.75 | 4 | name = input("请输入姓名:")
phone = input("请输入电话:")
email = input("请输入邮箱")
gender = input("请输入性别:")
#print("姓名%s\n"%name,"电话%s\n"%phone,"邮箱%s\n"%email,"性别:%s\n"%gender))
|
c7a00a4d80d06edade8943467ae5081301d962ae | fengshuai1/1805 | /7day/个人身高体重.py | 269 | 3.78125 | 4 | name = input("请输入姓名")
gender = input("请输入性别")
phone = input("请输入电话")
height = input("请输入身高")
weight = input("请输入体重")
#print("name%s\n"%name,"gender%s\n"%gender,"phone%s\n"%phone,"height%s\n"%height,"weight%s\n"%weight)
|
e2b5f3aa3c8e165093f31b1ab0b2063613d057f5 | fengshuai1/1805 | /13day/4-动物.py | 165 | 4.0625 | 4 | lista = ['cat','dog','pig']
for a in lista:
print(a)
for a in lista:
print("a",a," would make a great pet.")
print("Any of these animals would make a great pet.")
|
f9883d61fa2e83574403cd62ce976391d3b31e71 | dmunozc/spambase-classifier | /nbg_lr_classifier.py | 4,531 | 3.640625 | 4 | """Demonstration of a logistic regression and naive gaussian classifier.
It uses the spambase dataset.
"""
import numpy as np
import argparse
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
from sklearn.linear_model import LogisticRegre... |
1ebd53f3464864b852ad572eaadba38964ca0a8a | CodecoolBP20172/pbwp-3rd-si-game-statistics-frnczdvd | /printing.py | 728 | 3.8125 | 4 | # PRINTING FUNCTIONS
# FERENCZ DAVID
# 2017.07.08
# CODECOOL BUDAPEST
# PYTHON 3.6.1
import reports
def printing():
print("")
print("Judy's questions:")
print("1. How many games are in the file? ", reports.count_games("game_stat.txt"))
print("2. Is there a game from 1997? ... |
8a56c6ca5b29f238ed16e467a9b38c8e2089d0a3 | PratikMahobiya/PVT_data | /3RI_python/N_O_B-in_R_triangle.py | 301 | 3.984375 | 4 | def square(n):
count=0
while n>2:
count += (n-2)//2
n -= 2
return count
def square1(n):
s=(n-2)
s=s//2
c=(s*(s+1))//2
return c
if __name__=="__main__":
n=int(input("Enter a side of triangle: "))
print("Number of Possible Block is :- ",square1(n)) |
810a2327dc8f2c3a4ebf6b8102258ebdecfc46aa | PratikMahobiya/PVT_data | /3RI_python/no_stairs.py | 404 | 3.84375 | 4 | def step(n):
a=[]
if (n==1):
return a.append(1)
elif (n==2):
return a.append(2)
else:
return a.append(int(step(n-1) + step(n-2)))
if __name__=="__main__":
while True:
try:
stp=int(input("enter the no of steps"))
print(step(stp... |
debc4549e0c739264fc7c5c0e8b2cdb6e119f1e2 | PratikMahobiya/PVT_data | /3RI_python/test4.py | 284 | 3.734375 | 4 | x="Py54tH4#(&%;,;,oN"
count1=0
count2=0
count3=0
count4=0
for char in x:
if char.islower() or char.isupper():
count1= count1+1
elif char.isnumeric():
count2=count2+1
else:
count3=count3+1
print("lower: ",count1," digit: ",count2," symbol: ",count3) |
a60aea6bb805ccd15fc2a1dacd15544bab6a9b30 | PratikMahobiya/PVT_data | /3RI_python/p2.py | 176 | 4.0625 | 4 | x=int(input("Enter a number Btw 5 to 10-->\n"))
fact=1
if(x>=5 and x<=10):
for i in range(1,x+1):
fact=fact*i
print(fact)
else:
print(x,"not a valid input") |
adc2380b7eceba89b4ddd86788414d783b9a5179 | PratikMahobiya/PVT_data | /3RI_python/func_fact.py | 286 | 3.859375 | 4 | def fact(a):
if(a>1):
return (a*fact(a-1))
else:
return 1
if __name__=="__main__":
while True:
try:
a=int(input("enter a no"))
#print(fact(a))
break
except:
print("enter again") |
2d0e97298c048c97f711cf0aca1f23e303664424 | PratikMahobiya/PVT_data | /3RI_python/a1.py | 71 | 3.8125 | 4 | import re
s="This city is called Spain"
y=re.findall("is",s)
print(y) |
422e8e10f891ff5b656fc646d883e02566037e3d | fszatkowski/python-tricks | /1_typehints/3.py | 796 | 3.953125 | 4 | from typing import List, Optional, Union
# Type hints can be used for functions / methods
def naive_tokenize(string: str) -> List[str]:
return string.split(" ")
# We can also specify optional parameters with type hints
def p_norm(vector: List[Union[float, int]], p: Optional[int] = None):
if p is None:
... |
e6317da979aac279264377e479da36fcf7328987 | ptrk09/BMSTU-Analysis-Of-Algorithms | /lab01/main.py | 5,759 | 3.515625 | 4 | import string
import random
from time import time
OUTPUT_DEFINE = False
def outputTable(table, str1, str2):
print("\n ", end=" ")
for i in str2:
print(i, end=" ")
for i in range(len(table)):
if i:
print("\n" + str1[i - 1], end=" ")
else:
print("\n ", e... |
b03612dfc99d2dac4824a412bf0d17d19bfb1bee | tipech/spatialnet | /generators/common/random_functions.py | 8,939 | 4.15625 | 4 | """Random Number Generators
Implements the Randoms class, a static class that provides factory
methods that each return Callable (lambdas), preconfigured to generate
random values based on a particular distribution or random number
generation function.
The only missing parameters in the lambda functions are th... |
3e1a45ee7a4577d46b98874c7959743134d12af1 | Francodo/Module_3_Challenge | /PyPoll.py | 3,296 | 4.09375 | 4 |
#Here are the dependencies (in this case Comma Seperated Values(CSV) and Operating System(OS))
import csv
import os
#Assign a variable to load file from a path
file_to_load = os.path.join("Resources/election_results.csv")
#Assign a variable to save the file to a path
file_to_save = os.path.join("Anal... |
d94e45a36ef9ca14cc94a31ebae39fcb87d51a85 | IstifadatulKamilah/Tugas-Pemograman-Dekstop | /5.py | 529 | 3.859375 | 4 | username=("IstifadatulKamilah")
passwordku=("milamila01")
def masuk(user,password):
if user != username and password != passwordku:
stop = False
else:
stop = True
return stop
a= 3
for i in range (0,a):
userbaru = input("username = ")
passwordbaru = input ... |
a3d44afbb26fbc1e6c08adedcc91a7eda6aa41b2 | Sagar5885/HackerRankPython | /HackerRank/Implementation/EqualizeTheArray.py | 341 | 3.53125 | 4 | def equalizeArray(arr):
s = set(arr)
count = 0
for i in s:
tmp = arr.count(i)
if(tmp > count):
count = tmp
return arr.__len__() - count
if __name__ == "__main__":
n = int(input().strip())
arr = list(map(int, input().strip().split(' ')))
result = equalizeArray(ar... |
7ec3a95aba804442450c3b45cc023c6326787776 | Sagar5885/HackerRankPython | /HackerRank/WarmUp/DiagonalDifference.py | 413 | 3.75 | 4 | import sys
def diagonalDifference(a, n):
d1 = 0
d2 = 0
i = 0
while(i<n):
d1 += a[i][i]
d2 += a[i][n-i-1]
i += 1
return abs(d1-d2)
if __name__ == "__main__":
n = int(input().strip())
a = []
for a_i in range(n):
a_t = [int(a_temp) for a_temp in input().str... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.