blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
855228f15ec437b2b2e9c2d368babd54522fdc7c | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/222/users/4082/codes/1602_842.py | 329 | 3.703125 | 4 | # Teste seu codigo aos poucos.
# Nao teste tudo no final, pois fica mais dificil de identificar erros.
# Nao se intimide com as mensagens de erro. Elas ajudam a
num=int(input("quatro digitos:"))
numero1=(num//1000)
numero2=(num//100) %10
numero3=(num//10) %10
numero4=(num%10)
soma=(numero1+numero2+numero3+numero4)
pri... |
0dd280ebdb8f9fca7dca96b0ba8721ea4e56cae2 | Kaushiksekar/SDE_Prepration | /Python_Specifics/Inheritance/Diamond_Problem_2.py | 322 | 3.859375 | 4 | class A:
def m(self):
print("m of A")
class B(A):
pass
class C(A):
def m(self):
print("m of C")
class D(B,C):
pass
x = D()
x.m() # prints m of C as B has nothing
# In python 2, it would print m of A
# This order of browsing through base classes is called Method Resolution
# Order(MRO... |
fba92ecbad70e8663996bf6ec3ae4875e412e193 | Aasthaengg/IBMdataset | /Python_codes/p03045/s703851186.py | 843 | 3.71875 | 4 | #Union Find
#xの根を求める
def find(x):
if par[x] < 0:
return x
else:
par[x] = find(par[x])
return par[x]
#xとyの属する集合の併合
def unite(x,y):
x = find(x)
y = find(y)
if x == y:
return False
else:
#sizeの大きいほうがx
if par[x] > par[y]:
x,y = y,x
... |
4ddf968cbbc8c59ae91b73d107461a7be49541c7 | Tingyinlee/Algorithm | /Leetcode/707#_DesignLinkedList_05121127.py | 5,362 | 4.09375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[ ]:
class ListNode:
def __init__(self, val): #畫好每個節點長什麼樣
self.val = val
self.next = None
class MyLinkedList(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.head = None
def get(self... |
a4f546cf7a9a760e098e765c7dcb51766615093e | jboenawan/Python-Programming-MIS3640 | /session10-dictionary_exercise/word.py | 2,651 | 3.90625 | 4 | # fin = open('words.txt')
# line = fin.readline()
# print(line)
# print(repr(line)) #prints the /n after the word.
fin = open('C:/Users/jboenawan1/Documents/Fall 2017/Problem Solving & Design/Python-Programming-MIS3640/session10-dictionary_exercise/words.txt')
for line in fin:
word = line.strip()
# print (wor... |
616dd85f62a20d2f438a3a7aeb3e59742b596990 | deepakag5/Data-Structure-Algorithm-Analysis | /leetcode/array_move_zeroes.py | 218 | 3.53125 | 4 | def moveZeroes(nums):
pos = 0
for i in range(len(nums)):
if nums[i] != 0:
nums[pos], nums[i] = nums[i], nums[pos]
pos += 1
return nums
print(moveZeroes([0, 1, 0, 3, 12]))
|
06520018b46a21983c87e5521f961bc8b757a16a | Kartik1801/VocaVBT | /jumbleword.py | 900 | 3.984375 | 4 | # Python program for jumbled words game.
# import random module
import random
# function for choosing random word.
def choose():
words=[]
if not words:
with open("jumblewords.txt","r") as list:
for word in list:
word=word.strip('\n')
if (len(word)>4):
... |
15162ccec2604141e2261a670bc515051e453735 | SpyrosRoum/Turtle_Racing | /turtle_racing.py | 2,707 | 4.0625 | 4 | import turtle as tt
from tkinter.messagebox import askyesno
import random
import mouse
y = 450
x = -500
lines= 15
playing = False
play = True
tt.setup(width=1900, height=1000)
tt.title("Turtle Racing!")
# tt.bgcolor("green")
def set_up():
bob = tt.Turtle()
bob.speed(0)
bob.up()
... |
753af1dd6f78ade97e418642aa0adc7f7cf947b3 | koltpython/python-exercises-spring2020 | /section3/starter/nerdySanta.py | 316 | 3.859375 | 4 | # Using a boolean variable can be helpful for us. We call these
# types of boolean variables "flags"
isPrime = True
# Let's take the age from the user
# Check if the age is valid. While it is, do the necessary checks and
# loops to determine if the user has a gift or not. Then take the age
# from the user again.
|
7b366998a3206fd6166180fbbbd7009fcfe38456 | tkremer72/Python-Masterclass | /3.ListsAndTuples/1.Sequences/lists_intro.py | 566 | 4.1875 | 4 | computer_parts = [
"computer", # index 0
"monitor", # index 1
"keyboard", # index 2
"mouse", # index 3
"mouse pad" # index 4
]
# for part in computer_parts:
# print(part)
# print()
# print(computer_parts[2]) # returns index 2 which is keyboard
# print()
# print(computer_parts[0:3]) #... |
899eae525fc147c523c73100bffe8c97518db1e5 | FelipeSPB/client_weather_api | /run.py | 1,763 | 3.546875 | 4 | from pathlib import Path
import os
import sys
class Menu:
def __init__(self):
self.choices = {
"1": self.config_environment,
"2": self.discovering_id_city,
"3": self.quit
}
def display_menu(self):
print("""
API CONFIG MENU\n
1. C... |
8653d86a11ff2291241b0775c44d825a2c31282e | Starfloat/PCC | /Chapter 8 - Functions/formatted_name.py | 632 | 4.125 | 4 | # To make the middle name optional, give the middle_name argument an empty value
# set the default of the middle_name to an empty string and move it to the end
# of the list of parameters
def get_formatted_name(first_name, last_name, middle_name=''):
"""Return a full name, neatly formatted."""
if middle_... |
1241e1e1a0c7610afca6231b19282ef703193289 | nickwilling/cat-and-dog | /pandas/pandasPlotData.py | 604 | 3.53125 | 4 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
#plot data
#Series:线性的数据:就是一维的数据
data = pd.Series(np.random.randn(1000),index=np.arange(1000))
#累加
data = data.cumsum()
data = pd.DataFrame(np.random.randn(1000,4),index=np.arange(1000),columns=list("ABCD"))
data = data.cumsum()
ax = data.plot.s... |
1be671113daac563792248457849612010a2a5e5 | guilhermea23/Python-Exercises | /exercises/strings/using_ascii.py | 122 | 3.6875 | 4 | s = input()
values = []
for letter in s:
value = ord(letter)
values.append(value)
added = sum(values)
print(added) |
8ab6d28a60c35ef13616668553e8aad0d6132a4d | Rinkikumari19/python | /while_loop/pattern.py/opposite_print.py | 113 | 3.859375 | 4 | i = 6
while i >= 0:
b = 0
while i > b:
print ("*",end="")
b=b+1
print ("*")
i=i-1 |
7728853652d76cd2b95683f1bd201cdcb3acf102 | spalladino/algoritmos-gcba | /codigo/python-sorting/insertionsort.py | 235 | 3.796875 | 4 | def sort(arreglo):
for j in range(1, len(arreglo)):
elem = arreglo[j]
i = j - 1
while (i >=0) and (arreglo[i] > elem):
arreglo[i+1] = arreglo[i]
i = i - 1
arreglo[i+1] = elem
|
d5eecbb9a14f90d74fbbd3229b1458137764b991 | AdnanSlef/tamu2020 | /misc/woof/solve.py | 447 | 3.5 | 4 | #!/usr/bin/env python3
with open('woof.txt','r') as f:
data = f.read().split()
print(data)
numdata=[]
for x in range(3):
for y in range(3):
for z in range(3):
if x != y and x!=z and y!=z:
numdata.append(int(''.join(word.replace('woof',str(x)).replace('bark',str(y)).replace('r... |
19e9e3f8acf5ce507bf27a28ca148e416a61af7c | shchoice0812/TIL | /Python Advanced/08. Closure.py | 1,349 | 3.578125 | 4 | """
클로저는 하나의 함수로 여러가지 함수를 간단히 만들어낼 수 있으며, 기존에 만들어진 함수나 모듈을 수정하지 않고도 wrapper 함수를 이용해 커스터마이징할 수 있게 해준다.
"""
# 1-1. lotto program을 통한 이해
import random
def lotto_generate_num():
num_list = [n for n in range(1, 10)]
random.shuffle(num_list)
def lotto_select_num():
while(True):
selected... |
825466506f8585d5b2e8d0ff1712a436f1d35bf9 | darkless456/Python | /内外取值函数传递.py | 204 | 3.640625 | 4 | def changeme (mylist):
mylist.append ([1,4,5])
print ("内取值:" , mylist)
return
mylist = [9,10,11] # 缩进关系在上面更新优先
changeme (mylist)
print ("外取值:" , mylist)
|
5d4f2e31f7bff2142d6275ce4c532a92da7a8b44 | donghe123178/AlgorithmQIUZHAO | /Week_03/[55]跳跃游戏.py | 1,514 | 3.5625 | 4 | # 给定一个非负整数数组,你最初位于数组的第一个位置。
#
# 数组中的每个元素代表你在该位置可以跳跃的最大长度。
#
# 判断你是否能够到达最后一个位置。
#
# 示例 1:
#
# 输入: [2,3,1,1,4]
# 输出: true
# 解释: 我们可以先跳 1 步,从位置 0 到达 位置 1, 然后再从位置 1 跳 3 步到达最后一个位置。
#
#
# 示例 2:
#
# 输入: [3,2,1,0,4]
# 输出: false
# 解释: 无论怎样,你总会到达索引为 3 的位置。但该位置的最大跳跃长度是 0 , 所以你永远不可能到达最后一个位置。
#
# Related Topic... |
a4ecbff76dcc7f1a1771935ab05181ec0670f201 | sarathkumar22/phython-programming | /biginner level/odd or even.py | 116 | 4.09375 | 4 | x=int(input("enter the value"))
x in range(1<=x<=100000)
if(x%2==0):
print("x is even")
else:
print("x is odd")
|
34529c80ca3a91c4f004d6c21e01ddf99c3045b9 | xuychen/Leetcode | /interviews/huawei/8.13/1.py | 294 | 3.640625 | 4 | import re
def get_weight(string):
strings = filter(lambda x: x != "", re.split("\W", string))
lengths = map(len, strings)
string_length = len(strings)
return float(sum(lengths)) / string_length
print(get_weight("we have met at 11:00."))
print(get_weight("Nice to meet you.")) |
3827459d5d778360ad402756aa1b933b8795feb0 | alejandromarroquin/functionsandalgorithmswithpython | /Notacion-Asintotica.py | 568 | 3.703125 | 4 | # Ley de la suma
def f1(n):
for i in range(n):
print(i)
for i in range(n):
print(i)
# o(n)+o(n)=o(n+n)=o(2n)=o(n) -> La función crece en o(n)
def f2(n):
for i in range(n):
print(i)
for i in range(n*n):
print(i)
#o(n)+o(n*n)=o(n+n**2)=o(n**2) ... |
fec58978dcc91018b7965d176f0f7fadbd731e71 | WesleyFerreira01/ExerciciosCurso | /Dicionario.py | 226 | 3.59375 | 4 | cores = {'verde':'green', 'vermelho': 'red', 'preto': 'black', 'branco': 'white'}
cor = input('Escolha a cor que deseja traduzir:').lower()
traduçao =cores.get(cor,'Esta cor nao consta no meu dicionãrio')
print(traduçao) |
29510289edb7224830c20abb100203784064beab | daksh301107/bank | /bank.py | 974 | 3.765625 | 4 | class Atm:
def __init__(my,accountnumber,pincode):
my.accountnumber = accountnumber
my .pincode = pincode
def checkBalance(my):
print("Your balance is 310000")
def withdrawl(self,amount):
newAmount = 310000 - amount
print("you have withdrawn amount "+str(a... |
875f69b797161c9b691ff48b50875c9d267b49b1 | scilover/Algorithm | /DP.py | 510 | 3.515625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Oct 2 15:26:09 2019
@author: witty
"""
# 动态规划法
## 加法几乎不占用时间,预先存好变量关系,再运算。
output = [None]*200000
def FibonacciNew(n):
result = output[n]
if output[n] == None:
if n == 0:
result = 0
elif n == 1:
result = 1
... |
086aef222a9681c6e9c3b25070762b3c8e21374b | GrishaAdamyan/All_Exercises | /homework_2.py | 403 | 3.90625 | 4 | # 1
word = input('Enter number ')
list1 = []
while word != 'End':
list1.append(int(word))
word = input('Enter number ')
dictionary = {}
for number in list1:
dictionary[number] = dictionary.get(number, 0) + 1
print(dictionary)
# 2
string = input()
odd_symbols = 0
for symbol in set(string):
if string.cou... |
cf1d63138481eb71297219326341e53c09860c46 | zigaen/Python_Vaje | /Unit_converter.py | 546 | 4.03125 | 4 |
compliance = input("Hi, i am converting km in to miles, would you like to continue? y/n __ ")
while True:
if compliance == "y":
km = (input("Enter the number of kilometers: "))
km = float(km.replace(",", "."))
miles = km * 1.60944
print("That makes: " + str(round(miles, 2)) + " ... |
762aa8d390d346311a5b5086495541850815564c | nukarajusundeep/myhackerrank | /Forked_Solutions/input.py | 566 | 3.875 | 4 | '''
TASK:
=========
You are given a polynomial of a single indeterminate (or variable), .
You are also given the values of and . Your task is to verify if .
'''
def eval_polynomial(poly, val):
xs = [ x.strip().replace('^','**') for x in poly.split('+') ]
return sum( [eval(n.replace('x', str(val))) for n in ... |
c464769b9a7d8fee1d2393977b4eb97e5043c639 | antonpetkoff/Programming101 | /Programming101/week5/Cinema_reservation_system/With_ORM/command_parser.py | 2,179 | 3.515625 | 4 | from cinema import Cinema
from reservation import Reservation
import sys
class CommandParser:
def __init__(self, cinema):
self.commands = {} # command : function
self.cinema = cinema
self.__fill_commands()
def add_command(self, command, function):
self.commands[command] = fu... |
055bdb84fb69095c42ed20ad129dc25196f1f4bd | Angel-Saez-Gonzalez/module4 | /dictionaries.py | 1,817 | 3.953125 | 4 | dictionary = {"cat": "chat", "dog": "chien", "horse": "cheval"}
phone_numbers = {'boss': 5551234567, 'Suzy': 22657854310}
print(dictionary)
print(phone_numbers)
print(dictionary["cat"])
print(phone_numbers["boss"])
print()
print("Return the keys")
for i in dictionary:
print(i)
print()
print("Return the keys")
... |
1ffbf199e2ac57e917519f4e3588648f94289322 | treyhakanson/pile | /Facebook/rearrange_str.py | 508 | 3.65625 | 4 | from collections import defaultdict
def rearrange_str(s):
count = 0
letters = defaultdict(int)
start_char = ord("A")
for char in s:
if char.isdigit():
count += int(char)
else:
letters[char] += 1
s2 = ""
for i in range(start_char, start_char + 26):
... |
86758150ad12d8328b44d990833b7518c951d4aa | LannibaleS/Python_fullstack | /day22/3.面向对象的引入.py | 1,962 | 4.3125 | 4 | print(dict)
d = {'k':'v'}
print(d)
'''
class 类名:
属性 = 'a'
print(类名.属性)
类名的作用:操作属性,查看属性
'''
class Person:
country = 'China' # 创造了一个只要是这个类就一定有的属性
# 类属性 静态属性
def __init__(self, *args): # init是初始化方法,self是对象,是一个必须传的参数
# self就是一个可以存储很多属性的大字典
... |
47aa6d554cf7085379e1d0b5fb84e0f338b19141 | RufaroMachingambi/project | /practical assignment 1 grace.py | 1,069 | 3.71875 | 4 |
'''number 6 Question:Write a Python program to add 'ing' at the end of a given string (length should be at least 3). If the given string already ends with 'ing' then add 'ly' instead. If the string length of the given string is less than 3, leave it unchanged.
Sample String : 'abc'
Expected Result : 'abcing'
S... |
c5d9dfc0af25c9a2de26f3e430161823e7cce059 | sujatha-2/test | /shh.py | 285 | 4.28125 | 4 | num1=float(input("Enter first number:"))
num2=float(input("Enter second number:"))
num3=float(input("Enter third number:"))
if(num1>num2)and(num1>num3):
largest = num1
elif(num2>num1)and (num2>num3):
largest = num2
else:
largest = num3
print("the largest number is",largest)
|
143baa18094a43c8fe8c5595210a3ec6ab75852f | NorthcoteHS/10MCOD-Simon-LO | /user/Calculator.py | 176 | 3.59375 | 4 | """
Program: Calculator
Name: Simon Lo
Date: 15/02/18
Desc: to calculate
"""
import random
nums = [x for x in range(10)]
random.shuffle(nums)
nums
[6, 3, 5, 4, 0, 1, 2, 9, 8, 7]
|
a4eda5ca207f7bc4199429551685bcfe5e33a429 | CaptainTec/LeetCode_Python3 | /dfs_medium_153_Binary_Tree_Upside_down.py | 2,079 | 3.953125 | 4 | # # Definition for a binary tree node.
# # class TreeNode:
# # def __init__(self, x):
# # self.val = x
# # self.left = None
# # self.right = None
# 较low的递归 -- 自己写的
# class Solution:
# def upsideDownBinaryTree(self, root: TreeNode) -> TreeNode:
# if not root:
# return... |
f36ce88c8109e432377bb14793a5ebf92da068a8 | Divya23789/PythonLab | /Basic1/count the number 4.py | 209 | 3.921875 | 4 | #Write a Python program to count the number 4 in a given list.
def num(n):
count = 0
for num in n:
if num == 4:
count = count+1
return count
print(num([1,2,3,4,5,4,6,4,8,4]))
|
4868cfa5304b4935cc4f4c91f7a7e8c88240a090 | hemangi44/PythonPractice | /practicals/practice-decorators/pr6-decorators.py | 517 | 3.890625 | 4 | # any object which implements the special __call__() method is termed callable
def smart_divide(func):
def inner(a, b):
print("I am going to divide", a, "and", b)
if b == 0:
print("cannot divide with 0!")
return
return func(a, b)
return inner
def divide():
... |
a29465450f6d37acbfa8ae0f8821504663cff1fe | chrisortman/exercises | /chapter-5.2/ex_5_13.py | 1,521 | 4.46875 | 4 | # Programming Exercise 5-13
#
# Program to display a table of times and falling distances for a specific range in seconds.
# This program accepts no input,
# but uses a loop to pass a range of times in seconds to a function
# that returns the falling distance for that amount of time,
# and displays the resu... |
9715cc93144ca49b845f6aeb960820281c9af94d | zhangsanjin3355/zxpython | /37-函数嵌套练习.py | 621 | 4.21875 | 4 | def sum_3_num(a,b,c):
result = a+b+c
# print("%d+%d+%d=%d"%(a,b,c,result))
# print(result)
return result
def average_3_num(a,b,c):
result2 = sum_3_num(a,b,c)
result2 /= 3
#print("平均值是:%d" % result2)
return result2
def square_3_sum(a2,b2,c2):
result3 = average_3_num(a2,b2,c2)
... |
4615d070610ac817868feb506bb7485c76d457b4 | xxxsssyyy/offer-Goal | /46圆圈中最后剩下的数字.py | 1,294 | 3.890625 | 4 | # -*- coding:utf-8 -*-
"""
题目描述:每年六一儿童节,牛客都会准备一些小礼物去看望孤儿院的小朋友,今年亦是如此。
HF作为牛客的资深元老,自然也准备了一些小游戏。其中,有个游戏是这样的:首先,让小朋友们围成一个大圈。
然后,他随机指定一个数m,让编号为0的小朋友开始报数。每次喊到m-1的那个小朋友要出列唱首歌,然后可以在
礼品箱中任意的挑选礼物,并且不再回到圈中,从他的下一个小朋友开始,继续0...m-1报数....这样下去....
直到剩下最后一个小朋友,可以不用表演,并且拿到牛客名贵的“名侦探柯南”典藏版(名额有限哦!!^_^)。
请你试着想下,哪个小朋友会得到这份礼品呢?(注:小朋友的编号是从0到n-... |
9302d8f813a57f1b2d6c23ca10fdb8d06ba849c2 | La4La/STEP | /STEP/step4/AAA_ZZZ.py | 384 | 3.84375 | 4 | import re
upperReg = re.compile(r'^[A-Z]+$')
def isupper(s):
return upperReg.match(s) is not None
count = 0
f = open('pages.txt', encoding='utf-8')
line = f.readline()
while line:
items = line[:-1].split('\t')
pageName = items[1]
if len(pageName) == 3 and isupper(pageName):
count += 1
... |
10b0c8b78c04fc637157b67673a270908359f66d | senaaac/coding-starter | /week_01_python/04-if-statement.py | 537 | 3.609375 | 4 | #참과 거짓 boolean
# if
# True or False
# 거짓: none, false, 0
# and or not
# a = True
# b = False
#
# # a가 참이고, 그리고 b가 참이라면 (a와 b가 둘다 참이어야 된다)
# print(a and b)
# # a가 참이거나 혹은 b가 참이라면 (a나 b 둘 중 하나라도 참이면 된다)
# print(a or b)
d = 7
if d > 10:
print("숫자는 10보다 큽니다")
elif d > 5 and d <= 10:
print("숫자는 10보다 작거나 같고, 10보다는 큽... |
281ed9768e3f4d765b1dc69ce1d966073294ce30 | liuluyang/homework | /homework-05-09/homework_05.py | 4,816 | 3.890625 | 4 |
"""
1. 编写python程序,该程序可以创建一个文件,文件内容为一首唐诗。
2. 编写一个Python程序,读入第1题创建的唐诗文件,输出该唐诗文件中包含的字数和句数。
3. 编写一个python程序,程序读入python_zen.txt文件,
把其中句子顺序倒排后输出到另外一个文件python_zen_reverse.txt中。
4. 编写一个python程序,程序读入python_zen.txt文件,
提取该文件中所用到的单词组成的列表(即该文件用到了哪些不同的单词),
并把该单词列表输出到另外一个文件vocabulary.txt中。
5. 编写一个python程序,程序读入The Adventures of... |
367ed510b397bbe19efd32b6b26ed0ccbc47b988 | Cian88/Python | /multiply.py | 338 | 3.765625 | 4 | # Table de multiplication
import os
logiciel_on=True # sans info contraire on peut relancer une autre table
while logiciel_on:
from package import multiplication
quitter=input("Voulez-vous continuer ? (O/N) :")
if quitter not in ("o","O"):
logiciel_on=False
os.system=("pause")
input("Appuyez sur une touc... |
863b1aaf345ae63431ce1eeef70ac52d0ae66ccc | StarPower7L/tutorial-python-ep1 | /tuturial.py | 382 | 4.15625 | 4 |
#How to say something
# str
# print("Hello, World!")
# int
# print(1)
# bool
# print(True)
# this stores the str "Name"
# name = "Name"
#INPUT
#input("Whats youre name?: ")
#Says hello to the name
# name = input("Enter Your Name: ")
# print("Hello, " + name + " Welcome!")
num1 = int(input("Enter a number: "))
n... |
b98436be919f55b81aec65074992d590d6bf35d3 | Rohitth007/CS50x | /Week7/houses/import.py | 1,148 | 3.875 | 4 | from sys import argv, exit
from cs50 import SQL
import csv
if len(argv) != 2:
print("Usage: python import.py characters.csv")
exit(1)
db = SQL("sqlite:///students.db") # Connecting with SQLite3
with open(argv[1], 'r') as data: # Opening CSV file
reader = csv.DictReader(data)
for row in reader:
... |
d294b617feba3179ce7de7bdee1e884d80c0cbcc | YJFKD/dynamic-pdp-simulator | /Code/common/route.py | 2,727 | 3.578125 | 4 | import sys
class Route(object):
def __init__(self, route_id: str, start_id: str, end_id: str, distance: float, time: float):
'''
Inputs:
- route_id: index of the route
- start_id: start location id
- end_id: end location id
- distance: route distance
- time: ... |
c84ecbfc07423ec1d2268842c59a005a793bffdf | rafaelperazzo/programacao-web | /moodledata/vpl_data/312/usersdata/279/75643/submittedfiles/esferas.py | 326 | 3.765625 | 4 | # -*- coding: utf-8 -*-
A=float(input('A'))
B=float(input('B'))
C=float(input('C'))
D=float(input('D'))
if A==(B+C+D) :
if B+C==D:
if B==C:
print('s')
else:
print('n')
else:
print('n')
else:
print('n... |
ad3320a2fad7bea5965339a580dc43e9c4a32ab5 | bindaldhara/URL-shortener | /URL.py | 275 | 3.921875 | 4 | import pyshorteners #library in python for shortening URL
def shorten(url):
return pyshorteners.Shortener().tinyurl.short(url) ## shortening the URL
url = input("Enter URL: ") #takes input(URL) from the user
print("Shortened URL : ", shorten(url)) #returns output
|
08b4b9f1f264e35d94bd397f4b87a40888f961ea | KyleSMarshall/LeetCode | /[994] Rotting Oranges.py | 3,316 | 3.75 | 4 | # Problem:
'''
In a given grid, each cell can have one of three values:
the value 0 representing an empty cell;
the value 1 representing a fresh orange;
the value 2 representing a rotten orange.
Every minute, any fresh orange that is adjacent (4-directionally) to a rotten orange becomes rotten.
Return th... |
404a690cfb1982b147be8c491eaea8f7eecc446c | sdbaronc/taller_de_algoritmos | /algoritmo_31.py | 95 | 3.796875 | 4 | n=int(input("ingrese un numero"))
if n>=10:
n=n*3
print(n)
else:
n=n/4
print(n) |
6e7bf0dcea437446a2d7e36d06d525b54ff07e08 | K753951/UCSanDiego-Data-Structures-Projects- | /Rope/rope.py | 24,894 | 3.625 | 4 | import sys
from time import process_time
class Node:
def __init__(self, key, character, left_child, right_child, parent):
self.key = key
self.character = character
self.left_child = left_child
self.right_child = right_child
self.parent = parent
class SplayTre... |
a17c453c8d6419ddd8b4e030d1cbd4a1c266b11b | bokveizen/leetcode | /1105_Filling Bookcase Shelves.py | 763 | 3.5 | 4 | # https://leetcode-cn.com/problems/filling-bookcase-shelves/
from typing import List
class Solution:
def minHeightShelves(self, books: List[List[int]], shelf_width: int) -> int:
book_num = len(books)
dp = [1000 * 1000] * (book_num + 1)
dp[0] = 0
for i in range(1, len(dp)):
... |
5699610b6531ff08e185093e8df3100aee8dca1b | knutin/pyman | /game.py | 231 | 3.578125 | 4 | """
Game logic
"""
from constants import *
def allowed_position(m, position):
"""Returns True if pacman is allowed to be in the given position"""
x, y = position
object = m[x][y]
return object in ALLOWED_OBJECTS
|
c7fb8db68364af87d128f502e09a00831b3183ab | alexandraback/datacollection | /solutions_5634947029139456_0/Python/mengsung/A.py | 1,956 | 3.515625 | 4 |
number_of_flip = 0
min_flip = -1
def number_of_ones(depth, array_of_string) :
count = 0
for s in array_of_string :
if s[depth] == '1' :
count += 1
return count
def flip(depth, array_of_string) :
for s in array_of_string :
if s[depth] == '1' :
s[de... |
d536b859153c26ae0a3d552f9598cc4509d99888 | Molly-l/66 | /mounth001/day07/homework02.py | 408 | 3.578125 | 4 |
def max01(a,b,c,d):
# a=int(input('输入第一个数字'))
# b=int(input('输入第二个数字'))
# c=int(input('输入第三个数字'))
# d=int(input('输入第四个数字'))
max_value=a
if max_value<b:
max_value=b
if max_value<c:
max_value=c
if max_value<d:
max_value=d
# print('输出',max_value)
return max_... |
5f32a7aa725b900e90729c77dc43a12588187445 | akhila1432/hackerrank | /default_dict22.py | 126 | 3.953125 | 4 | word = ("abced","abcedf","bcde","abcde")
for item in word:
if len(item)in word:
print(item.count(item))
|
5e1d89bd0ab671a3c1bac717bec6e1e1a5a1f355 | Andchenn/Lshi | /day02/dict1.py | 646 | 3.859375 | 4 | # 字典:以大括号形式的键值对数据组合,{“name”:“张三”,“age”:18}
# 提示一下:一般key(99% 都是字符串类型)
# 不可变类型:数字 元组 可变类型:变量 列表
my_dict = {"name": "张三", "age": 18}
print(my_dict, type(my_dict))
# 字典是无序的(没有下标的概念)
# 通过key值来取vaule
vaule = my_dict["name"]
print(vaule)
# 如果没有此键,使用[]会崩溃
# vaule = my_dict["sex"]
# print(vaule)
# 如果使用get方式取值不会崩溃,会返回None
# ge... |
57b0ae41b4032cae8dafa488297cd8cdda8b9c49 | arun3542/Jala-Technologies | /collections/collections.py | 1,022 | 3.984375 | 4 | # 1. Create an ArrayList of type String with 10 string elements. Add 10 string elements to
# ArrayList and perform the below operations
# Add an element to the ArrayList
# Iterate through the ArrayList by using Iterator object
# Add an element at a specific index
# Remove an element from the ArrayList, Remove at a... |
74f23b133236373fcb0f918a2a868b95d79227e4 | syurskyi/Algorithms_and_Data_Structure | /_algorithms_challenges/leetcode/LeetCode/965 Univalued Binary Tree.py | 884 | 4.125 | 4 | #!/usr/bin/python3
"""
A binary tree is univalued if every node in the tree has the same value.
Return true if and only if the given tree is univalued.
Example 1:
Input: [1,1,1,1,1,null,1]
Output: true
Example 2:
Input: [2,2,2,5,2]
Output: false
Note:
The number of nodes in the given tree will be in the rang... |
2fd90f2a89d75670d4cf3efa935edbafb599d54c | giahienhoang99/C4T-BO4 | /session4/bt2.py | 167 | 3.9375 | 4 | while True :
a = input("Please enter your password : ")
if a.isalpha() :
print("Valid")
break
else :
print("Invalid.Try again.")
|
18a7059c583e4221a358a9b3b8eb05e5e44c66a7 | dragonmushu/BacteriaMotion | /src/canvas.py | 3,974 | 3.828125 | 4 | import tkinter as tk
from constants import *
from maze import Maze
class MazeCanvas:
def __init__(self, root, simulation_end_callback):
self.canvas = tk.Canvas(root, width=MAZE_WIDTH + 2 * BORDER_SIZE, height=PANEL_HEIGHT + 2 * BORDER_SIZE,
background="black")
sel... |
52071a495131f42fb433202a088658d7bd0f8961 | dim4o/python-samples | /dynamic-programming/coin_changing_min_number_of_coins.py | 2,360 | 4.03125 | 4 | def get_min_number_of_coins(coin_denominations, total):
"""
Given coins of certain denominations and a total, how many minimum coins
would you need to make this total. Note that the denominations are with unlimited supply.
For better context see: https://youtu.be/Y0ZqKpToTic
Example:
0 1 ... |
ec02cb5876426fa36a233a638029d2730132763b | JoyiS/Leetcode | /crackfun/211. Add and Search Word - Data structure design.py | 2,179 | 4.03125 | 4 | '''
Design a data structure that supports the following two operations:
void addWord(word)
bool search(word)
search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter.
For example:
addWord("bad")
addWord("dad")
addWord("mad")
sea... |
c2a6ca9d4f8f26967f4d23d1303c7614a535b1ec | kruart/coding_challenges | /hackerRank/python3_/defaultdict.py | 333 | 3.734375 | 4 | # https://www.hackerrank.com/challenges/defaultdict-tutorial/problem
from collections import defaultdict
if __name__ == '__main__':
n, m = map(int, input().split())
d = defaultdict(list)
for i in range(1, n+1):
d[input()].append(i)
for i in range(0, m):
print(" ".join(map(str, d[input... |
4626294642d8e6bb9c6c62783151e89383f42ebb | mrmukto/Python-Practise | /tarnaryOperator.py | 241 | 3.875 | 4 | a = 20
b = 10
print( a if a>b else b)
"""
logiacal opertator and short form
"""
m = int(input())
if 80<= m <=100:
print("A+")
elif 70<= m <=79:
print("A")
elif 60<=m and 69>=m:
print("B+")
else : print("result is not Goood") |
54476d5a03a05794d40606e702dbb59ef4179323 | c940606/leetcode | /笔试/英伟达2.py | 402 | 3.59375 | 4 | # -*- coding:utf-8 -*-
from collections import Counter
class Solution:
def __init__(self):
self.c = None
# 返回对应char
def FirstAppearingOnce(self):
# write code here
cnt = Counter(self.c)
for a in c:
if cnt[a] == 1:
return a
return "#"
... |
ffe7e3ca9efb3076501fd40d0c02f7c46c8a1f83 | Aehrlich98/fu_dbs_project_schehrlmar | /misc_files/data_cleaning-scripts/owid-co2-data.py | 1,281 | 3.84375 | 4 |
#https://docs.python.org/3/library/csv.html
import csv
#zieht Country, Year, Score, Rank, Healthyl Life Expectancy aus world-happiness-index.csv
#und fügt sie in dieser Spalten-Ordnung als neue CSV zusammen:
#Das Script ist hardgecoded für dei speziellen Formatierungen der fuenf Dateien und muss im gleichen Ordner wi... |
239dc52fa83c885698a6ea64a16d5a83310803ef | mur6/learning-algorithms | /Problem/Collatz/collatz.py | 314 | 3.84375 | 4 | import sys
def iter(n):
# 偶数なら、2で割る
# 奇数なら、3倍して1を足す。
while True:
yield n
if n == 1:
break
if n % 2 == 0:
n //= 2
else:
n = (3 * n) + 1
n = int(sys.argv[1])
print(" ".join(map(str, iter(n))))
|
25a1ad71c3d3c596fbcad45bbd809d32f503141f | jiachiwen/1082NO-BASE-in-Python | /0413.03.py | 297 | 3.5 | 4 | height=[176.5,177,154,165.8,156.4]
weight=[86.7,72.3,52.3,58.6,67.2]
bmi=[0,0,0,0,0]
for i in range(0,len(height)):#抽取出height的資料再放進去
height[i]=height[i]/100
for i in range(0,len(bmi)):
bmi[i]=weight[i]/(height[i]**2)#大家都要抽出第i個來計算
print(bmi) |
495fac637213e558b1b18325dfbe19e8a2364895 | chandrap08/leetcode | /tree.py | 1,109 | 4.03125 | 4 | class Tree(object):
def __init__(self):
self.stack = []
def breadth_first(self,root):
n = root
self.stack.append(root.data)
child_stack =[]
for c in n.get_children():
child_stack.append(c)
while child_stack:
for c in child_stack:
... |
d705a5f712301a8f0ad65f13bdcf83c6c768b368 | Lraviteja/bill_printing | /family.py | 1,097 | 4 | 4 |
"""
creating a class for family members
"""
class family_members:
def __init__(self):
self.list=[{'Name':' ','Age':' ','Gender':' ','id':' '}]
def add_familyMember(self,name,age,gender,id):
dict={'Name':name,'Age':age,'Gender':gender,"id":id}
self.list.append(dict)
return di... |
03e0579b1bb4278b36df3714f7bc2c047efefd61 | leon0417/LThinkPython | /T9_1.py | 3,426 | 3.515625 | 4 | from T8_1 import *
def len_larger_than_N(path, N):
fin = open(path)
for line in fin:
if N < len(line.strip()):
print(line.strip())
def words_no_e(path):
fin = open(path)
cnt = 0
sum = 0
for line in fin:
sum += 1
if -1 == find(line.strip(), 'e', 0):
... |
0ed46deae76abd26b215d3fa49134279cf65b8eb | Menah3m/leetcode-Python | /[剑指offer-47]max-value-of-present.py | 1,007 | 3.71875 | 4 | """
在一个 m*n 的棋盘的每一格都放有一个礼物,每个礼物都有一定的价值(价值大于 0)。你可以从棋盘的左上角开始拿格子里的礼物,并每次向右或者向下移动一格、直到到达棋盘的右下角。给定一个棋盘及其上面的礼物的价值,请计算你最多能拿到多少价值的礼物?
示例 1:
输入:
[
[1,3,1],
[1,5,1],
[4,2,1]
]
输出: 12
解释: 路径 1→3→5→2→1 可以拿到最多价值的礼物
来源:剑指offer-47
链接:https://leetcode-cn.com/problems/li-wu-de-zui-da-jie-zhi-lcof
"""
class Solution:
... |
5b49301542be08acb42bfe89f128950a660d5276 | heitormariano/python-bootcamp | /basics/numbers.py | 270 | 4.125 | 4 | numOne = 10
numTwo = 3.3
result = numOne + numTwo
print("The result is:", result)
numOne = 30.36
numTwo = 12.55
anotherResult = numOne - numTwo
print('The result is {}'.format(anotherResult))
numOne = 300
numTwo = 100
print('The result is {}'.format(numOne / numTwo))
|
ed524f1c7d864f9bbfb43fc653637594ad4d9685 | PacktPublishing/Software-Architecture-with-Python | /Chapter04/big_o.py | 1,262 | 3.65625 | 4 | # Extra Code
"""
Big-O notation image generator. Code which generated the Big-O
growth graph (order) in the book.
"""
import numpy as np
import math
import matplotlib.pyplot as plt
from functools import reduce
def f(t):
return np.exp(-t) * np.cos(2*np.pi*t)
def k(t):
return [0]
def l(t):
return list... |
6ef83dfd225f79a75e20aab81cf921b87be54989 | ashaheedq/Python-assignments | /Problem sets/10/ps10pr1.py | 5,843 | 4.25 | 4 | #Problem Set 10 Problem 1
# Abdulshaheed Alqunber
# ASQ@BU.EDU
# Partner: Ali Salem
# alisalem@bu.edu
class Board:
def __init__(self, height, width):
'''constructs a new Board object by initializing the following three attributes:
• an attribute height
• an attribute width
• an attribute... |
5496ca7a5ba9ae57e6f168e4dff2b4b7aac5c842 | Vynstyn/Python-School-Work | /PE 3-16 February Days.py | 1,009 | 3.9375 | 4 | """ Roger Rues Student ID: 1000130372
Program Exercise# 3-16 Febrruary Days Assignment# 0
Due Date:
Program Description:
This program displays the amount of days in the month of February
"""
#*** Modules\Libraries
import os #*** system() - OS commands
#*** Begi... |
d9a93199d7b47690b33a44c1cc99f79bce9a3314 | dylan-pham/Project-Euler | /new solutions/1.py | 327 | 4.21875 | 4 | # sum_of_multiples : Num, Num -> Num
# given a number, finds the sum of its multiples below a second given number
def sum_of_multiples(multiple, _max):
_sum = 0
for i in range(_max):
if (i % multiple) == 0:
_sum += i
return _sum
print(sum_of_multiples(3, 1000) + sum_of_multiples(5, 1000) - sum_of_multiples(15,... |
354d25a188caf3d4c0de98f704ca571710a9cf80 | lchang1977/SDNHeaderAuthentication | /generateKeys.py | 2,372 | 3.640625 | 4 | #usr/bin/python/generateKeys.py
"""
This program generates keys that are binded to a certain host id
Usage: python generateKeys.py -keydir <path_to_keys> -host_id <args of host_id>
<path_to_keys> is the directory in which all keys will be generated
By default keys are generated in a folder called keys in the current ... |
688ab24090a8b079db0b8ed185860746c0709a9f | mikez321/practice_projects | /other_challenges/python/ascending_list.py | 1,582 | 4.25 | 4 | """Ascending list challenge from checkio."""
import unittest
from IPython import embed
def is_ascending(nums: list) -> bool:
"""
Return true if all elements in a list are in least to greatest order.
:param nums: A list of ints
:return: If the list is sorted from least to greatest value the function
... |
bdda22972c075188319a1aa5eaec2ded5fb25883 | cmoore3433/Algorithms-DataStructures | /quicksort.py | 1,229 | 3.703125 | 4 | from statistics import median
def quickSortStart(array, p=0):
r=len(array)-1
if p<r:
q=partition(array,p,r)
quickSort(array, p, q-1)
quickSort(array, q+1, r)
def quickSort(array, p, r):
if p<r:
q=partition(array,p,r)
quickSort(array, p, q-1)
qui... |
10b6b5524995741bcfb4f31042014bd24a71ba67 | bobcaoge/my-code | /python/face_programs/codes/07_2_getMaxValueInEachWindow.py | 742 | 3.859375 | 4 | # /usr/bin/python3.6
# -*- coding:utf-8 -*-
from data_structure.queue import Queue
def get_max_values_of_list(data_list, window_length):
q = Queue()
res = []
for index, data in enumerate(data_list):
put_queue(q, index, data_list)
if q.peek() == index - window_length:
q.poll()
... |
8ee107533972f4b4718ae2b7cd0c5a36cf6053f5 | Paul-A-Newman-Fanclub/csc111-project | /bigquery.py | 7,653 | 3.765625 | 4 | """
CSC111 Final Project: Reconstructing the Ethereum Network Using
Graph Data Structures in Python
General Information
------------------------------------------------------------------------------
This file was created for the purpose of applying concepts in learned in
CSC111 to the real world problem domain of cryp... |
5006e946e761ea884aec570997c897b75138189a | kevintaehyungkim/code-problems-python | /test.py | 685 | 4.125 | 4 | # -*- coding: utf-8 -*-
def max_sum(nums):
if not nums:
return 0
elif len(nums) <= 2:
return sum(nums)
return max(max_sum_helper(nums[0],nums[2:]), max_sum_helper(nums[1], nums[3:]), max_sum_helper(nums[0], nums[3:]))
def max_sum_helper(curr, nums):
if not nums:
... |
e183062824199b0e13200546e7e9392f145c91cd | Koozzi/Algorithms | /SAMSUNG/삼성코딩테스트기출/G2_17143_20210309.py | 1,629 | 3.75 | 4 | def get_shark(j):
global N
for i in range(N):
if board[i][j]:
value = board[i][j][2]
board[i][j] = []
return value
def next_location(i,j,shark):
global N, M
s,d,z = shark
if d <= 2: s %= (2 * N - 2)
else: s %= (2 * M - 2)
for _ in range(s):
... |
8094919f113895d221b3038cea15d2a3d9d925d8 | albusdumbledore1/swapping-file-code | /swappingFile.py | 303 | 3.578125 | 4 | def swapData():
file1=input("enter your file1 : ")
file2=input("enter your file2 : ")
f1=open(file1,'r')
data_f1=f1.read()
f2=open(file2,'r')
data_f2=f2.read()
f1=open(file1,'w')
f1.write(data_f2)
f2=open(file2,'w')
f2.write(data_f1)
swapData()
|
2a9fcfd2f2ec3408bd387272e3fffdb91e97611a | kbooth1000/immersive11-18-unit1 | /guess_number.py | 515 | 3.890625 | 4 | # name = raw_input('What is your name? >')
# print 'Hi ' + name
# print type(name)
secret_number = 5
secret_guessed = False
while(secret_guessed == False):
users_guess = int(raw_input('Guess my number: '))
if(users_guess == secret_number):
print('Yep, it is %s' % secret_number)
secret_guessed =... |
c30a099474b2a62c47809c2349c45346fcc0dd2f | zamanwebdeveloper/OOP_in_Python | /Python 3.8 Programming/Function3.1.py | 344 | 3.796875 | 4 | def print_greatest_no(a,b,c):
greatest = 0
if a>b:
if a>c:
greatest = a
else:
greatest = c
elif b>a:
if b>c:
greatest = b
else:
greatest = c
else:
greatest = c
print(greatest,"is greatest")
a = 40
b = 50
c = 60
... |
c8da1852556761fda81b41450363199cbf020eb0 | saivythik/python-game-projects | /snake.py | 2,955 | 3.875 | 4 | import turtle
import time
import random
delay=0.1
#set up the screen
wn=turtle.Screen()
wn.title("Snake Game by vythik")
wn.bgcolor("light blue")
wn.setup(width=600 , height=600)
wn.tracer(0)
#Snake head
head=turtle.Turtle()
head.speed(0)
head.shape("circle")
head.color("black")
head.penup()
head.goto(0... |
736633e5ef191411d68e18fc7834c32a80473a5d | vishnoiprem/pvdata | /lc-all-solutions-master/005.longest-palindromic-substring/test.py | 1,767 | 3.609375 | 4 |
Input="babad"
Output="bab"
#Note: "aba" is also a valid answer.
#Example1:
Input=" ab | 9999/ a "
Output=True
def longestPalindrom(s):
l=0
r=len(s)-1
status=True
while l<r:
if not s[l] in "abcdefghijklmnopqrstuvw":
l= l+1
if not s[r] in "abcdefghijklmnopqrstuvw":
r=r-1
if s[l]!=s[r] and s[l] ... |
77b08da7f10218fcae32021e964ecc7a347704b1 | mwhit74/interpreter | /rbi/interp.py | 3,769 | 3.671875 | 4 | import pdb
#Token types
#EOF used to signal end of input
INTEGER, PLUS, MINUS, EOF = "INTEGER", "PLUS", "MINUS", "EOF"
class Token(object):
def __init__(self, value, type):
self.value = value
self.type = type
def __str__(self):
return "Token({}, {})".format(self.value, self.type)
... |
4fc0656150847a90e432b7de4fc2378e91ee344c | tanmaynaik/Tanmaynaik | /Aug16/ASCII_value.py | 153 | 4.40625 | 4 | # Find ASCII value of 'x' and 'X'
value = 'x'
print ("ASCII value of x is: ",ord(value))
VALUE = 'X'
print ("ASCII value of X is: ",ord(VALUE))
|
16123573e48714335584481f9672904c64be1337 | absbin/genreator-test | /davin_reddy/class_inside_class.py | 533 | 3.671875 | 4 |
class Student:
def __init__(self,name,rollnu):
self.name=name
self.rollnu=rollnu
def show(self):
print(self.name,self.rollnu)
class Laptop:
def __init__(self):
self.brand="HP"
self.cpu="i5"
self.ram=8
def show(self):
... |
a443e2763658b2cbfb760dbd6010f9fb42826cd7 | skang6283/algorithm_daily | /카카오개발겨울인턴십 2019/튜플.py | 403 | 3.5625 | 4 | def solution(s):
answer = []
s = s.replace("{", "").split("}")
s = list(filter(None, s))
val = []
for l in s:
val.append(list(filter(None, l.split(','))))
val.sort(key=len)
answer.append(val[0][0])
for l in val:
for num in l:
if num not in answer:
... |
7fbe6773b0f2e3a3ceb8eb0f0804814fb0399e08 | EmiCohenSoft/eCohenAdimra | /semana5/5ºEj_CalculadoraCientifica.py | 1,553 | 4.375 | 4 | #Calculadora científica:
#Para simular el funcionamiento de una calculadora científica, solicitar el ingreso de un número
#y mostrar un menu de operaciones disponible (seno, coseno, tangente, elevado al cuadrado y raíz cuadrada)
#Imprimir debajo el resultado luego de elegir la operación, repitiendo indefinidamente
#mie... |
a775a5a420f5acc9d451861a4ee3c3675b85a59d | barathganesh/ROCK-PAPER-SCISSOR | /RockPaperScissor.py | 1,376 | 4.125 | 4 | """ Rock Paper Scissors
----------------------------------------
"""
import random
import os
import re
os.system('cls' if os.name=='nt' else 'clear')
while (1 < 2):
print ("\n")
print ("Rock, Paper, Scissors - Let's Go!")
userChoice =input("Choose your weapon [R]ock, [P]aper, [S]cissors, or press ... |
862a4994c4a53c860c55d9a3ece96b7452bbfdde | ironidev/Python-Kriptografi | /helper/dekripsitransposisi.py | 1,004 | 3.609375 | 4 | ################################################################
# Dekripsi dengan sandi Transposisi
# Editor : Matius Celcius Sinaga
# Author : # http://inventwithpython.com/hacking (BSD Licensed)
# ################################################################
import math, pyperclip
def main():
pesanSaya = 'I... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.