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 |
|---|---|---|---|---|---|---|
b0ba09559d2c9526be915dd7baaf95d209796818 | Song-EunJu/likelion9th_django | /firstproject/WordCount/test.py | 218 | 3.53125 | 4 | sentence = "안녕 나는 은주 안녕"
wordList=sentence.split()
wordDict={}
for word in wordList:
if word in wordDict:
wordDict[word]+=1
else:
wordDict[word]=1
print(wordDict) |
59e86b19ae548eb8e2ebe0a40063c1d12122369b | lebrice/SimpleParsing | /examples/simple/inheritance.py | 2,278 | 3.578125 | 4 | from dataclasses import dataclass
from simple_parsing import ArgumentParser
@dataclass
class Method:
"""Set of options for the training of a Model."""
num_layers: int = 4
num_units: int = 64
optimizer: str = "ADAM"
learning_rate: float = 0.001
@dataclass
class MAML(Method):
"""Overwrites s... |
e44eba2c3eb05191817bfe28210167d4d08fc6c1 | LauraJaneStevenson/tree-practice | /invert_binary_tree.py | 421 | 3.859375 | 4 | from same_tree import TreeNode
from level_order import tree_one, print_tree_levels
def invert_tree(tree):
def switch_children(node):
temp = node.left
node.left = node.right
node.right = temp
if node.left:
switch_children(node.left)
if node.right:
switch_children(node.right)
switch_children(tree... |
f457df11bfd65137ebdd2bd72e36f2d524f1ecae | pysudoku/sudoku | /src/sudoku/algorithm/backtrackingAlgorithm.py | 5,438 | 4.15625 | 4 |
from sudoku.algorithm.position import Position
from sudoku.algorithm.exceptions import InvalidSudokuException
class BacktrackingAlgorithm:
"""
BacktrakingAlgorithm is a class that solve a given sudoku
"""
MAXLINEAS = 0
MAXCOLS = 0
def solve(self, sudoku):
"""list_to_dic is a fun... |
3da3262b87a748f6398a564fb714b4b5c7909ed6 | pysudoku/sudoku | /src/sudoku/game/PrintCommand.py | 2,652 | 3.5 | 4 | '''
Created on Jul 18, 2013
@author: Ines Baina
'''
from sudoku.game.SudokuCommand import SudokuCommand
from sudoku.game.exceptions.InvalidCmdParameterException import InvalidCmdParametersException
class PrintBoardCommand(SudokuCommand):
'''
PrintBoardCommand class prints the sudoku game in console
'''
... |
afcd633308eda42d2a5fb0eac9d483a42450b953 | dmitrime/algorithmic-puzzles | /leetcode/048-rotate-image.py | 221 | 3.546875 | 4 | class Solution:
def rotate(self, m: List[List[int]]) -> None:
N = len(m)
m.reverse()
for i in range(N):
for j in range(i+1, N):
m[i][j], m[j][i] = m[j][i], m[i][j]
|
15d4566def278d900b076998b5d1583cb0b6a5f3 | dmitrime/algorithmic-puzzles | /leetcode/002-add-two-numbers.py | 664 | 3.609375 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def extract_number(self, l):
n, mul = 0, 1
while l != None:
n += mul * l.val
mul *= 10
l = l.next
return... |
fa2d4e98c13b61f4eb23cf42ecd09ebb45031a11 | dmitrime/algorithmic-puzzles | /icpc/2011-finals/queue-solutionF.py | 4,313 | 3.984375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import Queue
from collections import namedtuple
class Restructure(object):
'''
Breadth first search solution.
Add all reachable states to the queue until an ending state is found.
'''
def __init__(self, N, D, machines):
self.D = D
self.N... |
e3b3fb76aa41081a178e8cccf8b60fc2146e1c6a | dmitrime/algorithmic-puzzles | /leetcode/133-clone-graph.py | 807 | 3.5625 | 4 | """
# Definition for a Node.
class Node:
def __init__(self, val = 0, neighbors = None):
self.val = val
self.neighbors = neighbors if neighbors is not None else []
"""
class Solution:
def helper(self, node, clone, seen, m):
if not node:
return
if node.val in seen:
... |
415e47a43daeedb8f744e9de4ea6ce8fa49ebbfb | PavelMPD/word-book | /word_book/utils/txt_parser.py | 1,026 | 3.5 | 4 | # -*- coding: utf-8 -*-
import re
class TxtParser(object):
WORD = 'word'
EXPLANATION = 'explanation'
EXAMPLE = 'example'
UNKNOWN = 'unknown'
def __init__(self, filename):
self.filename = filename
def parse(self):
with open(file=self.filename, mode='rt', encoding='utf-8-sig') ... |
43aad2dcef9fd9d9cd959e5924296a6d4641e7d4 | miroslavio/Python_Euler | /problem_40.py | 544 | 3.71875 | 4 | dig_count = 0
counter = 1
answer = 1
for i in range(1, 1000000):
temp = i
digits = [] # store digits of number here
while temp:
digits.append(temp % 10)
temp //= 10
j = len(digits) - 1
while j >= 0:
dig_count += 1 #count every single digit
if dig_count == ... |
35343ba5cec49941545b53334a67ef387553f77d | miroslavio/Python_Euler | /problem_51.py | 829 | 3.71875 | 4 | import sieve
primes = sieve.sieve(10000000) # try up to this limit
##def repeat_dig(n):
## digits = [0]*10
## while n:
## digit = n%10
## if digits[digit] == 1: # repeat digit found
## return True
## else:
## digits[n%10] = 1
## n //= 10
##
## ... |
cbef1539b0cf852735fc025143a200ef64c2d461 | miroslavio/Python_Euler | /problem_21.py | 724 | 3.890625 | 4 | import math
def sum_divisors(number):
limit = int(math.sqrt(number)) + 1
if number < 2:
return 0 # 1 has no divisors
divisor_sum = 1 # 1 is counted always
for n in range(2, limit):
if number % n == 0: # Found a divisor
divisor_sum += n
divisor_sum += nu... |
c442cd46170cee8b101dec462cb030208f839fee | miroslavio/Python_Euler | /problem_2.py | 489 | 3.890625 | 4 | def fibonacci(n): #Recursion is very slow, do not use this
if n<2:
return n
else:
return (fibonacci(n-1)+fibonacci(n-2))
# Starting numbers and limit
limit = 4e6 #4 million
num_1 = 1
num_2 = 2
total_sum = 0 # Final answer
while num_2 < limit:
if num_2%2 == 0: # Check if even
... |
1e71ee00f79f7fd22172a7fc9d19051b56ae9adb | miroslavio/Python_Euler | /problem_5.py | 1,274 | 3.796875 | 4 | # Find the first natural number that is divisible by all numbers from 1 to 20
# The number must clearly be even, so SKIP ALL ODD NUMBERS.
# The number must be a multiple of 10, so check for N % 10 == 0
# Start with brute force
def brute_force():
number = 20
div = 2
while div < 21:
if num... |
90686eaaf233bc0794b40e56d7aaf222fb2784cf | Ayushchaudhary-Github/Python_Practice | /Crash Course Python/week-2/Conditionals/Comparing_thing.py | 336 | 4.09375 | 4 | """
Figure out what's the relationship between the strings
"cat" and "Cat" by replacing the plus sign with comparison operators.
"""
"""
print("cat" + "Cat")
"""
"""
"cat" equals "Cat"
"cat" is smaller than "Cat"
"cat" is larger than "Cat"
"""
#Answer
#ok done
# code
# print("cat" == "Cat")
# false
# "cat" is la... |
4cf2b8d297769536725bdcea32b72b62e4174067 | Ayushchaudhary-Github/Python_Practice | /Basic code/find-lucky-number.py | 337 | 3.890625 | 4 | """
#Simple way
name = "Ayush"
number = len(name)*9
#Ptinting Your name and lucky number
print("Hello "+name+"Your lucky number is "+str(number))
"""
#Using a function
def lucky_number(name):
number = len(name)*9
print("Hello "+ name +". Your Lucky number is: "+ str(number))
lucky_number("Ayush")
luc... |
9c9607fcd06a419f46020b92da539a13fd4e34d6 | EthanBukenya/mypythonprograms | /app.py | 394 | 4.03125 | 4 | an_letters = "aehislofmnrxAEHISLOFMNRX"
word = input("enter a word...ill cheer for you : ")
times = int(input("whats your enthusiasm level between 1 - 10 : "))
for char in word:
if char in an_letters:
print("give me an " + char + " ! " + char + " !")
else:
print("give me a " + char + " ! " + ... |
19430f622eb0b6fefcc286d6d926e0a0f21705af | c4llmeco4ch/guessingGame | /main.py | 636 | 3.828125 | 4 | low = 0
high = 100
guess = 50
correct = False
while not correct and high >= low:
print("My guess is "+ str(guess))
validAns = False
while not validAns:
ans = input("Too high (h), too low (l) or correct (c)?: ")
if(ans == "c"):
print("Yay :D")
exit()
elif(ans == "h"):
high = guess - ... |
9bcda88e4f98b4e8034c7be9290c84e9f16c2cd3 | IvanBrasilico/bhadrasana | /bhadrasana/utils/csv_handlers.py | 6,686 | 3.953125 | 4 | """Classes para reunir tarefas repetitivas com arquivos csv e planilhas.
Padrão do arquivo csv usado é o mais simples possível:
- Nomes de campo na primeira linha;
- Valores nas restantes;
- Único separador é sempre a vírgula;
- Fim de linha significa nova linha;
- Para comparações, retira espaços antes e depois do co... |
00005edc918032bb5a4dfc3cd97452ab8a9a9924 | zeya2u9/Applied-Cryptography | /Assignment-3/que2.py | 5,954 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Dec 9 18:44:22 2020
@author: zeyau
Write programs to implement the following for 64-bit numbers.
a. Euclidean algorithm
b. Extended euclidean algorithm
c. Multiplicative inverse algorithm
d. Square and Multiply algorithm
"""
import math
import time
import numpy as np
"""mo... |
e27511cf6a76b105720b3b4f1e3ff0bad2558bd4 | ArpanMahatra1999/Matplotlib | /simpleGraph.py | 160 | 3.5625 | 4 | import matplotlib.pyplot as plt
# plt.plot([1,2,3,4,5,100])
# plt.show()
xValues = [1,2,3,4,5,100]
plt.plot(xValues,[i**2 for i in xValues])
plt.show() |
4688fc499cf2f6c22319a8b8fb04beb714886829 | ivanlein1998/boring-gmae-created | /HeadOrToss/HeadOrToss.py | 754 | 4 | 4 | import random
def HeadOrToss():
randomInt = random.randint(1,2)
if randomInt == 1:
print ("The coin is Heads Up")
elif randomInt==2:
print ("The coin is Tosses Up")
def throwAgain():
again = input("Try Again? (Y/N) \n")
if again == 'Y' or again =='y':
HeadOrToss()
thr... |
ae01d892b8fb2d41210dbed1455afed0f206cfab | BabyNaNaWang/41daysToLearnPython3 | /零基础学习python3.day13.模块.py | 3,250 | 3.65625 | 4 | import math
import random
import statistics
import keyword
import hello
import module1
import cubed
# date:2019-4-23
# author:Ivo Wang
# describition:模块
# editor for code: vs code
# 模块的定义
# 大型程序分割多个包含Python代码的文件,也称为模块
# Python自带、包含许多重要功能的模块称为内置模块。
# 导入内置模块
# 可使用语法import[模块名]导入模块,将[模块名]替换为希望导入模块的名字。
# 导入模块之后可使用模块中的方法和... |
5d6afb6166a9ca9b5dd697099b9b571c243674db | BabyNaNaWang/41daysToLearnPython3 | /零基础学习python3.day7.容器集合.py | 2,305 | 3.71875 | 4 | # date:2019-4-17
# author:Ivo Wang
# describition:容器集合、三引号字符串、索引、字符串是不可变的、字符串拼接
# editor for code: vs code
# 容器集合
# 定义:集合(set)是一个无序的不重复元素序列。
# 集合中的元素必须是不可变类型的
# 创建集合的方法有两种:
# 第一种:通过set(value)创建空集合
my_set = set('hello')
print(my_set)
# 第二种:通过{value,value1}方式创建
my_set = {1,2,3,3}
print(my_set)
# 定义不可变集合: [变量名] = fr... |
5f9a200a07fd58f99c4376ea3fc4bd0cde9f90d6 | Chirurgus/sudoku | /sudoku/solve.py | 1,106 | 3.921875 | 4 | # Created by Oleksandr Sorochynskyi, and Sebastien Meyer
# On 08/01/2020
from copy import deepcopy
def solve_sudoku(sudoku):
'''
Solve a sudoku
:param sudoku: A :class:`SudokuGrid` to be solved
:returns: A :class:`SudokuGrid` object with solved sudoku.
'''
s = deepcopy(sudoku)
return _sol... |
ccd8fcac0f1013475dc05a166f83447a414b8d76 | KimJinYounga/Algorithm_python-2020- | /python/Baekjoon/정렬/국영수.py | 524 | 3.578125 | 4 | N = int(input())
arr = []
for i in range(N):
person = input().split()
arr.append([person[0], int(person[1]),int(person[2]),int(person[3])])
# arr = sorted(arr, key = lambda x:x[0])
# arr = sorted(arr, key = lambda x:x[3], reverse = True)
# arr = sorted(arr, key = lambda x:x[2])
# arr = sorted(arr, key = lambda... |
51d2ef7f05de289fe26271a4ad5b870a1aaa16bd | AdeAlonso/Analisis-numerico | /1.py | 96 | 3.5 | 4 | #Suma 2 numeros
a=input('Valor de a? ')
b=input('Valor de b? ')
c=a+b
print'La suma es '+str(c)
|
7dfb7dc6d2e8956c436ed86a6396302c196cc37f | AdeAlonso/Analisis-numerico | /Ejer10.py | 635 | 3.5625 | 4 | #Programa para hacer eliminacion hacia adelante.
#Funcion para imprimir matriz
def imprimeMatriz(A):
for fila in A:
for elemento in fila:
print elemento,'\t',
print
A=input('A? ')
n=len(A)
#i=0
S=input('B? ')
for i in range(n):
l=i+1
q=i
for j in range(l,n,1):
p=float(... |
8a2ce2882e473e20dfbf7814fada4cf9fe861ee1 | feikiss/mysite | /study/__init__.py | 1,893 | 3.515625 | 4 | # #!/usr/bin/env python
# # -*- coding: utf-8 -*-
# print '''line1
# ...line2
# ...line3'''
# print None
# a = 1
# print a
# a = '1234'
# print a
#
# classmates = ('Michael', 'Bob', 'Tracy')
# print classmates[1]
#
# age = 3
# if age >= 18:
# print 'your age is', age
# print 'adult'
# else:
# print 'your... |
890c9821ce2679652696f2d4a1efca0898268e4d | f1urps/mao | /server/mao/card.py | 2,977 | 3.59375 | 4 |
from enum import Enum
import random
class CardType (Enum):
VALUE_ACE = "ace"
VALUE_TWO = "two"
VALUE_THREE = "three"
VALUE_FOUR = "four"
VALUE_FIVE = "five"
VALUE_SIX = "six"
VALUE_SEVEN = "seven"
VALUE_EIGHT = "eight"
VALUE_NINE = "nine"
VALUE_TEN = "ten"
VALUE_JACK = "jac... |
ef38753011c83bd8ef48bdc29acfdbaa6bcc4c49 | admtlab/PittGrubServer | /pittgrub/storage/image.py | 4,386 | 3.625 | 4 | """
Store and retrieve images in/from filesystem
"""
import os
from typing import List, Optional
from PIL import Image
class ImageStore:
# number of subdirectory levels
LEVELS = 3
# upper bound for image id (must be less than this)
BOUND = 1_000_000_000_000 # 1 trillion
# padding for image n... |
3896a97bc0ed331a34c54fcf6a449ef47c6d3003 | Rinoahu/spa | /quicksort.py | 4,142 | 4.21875 | 4 | #!/usr/bin/python
# Author: Arturs Polis
#
import math
import sys
import itertools
def SelectPivot(R):
"""
Cacluclate a pivot given list of strings R
Pick the last, the first, and the middle element, and choose their median as a pivot
Source: http://www.cs.utexas.edu/~lavender/courses/EE360C/lectures/... |
f2890dda63ae8adf7a6e52cc793fbc5a4e07265c | desmetr/MoSIS | /1checkingRequirements/use case3/scannerUseCase3.py | 6,115 | 3.6875 | 4 | import string
False = 0
True = 1
# trace FSA dynamics (True | False)
__trace__ = False
# __trace__ = True
class Scanner:
"""
A simple Finite State Automaton simulator.
Used for scanning an input stream.
"""
def __init__(self, stream):
self.set_stream(stream)
self.current_state=None
self.accepting_stat... |
96e10713cc6a96760cac49a28101112337e3784e | fwkraft/SmartChess | /Software/GPIO_Hello_World/gpio_hello_world.py | 1,295 | 4 | 4 | # gpio_hello_world.py
# Written by William Kraft on 7/5/2021
#
# Basic program to demonstrate RPi GPIO interfaces with LED and Hall Effect Switch circuits
# LED is wired to GPIO2 pin on RPi
# Hall Effect Switch Module is wired to GPIO14 on RPi
# Software will toggle LED state on rising & falling edges of Hall Effect i... |
2f4f57900731a403228080d2d6227480b97d1365 | Abhinanda123/Car-Price-Prediction | /plots.py | 1,433 | 3.578125 | 4 | # Import necessary modules
import streamlit as st
import matplotlib.pyplot as plt
import seaborn as sns
import random
# Define a function 'app()' which accepts 'car_df' as an input.
def app(df):
st.set_option('deprecation.showPyplotGlobalUse', False)
st.header("Data Visualisation")
col_list= st.multisel... |
74edcc96c29e71bbdc2f3efe5e6586e7ca4e8e61 | roshande/codingWebsites | /Codechef/AUG19B/CHEFDIL/chefdil.py | 1,272 | 3.59375 | 4 | possibilities = {
"1":True,
"0":False,
"10":True,
"01":True,
"11":False,
"00":False,
"000":False,
"001":True,
"010":True,
"011":False,
"100":True,
"110":True,
"101":False,
"111":True
}
def is_possible(S):
print(S)
if S.count("1") == 1:
return True
... |
4d98730f556522a419f48a66edf0f124ccb00f34 | roshande/codingWebsites | /Codechef/BFTT/bftt.py | 623 | 3.546875 | 4 | def three3(num,cnt):
if num < 333:
return 333
if cnt > 3:
return num+1
if num == 333:
return 1333
if cnt < 4:
ten = 1
temp_num = num
while temp_num > 0:
digit = int(num/ten)%10
if digit != 3:
if cnt >= 3:
num += ten*(digit+1)
break
num = num + (3-digit)*(ten)
cnt +=1
if d... |
b6e851575bc4b9173bc42c7861022fd9226684e0 | roshande/codingWebsites | /Codechef/PINS/pins.py | 135 | 3.5 | 4 | for _ in range(int(input())):
n = int(input())
if n == 1:
print(1,1)
else:
denom = '1' + ''.join('0'*int(n/2))
print(1,denom)
|
7863df93b0077b2aa0772bbbb24c39cc3d6cbc16 | roshande/codingWebsites | /Codechef/FCTRL/fctrl.py | 138 | 3.515625 | 4 | for _ in range(int(input())):
n = int(input())
ans = 0
x = (n//5)
p = 1
while x > 0:
ans += x
p+=1
x = (n//(5**p))
print(ans)
|
b781e7f1b99406ceedbe88b4f018dd74a5de0aa8 | roshande/codingWebsites | /Codechef/ATTND/attnd.py | 506 | 3.734375 | 4 | for _ in range(int(input())):
n = int(input())
names = []
name_map = {}
for _ in range(n):
firstname,lastname = input().split()
if firstname in name_map.keys():
name_map[firstname].append(lastname)
else:
name_map[firstname] = [lastname]
names.appen... |
a6b8cc36d9b9815c64052c1ed6df687a51e4b08e | Vvollono/First_step_pandas | /first_step.py | 775 | 4.03125 | 4 | import pandas
data = pandas.read_csv("weather_data.csv")
print(data["temp"])
data_dict = data.to_dict()
print(data_dict)
temp_list = data["temp"].to_list()
avg = round(sum(temp_list) / len(temp_list), 2)
print(avg)
print(data["temp"].mean())
print(data["temp"].max())
#Get data in Columns
print(data["condition"... |
0d24c54ddad66895ed31c0f3da5639350d25fe92 | jhammelman/HSSP_Python | /lesson2/text_adventure_game.py | 1,283 | 4.15625 | 4 | #!/usr/bin/env python
print("You are standing in front of a black iron gate with rusty hinges and a large gold lock. Behind the gate stands an ominous castle, shrouded with clouds and with large gargoyles that cast creepy shadows onto the ground.")
go_in = raw_input("Do you try to open the gate? (y or n) ")
if go_in =... |
ded78f52bcbfc43f1fc896cae54fd5c2111f6a28 | iveirasuoc/BlaBlaCrawler | /src/main.py | 2,716 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Función principal del código. Puede ser ejecutada dando los parámetros en la llamada
o, en su defecto, se peidrán por pantalla.
"""
# Importamos los módulos que necesitamos
import blablaCrawler
import sys
# Definimos una función que devuelva los argumentos de la sentencia
def ma... |
a627ef45f60b4825b3a8fa241524d8385ab3ec20 | JonathanKarr33/Learn_to_Code | /Learn Python/Prepare for Microsoft Python Exam/def.py | 229 | 3.6875 | 4 | from random import random
def age():
try:
n= int(input("How old are you: "))
return "You are " +str(n) +" years old."
except:
print ("Not a valid input")
age()
age()
a = age()
print (a) |
305844671b0e90f794ce5358f74d7c43838e1be9 | JonathanKarr33/Learn_to_Code | /Learn Python/Prepare for Microsoft Python Exam/student_class.py | 941 | 3.703125 | 4 | class student:
def __init__(self,name,gpa,is_on_probation):
self.name = name
self.gpa = gpa
self.is_on_probation = is_on_probation
def status (self):
if self.is_on_probation == False:
if self.gpa >= 4.350:
return (self.name + " is a Validictorian and h... |
1e39810f45bc080a974624daba80e657a78080bd | JonathanKarr33/Learn_to_Code | /Learn Python/Prepare for Microsoft Python Exam/test2.py | 233 | 3.625 | 4 | list1 = [1,2]
list2 = [3,4]
list3 = list1 + list2
list4 = list3 * 3
print(list4)
alpa ="abcdefgjijklmnopqrstuvwxyz"
print(alpa[3:15:3])
print(alpa[3:15:-3])
print(alpa[15:3:3])
print(alpa[15:3:-3])
print(alpa[15:3])
print(alpa[::-3]) |
83287669e3ae6df5f3325ab6d5a60039f32d3940 | abhishekshree/gsoc-scraper | /scraper.py | 1,279 | 3.5 | 4 | import csv
import requests
out = "gsoc2021.csv"
url = "https://summerofcode.withgoogle.com/api/program/current/project/?page=1&page_size=20"
fields = ['Name', 'Organization', 'Project']
page = requests.get(url)
total_pages = int((page.json())['count'] / 20) + 1
print("Starting to write in the " + out + " file...")
... |
1b5bc2c9a37aa5693d727a57d246ae1bbb7e1066 | Imfatdong/pylearn | /base/26-进程通信_4.py | 1,390 | 3.671875 | 4 | import random
import threading, time, queue
"""
生产者消费者模型,利用condition完成
"""
def producer(q: queue.Queue, condition: threading.Condition, name: str):
while True:
value = chr(random.randint(65, 90))
with condition:
if not q.full():
print("%s生产了 %s" % (name, value))
... |
ee6180a0b8cb4843bc00d95cdf11116d83f18416 | isaacbyr/MailConverter | /mailConverter.py | 6,249 | 3.84375 | 4 | from tkinter import *
from tkinter import messagebox
import smtplib
from email.message import EmailMessage
from tkinter import filedialog
def main ():
# read from the text file
f_content = read_text_file()
if (f_content != False):
if "gmail" in EMAIL_ADDRESS:
send_gmail(f_content)
... |
a0b9298f53a17f612aabfaab15c89b1f72ee58d8 | jupiterorbita/python_stack | /python_OOP/bike.py | 1,939 | 4.75 | 5 | #http://learn.codingdojo.com/m/72/5471/35330
#Assignment: Bike
# Create a new class called Bike with the following properties/attributes:
# price
# max_speed
# miles
# Create 3 instances of the Bike class.
# Use the __init__() method to specify the price and max_speed of each instance (e.g. bike1 = Bike(200, "25mph")... |
ce7d0ffa978ce9565290d9b901958bad5b5b3e8c | jupiterorbita/python_stack | /python_fundamentals/functions_interm_II_dict.py | 890 | 4.125 | 4 | # Assignment: Functions Intermediate II
# Write the following function.
# Part I (essential)
# Given the following list:
# students = [
# {'first_name': 'Michael', 'last_name' : 'Jordan'},
# {'first_name' : 'John', 'last_name' : 'Rosales'},
# {'first_name' : 'Mark', 'last_name' : 'Guillen'},
# {'... |
203e18a69055f9798eca75904bb159e09ece28e3 | tecx/learn-python | /codecademy.py | 2,176 | 3.515625 | 4 | #=========================================
# Example for filter() and lambda
garbled = "IXXX aXXmX aXXXnXoXXXXXtXhXeXXXXrX sXXXXeXcXXXrXeXt mXXeXsXXXsXaXXXXXXgXeX!XX"
message = filter(lambda k: k != "X", garbled)
print message
#=========================================
# BITwise
print 5 >> 4 # Right Shift
print 5 <<... |
3b4be1d8c0d7d9b1967adfee2455950b24922aee | jnathnjshua/CS-115 | /CS 115/life_starter/life.py | 3,459 | 3.921875 | 4 | #
# life.py - Game of Life lab
#
# Name:Jonathan Joshua
# Pledge:I pledge my honor that I have abided by the Stevens Honor System.
#
import random, sys
def createOneRow(w):
"""Returns one row of zeros of width "width"...
You should use this in your
createBoard(w, h) function."""
row = []
f... |
3272aae7bbc10f35e86b5665327efc0e711ee202 | 786kittu/project | /functions.py | 212 | 3.703125 | 4 | #This is my
#git
def printany():
print "_"*20
def calculate(num,x):
print num*x
printany()
num = input("Enter number :->")
for x in range(1,11):
calculate(num,x)
|
0cc030ba86bdf7454c3cc5a4cfa1ae3c8281bbe1 | 786kittu/project | /list.py | 175 | 3.875 | 4 | abc = [1,3,5,6,2,8,33,21]
abc.append(56)
print abc
abc.pop(7)
print abc
abc.insert(6,12)
print abc
abc.sort()
print abc
abc.reverse()
print abc
l=[abc]
for v in l:
print v |
2d88a7f0a2577aa264625816d2bc9c4c2c39fd19 | kuzaleks/pythonizer | /assignments/compr.py | 717 | 3.90625 | 4 | # Copyright 2016 Aliaksei Kuzmin
def list2dict(L):
"""
input: a list L of elements
output: a dict with keys {0...len(L)-1} and
entries L[i]
example: given L = [10, 20, 30] return dict:
{0: 10, 1: 20, 2: 30}
"""
pass
def mfilter(L, num):
"""
input: list of numbers and a num... |
44dfd1b21628a24793123f644494bd61a6b0f094 | morco6/The-patient-needs-mental-therapy | /PreprocessingData/FixOthers.py | 777 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Last finish's:
1)Change under zero values to positive numbers in 'Age' column
2)Fix numbers that are not between 18-120 (by filling them via median)
"""
class FixOthers:
def __init__(self, dataset):
self.ds = dataset
def fixAge(self):
#negat... |
9d9b20ca02d734d95f4e57ad8eb3eeb5bc8626dc | emilymendelson/Music-Recommendation-Software | /recommendations.py | 5,719 | 3.765625 | 4 | """The recommendations module creates a randomized dictionary of subscribers and music ratings. It recommends
a music genre for a user, calculates how similar two users are, and matches users based on similarity."""
from random import *
from math import *
# initialize subscribers list and music_genre list
subscribe... |
946c4625933fee435381daf222943580d9ceee49 | PavithraRamasamyR/python | /read.py | 586 | 3.828125 | 4 | fo= open("foo.txt","r+")
str= fo.read(10);
print ("Read string is:", str)
position= fo.tell();
print ("Current file position:", position)
position= fo.seek(3,0);
str=fo.read(10)
print ("Again read string is:", str)
fo.close()
existing file test1.txt
os.remove("test1.txt","test2.txt")
delete file test2.tx... |
b2797d972d08c4422d72754c8cefacc3d67a43e4 | PavithraRamasamyR/python | /circle1.py | 57 | 3.875 | 4 | r=5
PI=3.14
A=PI*r*r
print("Area of circle A is:",A)
|
f9728310d7b471e7358ca57c0ea8ccb8a0cc828b | PavithraRamasamyR/python | /sample1.py | 251 | 4 | 4 | a=int( input("Enter A value"))
b= int(input ("Enter B value"))
c=a+b
d=a-b
e=a*b
f=a/b
print("The addition of two values",c)
print("The addition of two values",d)
print("The addition of two values",e)
print("The addition of two values",f) |
e5eeddc062d99c57bc9396e49dd4703fc83e9ca8 | Dalsallum/Predicting-Students-Scores | /Linear_Reg.py | 3,954 | 3.90625 | 4 | import pandas as pd
import numpy as np
from sklearn import linear_model
import sklearn
import os
import matplotlib.pyplot as plt
import seaborn as sns
# location to store the files
os.chdir(r'C:\Users\komsi\Desktop\Projects\ML_projects\Students')
# the data
student_data = pd.read_csv(r'C:\Users\komsi\Desk... |
a4861a62adeded7549d0fbecafab04e4af23af7f | edson-gonzales/sudoku2015-C | /src/algorithms/algorithm.py | 1,278 | 3.859375 | 4 | """
This module is the Algorithm base class created just for generalize the solution process, and
have generic methods that will be implemented by the classes who inherited this base class.
"""
import time
class Algorithm(object):
def solve_sudoku(self, grid_basic_format):
""" Generic method that needs to... |
a9b3e731fdf981412f034e0b7eabaa4a1d3ba972 | pibedas77/pibedas77.github.io | /Week_01.py | 589 | 4.0625 | 4 | # guessing game
from random import randint
from IPython.display import clear_output
guessed = False
number = randint(0, 100)
guesses = 0
while not guessed:
ans = input("Try to guess the number I am thinking of! ")
guesses += 1
clear_output()
if int(ans) == number:
print("Congrats! You guess... |
3eedf6ad8b367b7e29808b317b45efcdad7d278a | rakhatyeskenov/Web-development-2021-spring | /labs-main/lab7/Task1/informatics-tasks/13a.py | 296 | 3.609375 | 4 | from math import ceil, sqrt
def perfectSquares(l, r) :
number = ceil(sqrt(l));
n2 = number * number;
number = (number * 2) + 1;
while ((n2 >= l and n2 <= r)) :
print(n2, end= " ");
n2 = n2 + number;
number += 2;
a = int(input())
b = int(input())
perfectSquares(a, b);
|
8e328257eaff5722eaad8254c8364941040ba872 | rakhatyeskenov/Web-development-2021-spring | /labs-main/lab7/Task1/informatics-tasks/13.py | 184 | 3.703125 | 4 | # def listSquares(a, b):
# for i in range(a, b + 1):
# if (i**(.5) == int(i**(.5))):
# print(i, end=" ")
#
# a = int(input())
# b = int(input())
# listSquares(a, b)
#
|
ac3b57b01d336dce1aed385b1b99e8ae1e49d6f2 | MaxBlye/hello-willy | /willy.py | 122 | 3.71875 | 4 | def read_name():
name = input("Cmo te llamas, Ratman?")
return name
def greetins(name)
print("Hello, %s"!, % name) |
0bd62803aa07f61ca02ef14fa0762d92c5c8c877 | svallelian/Project-Euler | /problem-011.py | 1,766 | 3.65625 | 4 |
"""
Created on Aug 7 2016
Project Euler Problem 011
Find the greatest product of four adjacent numbers in the same direction
(up, down, left, right, or diagonally) in the 20×20 grid
@author: sarahv
"""
import numpy as np
" Extract the grid as an array "
array = np.loadtxt('Problem011.txt');
def maxUDLRProduct(arr... |
a62e2b8fffa56f2a3f4362ff0e667f04c0a66620 | dylanmccoy/foobar | /foobar1.py | 3,972 | 3.578125 | 4 | def re_id(n):
max_sieve = 3 * (n + 5)
sieve = [True] * max_sieve
primes = []
len_so_far = 0
overshoot = 0
for next_p in range(2, max_sieve):
if len_so_far >= n + 5:
break
if sieve[next_p]:
len_so_far += len(str(next_p))
if len_so_far > n:
... |
946b5ca553b7d87a0201dc75bebb504131988285 | robertcalvertphd/core_irt | /core/h_ui.py | 1,335 | 3.875 | 4 | def get_int(prompt, max, min = 1):
while 1:
try:
ret = int(input(prompt))
if max >= ret >= min:
return ret
else:
print("response not in valid range. Min = ", min, ". Max = ", max, ".")
except ValueError:
print("invalid r... |
820e41dd3226a3e412a3139ee0e25f7f6e327340 | Yawar86/Piaic | /piaic.py | 6,569 | 4.25 | 4 |
#capitalized string
string = "python is awesome."
capitalized_string = string.capitalize()
print('old string: ', string)
print('capitalized sting:',capitalized_string)
print()
#centered string
new_string = string.center(24)
print("centered string: ", new_string)
print()
#lower case string using case... |
87ef4a8940f199a7d17bc0ec9d3526d775e9fc01 | rulma/Network_Visualization | /Network Matrix Example.py | 1,904 | 4.03125 | 4 | #Create cvs reader to collect data on the number of unique stores, their country of operation, and the number of relationships they have
#initialize needed libraries
import csv
import os
from operator import itemgetter
import networkx as nx
import pandas as pd
import matplotlib.pyplot as plt
from networkx.algorithms i... |
acf677f271db815dae221c02708302e459236cec | MatthewChipmunk/Hackathon | /My Game.py | 7,615 | 3.765625 | 4 | from tkinter import *
from tkinter import messagebox
from tkinter.font import Font
import sys
import random
# Variables
morale, money, employment, materials = 50, 50, 50, 50
days = 1
# Robot names & Scenarios
bots = ['Jeremy', 'Bill', 'Ashley', 'Jill', 'William', 'Amy']
Scenarios = ['Can I hack the computer system?',... |
cb4b979768eb10efe5ae2f566f8e7d0f319cdd1f | MatthewChipmunk/Hackathon | /Future.py | 4,347 | 3.828125 | 4 | from tkinter import *
from tkinter import messagebox
from tkinter.font import Font
import sys
import random
run = True
morale = 50
money = 50
employment = 50
resources = 50
root = Tk()
root.title('Crazy Future Business')
root.geometry('500x500')
root.configure(bg='black')
robots = ['Jeremy', 'Anna', 'Bob', 'Sophia', '... |
12e49b02b5df6fcd1b8809796dbf1b6c48a741ae | wikankun/distributed-paralel-system | /1_IPC/02.tugas_udp_client.py | 627 | 3.59375 | 4 | # import library socket karena akan menggunakan IPC socket
import socket as sc
# definisikan target IP server yang akan dituju
UDP_HOST = "192.168.1.15"
# definisikan target port number server yang akan dituju
UDP_PORT = 4044
# print ("target IP:", UDP_IP)
print("target IP:", UDP_HOST)
# print ("target port:", UDP_P... |
ef098c0cb2a594e9f1d032a51146f0c356ce0ec0 | lcapkovic/nand2tetris | /Week6/SymbolTable.py | 686 | 3.96875 | 4 | """Keeps a correspondence between symbolic labels and numeric addresses."""
symbolTable = {
"R0":0,
"R1":1,
"R2":2,
"R3":3,
"R4":4,
"R5":5,
"R6":6,
"R7":7,
"R8":8,
"R9":9,
"R10":10,
"R11":11,
"R12":12,
"R13":13,
"R14":14,
"R15":15,
"SCREEN":16384,
"KBD":24576,
"SP":0,
"LCL":1,
"ARG":2,
"THIS":3,
... |
30d818c11dfef7e44983c74a62e3cd353e2040fa | dataAlgorithms/dataStructure | /tree/binarySearchTree.py | 10,885 | 4.0625 | 4 | #! coding=utf-8
import copy
import unittest
class BST(object):
"""Tree node: left and right child + data which can be any object
"""
def __init__(self, data):
"""Node constructor
@param data node data object
"""
self.left = None
self.right = None
self.data... |
de9dca13a3f880c9989e57df966fe8c4d7e2a14b | dataAlgorithms/dataStructure | /stack/balancedParentheses.py | 745 | 3.890625 | 4 | def validateExpression(expression):
stack = []
pushChars, popChars = "<({[", ">)}]"
for c in expression:
if c in pushChars:
stack.append(c)
elif c in popChars:
if not len(stack):
return False
else:
stackTop = stack.pop()
... |
46bd20d948c2d1e463e84f2f5403d2507831bd43 | dataAlgorithms/dataStructure | /linkedList/josephusCircleLinkedList.py | 8,855 | 3.59375 | 4 | '''
Question:
There are n people standing in a circle waiting to be executed. The counting out begins at some point in the circle and
proceeds around the circle in a fixed direction. In each step, a certain number of people are skipped and the next
person is executed. The elimination proceeds around the circle (whic... |
dca9424a44710c0db2f54365ceac5e9fcd2bda8e | dataAlgorithms/dataStructure | /linkedList/concatCircularLinkedList.py | 6,247 | 3.671875 | 4 | # Concat two Circular linked list
def concatList(last1, last2):
if last1 is None:
last1 = last2
return last1.next
if last2 is None:
return last1.next
ptr = last1.next
last1.next = last2.next
last2.next = ptr
last1 = last2
return last1.next
# Get the last node
def ... |
53aefa8305d1a73194aecef894cb7cb8fb287806 | carpeyoyo/Python-TicTacToe | /TTT_game.py | 4,699 | 4.1875 | 4 | # Joshua Mazur
# Actual game class
##############################
'''The Game Class.'''
class game:
"""Contains all necessary variables and methods to play tictactoe alone."""
def __init__(self):
# Game Constructor
# New game method is called
self.newGame()
def newGame(self):
... |
dbc99eaf16b6e02ec3f3e69745549b0a02bdbef2 | Chrysippean/Rubiks-Cube-Q-Learning | /cubetest.py | 4,314 | 3.8125 | 4 | cubemain = []
for i in range(6):
cubemain.append([i,i,i,i])
print(str(cubemain))
front = cubemain[0]
back = cubemain[1]
left = cubemain[2]
right = cubemain[3]
up = cubemain[4]
bottom = cubemain[5]
f0 = front[0]
f1 = front[1]
f2 = front[2]
f3 = front[3]
b0 = back[0]
b1 = back[1]
b2 = back[2]
b3 = back[3]
l0 = left[... |
28bb56d8053f5f7bb87a5d02b39659d7270c385d | AsmaaGHSamir/GProject | /DB.py | 921 | 3.546875 | 4 | import sqlite3
with open("C:\\Users\Asmaa Samir\Desktop\Project\data.txt", "w") as myFile:
my_tuple1 = ('google.com ', '198.188.3.2 ', '255.255.255.0', '11:01 ')
my_tuple2 = ('youtube.com', '199.588.35.22', '255.255.255.0', '1:01')
my_tuple3 = ('google.com', '198.155.66.1', '255.255.255.0', '7:55')
... |
db273d324cceae6725e9b753373f78d5d9ea007d | BrodyJorgensen/practicles | /prac_1/loops.py | 480 | 4.28125 | 4 | #for the odd numbers
#for i in range(1, 21, 2):
# print(i)
#count to 100 in lots of 10
#for i in range(0, 101, 10):
# print(i)
#to ocunt down from 20
#for i in range(20, 0, -1):
# print(i)
#printing different numbers of stars
#number_of_stars = int(input("Number of stars: "))
#for i in range (number_of_star... |
6c9967f527558fa5a7fd3a922c58917f74df958a | BFFV/PythonCourseHW | /Tareas/T00/user.py | 21,050 | 3.65625 | 4 | import events as e
import datetime as d
# Representa a los usuarios conectados
class User:
def __init__(self, user):
self.user = user
# Menú principal del usuario
def main_menu(self):
while True:
print("Bienvenido(a) de nuevo, " + self.user + "!\n" +
"¿Qué acción... |
7b85ca3844a0bf6a496f6da0ea4073ba263654cd | deivisongithub/introdu-o-linguaguem-python | /Lista de exercícios 4/Questão 2.py | 489 | 4 | 4 | # Aluno: Deivison Rodrigues jordâo
# Programa para substituir os números pares pelo seu doblo e ímpares pelo seu triplo
# em um lista.
vetor = []
x = 1
while(x == 1):
vetor.append(int(input("digite um número: ")))
x = int(input("caso queira continuar fornecendo elementos digite 1,para obter o resulta... |
d013e5593b9d486e1b1249751ab17c454201dcf4 | deivisongithub/introdu-o-linguaguem-python | /Lista de exercícios 4/Questão 3.py | 394 | 4.09375 | 4 | # Aluno: Deivison Rodrigues jordão
# programa que soma as colulas de uma matriz definida pelo usuário.
vetor = [None] * 3
matriz = [[None]*3 for i in range(0,2)]
for i in range(2):
for j in range(3):
matriz[i][j] = (int(input("digite um número para a linha [%d] e para a coluna [%d] :"%(i,j))))
... |
65868fae5982c986f655baa70562632bceb3616f | mingmardolma/python-programs | /filter.py | 270 | 3.625 | 4 | """
selective
"""
import pandas as pd
import numpy as np
infile = input("Enter input file name: ")
outfile = input("Enter output file name: ")
df = pd.read_csv(infile)
df = df.loc[(df["Grade"] == 3) & (df["Year"] == 2019)]
df.index.names = [" "]
df.to_csv(outfile)
|
d316bc8ecbf3efa30c647d0f2b50faee0cb11a8b | MattStammers/ClinDev-algorithms | /09 palindrome/number_palindrome.py | 1,099 | 4.09375 | 4 | # import unittest
# The function below can check if a number is a palindrome and returns a bool.
def digits(x):
digs = []
while x != 0:
div, mod = divmod(x,10)
digs.append(mod)
x = div
return digs
def is_palindrome(x):
digs = digits(x)
for f, r in zip(digs,reversed(digs)):
if f != r:
... |
a8f5ed28bb25e3481f58ea5077e8eb2987be6d62 | thonny/thonny | /misc/blocks_katse.py | 940 | 3.546875 | 4 | import tkinter as tk
from tkinter import ttk
pos = [0, 0]
def down(e):
pos[0] = e.x
pos[1] = e.y
def drag(e):
dx = e.x - pos[0]
dy = e.y - pos[1]
c.move("pop", dx, dy)
pos[0] = e.x
pos[1] = e.y
root = tk.Tk()
pw = ttk.PanedWindow(root, orient=tk.HORIZONTAL)
pw.grid()
c = tk.Canvas(pw... |
f065d85feefeeaad44ba0aa6ece2d3f389119916 | thonny/thonny | /thonny/plugins/circuitpython/api_stubs/aesio/__init__.pyi | 2,602 | 3.671875 | 4 | """AES encryption routines
The `AES` module contains classes used to implement encryption
and decryption. It aims to be low overhead in terms of memory.
For more information on AES, refer to `the Wikipedia entry
<https://en.wikipedia.org/wiki/Advanced_Encryption_Standard>`_.
"""
from __future__ import annotations
f... |
6f39faa37967cb68e595438dea4766baf7eab12b | thonny/thonny | /thonny/plugins/circuitpython/api_stubs/time/__init__.pyi | 3,466 | 3.703125 | 4 | """time and timing related functions
|see_cpython_module| :mod:`cpython:time`.
"""
from __future__ import annotations
from typing import Sequence
def monotonic() -> float:
"""Returns an always increasing value of time with an unknown reference
point. Only use it to compare against other values from `time.mo... |
4f9ec02223295c193a8f4194fc4f92428542f25a | thonny/thonny | /thonny/plugins/micropython/base_api_stubs/ucollections.pyi | 5,810 | 3.9375 | 4 | """
collection and container types.
Descriptions taken from:
https://raw.githubusercontent.com/micropython/micropython/master/docs/library/collections.rst.
====================================================
.. module:: collections
:synopsis: collection and container types
|see_cpython_module| :mod:`python:colle... |
adc0d08f0dda305baa24a454a56e8d179aef457d | thonny/thonny | /thonny/plugins/circuitpython/api_stubs/traceback/__init__.pyi | 3,773 | 3.515625 | 4 | """Traceback Module
This module provides a standard interface to print stack traces of programs.
This is useful when you want to print stack traces under program control.
|see_cpython_module| :mod:`cpython:traceback`.
"""
from __future__ import annotations
import io
from types import TracebackType
from typing impor... |
ed513775e1aa28508b71c77de70489a9bbab14bb | tnakatani/Udacity_DAND | /1_Python_Numpy_Pandas/python_notes/open_file2.py | 298 | 3.5 | 4 | sentences = []
with open("some_file.txt") as f:
# print(sentence.readline())
# print(sentence.readline())
# print(sentence.readline())
# print(sentence.readline())
# print(sentence.readline())
for line in f:
sentences.append(line.strip())
print(sentences)
|
8038f6ebd77ade122789a800c6ece9891a303e58 | xiaojiangzhang/leetcode_Record | /力扣_牛客刷题/数据结构基础/二刷/冒泡排序.py | 378 | 3.875 | 4 | def bubbleSort(nums):
n = len(nums)
flag = True
for i in range(n):
if flag:
flag = False
for j in range(n - i - 1):
if nums[j + 1] < nums[j]:
nums[j + 1], nums[j] = nums[j], nums[j + 1]
flag = True
return nums
res ... |
87acc40e6edfb8a62c58ff55b2ad1a27ff3646a4 | xiaojiangzhang/leetcode_Record | /力扣_牛客刷题/字符串去标点.py | 494 | 3.953125 | 4 | # 编一个程序,从 string 对象中去掉标点符号。要求输入到程序的字符串必须含
# 有标点符号,输出结果则是去掉标点符号后的 string 对象
'''
样例输入
String:a1,b2.c3-d4!
样例输出
Enter a string:
Result:
Stringa1b2c3d4
'''
print("Enter a string:")
string = input()
re = str()
for i in string:
if 47 < ord(i) < 58 or 64 < ord(i) < 91 or 96 < ord(i) < 123:
re += i
if re:
p... |
fc2436cb9294b854e261864df9fd2554a5bb0d0f | xiaojiangzhang/leetcode_Record | /力扣_牛客刷题/a携程第一题.py | 748 | 3.765625 | 4 | """题目描述:
给定一个由 n 个小写英文字母组成的字符串 s = s1 ... sn ,另给定 k 个各不相同的英文字母,
计算在所有 s 的子字符串中有多少可以由这 k 个字母或这 k 个字母的子集组成。(相同子字符串视为多个子字符串)
输入
第一行为空格分开的两个数字代表 n 和 k 。( 1 <= n <= 105 , 1 <= k <= 26 )
第二行为字符串 s 。
第三行为 k 个由空格分隔开的小写英文字母。
输出
子字符串数量。
"""
import sys
def num_sub_Str(str):
sub = []
for i in range(len(str)):
... |
e8258ae1e9512bf6725cccb233677e01398a7c86 | xiaojiangzhang/leetcode_Record | /力扣_牛客刷题/model-滑动窗口/3. 无重复字符的最长子串.py | 1,100 | 3.59375 | 4 | '''
给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。
示例 1:
输入: "abcabcbb"
输出: 3
解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。
示例 2:
输入: "bbbbb"
输出: 1
解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。
示例 3:
输入: "pwwkew"
输出: 3
解释: 因为无重复字符的最长子串是 "wke",所以其长度为 3。
请注意,你的答案必须是 子串 的长度,"pwke" 是一个子序列,不是子串。
'''
class Solution:
def lengthOfLongestSubstring(self... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.