blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
dd61557516635e0dc67c67910478380c99c8d7a8 | josephjoju2/Automate-with-python | /dict/ex6.py | 276 | 3.546875 | 4 | import pprint
stuff={'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1, 'arrow': 12}
print('inventory: ')
total=0
inventory={}
for k,v in stuff.items():
total+=v
temp=k
k=v
v=temp
inventory[k]=v
pprint.pprint(inventory)
print('total items: '+str(total))
|
10c86fb510fa55f4072263bc37e686d12cf29c87 | Coursal/PyDFA | /scan_input_file.py | 1,899 | 4.125 | 4 | from dfa import *
def scan_input_file(input_file_name):
" A function that scans the input file line by line and returns a DFA object based on what's scanned "
input_file = open(input_file_name, 'r') # open the input file
# read the 1st line and turn it to an integer
num_of_states = int(input_file.re... |
e4562704b70269ddd6eccf5a58f01542198b3285 | green-fox-academy/Unicorn-raya | /week-03/day-02/Sum/sum_test.py | 648 | 3.609375 | 4 | import unittest
from sum import Sum
class Test_sum(unittest.TestCase):
def setUp(self):
self.sum = Sum([1,2,3,4,5]).getSum()
self.emp_sum = Sum().getSum()
self.one_element_list = Sum([2]).getSum()
self.multiple_list = Sum([2,3,4,5]).getSum()
self.none_list = Sum([None]).getSu... |
e15bd043b24c9cd343f670c69d16d165f3806806 | kana986ike/python_practice1 | /dice_game.py | 454 | 3.515625 | 4 | import dice
num = int(input('4,6,8,12,20のどれで勝負しますか?:'))
my_dice = dice.Dice(num)
computer_dice = dice.Dice(num)
my_pip = my_dice.shoot()
cpu_pip = computer_dice.shoot()
print('CPU:'+str(cpu_pip)+'あなた:'+str(my_pip))
if my_pip > cpu_pip:
print('おめでとうございます。あなたの勝ちです。')
elif my_pip < cpu_pip:
print('残念!あなたの負けです。... |
965717d14c6f598105646e3b96e785c09de125bc | saddamEDocument123/AllDocumentEbook | /DocumentEbook/Python-Doc/PaythonProgramPractic/FileIO.py | 606 | 4 | 4 | #File I/O
#creating file
#Reading file
#open function
#
#open function taken two parameter
file1 = open("textFile.txt","r")
#this is for read for file
print file1.read()
#it is showing only space or
#cursor now is last thets why its showin
# space
#if onece we read the file then if we want to again read that fi... |
55107eeb17f75f13862c9baed8222db613633cb8 | jigneshbhimani/SQL-Query | /6Query(And).py | 460 | 3.53125 | 4 | # 6.SQL AND Query:
# WHERE clause can be combined with AND operator.
# AND operator is used to filter records based on more than one condition:
# The AND operator displays a record if all the conditions separated by AND are TRUE.
# AND Syntax:
'''
SELECT column1, column2, ...
FROM table_name
WHERE condition... |
d9dc3d5721c4cb09715aba6752de598d80fade84 | jay6413682/Leetcode | /Linked_List_Cycle_141.py | 2,640 | 3.625 | 4 |
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def hasCycle(self, head: ListNode) -> bool:
""" https://leetcode-cn.com/leetbook/read/linked-list/jbex5/
https://leetcode-cn.com/problems/linked-list-cycl... |
c57fca636440cc0e07bc92ae59828106b65686cc | andrii-bublyk/sigma-python-nov-20 | /homework02/task5.py | 574 | 3.953125 | 4 | cards_dict = {
"2": 1,
"3": 1,
"4": 1,
"5": 1,
"6": 1,
"7": 0,
"8": 0,
"9": 0,
"10": -1,
"J": -1,
"Q": -1,
"K": -1,
"A": -1
}
user_cards_string = input("enter cards: ")
clear_cards_string = user_cards_string.replace(" ", "").replace("'", "")
user_cards = clear_cards_... |
a90043bc6c8e2de89f2f57de44b6ff9c15d3e471 | mivargas/ejercicios-de-python | /graficos/entry_interface.py | 1,620 | 3.859375 | 4 | from tkinter import *
root=Tk()
root.title("primer entry")
miFrame=Frame(root, width=1200, height=600)
miFrame.pack()
nombreLabel=Label(miFrame, text="Nombre:")
#nombreLabel.place(x=80, y=100) #forma incorrecta para trabajar con varios elementos ya que se superponen
nombreLabel.grid(row=0, column=0, sticky="e", pad... |
a110e4878f8052389e97f05502058ab7a851e6f0 | Chainso/HLRL | /hlrl/core/experience_replay/binary_sum_tree.py | 3,247 | 4.0625 | 4 | import numpy as np
class BinarySumTree():
"""
A binary sum tree
"""
def __init__(self, num_leaves):
"""
Creates a binary sum tree with the given number of leaves
num_leaves : The number of leaves in the tree
"""
self.num_leaves = num_leaves
self.size = 0... |
2fc8288f036c172a2407c28873b868a28fe27522 | zhankq/pythonlearn | /alivedio/base2/employee.py | 2,540 | 3.828125 | 4 | #显示系统 的欢迎信息
print('-'*20,'欢迎使用员工管理系统','-'*20)
user_list = []
#user_list.append(['姓名','年龄','性别','住址'])
#根据用户选择做相关的操作
while True:
#显示 用户的选项
print("请选择要做的操作:")
print("\t1.查询员工")
print("\t2.添加员工")
print("\t3.删除员工")
print("\t4.退出系统")
user_choose = input("请选择【1-4】:")
if user_choose == '1':
... |
e6fc1fd55f0892a883cfe68d29bd92168ab19101 | shrddha-p-jain/Python | /Assignment 0/13.py | 254 | 3.703125 | 4 | s = input("enter a string: ")
y = int(input("Position where you want to delete:"))
if(y<0):
print("Position must be positive")
else:
output = ''
for i in range(len(s)):
if(i!=y-1):
output+=s[i]
print(output)
|
de559eeacd0530766bab9e20945da1403bb3967c | Hellofafar/Leetcode | /Medium/152.py | 1,642 | 4.0625 | 4 | # ------------------------------
# 152. Maximum Product Subarray
#
# Description:
# Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.
# Example 1:
# Input: [2,3,-2,4]
# Output: 6
# Explanation: [2,3] has the largest product 6.
#
#... |
2acc7a47cf9b0a0c5da05fa90183e61b9d681dfe | JohnStevensonWSU/Ranking | /main.py | 924 | 3.609375 | 4 | import IndexList
def main():
index = IndexList.indexList()
index.add("hello", 1)
index.add("hello", 1)
index.add("hello", 1)
index.add("hello", 2)
index.add("hello", 2)
index.add("hello", 3)
index.add("there", 1)
index.add("there", 1)
index.add("there", 2)
index.add("t... |
24dbdf24511c11bab1986b134a86ac7d30f60fbb | Provinm/leetcode_archive | /problems1_100/7_Reverse_Integer.py | 778 | 3.984375 | 4 | # coding=utf-8
'''
7. Reverse Integer
Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
'''
class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
if x == 0 or not -1*(2**32) <= x <= 2**32 ... |
28beb4a3e37bd17ac224a8e0e606d5da6ab961a1 | ARJUNRAJOP/PYTHON-MYCAPTAIN | /administration.py | 1,118 | 3.9375 | 4 | import csv
num=1
def write_csv(info_list):
with open('C:/Users/Shrinivas/Desktop/student.csv' , 'a', newline='') as f:
writer=csv.writer(f)
if(f.tell()==0):
writer.writerow(["Name","Age","Contact","E-mail ID"])
writer.writerow(info_list)
condition=True
while(condition):
... |
2119aa05b2146c5e1ec3420b46c387eb690e458f | luiz158/Part-Manager | /computer_part_manager.py | 9,375 | 4.125 | 4 | from tkinter import *
#import database db module
#from db import Database class
from db import Database
#import messagebox library from tkinter
from tkinter import messagebox
#now here we will instanciate the db object
#it will create the table if not already present
db = Database('store.db')
#here are all the funct... |
e15d04cb6ecde05459936684d554509d8b6e3903 | yejineer/Study | /BigData/Lab2/q4.py | 219 | 3.921875 | 4 | for i in range (0, 10):
for j in range(0, 10 - i - 1):
print(' ', end='')
for j in range(0, i*2+1):
print('*', end='')
for j in range(0, 10 - i - 1):
print(' ', end='')
print('')
|
151b79e16dcb12393d1ad4d6f982ec5d00eb357c | CaiJiJi/My_Dirty_Scripts | /md5_crack_challenge/h.py | 158 | 3.609375 | 4 | import crypt
salt = 'shishaclub'
with open('wordlist.txt','rb') as f:
for password in f:
print(crypt.crypt(password.strip(),salt))
|
4be3c67ed10d182172fc909e57226c60129d9988 | Spuntininki/Aulas-Python-Guanabara | /ex0096.py | 251 | 3.71875 | 4 | def area(x, y):
a = x * y
print(f'a aréa de um terreno {x}x{y} é {a}m²')
print('Controle de Terrenos')
print('-'*30)
l = float(input('Insira a largura do terreno (m): '))
c = float(input('Insira o comprimento do terreno (m): '))
area(l, c) |
7c4f04d8a9b8c5d9e9c1378fcdf9df5403924cb9 | PabloG6/COMSCI00 | /Lab3/emoticons.py | 330 | 4.15625 | 4 | user_input = input("Enter an emotion: ")
if (user_input=="happy" or user_input=="smiling"):
print(':-)')
elif (user_input=='sad'):
print(':-(')
elif (user_input=='happy'):
print(':-)')
elif(user_input=='crying'):
print(':-’(')
elif(user_input=='laughing'):
print(':D')
else:
print("Try another em... |
0b7d3a91aa3a3d8ad24134d434de4528404417fa | MeisterKeen/Python-Projects | /abs1.py | 992 | 4.4375 | 4 |
import abc
from abc import abstractmethod # If I don't do this, I have to write the
# decorator as "@abc.abstractmethod"
# So this class will be the parent class:
class Abstract(object):
@abstractmethod
def abstractery(self):
pass
# So this is the method we'r... |
976878bdbe2b0d3216f89654d26a96e1eeefbd45 | workready/pythonbasic | /sources/t03/t03ej23.py | 286 | 4.0625 | 4 | x,y = 8, 4
if x > y:
print("x es mayor que y")
print("x es el doble de y")
if x > y:
print("x es mayor que y")
else:
print("x es menor o igual que y")
if x < y:
print("x es menor que y")
elif x == y:
print("x es igual a y")
else:
print("x es mayor que y") |
81c6413fcdbccbd24d64239d9c972e52cff575d1 | modihere/intro-to-ml | /coding_standards/newtest1.py | 835 | 3.78125 | 4 | class FindChar:
def __init__(self, string):
# constructor initialization
self.string = string
def find_char(self, check, element):
# function to return the second element or the element being searched
if check == 0:
# returning the second element in this block
return self.string[1]
else:
# a exce... |
88a4515a439dac8e4eea321d0721567598ea9c5c | BigPieMuchineLearning/python_study_source_code2 | /exercise_6_1.py | 114 | 3.734375 | 4 | n=int(input())
def absolute_number(n):
result=n if n>=0 else -1*n
print(result)
absolute_number(n)
|
c0d57f1b19a72b1232ee5399dba3c78352c6e0c8 | vinnav/Python-Crash-Course | /CheatSheets/3lists.py | 2,545 | 4.4375 | 4 | listExample = ["element0", "element1", "element2", "element3"]
listExample[0] = "element0" # First element of the list
listExample[-1] = "element3" # Last element of the list
# Changing, adding, removing elements
listExample[0] = "new_element0" # Change element 0
listExample.append("element4") ... |
5a88927ab7ea44f570dd66b58894c4a44a91c724 | Neveon/python-algorithms | /greedy_algorithm/optimal_task.py | 1,165 | 4.46875 | 4 | # Given a list of numbers with each number corresponding to a duration of a task
# assign each item to a 'worker' with each 'worker' taking 2 items/tasks maximum
# and contain the minimum max duration to wait
# EXAMPLE
# [6, 3, 2, 7, 5, 5]
# worker 1 (6, 3)
# worker 2 (2, 7)
# worker 3 (5, 5)
# max(6+3, 2+7, 5+5) = 1... |
0cc1a20a886dec2e2d65d8187a6eb1e6f92814b6 | Abhi7865/python-projects | /cal.py | 1,101 | 4 | 4 | import numpy
def add():
num1=int(input("enter number 1:"))
num2 = int(input("enter number 2:"))
return num1+num2;
def sub():
num1 = int(input("enter number 1:"))
num2 = int(input("enter number 2:"))
return num1-num2;
def multi():
num1 = int(input("enter number 1:"))
num... |
f5e80a16365a780e86abd909c7d50661a9501182 | Miguel2308/Analisis-de-Datos | /DiccionariosDA.py | 3,743 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Oct 11 20:56:55 2020
@author: Admin
"""
# podemos crear una lista con tupla y transformarlas en un diccionario
diccionary = [(1,'uno'),(2,'dos'),(3,'tres'),(4,'cuatro'),(5,'cinco')]
mi_diccionario = dict(diccionary)
print(mi_diccionario,'Diccionario creado a p... |
9694c5a1fd26e5ac11fd34b54fc3652827c62c8c | Samm0007/Prepas | /2.12_Cine.py | 298 | 3.546875 | 4 | edad = int(input('Bienvenido al CineUNIMET\n Ingrese su edad para determinar el costo de su boleto: '))
if(edad<4):
print('Tu entradas en GRATIS!!')
elif(edad>= 4 and edad<=18):
print('El precio de tu entrada es de $10')
elif(edad>18):
print('EL precio de tu entrada es de $14') |
806298f73d8ee7a630dc00c5ae5546446404f594 | SKO7OPENDRA/gb-algorithm | /cw/cw_6/cw_6_3_2.py | 316 | 3.609375 | 4 | allocated = 0
for newsize in range(100):
if allocated < newsize:
new_allocated = (newsize >>3) + (3 if newsize < 9 else 6) # старое значение newsize со сдвигом на 3 байта вправо + 3 или 6
allocated = newsize + new_allocated
print(newsize, allocated) |
d33c02fc17f4243934078956a9fbf5530eb3891b | ragatol/aulas_jogos | /aula02/exemplo02.py | 491 | 4.1875 | 4 | # aqui a expressão booleana é True, então vai aparecer OK!
if (True): print("OK!")
# aqui a expressão booleana é False, então não vai aparecer FALSO!
if (False): print("FALSO!")
# aqui a expressão de comparação tem resultado verdadeiro
if (2 == 2): print("2 == 2 é verdadeiro!")
# e aqui a expressão de comp... |
c60f103959cb87ba38ab1a0a4d397f52c666efbe | sbsdevlec/PythonEx | /Hello/DataType/Day01/lotto2.py | 170 | 3.53125 | 4 | import random
game = int(input("몇게임?"))
for i in range(0,game):
lotto = random.sample(range(1,46),6)
lotto.sort()
print(i+1,"게임 : ", lotto)
|
5b16c75a8db9f48d1ec7b1ef1d54b862a0a593f2 | stuti-rastogi/leetcode-python-solutions | /1472_designBrowserHistory.py | 2,082 | 3.5 | 4 | class BrowserHistory:
def __init__(self, homepage: str):
self.history = [homepage]
self.curr = 0
self.bound = 0
def visit(self, url: str) -> None:
self.curr += 1
if self.curr == len(self.history):
self.history.append(url)
else:
self.histor... |
598368daf9e77feabf1e9aebbafb0d275a7b7603 | Elmlea/pythonAuto | /ch2_q13.py | 906 | 4.34375 | 4 | type = "" # initialise the variable because it gets checked shortly
print("That's the variable initialised.") # so I know the program has started!
while ("for" not in type) and ("while" not in type):
type = input("Would you like to print your numbers using a FOR loop, or a WHILE loop? :> ")
if "for" in type... |
3edd48b0464e138391ff31967b2f869d31654339 | MilanMolnar/Codecool_OW | /using_if/if_4.py | 812 | 3.734375 | 4 | def easter():
while True:
try:
T = int(input("Irjon be egy évet: "))
except ValueError:
print("Szamokkal adja meg az évet")
if T > 2099 and 1800 < T:
print("Kérem évszámot adjon meg 1800 ls 2099 között")
else:
break
A = ... |
f85e2f39dbbc6e760d195be2823dfeb3c8c62bd9 | Bray821/PythonProgram1 | /OOPCalc.py | 298 | 3.703125 | 4 | prices = {
"Strawberries" : "$1.50",
"Banana" : "$0.50",
"Mango" : "$2.50",
"Blueberries" : "$1.00",
"Raspberries" : "$1.00",
"Apple" : "$1.75",
"Pineapple" : "$3.50"
}
number = "$1.50"
new_num = ""
anwser = 0
for i in number
if i.isnumeric() or i == "." :
new_num +=
|
36e982f9ac8c26f86258cb8c4755811e79a2d8f2 | ccdv2and4dalao/CenterAirConditioner | /abstract/model/user.py | 1,257 | 3.953125 | 4 | from abc import abstractmethod
from abstract.model.model import Model
class User:
table_name = "user"
# 主键
id_key = "id"
# 身份证号
id_card_number_key = "id_card_number"
def __init__(self, user_id=0, id_card_number=''):
self.id = user_id # type: int
self.id_card_number = id_card... |
19dc23c65cd63abd45d1eafbb1a3d7f055183e4c | gabriellaec/desoft-analise-exercicios | /backup/user_162/ch44_2020_04_06_14_31_58_503502.py | 205 | 3.828125 | 4 | lista = {"janeiro":1, "fevereiro":2, "março":3, "abril":4, "maio":5,
"junho":6,"julho":7,"agosto":8, "setembro":9, "outubro":10,
"novembro":11, "dezembro":12}
a = input()
print(lista[a]) |
7a0ae88ce40c183c282e86b866d02bd38fc60aa8 | shubhkalani/MachineLearning | /CC36_SLR.py | 1,247 | 3.90625 | 4 | import pandas as pd
import matplotlib.pyplot as plt
Foodtruck = pd.read_csv("Foodtruck.csv")
#Splitting into dependent and independent columns
X=Foodtruck.iloc[:,0:1]
Y=Foodtruck.iloc[:,1]
#Splitting into train and test data
from sklearn.model_selection import train_test_split
X_train,X_test,Y_train,Y_test = train_te... |
c5f6d877ce389cb21bf097aa5f9eb3177769aa45 | bpnsingh/git_pract | /codeAcademy/Advancedloop/Max Num.py | 414 | 4.25 | 4 | """Create a function named max_num() that takes a list of numbers named nums as a parameter.
The function should return the largest number in nums"""
#Write your function here
def max_num(lst):
max = lst[0]
for num in lst:
if num < max:
continue
else:
max=num
return ... |
e4c0274fa0b7304e05c4c6842a5acdb76f7c59e9 | compsciprep-acsl-2020/2019-2020-ACSL-Python-Akshay | /Class9-28/variables.py | 164 | 4.0625 | 4 | a = int(input("Enter number 1"))
b = int(input("Enter number 2"))
#add
print(a+b)
#subtract
print(a-b)
#product
print(a*b)
#quotient
print(a/b)
#modulus
print(a%b)
|
4f3b6ed9fc29b5eaa09b9e1d76fe9a86d63513d4 | Inimesh/PythonPracticeExercises | /4 Function exercises/Ex_95.py | 709 | 4.03125 | 4 | ## A function that generates a random liscence plate in either an old style
# (three letters followed by three numbers), or new (four numbers followed by
# three letters). main() function runs function and displays liscence plate.
def randLiscence():
from random import randint
liscence = ""
isNew = randint... |
72f7d7a673d4f8e8c64549aff73eabcbdcc82631 | Devansh2005/Tkinter | /tk.py | 4,047 | 3.96875 | 4 | # create a tkinter window
import tkinter as tk
from csv import DictWriter
import os
from tkinter import ttk
win =tk.Tk()
win.title("Devansh") # devansh as a title of window
# Create Labels -- ttk --> radio button, labels
# from tkinter import ttk
name_label=ttk.Label(win,text="Enter your name :")
name_label.grid(... |
7c0ebb8658d2966ce0d4a15ed3a2585bfb8d98b3 | 1GBattle/gab_locator | /gag_functions/check_multi_line_comment.py | 449 | 3.53125 | 4 | # declares and function that takes in two args operators and data types
# function iterates through operators until the /* or */ operator is found
# once operators is found the correct data type is appended to the array
def check_multi_line_comment(operators, data_types_to_pass):
for operator in operators:
... |
419170c48149d1b530d7eeca3d6f538f66f582d0 | ikramulkayes/Python-practice-codewars.com- | /untitled11.py | 408 | 3.53125 | 4 | def DNA_strand(dna):
p = list(dna)
k = list()
for word in p:
if word == "A":
k.append("T")
elif word == "T":
k.append("A")
elif word == "C":
k.append("G")
elif word == "G":
k.append("C")
s... |
5a6ca69f52389c89b253c1282432c5d81af3ebda | TMAC135/Summaries-By-Myself | /python/OO_in_python/5_描述对象的特征/private1.py | 161 | 3.546875 | 4 | class A:
def __init__(self):
self._ab = 0
def info(self):
print(self._ab)
a = A()
a.info()
a._ab = 3
a.info()
print(a._ab)
|
3024f25d2a4c1dbde85e568cc628b27bec3b803c | mateusz-kleszcz/Algorithms-and-Data-Structures | /list/merge from their end.py | 967 | 3.875 | 4 | class Node:
def __init__(self):
self.value = None
self.next = None
def printList(L):
while L is not None:
print(L.value, '->', end=' ')
L = L.next
print('|')
def tab2list(T):
H = Node()
C = H
for i in range(len(T)):
X = Node()
X.value = T[i]
... |
c223257e355adcdc28e9afdff6ea97b621ccc6a5 | Jeaced/simulated_annealing | /annealing.py | 3,120 | 3.671875 | 4 | import pandas as pd
import matplotlib.pyplot as plt
import math
import random
NUMBER_OF_CITIES = 30
INITIAL_TEMPERATURE = 15000.0
COOLING_RATE = 0.004
columns = [6, 17, 18, 20]
df = pd.read_csv('cities.csv', header=0, usecols=columns)
df = df.sort_values('Население', ascending=False, na_position='last')
df = df[0:NUM... |
de68b1bbd9e21dcc2ac44109f93422eb941b1f75 | viQcinese/kanji_frequency | /kanji_frequency.py | 3,141 | 4.09375 | 4 | # Analyse a text file and sort most frequent Kanji
# Create a text file to store Kanji frequency
# Display 20 most frequent Kanji
import operator
# Get text from target file = source
def get_text(source):
with open(source, "r", encoding='utf-8') as f:
text_string = f.read()
return text... |
f581a2807efb2a1cfd4d08550f743f51e31b8163 | TheTechTeen/CIS-110-Portfolio | /line_properties.py | 1,286 | 4.03125 | 4 | # Properties of a Line
# Calculates the endpoints, length, and slope of a user-defined line
# Aiden Dow
# 9/26/2019 - Revised 12/20/2020
import datetime
from graphics import GraphWin, Text, Point, Line, Circle
import math
def main():
# Create graphics window
win = GraphWin("Properties of a line", 500, 500)
... |
83d185835b46f714df13ab7ddb54d6256cb6b19c | nugeat23/workspace | /01.python/ch03/ex03.py | 295 | 3.953125 | 4 | a = "Korea 서울 1234"
print(a)
# a = "I Say "Hello" to you" <-- 인용 부호 에러
# print(a)
a = 'I Say "Hello" to you'
print(a)
a = "I Say 'Hello' to you"
print(a)
a = "I Say \\ \t'Hello', \n\"Good Morning\" to you"
print(a)
print("hello")
print("world")
print("hello\nworld")
|
bd3a4b2fb0e550ff3f9ce8d794ad3733d07c87e6 | ArnavMohan/MiscCode | /Simultaneous_Equation_Solver/matrix.py | 5,574 | 3.875 | 4 |
#init, fill, add, sum,mult, transpose, determinant, sum_product
#_________________________________________________________________
class Matrix: #TODO replace errors with method error, better error descriptions
num_rows = 0#TODO improve printing -- __printRow with string manipulation
num_cols = 0
de... |
07b85aca9f570f885ec4dcad4f561539b350510f | DoctorLai/ACM | /binarysearch/Longest-Anagram-Subsequence/Longest-Anagram-Subsequence.py | 344 | 3.578125 | 4 | # https://helloacm.com/algorithm-to-find-the-longest-anagram-subsequence/
# https://binarysearch.com/problems/Longest-Anagram-Subsequence
# MEDIUM, HASH TABLE
class Solution:
def solve(self, a, b):
aa = Counter(a)
bb = Counter(b)
ans = 0
for i in aa:
ans += min(aa[i], bb... |
262af4e389c09ab894ab8632c9b365af885e146d | ghonk/simsextet | /instructs.py | 1,896 | 4.25 | 4 | cond_instructs = (
" Hello! In this study, you are going to see a series of different sets of"
" items (words). For each set, your goal is to find the two items in the set"
" that are most similar to one another. When you've chosen the two items that"
" are most similar, use the mouse to select the items and then ... |
186871bc53d0f69d6ec747ac436eeba36db4ac6a | hellojessy/CSCI-1100 | /Homeworks/Homework 4/hw4Part3.py | 2,256 | 3.53125 | 4 | import hw4_util
# Function to read pokemon list and coordinates given to each pokemon
# Prints out list of pokemon with coordinates
def print_pokemon(pokemon, coord):
i = 0
print('Current pokemon:')
for i in range(len(pokemon)):
print(' ' * 4, pokemon[i], 'at', coord[i])
i += 1
# Fu... |
0dfc2fa2287f2cb5d6feeba6e6c02055f42d3eaa | komal-kumarii/python_basics | /if_else/water.py | 169 | 3.78125 | 4 | water=int(input("filter me kitna pani h"))
if water<1:
print("or bharna h")
elif water>1 and water<10:
print("ni bharna h")
else:
print("overflow ho jata h") |
f45bbeea0eeed0f2fa74ac433ba204a1f6b4dfc6 | DanielFernandoYepezVelez/Fundamentos-Python | /05-Condicionales/05-Ternario.py | 344 | 4.09375 | 4 | """ Muestra El Mensaje Por Pantalla Si x == 5, Por El Contrario Muestra El else """
x = 54
print('X Es Igual a 5') if x == 5 else print('X No Es Igual a 5')
""" Muestra El Valor De La Variable Si La Condición Se Cumple, Por El Contrario Muestra El else """
es_bonito = False
estado = "Es bonito" if es_bonito else "No e... |
01d371399bc5726cf6cf0598f0227a7d3fc5c515 | colkipyeg/Python_Basics | /sololearn.py | 984 | 4 | 4 | # x=123.456
# print(x)
# x="This is a string"
# print(x+"!")
#
# spam=2
# eggs=3
# del spam
# eggs=4
# spam=5
# print(spam*eggs)
#
# x="a"
# x*=3
# print(x)
#
# spam="7"
# spam=spam+"0"
# eggs=int(spam)+3
# print(float(eggs))
#
# x=5
# y=x+3
# y=int(str(y)+"2")
# print(y)
#
# x=3
# num=17
# print(num%x)
#
#
# if 10>5:
... |
88f8f5956497eebf74751219160cc97790355744 | oceanpad/python-tutorial | /code/basic/closure.py | 222 | 3.65625 | 4 | def lazy_sum(*args):
def sum():
ax = 0
for n in args:
ax = ax + n
return ax
return sum
t = lazy_sum(1,3,5)
print(t())
t1 = lazy_sum(1,3,5)
t2 = lazy_sum(1,3,5)
print(t1 == t2)
|
69f0f771593f1138bf380e164e1649a79515e845 | Aasthaengg/IBMdataset | /Python_codes/p02999/s274696497.py | 79 | 3.515625 | 4 | a,b=input().split()
a=int(a)
b=int(b)
if a>=b:
print("10")
else:
print("0") |
473332adbebbe8bec777920ca422e43a5f02a9c3 | Robbot/w3resourcesPython | /Basic/1_20/Ex06.py | 502 | 3.625 | 4 | '''
Created on 24 mar 2018
Write a Python program which accepts a sequence of comma-separated numbers from user and generate a list
and a tuple with those numbers
How to remove warnings from code?
Another option would be disabling that check altogether (for all variables) in
PyDev > Editor > Code Analysis > Others >... |
592aea87c6b5967bfda0ba47d1caed5f1fcc1304 | flaviasilvaa/ProgramPython | /50.AddSixEvenNumbers.py | 377 | 4.21875 | 4 | ###this program is going to read 6 numbers if show the sum only of those who are even. If the value entered is odd, disregard it.
total = 0
sum = 0
for count in range(1, 7):
number = int(input(f'Enter the {count} value?\n'))
if number % 2 == 0:
sum = sum + number
total = total + 1
print(f'You t... |
338464a52f92b97be6cd7967fca949fc7987abce | rafhaelom/Python | /PythonBrasil/EstruturaSequencial/10.py | 245 | 4.25 | 4 | # 10. Faça um Programa que peça a temperatura em graus Celsius, transforme e mostre em graus Fahrenheit.
temCelsius = float(input("Digite a temperatura em Celsius: "))
print("A temperatura em Fahrenheit eh: ", (1.8 * temCelsius) + 32, "ºF") |
71185b8868ef5974eb87f217086b328b8d5ab56b | remotephone/lpthw | /26thru30/ex30-01.py | 1,140 | 4.21875 | 4 | # Set up the numbers, define what = what
people = 30
cars = 40
trucks = 15
## FIRST BLOCK
# If cars are more than people, then print we should take the cars
if cars > people:
print "We should take the cars."
# If that's not true and cars are more than people, print do not take cars
elif cars < people:
p... |
6e17db32822b14dc668980f69ab922cb7fe4f9c5 | lost-person/Leetcode | /99.恢复二叉搜索树.py | 5,120 | 3.59375 | 4 | #
# @lc app=leetcode.cn id=99 lang=python3
#
# [99] 恢复二叉搜索树
#
# @lc code=start
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def recoverTree(self, root: TreeNode) -> None:
... |
d919f0d018289ab7e19cdba008632c9de15da86d | Geovane-Baldan/AP1 | /Dicionario.py | 5,302 | 3.734375 | 4 | from time import sleep
main = []
class Palavra:
def __init__(self):
self.termo = ''
self.sinonimos = []
self.classe = ''
def menu():
print('\n\033[30m')
print('='*30)
print('Menu:')
print('0 - Sair')
print('1 - Cadastrar')
print('2 - Listar')
... |
165687739cc23466a26e287d303d3457401d2216 | huaxiaojilzg/python-Spider-learning | /多线程/多线程类.py | 396 | 3.734375 | 4 | # 多线程 法2
from threading import Thread
class MyThread(Thread):
def run(self): # 固定的,线程可以执行之后,被执行的就是 run()
for i in range(100):
print(f'子线程1:{i}')
if __name__ == '__main__':
t = MyThread()
# t.run() #方法的调用
t.start()
for i in range(100):
print(f'主线程:{... |
87ba6582c9107f951e726b7f313284f123a5a0bd | matthew-cen/schedule-creator | /schedule.py | 4,667 | 3.703125 | 4 | import itertools
def create_schedule(nestedlist):
# nested list of sections
total_schedules = []
for combinations in itertools.product(*nestedlist):
time_conflicts = {}
good_schedule = True
for sections in combinations: # there is an extra tuple layer that this for loop goes thoru... |
c03718163bf5a7c27570b5d61dc6db5c81f57017 | jiaziming/oldboy | /上课练习2/day-7面向对象/高级面向对象—进阶篇/类的方法.py | 797 | 3.84375 | 4 | #!/usr/bin/env python
#-*-conding:utf-8-*-
class Animal:
def __init__(self,name,):
self.name = name
self.num = None
hpbbie = "meat"
@classmethod #类方法 不能访问实例变量
def talk(self):
print("%s is talking....." %self.name)
@staticmethod #静态方法,不能访问类变量和实例变量
def walk(self):... |
98369bd886e51df1a211536aa8e71ac97d36c915 | Pabloc98/Regresion_Predictiva | /Def/Graph/Func_graph.py | 1,753 | 3.53125 | 4 | import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
def BoxPlot(data, remover = None):
"""Esta función realiza un boxplot por cada variable numerica que contenga el dataset y que no este incluida en la lista remover
Parametros
------------
df: pandas dataframe
Dat... |
427aef3b5fa1d234252b29d183595411b34ab6f6 | Long0Amateur/Self-learnPython | /Chapter 6 Strings/Problem/20. timezone (unfinished).py | 590 | 4.5625 | 5 | # A programs converts a time from one time zone to another
#
# 1. Taking input
# 2. Create a datetime
# 3. Get the timezones (Eastern, Central, Mountain or Pacific)
# 4. Convert to timezones and store it
# 5. Print the time
# Visit: https://www.youtube.com/watch?v=3DT5_A9X7TM
# For instance
# Time: 11:4... |
a8702f91e12d71684050e7a5e2af4f93a5701358 | brandhaug/decision-tree | /decision-tree.py | 5,741 | 3.53125 | 4 | import math
import random
class Node:
def __init__(self, value):
self.value = value
self.children = {}
def print_tree(self):
a = [self.value]
for key, test in self.children.items():
a.append(self.children[key].print_tree())
return a
def print_tree_te... |
8696a50df5134d0963693aeaae1d49d8d011726b | XihangJ/leetcode | /hash/347_Top K Frequent Elements.py | 1,687 | 3.671875 | 4 | '''
Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.
'''
class Solution:
#method 3. Using frequency array. O(n), S(n).
def topKFrequent(self, nums: List[int], k: int) -> List[int]:
d = {}
freq = [[] for i in range(le... |
73b83d1dfa2fd2bb83c97a9b146ace61849a0ed0 | vinaybhosale/Python | /MatplotLibPieChart/PieChartFromCSV.py | 636 | 3.671875 | 4 | import matplotlib.pyplot as plt
import pandas as pd
class DrawChartFromCSV:
@staticmethod
def csvPiePlot():
df = pd.read_csv('medal.csv')
country_data = df["country"]
medal_data = df["gold_medal"]
colors = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#8c564b"]
explode... |
e91cd949f6abaee4ec8341f6b05fc0e9ae59e785 | Kolmogorova/python_Lesson2 | /lesson2.py | 2,638 | 3.9375 | 4 | """ Задача 1
i = 0
while i < 5:
i = i +1;
print(i, 0)
"""
""" Задача 2
Пользователь в цикле вводит 10 цифр. Найти количество введеных пользователем цифр 5.
number = 0
for i in range(1, 11):
a = input("Введите цифру: ")
if a == "5":
number += 1
print('Количество введенных цифр 5 составляет',num... |
851e444c6e65dfc65d597656b4bea9c918ba350e | abhaydhiman/Pyalgo | /Linked_List/Add_1_to_a_number_represented_as_linked_list/solution.py | 1,715 | 3.9375 | 4 | class Node:
def __init__(self, data) -> None:
self.data = data
self.next = None
class LinkedList:
def __init__(self) -> None:
self.head = self.start = None
def insert(self, item):
temp = Node(item)
if self.head == None:
self.head = self.star... |
d06629ac7f5c75a74e18188e17268403e155de12 | IHarmers/python101 | /lesson_4/flow_control.py | 1,330 | 4.3125 | 4 |
# Basic if statements
#
# Execute an operation if certain conditions are met.
#
happy = True # Try changing this to True
if happy == True:
print(":)")
if happy != True:
print(":(")
# if-else statements
drink = "Fanta" # Try changing this to values like: "Beer", "Fanta" or "Fristi"
soft_drinks = ["Cola",... |
461b8478d884dc4f7bfc709c54f49614d78c59b2 | eilyi/IS685_Week5 | /MultiplyThese.py | 147 | 3.859375 | 4 | #multiply these
num1= 1
num2 = 2
def MultiplyThese(num1, num2):
print(num1)
print(num2)
multiply = num1*num2
return MultiplyThese(multiply) |
2d80a6f4050e58f46ea193f0e1ea4f86c6403bb0 | pololee/oj-leetcode | /companies/airbnb/p336/Solution.py | 1,855 | 3.640625 | 4 | class Solution:
def palindromePairs(self, words):
"""
:type words: List[str]
:rtype: List[List[int]]
"""
if not words:
return []
# The words are unique as said in the question
# we can set up a table to achieve O(1) look up time
table = {}... |
833817b34943d44c05dc3023e84db0d51d553b03 | jiangshen95/PasaPrepareRepo | /Leetcode100/leetcode100_python/GenerateParentheses2.py | 543 | 3.546875 | 4 | from typing import List
class Solution:
def generateParenthesis(self, n: int) -> List[str]:
dp = []
dp.append([""])
for i in range(1, n + 1):
cur = []
for j in range(i):
for left in dp[j]:
for right in dp[i - j - 1]:
... |
5cda498e72bc1ccb415a1e9c5e956406057bd266 | j5int/j5basic | /j5basic/Colours.py | 1,703 | 3.59375 | 4 | #!/usr/bin/env python
# -*- noplot -*-
# Code taken from http://matplotlib.sourceforge.net/examples/pylab_examples/colours.py
# under new BSD-style license
"""
Some simple functions to generate colours.
"""
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
from... |
7659debcb24e3f5e29e87dfff8b872bc3c51a6e5 | makrist2/python | /test_8.py | 144 | 3.65625 | 4 | lst = [1, 2, 3, 4]
print(lst)
lst[lst.index(max(lst))], lst[lst.index(min(lst))] = lst[lst.index(min(lst))], lst[lst.index(max(lst))]
print(lst) |
021b9a48688527f64911249657d26b88dd703bb0 | daweibai/PCBS-langevo | /Language_evo_ILM.py | 8,309 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jan 24 03:39:42 2019
@author: Dawei
"""
#Reproduce Kirby's (2001) Iterated Learning Model simulating language evolution
import random
from random import randint
import string
import numpy as np
n_of_iterations = 100
#Number of iterations wanted
rules = {
#Initial rule spa... |
d51a54ade9afa834b1f7b383dc4650a5883daea8 | mcgranam/projecteuler | /projecteuler031.py | 1,577 | 3.59375 | 4 | #!/usr/bin/env python
# File name: projecteuler031.py
# Author: Matt McGranaghan
# Date Created: 2014/05/06
# Date Modified: 2014/05/06
# Python Version: 2.7
# In England the currency is made up of pound, and pence, p, and there are eight coins in general circulation:
# How many different ways can 2 be made ... |
f041f8bd2aa503fa474ca028d688d518dc133eab | sahmad11/ROC-HCI-SmileyCluster-Data-Analysis | /Data Mining/kmeans.py | 1,293 | 3.59375 | 4 | import pandas as pd
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
from sklearn import preprocessing
def main():
# Elbow method to compute the average score of the k-means on different k values in the range [1,... |
64677cf21e67f81d697d09a9dc150627636834d9 | omegajudith/pythonPro | /ex13.py | 313 | 4.25 | 4 | number_of_sequence = int(input("Enter the length of sequence: "))
def fibonacci(a):
if a == 0:
return None
elif a == 1:
print([1])
else:
fibo = [1, 1]
while len(fibo) < a:
elem = int(fibo[-2]) + int(fibo[-1])
fibo.append(elem)
print(fibo)
fibonacci(number_of_sequence) |
9726e89dfa36ad7ad8abf9f61bbd64fd31c69c77 | agj4/FishGame | /game.py | 6,748 | 3.5625 | 4 | '''Creates Fish Game
made Fall 2017
Final Project
@author Annika Johnson (agj4)'''
from tkinter import *
from random import randint
from fish import *
class Game:
''' Creates Fish Game'''
def __init__ (self, window):
self.window = window
self.window.protocol('WM_DELETE_WINDOW', self.safe... |
7be76a774c55aeb253087872c5d006d703b4042b | ml18fksa/Assessment1 | /agentframework.py | 2,968 | 3.5625 | 4 |
"""
This file Create by Fawziah Almutairi
Created on Mon Dec 16 01:25:40 2019.
Programming for Geographical Information Analysts: Core Skills.
@author: ml18fksa, the Student ID is 201288865.
Geography Programming Courses at University of Leeds.
"""
"""
agentframework.py defines a class Agents.
1. The initialisatio... |
0b6cf59560c702748c04891272b4326a876ba072 | GoogleCloudPlatform/training-data-analyst | /quests/dei/census/predictor.py | 1,697 | 3.734375 | 4 | import os
import pickle
import numpy as np
class MyPredictor(object):
"""An example Predictor for an AI Platform custom prediction routine."""
def __init__(self, model):
"""Stores artifacts for prediction. Only initialized via `from_path`.
"""
self._model = model
def predict(self,... |
c5b4551a3bd27991e70358944d560cd903aa10a6 | Devendra33/Machine-Learning | /Pandas/Practice/Data Analysis/ipynb_to_py/P_pandas_groupby.py | 414 | 3.671875 | 4 | import pandas as pd
ds = pd.read_csv("wheather.csv")
# now applying the groupby method
# for selecting a perticular city domain
# gives all details of mumbai city
# gives the maximum value of cities
# gives the minimum value of cities
# gives the averag
... |
678fff5f2af39d635503a29edb405549911ae923 | rkolyan/DBLabs | /lab_06/linq.py | 2,399 | 3.5625 | 4 | class AbstractTable:
def __init__(self, **kwargs):
for key in kwargs:
self.__dict__[key] = list();
def insert(self, values):
for key in self.__dict__.keys():
for i in range(len(values[key])):
self.__dict__[key].append(values[key][i]);
def __len__(sel... |
a0c1d0ae37de33bae1c8b5c9cb3ad378c81640de | fzr72725/GalvanizePre | /Unit2/Assignment_1d.py | 3,312 | 4.34375 | 4 | def count_match_index(L):
'''
Use enumerate and other skills to return the count of the number
of items in the list whose value equals its index.
Parameters
----------
L : {list} of {int}
Returns
-------
int : {int}
Example
-------
>>> count_match_index([0, 2, 2, 3, 6,... |
9528b6c4422fc33e37d370ef95309e2111069e91 | AhmedRaja1/Python-Beginner-s-Starter-Kit | /Code only/3- Control Flow/Even Odd using For loop Exercise.py | 185 | 4.0625 | 4 | even_number_counter = 0
for number in range(1, 30):
if number % 2 == 0:
print(number)
even_number_counter += 1
print(f"We have {even_number_counter} Even Numbers")
|
d4a6b7095cd42a45b9d63f398f7e71c2e43f99e1 | gogocruz/projecto_imfj1_2020 | /viewer_aplication/mesh.py | 16,398 | 3.90625 | 4 | """Mesh class definition"""
# Just import time if we need statistics
import time
import math
import pygame
from vector3 import Vector3
import matrix4
import numpy
class Mesh:
"""Mesh class.
Stores a list of polygons to be drawn
"""
stat_vertex_count = 0
"""Vertex count for statistics. This code th... |
9d3e30b2db1ea9ecdeb7a4dcfce7173b5c556ac6 | vitorln/AntSystens-Threads | /Cidades.py | 2,018 | 3.765625 | 4 | # -*- coding: utf-8 -*
import math
class Cidades:
def __init__(self): #construtos de Cidades
self.cidades = [] #vetor com todas as cidades
self.matriz_dist = [] #matriz com as distancias emtre as cidades
self.matriz_feromonios = [] #matriz com os feromonios entre as cidades... |
9ede0c1c3501c7d6d739dcd597763589a43c0b26 | tsodapop/UIC_Courses | /CS401/Project/CS401_Project_jtso2.py | 2,635 | 3.609375 | 4 | projdata1 = open("Projdata1.txt","r")
contents = projdata1.readlines()
votes = []
region = []
for row in contents:
rowline = row.split(" ")
votes.append(rowline[0])
region.append(rowline[1])
for row in new_content:
rowline = row.split(" ")
votes.append(rowline[0])
region.append(rowline[1])
... |
c26768f28c2d90a790b39a5814c0b1bb41d1a9e2 | JohnNurthen/cp1404practicals2020 | /cp1404practicals2020/prac_04/quick_picks.py | 580 | 3.953125 | 4 | import random
NUMBERS_PER_LINE = 6
MIN = 1
MAX = 25
def main():
quick_picks = int(input("How many quick picks would you like?: "))
while quick_picks <= 0:
print("Please enter a valid number: ")
quick_picks = int(input("How many quick picks would you like?: "))
for i in range(quick_picks):
... |
51d569a192de7b5cbf0ea5e042981511661183e4 | Tanmay53/cohort_3 | /submissions/sm_015_lalit/week_13/day_4/session_1/count_occurances_string.py | 189 | 3.5625 | 4 | inputX=input("Provide a string here : ")
dictX={}
for i in inputX:
if i in dictX:
dictX[i]=dictX[i]+1
else:
dictX[i]=1
for k,v in dictX.items():
print(k,v)
|
e3af8f8ba177a843f5d8720f9d282205986ec2e0 | UKVeteran/Adventures-in-Python | /Adventure 3/2/password.py | 579 | 3.625 | 4 | import tkinter as tk
window = tk.Tk()
def checkPassword():
password = "Oranges"
enteredPassword = passwordEntry.get()
if password == enteredPassword:
confirmLabel.config(text="Correct")
else:
confirmLabel.config(text="Incorrect")
passwordLabel = tk.Label(window, text="Pass... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.