blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
c5b0e574459bcf1b31c18d69970cd6acfb9502bd | Gitthuma/simple-signup-and-loggin-system | /app.py | 781 | 4.1875 | 4 | # Create welcome message that asks to create account and takes user input
print("Welcome! Please create an account:")
userName = input("Please enter username: ")
passWord = input("Please enter password: ")
# Print a congratulations message and ask user to log in
print("Congratulations! You have created a new accoun... |
77b53140a0c3ddab5056ebf1bd5e35724cef7dc4 | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_200/1316.py | 1,010 | 3.71875 | 4 | #!/usr/bin/env python2
import logging
logging.basicConfig(filename='debug.log',level=logging.DEBUG)
#logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger("default")
def tidyness(num):
index = 0
length = len(num)
tidy = ""
prev_digit = 0
for current_char in num[::-1]:
current... |
734a6ed81b7eb63eb19f3a980777c0f5054196f6 | sahildua2305/Pythonic-Algorithm-Implementations | /Abstract Data Types/Lists/Ordered Lists/Implementation.py | 2,073 | 4.21875 | 4 |
#For creating a single node
class Node:
def __init__(self,initdata):
self.data = initdata
self.next = None
def getData(self):
return self.data
def getNext(self):
return self.next
def setData(self,newdata):
self.data = newdata
def setNext(self,newnext):
... |
223d2925c759a6c3a4450f43d7fb439346015323 | hakaorson/CodePractise | /String/regular-expression-matching.py | 2,346 | 3.71875 | 4 | '''
Leetcode 10
给你一个字符串 s 和一个字符规律 p,请你来实现一个支持 '.' 和 '*' 的正则表达式匹配。
'.' 匹配任意单个字符
'*' 匹配零个或多个前面的那一个元素
所谓匹配,是要涵盖 整个 字符串 s的,而不是部分字符串。
s 可能为空,且只包含从 a-z 的小写字母。
p 可能为空,且只包含从 a-z 的小写字母,以及字符 . 和 *。
'''
class Solution_dynamic():
def isMatch(self, s, p):
s, p = '%#'+s, '%#'+p
matrix = [[False for j in range(... |
c38c7b167df9b3fb4d7cf4004fa4f3033b2a5029 | Artties/HUAWEI_Machine_Test | /Random_number_remove_duplicates.py | 1,539 | 4 | 4 | #明明想在学校中请一些同学一起做一项问卷调查,为了实验的客观性,他先用计算机生成了N个1到1000之间的随机整数(N≤1000),对于其中重复的数字,只保留一个,把其余相同的数去掉,不同的数对应着不同的学生的学号。然后再把这些数从小到大排序,按照排好的顺序去找同学做调查。请你协助明明完成“去重”与“排序”的工作(同一个测试用例里可能会有多组数据,希望大家能正确处理)。
#注:测试用例保证输入参数的正确性,答题者无需验证。测试用例不止一组。
#当没有新的输入时,说明输入结束。
#输入描述:
#注意:输入可能有多组数据。每组数据都包括多行,第一行先输入随机整数的个数N,接下来的N行再输入相应个数的整数。具体格式请看下面的"示例"。
... |
6cac5988b2612ca4ebe4c5f7d470d0e24945fd46 | sprash98/Tests | /Workout/workout.py | 10,120 | 3.765625 | 4 |
import pickle
import re
from collections import OrderedDict
def validate_numeric_params(type,*max):
if re.match("Age",type,re.I) :
units = "yrs"
elif re.match("Duration",type,re.I) :
units = "minutes"
elif re.match("Weight",type,re.I) :
units = "Kgs/Lbs"
else :
units =... |
618fb72bdf38974b157f55bee8eb86f8bae31e93 | sulemanmahmoodsparta/Data24Repo | /Databall/a_Players.py | 1,514 | 3.859375 | 4 | import random # for player generation
from abc import ABC, abstractmethod
# An Abstract class that cannot be initialised
class Players(ABC):
@abstractmethod
def __init__(self, fname, lname, value, position, score):
self.__first_name = fname
self.__last_name = lname
self.__value = value
... |
13048e126a14d55b869152a39e925dce5d57d7a5 | sevencd/learnpython | /lamba.py | 643 | 3.796875 | 4 | square = lambda x: x ** 2
print(square(3))
print([(lambda x: x * x)(x) for x in range(10)])
l = [(1, 20), (3, 0), (9, 10), (2, -1)]
l.sort(key=lambda x: x[1])
print(l)
"""
from tkinter import Button, mainloop
button = Button(
text='This is a button',
command=lambda: print('being pressed')) # ... |
5c4153f0fb05f1253183b3ba554101473926ced9 | IronDrago/Tic-Tac-Toe | /tic-tac-toe.py | 2,348 | 3.703125 | 4 | import random
def create_field():
board = [['.', '.', '.'],
['.', '.', '.'],
['.', '.', '.']]
return board
def draw_field(board):
for x in board:
print(x[0], x[1], x[2])
def player_move(token, board):
while True:
print('Ходит ', token)
line = input... |
5d1e128a577c7785d7549551f8f6a14cc4dc95a1 | linshaoyong/leetcode | /python/design/0232_implement_queue_using_stacks.py | 1,062 | 4.34375 | 4 | class MyQueue(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.data = []
def push(self, x):
"""
Push element x to the back of queue.
:type x: int
:rtype: None
"""
stack = [x]
tmp = []
... |
d0cff9eaed9ae3d7bebf95d19ed4425a974c0443 | Elyteaa/P5 | /Sandbox/AstarTemplate | 3,571 | 3.9375 | 4 | #!/usr/bin/python
#source for the tutorial: https://www.youtube.com/watch?v=ob4faIum4kQ
from Queue import PriorityQueue
class State(object): #this class stores all the results of Astar algorithm functions writte below
def __init__(self, value, parent, start = 0, goal = 0, solver = 0);
self.children = []
self.pare... |
efdf58aa771b30a2db40c5814ad1f2c1f13c968c | Ivernys-clone/maths-quiz1 | /user details/user_details_v1.py | 166 | 4.28125 | 4 | #The following code is wrtitten to ask for user information
name = input("What is your name")
#The print fuction will display the results
print("Hello",name)
|
1c4ee480cf8cd2612ddabda861fae32e62c2c2a7 | webscienceuniform/uniform | /assignment7/uniform_assignment7_3.py | 4,377 | 3.734375 | 4 | import random
import numpy as np
import matplotlib.pyplot as plt
import collections
#function to rolling two diece simultaneously and returns the sum of results
def rollDiceGetSum():
return random.randint(1, 6) + random.randint(1, 6)
#functions to calculate CDF
def calculateCDF(result):
frequencyNu... |
1a473383f61ee12090dba6828fd563380fac401c | Chairmichael/ProjectEuler | /Python/Complete/0012a - Highly divisible triangular number.py | 2,299 | 3.828125 | 4 | '''
The sequence of triangle numbers is generated by adding the natural numbers.
So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28.
The first ten terms would be:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
Let us list the factors of the first seven triangle numbers:
1: 1
3: 1,3
6: 1,2,3,6
10: 1,2,... |
b0a81e258dff8966d08dd1f228fb5ac20aa6f740 | Metbaron/Pong | /Pong1.py | 4,053 | 3.9375 | 4 | import turtle
import os
wn = turtle.Screen() # create window
wn.title("Pong")
wn.bgcolor("black")
wn.setup(width=800, height=600)
wn.tracer(0) # stops automatic updating
# Score
score_a = 0
score_b = 0
# Paddle A
paddle_a = turtle.Turtle() # Turtle object
paddle_a.speed(0) # speed of animation to max
paddle_a.s... |
0534aec84e9bd75e34af0dfec07f5fd179e0fc42 | Uttam1982/PythonTutorial | /02-Python-Flow-Control/01-If-else.py | 2,654 | 4.375 | 4 | # What is if...else statement in Python?
# Decision making is required when we want to execute a code only
# if a certain condition is satisfied.
# The if…elif…else statement is used in Python for decision making.
# ******************************************************************************
# Python if Statemen... |
ed135c2dd4b6ce99268194d97e9117bc43abafc4 | jmdibble/python-exercises | /ex6.py | 164 | 4.03125 | 4 | word = str(input("Type your favourite word: "))
word = word.lower()
new_word = word[::-1]
if new_word == word:
print("Yay!")
else:
print("Nope")
|
8e9ceeff6c9927830455a17d3b6fcdb9813888fc | biyoner/-offer_python_code | /50第一个只出现一次的字符_02.py | 1,187 | 3.671875 | 4 | #coding= utf-8
#author:Biyoner
import collections
class CharStatistics(object):
def __init__(self):
self.occurrrence = collections.OrderedDict()
def Insert(self,ch):
if self.occurrrence.has_key(ch):
if self.occurrrence[ch] >0:
self.occurrrence[ch] = -2
... |
675c46c9b05e7fa7f74a9113a2b15f50d6bbdf21 | mastermind2001/Problem-Solving-Python- | /snail's_journey.py | 1,349 | 4.3125 | 4 | # Date : 23-06-2018
# A Snail's Journey
# Each day snail climbs up A meters on a tree with H meters in height.
# At night it goes down B meters.
# Program which takes 3 inputs: H, A, B, and calculates how many days it will take
# for the snail to get to the top of the tree.
# Input format :
# 15 # For H
# 1 # F... |
e1402f9b16225913799870056215b643a961bcd2 | zuowanbushiwo/Speechprocess_t | /readwritewav.py | 1,312 | 3.53125 | 4 | # !usr/bin/env python
# coding=utf-8
import wave
import matplotlib.pyplot as plt
import numpy as np
def read_wave_data(file_path):
# open a wave file, and return a Wave_read object
f = wave.open(file_path, "rb")
# read the wave's format infomation,and return a tuple
params = f.getparams()
# get t... |
e9c7ada1853ad4429fe42d6549263fefdcb34280 | Da-Yuan/LeetCode-Python | /LeetCode-217.py | 445 | 3.640625 | 4 | # 给定一个整数数组,判断是否存在重复元素。
# 如果任何值在数组中出现至少两次,函数返回 true。如果数组中每个元素都不相同,则返回 false。
def Solution1(nums): # 超出时间限制
if len(nums)==1:
return False
for i in range(len(nums)):
for j in range(len(nums)-i-1):
if nums[i]==nums[-j-1]:
return True
return False
a1=[1,2,3,1]
a2=[1,2,3,4]
a3=[3,1]
print(Solution(a3)) |
abdc2fb4e7be0a91d0602d1c8fc1f9affc5b0a98 | bjan94/Interview-Questions | /strings/NextClosestTime.py | 1,501 | 4.15625 | 4 | from itertools import product
"""
Given a time represented in the format "HH:MM", form the next closest
time by reusing the current digits. There is no limit on how many times
a digit can be reused.
You may assume the given input string is always valid. For example,
"01:34", "12:09" are all valid. "1:34", "12:9" ... |
43cfe1e24f52f44424c88854dfc86830448c996a | DRTooley/AlgorithmsReview | /UCSD/Week1-SuffixTree/suffix_tree/suffix_tree.py | 1,019 | 3.953125 | 4 | # python3
import sys
class Edge:
def __init__(self, begin, end):
self.begin = begin
self.end = end
class Node:
def __init__(self, value, edges=None):
self.value = value
if edges is None:
self.edges = set()
else:
self.edges = edges
... |
04964f9c07d41cb53a0ce02e68c57f579aa0fb11 | dgallab/exercises_in_python | /python_f/data structures/LinkedList.py | 1,463 | 4.125 | 4 | class Node():
def __init__(self, dataval):
self.dataval = dataval
self.nextval = None #this will be another node
class LinkedList():
def __init__(self):
self.headval = None #this will be a node, not a datavalue
def add_node(self,node):
if self.headval is No... |
6dc7cb539824494aaa748ed1893403740a6192bd | Lavekernis/Problemy | /Problemy/Problem114_2.py | 1,735 | 3.640625 | 4 |
#Wcześniejsza próba implementacji za pomocą rekurecji z zapisywaniem
'''from memorised.decorators import memorise
@memorise()
def possib(n):
if n < 3:
return 1
else:
sum = 1
for i in range(0,n-3):
sum += possib(i)
return possib(n-1)+sum'''
#Iteracyj... |
214b4ec7a5aef78faa152d56b253692eb3f9c8c2 | taolin1996/Algorithm | /Chapter1/insert_sort.py | 464 | 3.5 | 4 | import random
import time
def insert_sort(A,n):
j = 0
for i in range(0,n-1):
j = i
key = A[j+1]
#print("key =",key)
while((key < A[j]) & (j >= 0)):
A[j+1] = A[j]
j -= 1
A[j+1] = key
test = [random.randint(1,800000) for i... |
6c86520234d5bbeeecc1296d16185c60e4eac6c3 | chr0m3/boj-codes | /0/1/1260/1260.py | 1,873 | 3.609375 | 4 | import collections
import sys
import time
input = sys.stdin.readline
def find_next(n: int, v: int, graph: list, visited: list):
for i in range(1, n + 1):
if graph[v][i] is True and visited[i] is False:
# Connected and not visited.
return i
return None
def dfs(n: int, v: int... |
79265dee5a7f6e7683e2b73b54d9baf9f1033a64 | gsudarshan1990/Training_Projects | /Classes/class_example6.py | 470 | 4.15625 | 4 | """This is an example of class which initializes twice"""
class Person:
"""This class describes about the person"""
def __init__(self):
"""This is used to intialize the values"""
self.firstname = "Johny"
self.lastname = "Depp"
self.eyecolor = "grey"
self.age = 42
person... |
499b2d8b89769ce4bc332b665a7ee149ea1158f0 | borko81/python_fundamental_solvess | /Final Exam Preparation - 24 July 2019/03. The Isle of Man TT Race.py | 2,010 | 3.546875 | 4 | import re
FOUND = False
pattern = re.compile(r'^([\#, \$, \%, \*, \&])(\w+)(\1)=(\d+)!!(\S+)')
while not FOUND:
notes = input()
length = len(notes)
temp = pattern.match(notes)
if temp and int(temp.group(4)) == len(temp.group(5)):
increase_with = int(temp.group(4))
hash_cod... |
0a73fa0abb613fe52c35ae0e4a59b0861fecce96 | kucherskyi/train | /lesson07/task06.py | 482 | 3.8125 | 4 | #!/usr/bin/env python
"""
Write a generator that consumes lines of a text and prints them to standard
output. Use this generator and a flatten function from the previous task to
print contents of two different files to a screen pseudo-simultaneously.
"""
from task05 import flatten
def line_writer():
yield
... |
602453edd8ae15a89bfab021a4427fc6d4b15c5e | KhangNLY/Py4E | /Assignment/Course 1 - Programming for Everybody (Getting Started with Python)/Week 6/4.6.py | 238 | 3.828125 | 4 | def computepay(h, r):
if h > 40:
return 40 * r + (h - 40) * (r * 1.5)
else:
return h * r
hrs = input("Enter Hours:")
rate = input("Enter Rate:")
p = computepay(float(hrs), float(rate))
print("Pay", p)
|
d68124c47ce8939dc69bf08b6d38758b8c09dc3b | Teresa90/demo | /assisngment2.py | 805 | 4.09375 | 4 | import math
def introduction_message():
print("This program computers the roots")
print("of a second order equation:")
print()
print(" ax^2+bx+c=0 ")
print()
def input_and_solve():
a = eval(input ("please enter a: "))
b = eval(input ("please enter b: "))
c = eval(input ("please e... |
f6ec074233d94acb8658090f547968fcbf2b34de | elabzina/python-washu-2014 | /hw4/classes.py | 4,380 | 4.03125 | 4 | class Node():
def __init__(self, _value=None, _next=None):
self.value=_value
self.next=_next
def __str__(self):
return str(self.value)
class LinkedList():
#pointers to the first and last nodes of the link are stored, also len stores the number of nodes.
#in case of the cycles l... |
3b7247bd24ffd07cbd139217f35f20f2311d7e54 | TheAlgorithms/Python | /ciphers/decrypt_caesar_with_chi_squared.py | 9,452 | 4.5625 | 5 | #!/usr/bin/env python3
from __future__ import annotations
def decrypt_caesar_with_chi_squared(
ciphertext: str,
cipher_alphabet: list[str] | None = None,
frequencies_dict: dict[str, float] | None = None,
case_sensitive: bool = False,
) -> tuple[int, float, str]:
"""
Basic Usage
===========... |
4aa73fe746ce789c8c6bfe9ff4d070e739831d01 | bbdavidbb/A_Star-Search-Algorithm | /puzzle.py | 4,019 | 3.765625 | 4 | import random
from copy import deepcopy
from itertools import chain
def gen_puzzle_n(n):
"""
Generate a puzzle of size nxn
@param n(int) The len of row and col
@return puzzle(2d list) An nxn 2d list
"""
size = n * n
temp = list(range(size))
temp = sorted(temp, key=lambda x: random.rand... |
4ff35b87bbc3bb3d996aebc45e5c8a1c17a1bf1b | upat0003/Data-Structure-Algorithms | /MIPS and Logical sequences/task1b.py | 375 | 4.3125 | 4 | year=int(input("Enter the year:")) #asking to enter the year to compare
if(year<1582):
print("Enter number greater than 1581") #if the condion meets, it will print the following statement
else:
if((year%4==0 and year%100!=0) or (year%400==0)):
print("Is leap year")
e... |
e2f65a57ea2e9aa3860b1663bed20710832c4477 | Ovidiu2004/Instruc-iunea-FOR | /5for.py | 119 | 3.859375 | 4 | nr=int(input("numarul este"))
s=0
for a in range(1,nr+1):
if a%3==0 or a%5==0:
s=s+a
print("suma =",s) |
bab7c7342d0cfddb3b9349e9ae9173b1123efd0a | berkercaner/pythonTraining | /Chap08/sets.py | 445 | 3.953125 | 4 | #!/usr/bin/env python3
# Copyright 2009-2017 BHG http://bw.org/
"""
It's a collection type. contains unordered collection of unique
and immutable objects
"""
def main():
a = set("We're gonna need a bigger boat.")
b = set("I'm sorry, Levy. I'm afraid I can't do that.")
print_set(a)
print_set(b)
def... |
dfcfb04ad15486e26f33af3cd260d7622712ecd7 | webjoaoneto/spotify-playlist-downloader-gui | /actions/youtube.py | 1,929 | 3.515625 | 4 | #!/usr/bin/python
# This sample executes a search request for the specified search term.
# Sample usage:
# python search.py --q=surfing --max-results=10
# NOTE: To use the sample, you must provide a developer key obtained
# in the Google APIs Console. Search for "REPLACE_ME" in this code
# to find the co... |
e38bd5619fbe6bcf5e779d02b6c5b33d308fadfc | behrouzmadahian/python | /GANS/01-DCGAN.py | 10,994 | 3.734375 | 4 | import numpy as np
import tensorflow as tf
import os, time, itertools, imageio, pickle
from matplotlib import pyplot as plt
from tensorflow.examples.tutorials.mnist import input_data
'''
we resize the images into (1,64,64,1).
Think about convolution, getting a p*p image (1, 64, 64, 1) and after several convolu... |
0c6ef09a8f561f197ea995a8cbf28617ee7b1292 | JuanGinesRamisV/python | /practica 5/p5e2.py | 383 | 3.96875 | 4 | #juan gines ramis vivancos p5e2
#Escribe un programa que pida dos números y escriba qué números entre ese
#par de números son pares y cuáles impares
print('Escribe un número')
numero1 = int(input())
print('Escribe un numero mayor que' ,numero1,)
numero2 = int(input())
for i in range(numero1,numero2+1):
if ((i%2) ==... |
db0d4790cf2dd9f4d8590906dede80c86c385032 | keerthidl/Python-Assignment-re-work- | /area.py | 984 | 4.3125 | 4 | #Implement a program with functions, for finding the area of circle, triangle, square.
import math
class Area:
def circle(radius):
pi = 3.1415
return (pi * (radius * radius))
def triangle(height, base):
return ((height * base)/2)
def square(side):
return (side * side)
from area import Area
def m... |
cfea0e7dc9f6ebd266dbb33317ee6a7dfa1f20a1 | cheyra90/CodeKatas | /count_sheep.py | 580 | 4 | 4 | '''
given
[True, True, True, False,
True, True, True, True ,
True, False, True, False,
True, False, False, True ,
True, True, True, True ,
False, False, True, True]
count the amount of Trues
'''
arr = [True, True, True, False,
True, True, True, True ,
True, False, True, False,
... |
cc26f2f374bc0be8b052417421006a6c362a3018 | Adarsh-Liju/Python-Course | /Fibonacci Series.py | 392 | 4.03125 | 4 | #Program 1 a)
f1=0#assigning the values
f2=1
s=0
n=int(input("Enter the number of terms"))#inputing the value
if(n==1):
print(f1)
elif(n==2):
print(f1,end=" ")
print(f2,end=" ")
elif(n>2):
print(f1,end=" ")
print(f2,end=" ")
for i in range(n-2):#adding the two variables
... |
77112434b7fec16bc976f58678aa6b99c6b56275 | JagadeeshMandala/python-programs | /set4/print pascal triangle.py | 121 | 3.609375 | 4 | n=int(input("enter the number"))
for i in range(n):
print(" "*(n-i),end=" ")
print(" ".join(map(str,str(11**i)))) |
c38c9be51ae23e97ef7febf0de42e62a0a60eb73 | Linkin-1995/test_code1 | /day17/exercise03(生成器应用).py | 754 | 3.96875 | 4 | """
练习:
list01 = [3,434,35,6,7]
定义函数,将全局变量list01中所有奇数返回.
1. 使用传统思想:
创建新列表存储所有结果,再返回列表
2. 使用生成器思想:
使用yield返回奇数
"""
list01 = [3, 434, 35, 6, 7]
def find01():
list_result = []
for number in list01:
if number % 2:
list_result.append(n... |
fb88499a2a09fcef279dda837c9d1923d69f4742 | kamisaberi/python-toturial | /7.extra_operators.py | 169 | 3.921875 | 4 | x = 5
y = 5
print(x == y)
print(x is y)
y = 6
print(x is y)
students = ["ali", "reza", "ahmad"]
print("Ali" in students)
print (x is not y)
print("ali" not in students)
|
5ffc0ae09229cbf802db7ee3940fba9989936e64 | PaulLiang1/CC150 | /linklist/link_list_cycle_ii_extra_space.py | 621 | 3.765625 | 4 | """
Definition of ListNode
class ListNode(object):
def __init__(self, val, next=None):
self.val = val
self.next = next
"""
class Solution:
"""
@param head: The first node of the linked list.
@return: The node where the cycle begins.
if there is no cycle, return null
... |
ac7cf28285f53c5341e77f47a8942dbbebd870a1 | zhucebuliaolongchuan/my-leetcode | /DataStructureDesign/LC170_TwoSum3.py | 1,258 | 4 | 4 | """
170. TwoSum 3 - Data Structure Design
Design and implement a TwoSum class. It should support the following operations: add and find.
add - Add the number to an internal data structure.
find - Find if there exists any pair of numbers which sum is equal to the value.
For example,
add(1); add(3); add(5);
find(4) -> tr... |
9bb50692bd5040c9e54cc807d08fe5959086300d | MjrMatt/PythonProjects | /ABSWP_myProjects/mclip.py | 551 | 3.796875 | 4 | #! python3
# mclip.py - A multi-clipboard program.
TEXT = {'agree': """Yes, I agree. That sounds fine to me.""",
'busy': """Sorry, can we do this later this week or next month?""",
'upsell': """Would you consider making this a monthly donation?"""}
import sys, pyperclip
if len(sys.argv) < 2:
print('Usage: mclip.... |
cb7b8c9c38399cf5925a8b1772ff510d8ec402a2 | ZvenZ2/vardata | /datafiler/find_num.py | 497 | 3.84375 | 4 | def find_num(setning, min, max):
hours_ahead = input(str(setning))
if hours_ahead == "":
return hours_ahead
try:
num = int(hours_ahead)
if (num >= int(min)) and (num <= int(max)):
num = int(num)
else:
print(f"Gi ett tall mellom {min} og {max}")
... |
1fa2422dd0247da931b38f6d8b4e460e0a59b216 | lmssr/python | /euler/problem2/test_problem2.py | 656 | 3.515625 | 4 | """Unit tests for p2.py."""
import unittest
from problem2 import sum_of_even_fibo_nums
class TestSumOfFibo(unittest.TestCase):
def test_sum_of_even_fibo_nums(self):
self.assertEqual(sum_of_even_fibo_nums(1), 0)
self.assertEqual(sum_of_even_fibo_nums(2), 2)
self.assertEqual(sum_of_even_f... |
315a665ee7572887d43eaa014e8d00f5d374a685 | HediaTnani/Python-for-Bioinformatics | /remove_seq.py | 2,520 | 3.671875 | 4 | # Removing all sequences(contigs) less than a particular length from a fasta file derived from metagenomic data
# Here the length of the sequences to be removed is taken as 300 bp
# Type "python remove_seq.py -i Path/of/your/fasta/file -l Cut off length of the sequences to be removed
# - o Output file name with exte... |
c4a95e364a723c6db4a9cd961f31e2a5d42c1dcf | maxschipper1/Exercise | /number_to3.py | 101 | 3.71875 | 4 | import time
x = 0
while True:
print(x)
x += 1
if x > 3:
x = 0
time.sleep(1)
|
1d6b9e561e9cd5302e967e47c87b4d2f0be62e0e | choidslab/IntroducingPython | /ch6/namedtuple.py | 337 | 4.09375 | 4 | from collections import namedtuple
Bird = namedtuple('Bird', 'bill tail')
duck = Bird('wide orange', 'long')
print(duck)
print(duck.bill)
print(duck.tail)
#parts 딕셔너리에서 key, value 값을 각각 추출하여 Duck클래스에 인자로 전달
parts = {'bill': 'wide orange', 'tail': 'long'}
duck2 = Bird(**parts)
print(duck2) |
bcfd2b97f062ede5979a9739aa482df9460810b9 | Sahilmallick/Python-Batch-38 | /day1/operators.py | 347 | 3.96875 | 4 | """
+
-
*
/=>float division
// => integer division
%=modulor
&
== ->comparioson operator
** -> power
"""
"""
a=int(input("enter a no.:"))
b=int(input("enter another no.:"))
print(a/b)
print(a//b)
"""
"""
a=int(input("enter a no.:"))
b=int(input("enter another no.:"))
print(a+b)
print(a-b)
print(a*b)
print(a//b)
print(a... |
7a908763ee75b87a794c44a5b6e40985b0872734 | devkant/competitive_programming | /pm4.py | 292 | 3.75 | 4 | a=str(input())
z=len(a)
flag=0
count=0
for i in range(0,z):
if a[i]=="a" or a[i]=="i" or a[i]=="0" or a[i]=="u" or a[i]=="e":
flag+=1
if a[i]!="a" or a[i]!="i" or a[i]!="0" or a[i]!="u" or a[i]!="e":
if flag>count:
count=flag
flag=0
print(count) |
1e71ebff8ced9cf24e9487c44ce63d0363f1540d | Rudrarka/planning-poker-server | /backend/game_service/player.py | 538 | 3.546875 | 4 | class Player:
"""
Holds information about the Player
"""
def __init__(self, id, name, is_admin, vote=None, sid=None) -> None:
self.id = id
self.name = name
self.is_admin = is_admin
self.vote = vote
self.sid = sid
def toJSON(self):
"""
Helper... |
06e267e0f74160e4564c975f36e01e4e93f5fca4 | reversedArrow/cmput291 | /lab exam2/lab_exam.py | 5,367 | 3.6875 | 4 | # Name: Xianhang Li
# CCID: 1465904
import sys
import sqlite3
import time
from random import randint
import datetime
# connection = None
cursor = None
connection = sqlite3.connect('lab_exam_2.db')
# Your functions go here
# ======================
def add_flight():
unique = True
while unique:
fl... |
8249f303ff1558fca3a88b54832a382d3e449dba | TNMR-m/NLP100knock | /09.py | 1,422 | 3.609375 | 4 | def kansu09(str_x):
str_x = str_x.split() # 文を単語ごとに分解する
a = 0
from random import shuffle # シャッフルをインポート
for i in str_x:
str1 = str_x[a] # 現在扱っている単語をstr1とする
mojisu = len(str_x[a]) # 現在扱っている単語の文字数
if mo... |
89fb5a097037e27734a242090654b4bda73e1dd8 | Douglasdai/CQU_Holiday_Improvment | /code-improve/DSC/day_1.py | 1,145 | 3.78125 | 4 | print("hello world")
str='Runoob'
print(str) # 输出字符串
print(str[0:-1]) # 输出第一个到倒数第二个的所有字符
print(str[0]) # 输出字符串第一个字符
print(str[2:5]) # 输出从第三个开始到第五个的字符
print(str[2:]) # 输出从第三个开始后的所有字符
print(str * 2) # 输出字符串两次
print(str + '你好') # 连... |
c6253f50e7f1a37f99bc285a3bbe5aa010bb03f8 | abulyomon/exercises | /locations.py | 5,205 | 4.0625 | 4 | """Coding exercise
You have a list of Cartesian coordinates of locations: List[ (Double, Double) ]. You have a second list of
approximate locations, of the same type. For example:
List 1:
[ (2.5, 2.1),
(0.9, 1.8),
(-2.5, 2.1), …]
List 2:
[ (0.0, 0.0),
(0.2, -0.1),
(2.4, 2.2),
(1.0, 2.0), …]
The coo... |
3bcf01364b6cbe7682ad109c4427eaae510a373e | nakulgoel55/skylight | /venv/thoughts_manager.py | 3,884 | 3.78125 | 4 | from edit_text_files import *
from other import *
from encryption_decryption import *
from data import textfile_array, month_to_days
from datetime import date
import datetime
from variables import *
def record_thoughts():
# Prints person's name
print(str(random_greeting()) + " " + str(read_file('name.txt')... |
4d9ba6fce3e837aced0294b7c8492ac112b379fc | isolde18/Class | /returnvalues3.py | 196 | 3.84375 | 4 |
def number():
num1=int(input("Please enter number "))
num2=int(input("Please enter number2 "))
return num1,num2
number1 , number2=number()
print(number1)
print(number2)
|
2737b91d62344bc16ff0532269d955a92c1c46c0 | BryanMorfe/ptdb | /tests/modify_db.py | 1,705 | 4 | 4 | from ptdb import parse
def change_password(email, current_password, new_password):
# This function will return True if we change the password in an entry or false if we couldn't.
# Before anything, we make sure that the current_password and the new_password are different and have a value.
if current_passw... |
9ca1cdfba64bdb0d656bc9a1722450dca83dc99f | TrellixVulnTeam/Demo_933I | /Demo/xiaoxiangkecheng/52week.py | 199 | 3.625 | 4 | week = 52
money = 10
money_total = 0
for i in range(week):
money_total += money
print(f'第{i}周,存入{money}元,总计{money_total}元')
money += 10
print(money_total)
|
54ed4339bf7ffbba7755fc612bba620e63788af8 | SimOgaard/MdhCases | /MdhCases/attgöralista.py | 2,545 | 3.765625 | 4 | #att göra lista
import pickle
import os
import json
längd = 60
linje = ("_"*längd)
thisdict = {}
menu = ["List | List todo","Add | Add todo","Check | check todo","Delete | delete todo",linje,"Save | Save todo to files", "Load | Load todo from files", linje]
metod = ["list", "add", "check", "delete", "save", "... |
731acb4236916b26e4ddbf91cf802d0d82560446 | WhiteRobe/ShuaTi | /leetcode/_test_/tree/test_删除子文件夹5231.py | 930 | 3.703125 | 4 | import unittest
from leetcode.tree import 删除子文件夹5231 as tT
class MyTestCase(unittest.TestCase):
def test_case_1(self):
s = tT.Solution()
self.assertEqual(["/a", "/c/d", "/c/f"], s.removeSubfolders(folder=["/a", "/a/b", "/c/d", "/c/d/e", "/c/f"]))
def test_case_2(self):
s = tT.Solution... |
b15acda680593474fa1ded5ce60f5875d1cb7294 | daniel-reich/turbo-robot | /437h8sNsWAPCcMRSg_23.py | 784 | 4.1875 | 4 | """
Write a function that returns `True` if the given number `num` is a product of
any two prime numbers.
### Examples
product_of_primes(2059) ➞ True
# 29*71=2059
product_of_primes(10) ➞ True
# 2*5=10
product_of_primes(25) ➞ True
# 5*5=25
product_of_primes(999) ➞ False
... |
1df5d570d004803df7766618e76c4c2a60d18aef | mischelay2001/WTCSC121 | /CSC121Lab01_Lab08_Misc/CSC121Lab2Problem4_PizzaSoda.py | 915 | 4.21875 | 4 | __author__ = 'Michele Johnson'
# Program Requirements
# A group of high school students are selling pizza and soda during a basketball game to raise fund for a field trip.
# Pizza is $3.50 per slice and soda is $1.25 per cup. Design a program to do the following.
# Ask the user to enter number of cups of soda ... |
457427a8dca45cfdf072cfe56ed9d1dcc156b1b7 | yongxuUSTC/challenges | /binary-tree-traversal-post-order.py | 2,433 | 4.0625 | 4 | '''Binary Tree Class and its methods'''
class BinaryTree:
def __init__(self, data):
self.data = data # root node
self.left = None # left child
self.right = None # right child
# set data
def setData(self, data):
self.data = data
# get data
def getData(self):
return self.data
# get left child of a ... |
392a4b26ca0a981f128dfee66c7c976157d59b7a | nvlinh/Python | /PythonCrashCourse2nd/Chap_4_WorkingWithLists/list.py | 3,277 | 4.375 | 4 | # 1. Looping through an entire list
foods = ['fish', 'meat', 'egg']
for food in foods:
print(food)
# 2. Avoid indentation error
print('2. Avoid indentation error')
# 2.1 Forgetting to ident
magicians = ['alice', 'david', 'carolina']
for magician in magicians:
# if print(magician) don't have indent in the left ... |
776883c023ee7d2a0fcbf7b8ce5c4f9c669e388f | daltonleshan/Just4Fun | /quicksort.py | 550 | 3.859375 | 4 | def partition(numbers, l, r):
pivot = numbers[r]
i = 0
for j in range(r):
if numbers[j] <= pivot:
numbers[j], numbers[i] = numbers[i], numbers[j]
i += 1
numbers[i], numbers[r] = numbers[r], numbers[i]
return i
def quicksort(numbers, l, r):
if l < r:
... |
e94f939d29ce6d949c4a425e6299b2e33870a694 | AdityaMisra/find_path_in_maze | /find_path.py | 1,309 | 3.625 | 4 | def is_cell_in_constraints(maze, x, y, n, m):
if n > x >= 0 and m > y >= 0 and maze[x][y] == 1:
return True
return False
def find_path(maze, x, y, cells_travelled, n, m):
if x == n - 1 and y == m - 1:
cells_travelled.append((x, y))
return True
if is_cell_in_constraints(maze,... |
6cd500bc83b4cbc2feaa76e3e399cb5daba6bd85 | nRookie/python | /effectivePython/37Item.py | 5,847 | 3.890625 | 4 | '''
Item 37: Use Threads for Blocking I/O , Avoid for Parallelism
The standard implementation of Python is called CPython. CPython
runs a Python program in two steps. First, it parses and
complies the source text into bytecode. Then, it runs the
bytecode using a stack-based interpreter. The bytecode interpreter... |
4ef41ed184a271b3e355a90fdfd42b71dd461b02 | abiewardani/robotorial_scrapping | /asset.py | 964 | 3.5625 | 4 | from utils import cleansingValue
def assetCalculation(data, historyYear, quartal, index):
assetNow = 0
assetLastQuartal = 0
assetNowRaw = 0
assetLastQuartalRaw = 0
for i, row in enumerate(data[index]):
if quartal > 3:
if i == 1:
assetNowRaw = row
... |
cad0ab9170353bd352f477ae39e4f3ec9e5ea157 | gwiily/Python-Crash-Course-Practice | /chapter10/10-10.py | 243 | 3.734375 | 4 | filename = 'alice.txt'
try:
with open(filename) as f:
contents = f.read()
except FileNotFoundError:
print("Can't find " + filename)
else:
times = contents.lower().count('the')
print("Word 'the' has been found " + str(times) + " times.") |
4fa0acd0d82c856015bad85d65dc685c3d6e8d8b | apophis981/programming_solutions | /lists/lists.py | 1,967 | 4.21875 | 4 | #!/usr/bin/python
listint = [1,4,3,5,6,7,8,2]
listchar = ['c','a','r','a','t','h']
# Index
# c
print(listchar[0])
# Negative indexing
# h
print(listchar[-1])
#prints t
print(listchar[-2])
# Slices
# 3rd to 5th element ['r', 'a', 't']
print(listchar[2:5])
# beginning to 3rd last character ['c', 'a', 'r']
print(lis... |
d76534596519a60d3c9f402635149485c1dfdbdc | King-liangbaikai/python-turtle | /捂脸哭表情包.py | 3,669 | 4.03125 | 4 | import turtle
# 画指定的任意圆弧
def arc(sa, ea, x, y, r): # start angle,end angle,circle center,radius
turtle.penup()
turtle.goto(x, y)
turtle.setheading(0)
turtle.left(sa)
turtle.fd(r)
turtle.pendown()
turtle.left(90)
turtle.circle(r, (ea - sa))
return turtle.position()
turtle... |
ff72998a7fc32c14441a108d6b6d50abc2006f0d | ivanji/csps | /fibonacci/fibMemo.py | 254 | 3.71875 | 4 | from typing import Dict
memo: Dict[int, int] = {0: 0, 1:1} # Base case
def fib(n: int) -> int:
if n not in memo:
memo[n] = fib(n - 1) + fib(n-2) #memoization
return memo[n]
if __name__ == "__main__":
print(fib(5))
print(fib(70)) |
5f33886568adc815303ab40d42b7cd1f666edde2 | landonsanders/python-dive | /linked-list.py | 509 | 3.703125 | 4 | class Node():
def __init__(self, cargo=0, nextNode=None):
self.cargo = cargo
self.nextNode = nextNode
def __str__(self):
return str(self.cargo)
node0 = Node(0)
node1 = Node(1)
node2 = Node(2)
node0.nextNode = node1
node1.nextNode = node2
node = node0
while node:
... |
fc17fee3406098eb1e1de341ee47b489cb5e0ba9 | grovesr/foo_bar | /foo_bar/carrotland.py | 23,766 | 4.03125 | 4 | '''
Created on Jan 30, 2016
@author: grovesr
google foo.bar challenge 4.1
Carrotland
==========
The rabbits are free at last, free from that horrible zombie science
experiment. They need a happy, safe home, where they can recover.
You have a dream, a dream of carrots, lots of carrots, planted in neat rows and
col... |
cf324e1d42d6498a2bcd908316c8eca46a60d4ed | nikc22/text_adventure | /backpack.py | 1,426 | 3.9375 | 4 | class Backpack():
def __init__(self, capacity):
"""Creates a Backpack, setting the max capacity"""
self.items = {}
self.weight = 0
self.max_weight = capacity
def get_inventory(self):
"""Prints the inventory in the backpack"""
if len(self.items) == 0:
... |
8a7ad5ceaa1413a23a256a7af6ac6e821da324bc | wnyoung/Sensor | /gpio/gpio_led/sample2.py | 564 | 3.78125 | 4 | import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
led_pin1 = 14
led_pin2 = 15
GPIO.setup(led_pin1, GPIO.OUT)
GPIO.setup(led_pin2, GPIO.OUT)
def Blink(numTimes,speed):
for i in range(0,numTimes):
print ("Iteration " + str(i+1))
GPIO.output(14,True)
time.sl... |
4645583949d89b2ab6ace0294d1de277d90e9120 | nullconfig/wsgi-calculator | /calculator.py | 5,559 | 4.15625 | 4 | """
For your homework this week, you'll be creating a wsgi application of
your own.
You'll create an online calculator that can perform several operations.
You'll need to support:
* Addition
* Subtractions
* Multiplication
* Division
Your users should be able to send appropriate requests and get back
proper... |
e1786a1f18640979af624aea10e07470fbbed09e | khalsakuldeep77/Competitive-programming | /valid parentheses.py | 507 | 3.65625 | 4 | class Solution:
def isValid(self, s: str) -> bool:
Dict={'[':']','{':'}','(':')'}
stack=[]
openn=['(','{','[']
for i in s:
if(i in openn):
stack.append(i)
elif i not in openn:
if(len(stack)==0):
return 0
... |
0420e3b5d17252060553d2394fb973997c08816f | vivekjha1213/Algorithms-practice.py | /data structure using python.py/array_question/tower_hunoi.py | 294 | 3.875 | 4 |
def TowerOfHanoi(n , start, mid, end):
if n == 1:
print("Move disk 1 from rod",start,"to rod",mid)
return
TowerOfHanoi(n-1, start, end, mid)
print("Move disk",n,"from rod",start,"to rod",mid)
TowerOfHanoi(n-1, end, mid, start)
# Driver code
n = 3
TowerOfHanoi(n, 'A', 'C', 'B')
|
dd8dbc43f9035fa227dce8325043fb14d7e08605 | capac/python-exercises | /edx-cs50/caesar.py | 937 | 4.09375 | 4 | from sys import argv
def rotate_char(char):
if char.isalpha():
if char.islower():
return chr(ord('a') + (ord(char) - ord('a') + int(argv[1])) % 26)
else:
return chr(ord('A') + (ord(char) - ord('A') + int(argv[1])) % 26)
return char
def main():
if len(argv) == 2:
... |
0406a1538909b5889a4a7f99878f83f0802ab91b | jurueta/exercism-python | /anagram/anagram.py | 472 | 3.75 | 4 | def find_anagrams(word, candidates):
resultado = list()
for letra in candidates:
if(letra.lower() != word.lower()) and (len(letra) == len(word)):
cant = 0
new_word = word
for i in letra.lower():
if i in new_word.lower():
cant += 1
... |
ca9ca4ca58adc46dd508af202413bdba59d1fd77 | Voron07137/Portfolio_experience | /07.2017/labyr_oop.py | 5,610 | 3.515625 | 4 | class Labyrinth:
def __init__(self, mat, begin, end):
self.matrix = mat
self.action(begin, end)
def init_walls(self):
for i in range(len(self.matrix)):
for j in range(len(self.matrix[i])):
if self.matrix[i][j] == 1:
self.matrix[i][j] = -1
... |
129e37095c66b73e4f0bc75cadf25ba7db39f640 | tahmed5/Basics-Of-NN | /linearregression.py | 2,065 | 3.71875 | 4 | import numpy
import time
def get_coordinates():
global x_coord
global y_coord
x_coord = []
y_coord = []
entering_coordinates = True
print('Enter Your x and y Coordinates in the format x,y')
print("Type 'done' when you are finished")
while entering_coordinates == True:
... |
daa9e0b1763f827a0e4ac37e06bf3b950e66a4e7 | TuxMan20/CS50-2017 | /pset6/mario.py | 485 | 3.9375 | 4 |
## Infinite loop to get an Int from the user, breaks when it is accepted
while True:
try:
h = int(input("Height: "))
except ValueError:
continue
else:
if h >= 0 and h < 20:
break
else:
continue
hashes = 1
spaces = h-1
for i in range(h):
for j i... |
c37cfa1798753fcd44b4b5174477a54fb3b798d8 | kevalrathod/Python-Learning-Practice | /other_Exmple/FileInput_Output.py | 371 | 3.796875 | 4 | #reading file and output file
f=open('myfile.txt','r')
print(f.name())
print(f.mode())
f.close()
#2nd method
with open('myfile.txt','r') as f:
size=4
fop=f.read(size)
while len(fop)>0:
print(fop,end='*')
fop=f.read(size)
#copy one file to another
with open('myfile.txt','r') as f:
with open('mynewtext.tx... |
a357db0a866dfe5567c67cb1bd2f1a3a75d3fc70 | deepsinghsodhi/python-OOPS-assignments | /Programs using Functions/01) Telephon_bill.py | 1,591 | 4.03125 | 4 | '''
1) Write a program that prompts the user to input number of calls
and calculate the monthly telephone bills as per the following rule:
Minimum Rs. 200 for up to 100 calls. Plus Rs. 0.60 per call for next 50 calls.
Plus Rs. 0.50 per call for next 50 calls. Plus Rs. 0.40 per call for any call beyond 200 calls.
'... |
00adb4416fb05217b477a32eb7bc713e98403bae | zhanggq96/AnimeStride | /Recommender/RC/RecommenderC.py | 6,126 | 3.71875 | 4 | ## Based off of python implementation of Coursera ML 1 Course.
## https://github.com/mstampfer/Coursera-Stanford-ML-Python
##
from matplotlib import use, cm
use('TkAgg')
import numpy as np
from scipy.optimize import minimize
# from show import show
## =============== Part 1: Loading movie ratings dataset ===========... |
b7f45c8336d421fcecb4be56503ee2ccf23516fd | yinghe616/NEKCEM | /bin/mapdegrees | 1,770 | 3.6875 | 4 | #! /usr/bin/env python
import sys
def establish_connectivity(elements):
result = []
def connected(a, b):
result.append((a,b))
el_point_count = len(elements[0])-1
if el_point_count == 4:
for quad in elements:
connected(quad[1], quad[2])
connected(quad[2], quad[4])
connected(quad[4],... |
7626d591317ba624a890c66ef3da9533d0283b52 | nd9dy/Algorithmic-Toolbox | /Algorithm Toolbox/Week 2 Code/Fibonacci Partial Last Digit Sum.py | 865 | 3.671875 | 4 | # Uses python3
import sys
them = [0,1,1]
i = 3
while True:
if them[i - 1] == 1 and them[i - 2] == 0:
break
new = (them[i - 1] % 10) + (them[i - 2] % 10)
real = new % 10
them.append(real)
i += 1
def fibonacci_sum_naive(n,m):
global them
if n == m:
if n < 2:
ret... |
2b2d0fa76ada5baa16f4d41d4b6cd64465d9f0db | wjddp0220/wjddp0000 | /파이썬/210723ox.py | 253 | 3.828125 | 4 | num = input("o 와 x를 배열하시오 : ")
score = []
for n in range(0, len(num)):
if(num[n] == "o"):
score += 1
elif(num[n] == "x"):
score += 0
elif(num[n] == num[n-1] == "o"):
score +=
score.append
|
a3a73030b3ccae8a84cb0fe8d0f4ce82a1e813c2 | jvasilakes/Search_Algorithms | /dfs.py | 691 | 3.984375 | 4 | #! /usr/bin/python2
# A depth-first search of graph for end
graph = {
'1': ['2', '3', '4'],
'2': ['5', '6'],
'5': ['9', '10'],
'4': ['7', '8'],
'7': ['8', '11', '12'],
'11': ['13', '14', '15'],
'12': ['16']
}
graph2 = {
'1': ['2', '3', '4'],
'2': ['5'],
'4': ['6'],
'5': ['6', '7'],
'6': ['7', '8']
}
d... |
1d8008e8d24ae3135cf971a910716b3c4f04bf1d | Sukhrobjon/leetcode | /easy/783_minimum_ difference_between_bst_nodes.py | 1,482 | 4.0625 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
"""
Given a Binary Search Tree (BST) with the root node root, return the minimum
difference between the values of any two different nodes in the tree... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.