blob_id stringlengths 40 40 | repo_name stringlengths 5 119 | path stringlengths 2 424 | length_bytes int64 36 888k | score float64 3.5 5.22 | int_score int64 4 5 | text stringlengths 27 888k |
|---|---|---|---|---|---|---|
49440bee99fe5e5c623f13d0e2a8932bbf9ecc6d | humana42/curso_em_video_Python | /ex055.py | 198 | 3.953125 | 4 | pesos = [ ]
for p in range(0,5):
peso = float(input('Digite o peso: '))
pesos.append(peso)
print('O maior peso é {}Kg' .format(max(pesos)))
print('O menor peso é {}Kg' .format(min(pesos))) |
0c465df382bbaa53b7ac968e51b8af3d86d58d51 | srea8/cookbook_python | /08/ExtendPropertyInSubClass.py | 2,446 | 3.96875 | 4 | # !/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Srea
# @Date: 2019-12-05 21:57:21
# @Last Modified by: srea
# @Last Modified time: 2019-12-05 22:27:00
#****************************#
#基本的@property使用,可以把函数当做属性用,@property的set,deleter,get
#
#
#****************************#
####@property demo1
class Person:... |
e812b84659a74be5a2b78d1b4dc419530a39fe86 | marczakkordian/python_code_me_training | /03_collections_homework/03_dictionary/04.py | 284 | 3.71875 | 4 | # Utworz tabliczkę mnożenia jako zagnieżdżoną listę o rozmiarze 10 x 10, wypełnioną wynikami mnożenia wiersz × kolumna.
multi_table = []
for i in range(1, 11):
multi_table.append([])
for j in range(1, 11):
multi_table[i-1].append([i*j])
print(multi_table) |
0ea71547f5e32639ad36c92e23ee5904e5ce3b7d | hugostubler/projet_RO | /tme2.py | 4,468 | 3.78125 | 4 | #!/usr/bin/env python
# coding: utf-8
# ### kcore decomposition
#
# In this notebook, you will find the python code for kcore decomposition (tme2). You can load any graph using the first function, which turns a txt file (usually a graph presented in list of edges) into a dictionnary structure of graph, which correspo... |
6cec76d04ce015e5d162c6b2f2512be3f49db355 | Andre-300/pdsnd_github | /bikeshare.py | 7,814 | 4.21875 | 4 | import time
import pandas as pd
import numpy as np
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv' }
def get_filters():
"""
Asks user to specify a city, month, and day to analyze.
Returns:
(str) city - name o... |
eaa13fa8f6bb2ab287196082e24d121b399326ba | orange-eng/Leetcode | /middle/22_Generate_Parentheses.py | 574 | 3.546875 | 4 | # Leetcode practice
# author: orange
# date: 2021/6/8
# 递归法(还是学不会呀)
class Solution:
def generateParenthesis(self, n: int):
ans = []
def DFS(s,L,R):
if L<R or L>n or R>n:
return
if L == n and R == n:
ans.append(str(s))
retur... |
b3ac0fbaf398833737607940fede0714d6f6d41d | duanyiting2018/learning_python | /bounce_ball_game.py | 1,418 | 3.6875 | 4 | from tkinter import *
import time,random
tk=Tk()
tk.title("Bounce ball game")
tk.resizable(0,0)
tk.wm_attributes("-topmost",1)
c=Canvas(tk,width=500,height=450,bd=0,highlightthickness=0)
c.pack()
tk.update()
class ball:
def __init__(self,ca,co):
self.ca=ca
self.id=ca.create_oval(10,10,30,3... |
d7d55d52218f76b7a5585ed5c31e661a8c8a3c49 | PanMaster13/Python-Programming | /Week 3/Practice files/Week 3, Practice 3.py | 179 | 3.5 | 4 | list1 = ["Winter","Summer","Autumn"]
list2 = ["Winter","Spring"]
list3 = ["Spring"]
set1 = set(list1)
set2 = set(list2)
set3 = set(list3)
answer = set1-set2-set3
print(answer)
|
0bee54c17cd22b4b91adb298c30a0a0c4d9304c9 | conleyl9125/Conley_Liam | /PYLesson_02/Lab_2.py | 259 | 3.578125 | 4 | x=8
y=9
print(x*y)
name = "Liam Conley"
address = "13579"
address2 = " Main Street"
city = "San Diego"
zipcode = " 92130"
state=", CA"
print(name)
print(address + address2)
print(city + state + zipcode)
w = 37
l = 54
h = 76
print((w * l + h * l + h * w) * 2)
|
28dd35a6107f76352bb81002ad917d5cfe938112 | HenDGS/Aprendendo-Python | /python/while_4.py | 355 | 3.75 | 4 | respostas={}
booleano=True
while booleano:
nome = input("Qual é o seu nome? ")
resposta = input("Qual é o seu animal favorito? ")
respostas[nome]=resposta
a=input("Vai deixar outra pessoas responder? (sim / não) ")
if a=="não":
booleano=False
for x, y in respostas.items():
print ("O animal favorito do(a)... |
205e8956f53247180fdc0efc367b1c7a72d06591 | pedrocolon93/JPythonLex | /Python Lexical Analyzer/LexicalAnalyzerPython/files/blablafile.py | 1,011 | 3.59375 | 4 | def srep(p):
'''Print the coefficient list as a polynomial.'''
# Get the exponent of first coefficient, plus 1.
exp = len(p)
# Go through the coefs and turn them into terms.
retval = ''
while p:
# Adjust exponent. Done here so continue will run it.
exp = exp - 1
coef ... |
ab9d413b9c55b83fbae3cf3dc7e966f287a1dd70 | emma-rose22/practice_problems | /leet_commonchars.py | 1,444 | 4.03125 | 4 | '''
Given an array A of strings made only from lowercase letters, return a list of all characters
that show up in all strings within the list (including duplicates). For example, if a character
occurs 3 times in all strings but not 4 times, you need to include that character three times
in the final answer.
You m... |
a57df7ea5ff8ed90b9460e5ff5f07f4ea2a29920 | ATSGlobe/DataScienceTraining | /nihad/python_crash_course.py | 1,161 | 3.90625 | 4 | s = 'Hi there Sam!'
print(s.split())
planet = "Earth"
diameter = 12742
print("The diameter of {} is {} kilometers.".format(planet,diameter))
lst = [1,2,[3,4],[5,[100,200,['hello']],23,11],1,7]
print(lst[3][1][2][0])
d = {'k1':[1,2,3,{'tricky':['oh','man','inception',{'target':[1,2,3,'hello']}]}]}
print(d['k1'][3]['t... |
2afd744e5550c94f06e19429be2693b128aafc5e | gtycody/Python-learning-plan | /dict_demo.py | 259 | 4.0625 | 4 | dict1 = {"brand": "Ford",
"model": "Mustang",
"year": 2016,
"price": 50000}
print(dict1)
print(len(dict1))
print(type(dict1))
for x in dict1.keys():
print(x)
for x, y in dict1.items():
print(x, y)
print(dict1["brand"])
|
229692176cf112497c996ed64973a0496723be0b | arielt/HackerRank | /word-break.py | 831 | 3.71875 | 4 | # Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
class Solution(object):
def wordBreak(self, s, wordDict):
"""
:type s: str
:type wordDict: List[str]
... |
3ed8dfd1371d7ff78887df378d706bca1c1c54e9 | Micky143/LPU_Python | /tuple,packing,dic etc..py | 2,012 | 3.984375 | 4 | rollno=[1,3,8,2,7]
print(rollno)
seating=[]
rollno.sort()
seating=rollno
print(seating)
#List : finite,ordered,mutable sequence of elements
#extend,insert,remove,clear(),count(),index(value,[start,[stop]]),pop([index])
#sort(key=None,reverse=False)
#Dictionary : Mutable map from hashable values to ar... |
657359c0f798ff7d67d5b754fbcf541777afaac5 | raoweijin/python | /palindrome.py | 672 | 3.515625 | 4 | class Solution:
"""
@param: s: A string
@return: A list of lists of string
"""
def isPalindrome(self, s):
for i in range(len(s)):
if s[i] != s[len(s)-1-i]: return False
return True
def dfs(self, s, stringlist):
if len(s) == 0: self.res.append(stringlist)... |
b76169e5e14a49bcc7a185bba82b749eefc4662c | kiryong-lee/Algorithm | /Codility/15-2.CountDistinctSlices.py | 860 | 3.578125 | 4 | # you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
# https://app.codility.com/demo/results/trainingPJZWAM-CXM/
def solution(M, A):
# write your code in Python 3.6
N = len(A)
if N == 1:
return 1
flag = [False] * (M + 1)
result = 0
start, e... |
0508c92f1a209530711641cd9e283f44040a2e76 | nana0calm/PythonLabs | /PyLab1/task11Lab1.py | 392 | 4.125 | 4 | # Напишите генератор frange как аналог range() с дробным шагом.
#Пример вызова:
#for x in frange(1, 5, 0.1): print(x)
# выводит 1 1.1 1.2 1.3 1.4 … 4.9
def frange(start, end, step):
while start<=end-0.2:
start +=step
yield start
for x in frange(1, 5, 0.1):
print(... |
cb9da4c2698cc8a191e8d75f83bce02f35e5b32b | Niteshraiss/python | /python_module1/week7/small.py | 248 | 3.734375 | 4 | small = None
for i in [10, 1, 1, 0, 4, 5, 2, 9]:
if small is None:
small = i
print('value of small', small)
elif i < small:
print('value of i', i)
small = i
print(small, '\t', i)
print('Smallest', small)
|
6cf1aa1d471ac3381d62ece02288576dc715ad4d | aclogreco/lpthw | /ex17.py | 604 | 3.8125 | 4 | # ex17.py
"""
Exercise 17 -- Learn Python the Hard Way -- Zed A. Shaw
A.C. LoGreco
"""
from sys import argv
from os.path import exists
# unpack cmd line arguments
script, from_file, to_file = argv
print "Copying from %s to %s" % (from_file, to_file)
in_file = open(from_file)
indata = in_file.read()
#print "The inp... |
f77db93cc190d7ed677d61aa96f9851b0fe1e4af | pfcskms1997/osscap2020 | /source_code/catchmind_ver2.py | 2,183 | 4 | 4 | #아직 해결 못한거:LED 출력, 음성인식
#공룡게임으로 얻은 색깔 블럭 갯수를 colorlistcnt
#색(빨주노초파보흰) colorlist
#colorlist=["red","orange","yellow","green","blue","purple","gray"]
colorlist=["black","red","green","yellow","blue","purple","skyblue"]
#colorlistcnt=[0,2,3,0,4,2,3]
colorlistcnt=[1,2,3,1,4,2,3]
from turtle import*
import time
import l... |
6a4130e2d71d6885f630a6c784ff05ec7cf81085 | johndamen/streamplot2d | /streamplot2d.py | 4,070 | 3.734375 | 4 | from matplotlib import streamplot, pyplot as plt
import numpy as np
from scipy.interpolate import griddata
def streamplot2d(ax, X, Y, U, V, nx=None, ny=None, color=None, linewidth=None, scale=1, **kw):
"""
Create a streamplot from an uneven grid
:param ax: Axes instance
:param X: multidimensional arra... |
eb72cfba09bd4fa36fd277830afea0f5e482fa78 | nikhil-sethi/courses | /Algorithmic Toolbox-Coursera/Algorithmic Warm Up/Last Digit of the Sum of Fibonacci Numbers Again/last_digit_of_the_sum_of_fibonacci_numbers_again.py | 1,227 | 3.75 | 4 | # python3
def last_digit_of_the_sum_of_fibonacci_numbers_again_naive(from_index, to_index):
assert 0 <= from_index <= to_index <= 10 ** 18
if to_index == 0:
return 0
fibonacci_numbers = [0] * (to_index + 1)
fibonacci_numbers[0] = 0
fibonacci_numbers[1] = 1
for i in range(2, to_index ... |
0b2617a207beb4799f12a40a3229b8bf10ba6a95 | pegasus-dyh/pyqt5_GUI | /learn/table_tree/DataLocation.py | 2,952 | 3.984375 | 4 | '''
在表格中快速定位到特定的行
1. 数据的定位:findItems 返回一个列表
2. 如果找到了满足条件的单元格,会定位到单元格所在的行:setSliderPosition(row)
Python笔记:
python字符串格式化有两种方法 https://www.cnblogs.com/poloyy/p/12443158.html
1 %
2 format(功能更强大)
1 %示例
%o:oct 八进制
%d:dec 十进制
%x:hex 十六进制
输入
print("整数:%d,%d,%d" % (1, 22.22, 33))
print("整数不足5位,左边补空格 %5d " % 22)
print(... |
d536ad106a052cef9d1a2fcffddfa3b357d2c225 | harishbharatham/Python_Programming_Skills | /Prob12_3.py | 661 | 3.71875 | 4 | from account import account, atm
for i in range (10):
accountlist = []
accountlist.append(account(id1 = i))
def main1():
print(atmSim.mainMenu())
choiceInput = eval(input("Enter a choice:" ))
if choiceInput == 1:
print(atmSim.GetBalance())
main1()
elif choiceInput =... |
26cf7ccddb79917d66208c37d678de4179958df4 | EpsilonHF/Leetcode | /Python/103.py | 1,242 | 4.03125 | 4 | """
Given a binary tree, return the zigzag level order traversal of its
nodes' values. (ie, from left to right, then right to left for the
next level and alternate between).
For example:
Given binary tree [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
return its zigzag level order traversal as:
[
... |
9f3f233f82f608ad663ed4b87f03b84f6c156638 | NilPatil7087/Python_Practice | /linkedlist.py | 2,329 | 4.0625 | 4 | class Node:
def __init__(self, value):
self.data = value
self.next = None
def get_data(self):
return self.data
def get_next(self):
return self.next
def set_data(self, value):
self.data = value
def set_next(self, next_node):
self.next = next_node
... |
3110557b32b40cc509140cf26667c32829dbd31e | diego-guisosi/python-norsk | /02-beyond-the-basics/03-decorators/08-decorators_instances.py | 748 | 4 | 4 | # Applying an instance as a decorator calls the instance
# This kind of decorators are useful to create collections of decorated functions, which can dinamically be
# controlled
class Trace:
def __init__(self):
self.enabled = True
def __call__(self, f):
def wrap(*args, **kwargs):
... |
9e76abd642b7c3525728c933709f7d8365074374 | KochetovNicolai/Python_822 | /gulevich/review_1/dfs_generator.py | 1,744 | 3.75 | 4 | import random
from abc import ABC, abstractmethod
from Maze import Maze, Cell, State
from Maze_generator import MazeGenerator
class DfsGenerator(MazeGenerator):
used = []
@classmethod
def get_neighbours(cls, cell, width, height):
# записывает в neighbours непосещённых соседей cell
... |
bbb5869d16e172a6b4fd0452382aa6bae315e0b7 | khadafyb/all-labs- | /lab6quest4.py | 157 | 3.703125 | 4 | def check_list(list1):
new2=[]
new1=[]
for i in list1:
if i==i:
new2.append(i)
print(new2)
return list1
|
270d8d8805e82ce027b65cd9c5afe46b725236ca | xiaoyaoshuai/- | /作业/7.20/058数字排序倒序.py | 92 | 3.703125 | 4 | info = [1,2,3,4,5]
info.sort(reverse=True)
print(info)
s = [1,2,3,4,5]
b = s[::-1]
print(b)
|
5fc28ce60be375b986e43fc8874791204ca3879e | MaratNurzhan/WD | /week_8/informatics/if_else/D1.py | 84 | 3.59375 | 4 | x=int(input())
if x<0:
output=-1
elif x==0:
output=0
elif x>0:
output=1 |
fde925f0273ba18b21932a416de07bf85bbb3346 | Senlian/LeetCode | /v18.py | 980 | 3.5 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
给定一个包含 n 个整数的数组 nums 和一个目标值 target,判断 nums 中是否存在四个元素 a,b,c 和 d ,
使得 a + b + c + d 的值与 target 相等?找出所有满足条件且不重复的四元组。
注意:
答案中不可以包含重复的四元组。
示例:
给定数组 nums = [1, 0, -1, 0, -2, 2],和 target = 0。
满足要求的四元组集合为:
[
[-1, 0, 0, 1],
[-2, -1, 1, 2],
[-2, 0, 0, 2]
]
来源:力扣(L... |
b490af36be7c268f0025d286948bbe5188831333 | LuLuuD/MSAI-Learn | /CV-Emmahuu/Code/Python basic practice/action13_0421.py | 1,420 | 4 | 4 | # -*- coding:utf-8 -*-
#@Time: 2020/4/21
#@Author: EmmaHuu
#@File: action13_0421
"""
"""
# def searchInsert2(nums:list, target:int, result = 0) -> int:
# def splitNum(nums, target, middle):
# global result
# if target <= nums[middle] and target >= nums[middle - 1]:
# result += middle
# splitNum(nums[middle ... |
fa472d74173aed424e1f1e30058f03c4d9930290 | gupongelupe/ExerciciosFeitosPython | /ex007.py | 149 | 3.609375 | 4 | n1 = float(input('Digite sua nota: '))
n2 = float(input('Digite sua nota: '))
media = (n1 + n2) / 2
print('Sua média é: {:.2f}'.format(media))
|
37da6d72b69936af2bd08ba8634183b7eb72cc48 | stubentiger/prog_task | /prog_task.py | 971 | 3.96875 | 4 | from collections import defaultdict
import csv
def main():
with open("product.template.csv") as opned_file:
reader = csv.reader(opned_file)
# skip header
next(reader, None)
# empty dict, when using for the first time sets default value of int (0)
groups = defaultdict(int)
... |
c91d9442f3203da1ca4cf43b7f4a982335595692 | s-zhang/puzzlehunt-tools | /puzzle-utils/words/wordsearch.py | 4,518 | 3.8125 | 4 | from .utils.dictionary import get_current_dictionary
class WordSearchResult:
def __init__(self, word, row, column, direction):
self.word = word
self.row = row
self.column = column
self.direction = direction
def wordsearch_reduce(grid, words):
"""
Finds the provided word... |
0e7c519ed9d42a9f94d828e2c53a0d8310b6115d | L0ganhowlett/Python_workbook-Ben_Stephenson | /18 Volume of cylinder.py | 236 | 4.0625 | 4 | #18 Volume of Cylinder
#Asking for radius and height
r = float(input("Enter the radius = "))
h = float(input("Enter the height = "))
import math
#Volume of cylinder(v)
print("Volume of cyliner = ",math.pi * h * (r ** 2)," sq.m")
|
38bf6ab07e3cdc2d86723b60173e5c5a329b4534 | yongxuUSTC/challenges | /longest-common-subsequence-find-one.py | 2,685 | 3.796875 | 4 | #Question: Given two sequences find a Longest Common Subsequence (LCS)
'''
A subsequence is a sequence that appears in the same relative order, but not necessarily contiguous.
So a string of length n has 2^n different possible subsequences.
References
1. http://www.geeksforgeeks.org/dynamic-programming-set-4-longest-... |
b7bb6a67411c62ff52bc3defd2743b2d060a5583 | ArunRamachandran/Problem-Solving-With-Algorithms-and-Datastructers | /Chapter5/selection_sort.py | 566 | 3.828125 | 4 | """ More improved version of sorting, instead of exchanging the pos
of each element in every pass, only one element will be shifted to
its corresponding position in each pass. """
def selection_sort(a_list) :
for fill_sloat in range(len(a_list) - 1, 0, -1) :
pos_max = 0
for location in range(1, fill_sloat + 1... |
009c40ed1d44ccbe2a1548f82f50e76ba9b35367 | RNTejas/programming | /Functions_An_Introduction/Functions/15.Guessing game in while loop.py | 706 | 4.0625 | 4 | import random
def get_integer(prompt):
while True:
temp = input(prompt)
if temp.isnumeric():
return int(temp)
# else:
print("Please choose an Integer")
highest = 1000
answer = random.randint(1, highest)
print(answer)
guess = 0
print("Please choose a ... |
d0186cbe01e8cf3dbaedd5f31369b8231bbc2d04 | PVequalnRT/Python_Study | /Python Lab/calculate_video_time/calculate_video_time0.py | 1,150 | 3.578125 | 4 | # 유튜브 영상 배속하면 총 걸리는 시간 계산
#시간 계산 함수
def calc(*times):
a = float(input("배속을 입력해 주세요 :"))
i = len(times) - 1
result = list()
while(i >= 0):
if i == len(times) - 1:
result.append(round(times[i] / a, 2))
print(result)
else:
temp = str(round(times[i] / a, 1... |
95640f09cb6136344b6942ffc4bbc49aa0e8c1c4 | khrithik0624/python | /minesweeper.py | 4,426 | 3.671875 | 4 | import random
import re
class Board:
def __init__(self, dim_size, num_bombs):
self.dim_size = dim_size
self.num_bombs = num_bombs
#helper function make_board to create board and plant bombs
self.board = self.make_board()
#assigns values to the board abot the bombs i... |
537df707873607f1ee44f726566c7a25b48f4882 | csbailey5t/python-typing-koans | /koans/py/100-easy-variable-wrong-type.py | 292 | 3.671875 | 4 | """
Koan to learn the variable type annotation.
"""
# msg variable is wrongly annotated as int, annotate proper type
msg: str = "hello world!"
# salary is annotated as int, annotate proper type
salary: float = 2345.67
# Set is_active as integer, annotate proper type
is_active: bool = True
|
8af6169c216ef5ae7e39bb7ac62ff9f4e474f6af | ganluannj/Python_practice | /classes/Coordinate.py | 1,420 | 4.21875 | 4 | import math
def sq(x):
return x*x
class Coordinate(object):
def __init__(self, x, y):
self.x = x
self.y = y
def __str__(self):
return "<"+str(self.x)+","+str(self.y)+">"
def distance(self,other):
return math.sqrt(sq(self.x - other.x)
+ sq(self.... |
e545b81fc3ff0bcc9d64b0c02c09858daa0dcd7b | rik0/rk-exempla | /algorithms/python/ilog2.py | 736 | 3.578125 | 4 | def ilog2(n):
'''
Return binary logarithm base two of n.
>>> ilog2(0)
Traceback (most recent call last):
...
ValueError: math domain error
>>> ilog2(-10)
Traceback (most recent call last):
...
ValueError: math domain error
>>> [ilog2(i) for i in range(1, 10)]
[0, 1, 1, 2... |
698f0ada0d591a9dd1033f3251a0866832ba1356 | pravishyatech/python_code | /fun2.py | 836 | 4.1875 | 4 | #wap to create a calculator using functions
def get_value():
x = int(input("Enter the first value : "))
y = int(input("Enter the second value : "))
return (x, y)
def add():
x,y = get_value()
print(x+y)
def subtract():
x,y = get_value()
print(x-y)
def multiply():
x,y =... |
26ea76fdbaf5bf2bba5e1eb3775cb2eec1c96258 | Minification/exercism-track-python | /isogram/isogram.py | 142 | 3.5625 | 4 | def is_isogram(string: str) -> bool:
letters = [s for s in string.casefold() if s.isalpha()]
return len(letters) == len(set(letters))
|
0ad7c8fc162cb6c40315cab59723379464ec7e3f | huicheese/Bootcamp | /Lab3/Lab 3 Example 4.py | 113 | 3.765625 | 4 | x=16
if (x<15):
if(x>8):
print ('apple')
else:
print ('banana')
else:
print ('chiku') |
14c83fa1dbb1e5c91cdcf2169723a47b0c7b0b60 | munyumunyu/Python-for-beginners | /python-exercises/guessing.py | 289 | 4.0625 | 4 | # #This is a simple guessing game in Python.
from random import *
number = randint(1,10)
while True:
guess = input('Pick a number from 1 to 10: ')
guess = int(guess)
if guess < number:
print('Its too low')
elif guess > number:
print('its to high')
else:
print('You Won')
break |
46c6cd1b6a62cb2f9733f32899ed553f1f00740f | pvr30/Python-Tutorial | /GUI Developement/labels_and_fields.py | 504 | 3.71875 | 4 | import tkinter as tk
from tkinter import ttk
def greet():
print(f"Hello {user_name.get() or 'World'} ")
root = tk.Tk()
root.title('Labels')
user_name = tk.StringVar()
name_label = ttk.Label(root, text='Name:')
name_label.pack(side='left', padx=(0,10))
name_entry = ttk.Entry(root, width=20, textvariable=user_nam... |
c1ab3793193f34464a05b0b227f4dbd27e14c2b7 | Dfmaaa/transferfile | /Python31/Sameer_database.py | 5,158 | 3.53125 | 4 | print("░██████╗░█████╗░███╗░░░███╗███████╗███████╗██████╗░ ░█████╗░░█████╗░██╗░░██╗██╗░░██╗░█████╗░██████╗░██╗░██████╗")
print("██╔════╝██╔══██╗████╗░████║██╔════╝██╔════╝██╔══██╗ ██╔══██╗██╔══██╗██║░░██║██║░░██║██╔══██╗██╔══██╗╚█║██╔════╝")
print("╚█████╗░███████║██╔████╔██║█████╗░░█████╗░░██████╔╝ ███████║██║░░╚... |
3efda02b44eccafad3858e02b2818e870573edc7 | ToxicMushroom/bvp-python | /practicum1/piramideblokjes.py | 1,135 | 3.90625 | 4 | volume = 0 # variabele voor het volume van de piramide in bij te houden, geinitialiseerd op 0 omdat een piramide begint vanaf 0
zijde = -1 # variabele voor de huidige zijde in bij te houden, geinitialiseerd op -1 zodat de while lus kan beginnen
vorige_zijde = -1 # variabele om de vorige zijde in bij te houden, geini... |
912b6944e58cae6f0c3db04ffe9a6810e759bf7a | ASAD5401/PYTHON-CODE | /intro to sets(hackerank).py | 302 | 3.796875 | 4 | def average(array):
# your code goes here
a=set(array)
b=list(a)
w=sum(b)
y=len(b)
t=w/y
x="{0:.3f}".format(t)
return x
if __name__ == '__main__':
n = int(input())
arr = list(map(int, input().split()))
result = average(arr)
print(result) |
51db4f241cb477db6046a5b21754f531f0679bd4 | eltinawh/flotbioinfo | /modules/nbautoeval/exercice_regexp.py | 4,475 | 3.78125 | 4 | # -*- coding: utf-8 -*-
from __future__ import print_function
import re
from .exercice_function import ExerciceFunction
class ExerciceRegexp(ExerciceFunction):
"""
With these exercices the students are asked to write a regexp
which is transformed into a function that essentially
takes an input strin... |
9b6dc68ddd81b5211e727f8f3cee6f334978eaff | auttij/aoc2020 | /2/exercise.py | 1,098 | 3.53125 | 4 | filepath = "input.txt"
def read_file_to_arr(filepath):
arr = []
with open(filepath) as fp:
lines = fp.readlines()
for line in lines:
arr.append(line.strip())
return arr
def exercise1(arr):
results = []
for line in arr:
result = check_row1(line)
results.append(result)
return sum(results)
def exercise... |
82e4fa52d5d913e992dfd267b8b24e244f5ede5b | ioef/PPE-100 | /Level3/q7.py | 317 | 4.28125 | 4 | #!/usr/bin/env python
'''
Write a program which can map() to make a list whose elements are square of elements in [1,2,3,4,5,6,7,8,9,10].
Hints:
Use map() to generate a list.
Use lambda to define anonymous functions.
'''
li = [1,2,3,4,5,6,7,8,9,10]
squaredElements = map(lambda x: x**2, li)
print squaredElements
|
a2bdd5fa2632c772d69c9f6c636555bbaa7b8e79 | louisspaghetti/ArminaCollab | /script.py | 1,288 | 4.25 | 4 | import random
running = True
level = 0
moves_remaining = 0
starting_value = 1
operator = 2
operation_list = ["addition", "subtraction", "multiplication", "division"]
#recursive function that applies random operations to a base number to scramble it
def apply_operations(base, operator = 2, iterations = 1, index = rand... |
9c936a7493bf972fc57d28e8bef54ad808445d2d | mattsuri/unit3 | /fri13.py | 410 | 3.8125 | 4 | #Matthew Suriawianta
#3/1/18
#fri13.py - prints out the next 10 Friday the 13th
from datetime import date
yearNow = date.today().year
monthNow = date.today().month
dayNow = date.today().day
monthAdd = 0
yearAdd = 0
if (dayNow > 13 and yearNow == 12):
if dayNow > 13:
monthAdd = 1
else:
monthAdd = 0
... |
da89a798b3999f24b168e03bf4de36210db1fcec | AliE99/speech-assistant | /main.py | 1,306 | 3.515625 | 4 | import speech_recognition as sr
import webbrowser
import time
r = sr.Recognizer()
def record_audio(ask=False):
with sr.Microphone() as source:
if ask:
print(ask)
audio = r.listen(source)
voice_data = ''
try:
voice_data = r.recognize_google(audio)
ex... |
7eb6e2fd5a853eeaa6fe0ba23d3f7c4a8ff20fcd | acc-cosc-1336/cosc-1336-spring-2018-Miguelh1997 | /src/homework/main/main_homework7.py | 743 | 3.71875 | 4 | #write import statement for homework 7 file
from src.homework.homework7 import pdistance, pdistance_matrix
'''
Write a main function to...
Read p_distance.dat file
From the file data, create a two-dimensional list like the following example:
[
['T','T','T','C','C','A','T','T','T','A'],
['G','A','T','T','C','A','T','... |
16cc704cb10dc4acb83823c5e4defddb91b16e5d | kaiwensun/leetcode | /1501-2000/1993.Operations on Tree.py | 1,857 | 3.515625 | 4 | class LockingTree:
def __init__(self, parent: List[int]):
N = len(parent)
self.parent = parent
self.locked_by = [None] * N
self.locked_subtrees = [set() for _ in range(N)]
def lock(self, num: int, user: int) -> bool:
if self.locked_by[num] is None:
self.lock... |
5be33c75852f4c22b422a5d8c430ab7adeedb18a | rlee32/election-fraud-pennsylvania | /predict.py | 1,767 | 3.53125 | 4 | #!/usr/bin/env python3
import json
from plot_turnout_by_age import ELECTION_YEAR, KEY_FILE, get_voters
from matplotlib import pyplot as plt
from typing import Dict, Set
import sys
MINIMUM_REGISTERED_VOTERS = 50
def plot_votes(votes: Dict[int, int], exclude: Set[int], style: str):
vv = list(votes.items())
vv... |
17b4344c40482fa60b1f139b907f0053e06c621e | akozyreva/python-learning | /13-generators/13.2-iter.py | 232 | 4.375 | 4 | s = 'hello'
for letter in s:
print(letter)
# but we can't iterate through next, only through for loop
# but what we can do is
s_iter = iter(s)
# and now iteration works
print(next(s_iter))
# show h
print(next(s_iter))
# show e
|
80f1b9d1de9ed75f0d22fd1619a4e88665c879cc | chebypax/Python-course | /lesson3/task6.py | 452 | 3.953125 | 4 | def is_word_to_add(word):
for symbol in word:
if ord(symbol) < 97 or ord(symbol) > 122:
return False
return True
def int_func(my_string):
new_string = []
my_string = my_string.split()
for word in my_string:
if is_word_to_add(word):
new_string.append(word.ti... |
ea0e93f32f253f0408fd96bcf00f7fa7b05beeab | SREELEKSHMIPRATHAPAN/python | /python1/co1/8prgrm.py | 81 | 3.640625 | 4 | s=input("enter a word")
con=s[0]
s=s.replace(con,"$")
s=con+s[1:]
print(s)
|
74c2038a6299334425e9eb0c3e1a93db940b7cc9 | viniTWL/Python-Projects | /break/ex69.py | 939 | 3.703125 | 4 | from time import sleep
mi = men = women = 0
print('===== CADASTRO DE PESSOAS =====')
while True:
print('>>>> Faça o cadastro')
i = int(input('Digite a idade:'))
s = str(input('Digite o sexo:[M/F]')).strip().upper()
while s not in 'MF':
s = str(input('Digite o sexo:[M/F]')).strip().upper()
if... |
0eca68667e922609b71db9a78582edbce5427c27 | ProjectHax/pySilkroadSecurity | /python/stream.py | 7,529 | 3.515625 | 4 | #!/usr/bin/env python3
import struct
import array
class stream_reader(object):
index = 0
data = None
size = 0
def __init__(self, data, index=0):
self.reset(data, index)
def reset(self, data, index=0):
if type(data) == array.array:
self.data = data
elif type(data) == list:
self.data = array.array('B... |
f7a1cf9dd1c14e7e43271738204743388f2f6ef8 | Simratt/N-Body_Simulation | /particle.py | 1,116 | 4.15625 | 4 | import pygame
class Particle:
''' This is a representation of a particle in space
=== Attributes ===
- _x: the x position of the particle
- _y: the y position of the particle
- coords: the coordinates of the particle on the screen
- size: the radius of the particle
- color: the color o... |
525fe7ffeada498adee6c83b8ac39631e97352f8 | ttomchy/LeetCodeInAction | /others/q57_insert_interval/solution.py | 1,867 | 3.6875 | 4 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
FileName: solution.py
Description:
Author: Barry Chow
Date: 2020/11/4 5:16 PM
Version: 0.1
"""
class Solution:
def insert(self, intervals: List[List[int]], newInterval: List[int]) -> List[List[int]]:
start = newInterval[0]
end = newInterval[1]
... |
94b4aa4bc9f5e528aa60a9b311a5b27ab27a3dff | neroexpress/GitHubRepo | /Amne/subranges.py | 2,563 | 3.703125 | 4 | '''
Code developed by - Narender Kumar
This code requires Python 3.0, and for other versions, the code will not compile.
Please make sure that all the required contstraints are met in the input text file,
the code will not check for the required constraints. That is 1 ≤ N ≤ 200,000 days
and 1 ≤ K ≤ N days.
This code c... |
9edce05dad818bcbcb1567e6d383730c317b26a5 | LamprechtMatyas/Python_labs | /palindrome.py | 428 | 3.921875 | 4 | import sys
def _main():
input_string = sys.argv[1]
isPalindrome = True
for i in range((len(input_string) + 1)//2):
if input_string[i] != input_string[len(input_string) - 1 - i]:
isPalindrome = False
break
if isPalindrome:
print("This is palindrome")
else:
... |
40b8d227dc9d8524f90ee55105fd24bf24f2d19a | shir21-meet/meetyl1 | /facebook.py | 918 | 3.703125 | 4 | class User():
def __init__(self, name, email, password):
self.name = name
self.email = email
self.password = password
self.friends_list = []
self.posts = []
def add_friends(self, email):
self.friends_list.append(email)
print(self.name + " has added " + email + " as a friends ")
def remove_friends(self... |
8619a4734ace9ed6082e68ac1b98443190be7378 | AlexandraWin/Pyautogui_AW | /Lists_AW.py | 580 | 3.84375 | 4 | import time
subjects = ['Comp Sci', 'History', 'Spanish', 'Science', 'Math', 'Dance']
for i in subjects:
if i == "History":
print ("My favortie subject is " + i + "!!!")
else:
print ("I like " + i + "!")\
friends = ['Hedgehogs', 'My Bed', 'Hunter', 'Noah Snapp', 'John', ]
for i i... |
1f885a981f6f3ac5f9495c5888ffff78699713fc | PedroGal1234/unite1 | /quiz1.py | 307 | 4.03125 | 4 | #Pedro Gallino
#9/11/17
#quiz1.py - my first proggramming quiz
print('Juan Pedro Gallino')
num1 = int(input('Enter a number: '))
num2 = int(input('Enter another number: '))
print('The sum of your numbers is: ', num1+num2)
print('The product of your numbers is: ', num1*num2)
print('Your lucky number is:',(num1*7)+(num... |
2980788f2903ddf1ab5662c761d2cff30cd65076 | sunshine-mtt/Selenium | /currency_exchange.py | 1,087 | 3.84375 | 4 | #美元汇率
USD_EXCHANGE_RATE = 6.77
#输入货币金额
currency_str_value = input("请输入带有单位的货币金额(如果退出请按Q): ")
#统计循环次数
i = 0
while currency_str_value != 'Q':
i = i + 1
# 获取货币单位
unit = currency_str_value[-3:]
if unit == 'CNY':
# 获取货币金额
rmb_str_value = currency_str_value[:-3]
rmb_value = eval(rmb_... |
ca427c708390f5a2f31c99007dc624ba8502daf8 | omakasekim/python_algorithm | /00_자료구조 구현/queue_파이썬의 데크 이용.py | 399 | 3.609375 | 4 | from collections import deque
queue = deque()
# 맨 뒤에 데이터 추가
queue.append('지우')
queue.append('광호')
queue.append('지희')
queue.append('주현')
queue.append('용현')
print(queue)
# 맨 앞 데이터에 접근
print(queue[0])
# 맨 앞 데이터 삭제(삭제하는 데이터를 return)
print(queue.popleft())
print(queue.popleft())
print(queue.popleft())
print(queue)
|
d53fd86411cfc51dfb630ac38e0681f17871e445 | quickeee/Coding-Bootcamp | /Prepatory weeks/28_09_2016_Python/exercise_2.py | 335 | 4.03125 | 4 | bitnumber = input('Please enter the 8-bit binary number for check: ')
if len(bitnumber) == 8:
sum = 0
for i in range(0,8):
sum += int(bitnumber[i])
if sum%2 == 0:
print('Parity check ok!')
else:
print('Parity check not ok')
else:
print('The number you entered in not a valid 8... |
732dec0d02e4af8787436b9e62c3d9113db76517 | calmcat/Algorithm | /bubble_sort.py | 238 | 3.78125 | 4 | def bubble_sort(A):
for i in xrange(len(A)-1):
for j in xrange(len(A)-1, i, -1):
k = j-1
if A[j] < A[k]:
A[j-1], A[j] = A[j], A[j-1]
A = [8, 7, 6, 5, 4, 3, 2, 1]
bubble_sort(A)
print A
|
447cab83643fcb45511d17064344526e59e813bd | rigsbyk/python-challenge | /PyPoll/main.py | 3,460 | 4.1875 | 4 | #!/usr/bin/env python
# coding: utf-8
#import os provides function for interacting with the operating system(OS)
#import csv is a module for importing and reading csv files
import os
import csv
#provides the path of the csv file "election_data.csv"
election_data = os.path.join("Resources","election_data.csv")
#init... |
7dfae30b2f25ade8b2cb75ecd66bfbe9c8261a9e | xiyiwang/leetcode-challenge-solutions | /2021-01/2021-01-25-kLengthApart.py | 2,335 | 3.546875 | 4 | # LeetCode Challenge: Check If All 1's Are at Least Length K Places Away (01/25/2021)
# Given an array nums of 0s and 1s and an integer k, return True if all 1's are at
# least k places away from each other, otherwise return False.
#
# Constraints:
# * 1 <= nums.length <= 10^5
# * 0 <= k <= nums.length
# ... |
28e37f4dd13f1842d48b6c59e8bded09688301bc | parvathi98/Basic | /program/6.py | 192 | 3.640625 | 4 | cm = 1000;
meter = cm / 100.0;
kilometer = cm / 100000.0;
print("Length in meter = " ,
meter , "m");
print("Length in Kilometer = ",
kilometer , "km");
|
3c097187ae7d7dae2bbc249c1e5988b97a18cf7f | jvalansi/word2code | /word2code/res/translations/TriFibonacci.py | 1,705 | 4.0625 | 4 | from problem_utils import *
class TriFibonacci:
def complete(self, A):
input_array = A
# A TriFibonacci sequence begins by defining the first three elements A[0], A[1] and A[2].
# The remaining elements are calculated using the following recurrence: A[i] = A[i-1] + A[i-2] + A[i-3]... |
5d100f66a04f3aad4a426cb2a299bec161550442 | kmoreti/python-masterclass | /Comprehensions/listcomp.py | 279 | 3.890625 | 4 | print(__file__)
numbers = [1, 2, 3, 4, 5, 6]
number = int(input("Please enter a number, and I'll tell its square: "))
squares = [number ** 2 for number in numbers]
# squares = [number ** 2 for number in range(1, 7)]
index_pos = numbers.index(number)
print(squares[index_pos])
|
d66d45a518af7f0376f1f0b87655e6310dca87a3 | subbuinti/python_practice | /getseassion.py | 362 | 4.03125 | 4 | month = int(input())
winter = (((month==12) or (month ==11)) or (month ==1))
spring = ((month == 2) or (month ==3))
summer = (((month ==4) or (month ==5)) or (month ==6))
rainy = ((month ==7) or (month == 8))
if winter:
print("Winter")
elif spring:
print("Spring")
elif summer:
print("Summer")
elif rainy:
... |
d666f8ce550f99690f15d1bad9bfedd2ddcd0027 | beatriceziliani/esercizi-libro | /Python/28.py | 271 | 3.8125 | 4 | valori= []
print ("rispondi con 0 al punteggio se hai finito")
while True:
nome = input ("Inserisci il nome dello studente")
punteggio = int (input ("quanti punti ha fatto?"))
if punteggio == 0:
break
valori.append(punteggio)
print (max (valori)) |
161f1df0e0fe00a17d34f74a9b41d1f9505e6dfa | darsovit/AdventOfCode2020 | /Day23/Day23.py | 1,292 | 3.5625 | 4 | #!python
class CrabCups:
def __init__(self, start):
self.state = start
self.rounds = 0
def __nextLower(aChar):
if aChar == '1':
return '9'
return chr(ord(aChar)-1)
def playRound(self):
saved_cups = self.state[1:4]
interstate = self.state[:1] + s... |
cebf74b1d7adcf746c5e97fdb8bfcd83827f79f2 | JohnEspenhahn/algorithms | /dynamic programming/longest_palindrome.py | 568 | 3.734375 | 4 | def find_longest(s):
"""
:type s: str
:rtype: int
"""
p = [[0]*len(s) for i in range(len(s))]
max_lng = 0
max_start = 0
max_end = 0
for lng in range(0,len(s)):
for i in range(0,len(s)-lng):
j = i + lng
if (lng == 0):
p[i][j] = True
elif (lng == 1):
p[i][j] = (s[i] == s[... |
7a92d43dfedfe78286a0618bf66eb53b9bc4ca37 | albert-yakubov/py-practice | /hackerrank/pairs_of_socks.py | 887 | 3.796875 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
# Complete the sockMerchant function below.
def sockMerchant(n, ar):
# color doesnt matter here because to make a pair of socks you only need two socks
# same answer goes for same color socks
# iniate count
count = 0
ar.sort()... |
b725ad0961fadcd78df9199f97232ffc4041b9de | shuheiktgw/data_structures | /Programming-Assignment-1/tree_height/tree_height.py | 1,330 | 3.703125 | 4 | # python3
import sys, threading
sys.setrecursionlimit(10**7) # max depth of recursion
threading.stack_size(2**27) # new thread will get stack of such size
class Node:
def __init__(self):
self.children = []
def add_child(self, child):
self.children.append(child)
class Tree:
... |
9a681664cc59eca8b7ea2f40cd444b97c9550052 | daniel-reich/turbo-robot | /e6fL5EiwGZcsW7C5D_17.py | 949 | 4.03125 | 4 | """
Create a function that converts a string of letters to their respective number
in the alphabet.
A| B| C| D| E| F| G| H| I| J| K| L| M| N| O| P| Q| R| S| T| U| V| W| ...
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---
0| 1| 2| 3| 4| 5| 6| 7| 8| 9| 10| 11| 12| 1... |
3c4b18dc9652d5beb8be8c3904b12ebe32f46606 | zhangruochi/OnlineLearning | /Data Structures and Algorithms/Algorithmic Toolbox/week 1/max_pairwise_product.py | 1,422 | 3.515625 | 4 | #python3
def fast_method(a, n):
max_indice_1 = -1
for i in range(n):
if max_indice_1 == -1 or a[i] > a[max_indice_1]:
max_indice_1 = i
max_indice_2 = -1
for j in range(n):
if j != max_indice_1 and (max_indice_2 == -1 or a[j] > a[max_indice_2]):
max_indice_2 = j
... |
612bcb009f157e7f8972a33f0b7693fc9e2398d0 | adityaKoteCoder/codex | /q_6.py | 247 | 4.375 | 4 | #accept a number from the uder and display if it is a palindome or not
def reverse_num(num):
num=int(input("enter the number"))
rev=0
while num!=0:
rev=rev*10+num%10
num=num/10
print(f"{num} is a palindrome")
|
1c1501e13cc6732ca55e3270de76306db9baa8df | ThanatoSohne/Misc-Projects | /Python Language/startNew.py | 4,473 | 3.640625 | 4 | # -*- coding: utf-8 -*-
from bs4 import *
from bs4 import BeautifulSoup as soup
from urllib.request import urlopen as req
from urllib.request import Request
from termcolor import colored as cl
import random as rn
import wikipedia as wiki
#Function to scrape and pull the word of the day from Dictionary.com
de... |
4fc8adf3c677113fc2b20efbd203e9296eb2714d | AnaArce/introprogramacion | /Practico_1/Ejercicio_11.py | 446 | 3.6875 | 4 | #Programa que entregue la edad del usuario a partir de su fecha de nacimiento
from time import localtime
t = localtime()
año_ac = t.tm_year
mes_ac = t.tm_mon
dia_ac = t.tm_mday
año = int(input("Año: "))
mes = int(input("Mes: "))
dia = int(input("Dia: "))
#año
edad1 = año_ac - año
#mes
edad2 = mes_ac - mes
#dia
edad3 = ... |
f4f327836daf5271a397819b1d73809b291147ae | timofeyabramski/Ising-model-files | /hello.py | 496 | 4.125 | 4 | #!/usr/bin/env python
class bikes:
'common base class for bikes'
bikecount = 0
def _init_(self, name, cost):
self.name = name
self.cost = cost
bikes.bikecount += 1
def displayCount(self):
print "Total number of bikes %d" % self.bikecount
def displayCount(self):
print "Name : ", self.name, ", cost: ",... |
1979be1c034fc762398263ba75035f17c4386e73 | tjhamad/CheckiO | /monkey typing.py | 497 | 3.828125 | 4 | # -*- coding: utf-8 -*-
from datetime import date
def days_diff(date1, date2):
d0 = date(*date1)
d1 = date(*date2)
delta = d0 - d1
print abs(delta.days)
return abs(delta.days)
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testi... |
04f19b0fc1f0ff0008fcb5aa830237b104c83a45 | yonatanGal/Four-In-a-Row | /ex12/board.py | 3,018 | 4.03125 | 4 | from .disc import Disc
BOARD_HEIGHT = 6
BOARD_WIDTH = 7
EMPTY = '_'
BLUE = 'blue'
RED = 'red'
PLAYER_ONE = '1'
PLAYER_TWO = '2'
class Board:
""" creates a board object """
def __init__(self):
self.__board = [['_', '_', '_', '_', '_', '_', '_'],
['_', '_', '_', '_', '_', '_', '_'... |
9e956269ff70341a7f1d73a8481b482c329d53d6 | emilywitt/HW05 | /HW05_ex00_TextAdventure.py | 3,314 | 4.3125 | 4 | #!/usr/bin/env python
# HW05_ex00_TextAdventure.py
##############################################################################
# Imports
from sys import exit
from sys import argv
# Body
def infinite_stairway_room(count,name):
print name + " walks through the door to see a dimly lit hallway."
print "At the ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.