blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
560052bb91cf1aca14094545b33836aaca488d99 | okoks9011/problem_solving | /leetcode/1203.2.py | 1,830 | 3.5 | 4 | import enum
class Color(enum.Enum):
WHITE = 0
GRAY = 1
BLACK = 2
class Solution:
def topological_sort(self, adjs):
n = len(adjs)
visited = [Color.WHITE] * n
order = []
def dfs(u):
visited[u] = Color.GRAY
for v in adjs[u]:
if vi... |
77ef8052781bcd56e622b45dfdcc2da2c3524f38 | Zahidsqldba07/CodeFights-9 | /Arcade/Intro/Level 12/spiralNumbers/code.py | 878 | 3.625 | 4 | def spiralNumbers(n):
square = [[0] * n for _ in xrange(n)]
counter = 1
direction = 0
x = 0
y = 0
X = n
Y = n
while counter <= n ** 2:
if direction == 0:
square[y][x] = counter
x += 1
if direction == 1:
... |
3d245ef51a40e87dfe98125eaecc997509101ff7 | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/anagram/3df5a510fb9543bb8e42ee8cdabff50d.py | 274 | 3.609375 | 4 | from collections import Counter
def detect_anagrams(word, candidates):
word_lower = word.lower()
word_counter = Counter(word_lower)
def pred(c):
return Counter(c) == word_counter and c != word_lower
return [c for c in candidates if pred(c.lower())]
|
4e3146b35b47e3e5723436e27936145f75bbc288 | hycap-academy/sailbot | /bearing.py | 3,234 | 3.53125 | 4 | import math
import py_qmc5883l
from time import sleep
from gps import *
import time
import RPi.GPIO as GPIO
import time
#Tahlequah Vashon Island
long1 = -122.516422
lat1 = 47.355398
tolerancelat = .00001
toleranellong = .00001
#houselat = 47.342257833
#houselong = -122.326749667
gpsd = gps(mode=WATCH_ENABLE|WATCH_N... |
b99985c1d8ae7807faf49e5cb2179550f69515bc | DaveZima/PycharmProjects | /tkinter/tkinter_menu.py | 2,353 | 3.96875 | 4 | #def example2():
root.title("Dave is Great")
user_name = tk.StringVar()
name_label = ttk.Label(root,text="Name: ")
name_label.pack(side="left",padx=(0,10)) # add 10 pixel spacing
name_entry = ttk.Entry(root, width=15, textvariable=user_name)
name_entry.pack(side="left")
name_entry.focus()
greet_button = ttk.Button(... |
a81bfee5a4e3b152acfa8e5c64c53fbf2a2c61a1 | Ziang-Lu/Design-Patterns | /4-Behavioral Patterns/2-Strategy Pattern/Customer Billing Example/Python/strategy_pattern_test.py | 2,712 | 4.21875 | 4 | #!usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Application that actually uses Strategy Pattern to provide multiple algorithms,
a family of algorithms, to perform a specific task (solve a specific problem),
so that the client can select which actual implementation to use at runtime.
"""
__author__ = 'Ziang Lu'
fro... |
c9e8f888f2f3a03c53a5a8786266b31f4b2ddee7 | byAbaddon/Basics-Course-Python-March-2020 | /4.0 Loops/10-oddEvenSum.py | 409 | 3.78125 | 4 | #oddEvenSum
loop = int(input())
even_sum = 0
odd_sum = 0
list_num = []
while loop > 0 :
list_num.append(int(input()))
loop -= 1
for i in range(len(list_num)):
if i % 2 == 0:
even_sum += list_num[i]
else:
odd_sum += list_num[i]
if even_sum == odd_sum:
print(f'Yes\nSum = {even_sum}... |
8302f3270037e850344f99ebc8187d79c787ef43 | ZhengLiangliang1996/LeetcodePyVersion | /MaxArea.py | 758 | 3.703125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 8 17:07:57 2019
@author: liangliang
"""
class Solution(object):
def maxArea(self, height):
"""
:type height: List[int]
:rtype: int
"""
#https://www.youtube.com/watch?v=wLo0xIRDjQc
res = 0
... |
6a8a6096fab33bc3bcb3015586a50f3610aa47e7 | jmcgee5/python-challenge | /PyBank/main.py | 1,849 | 3.53125 | 4 |
# First we'll import the os module
# This will allow us to create file paths across operating systems
import os
# Module for reading CSV files
import csv
print(os.path.dirname(__file__))
os.chdir(os.path.dirname(__file__))
csvpath = os.path.join("..", "Resources", "budget_data.csv")
print("Financial... |
30fbb12dbfda8bdc3a56f15a11b3da44a74f7f41 | bwigianto/two-player-zero-sum | /test_tictactoe.py | 2,032 | 3.59375 | 4 | import unittest
from tictactoe import *
class TestTictatoe(unittest.TestCase):
def test_next_player(self):
board = Board()
self.assertEqual(board.next_player(1), 2)
self.assertEqual(board.next_player(2), 1)
def test_gets_next_state_for_p1(self):
board = Board()
expecte... |
19db2307169609e933e9abe03ffa9ce1ffb9e21f | kaiyaprovost/algobio_scripts_python | /lab9_sort.py | 3,100 | 4.125 | 4 | def getInputList():
"""
No inputs
Returns the list to sort
"""
s = raw_input("Please enter a list of ints, separated by spaces: ")
a = [int(w) for w in s.split()]
return a
def getInputFirstN(n):
"""
Input N, output numbers 0 to n-1
Returns the list to sort
"""
... |
8ceb90a68a837294dc0f05b5f5937cad675ed87f | zhaobe/ml-with-python | /3_dog_id.py | 618 | 3.546875 | 4 | import numpy as np
import matplotlib.pyplot as plt
# 1000 dog population
retrievers = 500
greyhound = 500
# avg height (in) with +/- 2 inches
h_retrievers = 22 + 2 * np.random.randn(retrievers)
h_grey = 24 + 2 * np.random.randn(greyhound)
# create histogram
plt.hist([h_retrievers, h_grey], stacked=True, color=['r','... |
8de7af3fbc82c8d5277257ef53ad7f51ff8d5e6c | li3meng20/Louplus | /jump7.py | 270 | 3.65625 | 4 | Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>for i in range(1,101):
if i % 7==0 or i%10==7 or i//10==7:
continue
print(i)
|
9f4bb5d3d0f15436523489c711bce18587fabb81 | Jamie-Chang/advent2019 | /d6/main.py | 1,268 | 3.546875 | 4 | from __future__ import annotations
from collections import defaultdict
from typing import Iterator, Final
COM: Final[str] = "COM"
def read() -> Iterator[tuple[str, str]]:
with open("d6/input.txt") as f:
for l in f:
yield tuple(l.rstrip().split(")"))
def build_tree(orbits: Iterator[tuple[st... |
326c86c95c1cc22be94cd3a8b74abe3216e355ef | JeeZeh/kattis.py | /Solutions/no_duplicates.py | 243 | 3.609375 | 4 | words = list(map(str, input().split(" ")))
size = len(words)-1
dupe = False
for i in range(0, size):
word = words[i]
words[i] = ""
if word in words:
dupe = True
break
if dupe:
print("no")
else:
print("yes") |
e43b7d8d40f85666c6f55127d7c2103b9a8de9bd | RyanGriffith/movie_fundraiser | /02_ticket_loop_v2.py | 521 | 4.15625 | 4 | # start of loop
# initialise loop so that it runs at least once
name = " "
count = 0
MAX_TICKETS = 5
while name != "xxx" and count < MAX_TICKETS:
print("You have {} seats left ".format(MAX_TICKETS - count))
# get details
name = input("name: ")
count += 1
print()
if name == "xxx":
coun... |
5036afd46747be7ffeb3246d8730b94eb9f840b6 | biswasSaumyadip/Code-Daily | /Age_o_number_conversion.py | 374 | 4.125 | 4 | def age_calculation (age_number,days_in_a_year = 365):
return age_number * days_in_a_year
age = input("Enter your age: ")
while int(age) <0:
print("Error! Please enter appropriate age.")
age = input("Enter your age: ")
if int(age) >0:
break
if int(age) >0:
age_criteria = age_calculation(in... |
35cf59a09362c44bcf0e412ce17ab9416ebbf606 | vishakhagpt29/Recommender | /club_genre.py | 436 | 3.5 | 4 | from category import category
#clubs movies on the basis of their genre, genreates genre_movie dictionary
def club_genre():
temp_data = {}
for k in category:
x = category[k]
for index, item in enumerate(x):
if item in temp_data:
temp_data[item].append(k)
... |
b37ff6081b8f9c8e4c4c5292c42ae86e32eb45cd | ozzieliu/Metis-DataScience-Prework | /python/q8_parsing.py | 1,934 | 4.53125 | 5 | # -*- coding: utf-8 -*-
# The football.csv file contains the results from the English Premier League.
# The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of
# goals scored for and against each team in that season (so Arsenal scored 79 goals
# against opponents, and had 36 goals scored against the... |
5a71f3d831fa0f39513174df587892dbb43c5547 | sofia-russmann/Python-Practise | /3/probando_index.py | 162 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Aug 23 19:51:08 2020
@author: sofia.russmann
"""
n = [1, 3, 5, 7]
m = n.index(3)
p = n[0]
print(n)
print(m)
print(p)
|
e754334a70b15bf730e563f30824f7fd8aad165f | rameshrawalr2/TaskProject | /task1.py | 1,003 | 3.9375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 15 12:31:18 2018
@author: ramesh
"""
import pandas as pd
#main function definition
def main():
#Creating two DataFrame dframe,df
dframe=pd.DataFrame()
df=pd.DataFrame()
#Reading csv file and inserting in dataframe dframe
... |
a1d6e9689007dcbaa19b6ddcca944a3f40211de2 | kushrami/PythonProgramms | /LoopsInPython.py | 909 | 3.953125 | 4 | Count = 0
for Count in range(10):
Count = Count + 1
for InsideCount in range(10):
InsideCount = InsideCount + 1
print(Count,"*",InsideCount,"=",InsideCount*Count)
for Count in range(10,20):
Count = Count + 1
for InsideCount in range(10):
InsideCount = InsideCount + 1
pri... |
5463c1b1352dc08c2fb66018805e88a533c31c66 | Pkfication/cracking_coding_interview | /Chapter_2/2.5.1_sum.py | 1,599 | 3.5 | 4 | '''
Incomplete Solution
'''
class Node:
def __init__(self, data):
self.data = data
self.next = None
def addSameLenth(a, b):
global carry
if (a == None):
return None
res = Node(0)
res.next = addSameLenth(a.next, b.next)
sum = a.data + b.data + carry
print(a.data, b.... |
ff0966938c036e5224e8add7b4d78fd58a5c62a3 | avengerweb/gb-ml | /lesson1/task1.py | 431 | 3.9375 | 4 | # Diagram: https://drive.google.com/file/d/1a9kCYcswKoV5ZW6rqUBEVIYrCGIcYt6d/view
# No validation required (good user)
number = int(input("Input three-digit number: "))
# We shouldn`t use arrays :(
digit1 = number // 100
digit2 = number // 10 % 10
digit3 = number % 10
digits_sum = digit1 + digit2 + digit3
digits_prod... |
6ef1b14f7a489880d2f26d7c577a3ffd36192371 | DWhistle/Python3 | /Education/Books/PyEdu/1.lists/1lists.py | 428 | 3.703125 | 4 | cast = ["1", "2", "3", "4"]
#print(cast[1])
#print(len(cast))
cast.append(["123", 323232])
#print(cast[4])
cast.pop()
#print(len(cast))
cast.extend(["abc, asb"])
#print(cast[4])
cast.remove("1")
cast.insert(0, 121312321)
#print(cast[0])
numbers = ["\"1\"", "2", "3", "4"]
it = 0
for i in range(len(numbers)):
numb... |
c4a1ae9296091ec1a20a69f320e79c83b4a2ac78 | ErikWeisz5/chapter_work | /4/2.py | 130 | 3.6875 | 4 | t = int(input("time spent on treadmill"))
c = 0
a = 0
while a < t:
c = c + 4.2
a = a + 1
print("you decreased cals by", c) |
a6978a891362cb9d3bb9d9a2b7a644311d0f7e01 | nownabe/competitive_programming | /AizuOnlineJudge/ITP1_Introduction_to_Programming_1/ITP1_9_D_Transformation.py | 322 | 3.546875 | 4 | s = input()
q = int(input())
for _ in range(q):
command, *args = input().split()
a = int(args[0])
b = int(args[1]) + 1
if command == 'print':
print(s[a:b])
elif command == 'reverse':
s = s[:a] + s[a:b][::-1] + s[b:]
elif command == 'replace':
s = s[:a] + args[2] + s[b:... |
4c3ab5e456b2e02a7971b9f555e7dfc556e22a2f | brianchiang-tw/CodingInterviews | /14-1_Rope Cut I/by_dynamic programming.py | 1,487 | 3.65625 | 4 | from collections import defaultdict
class Solution:
def cuttingRope(self, n: int) -> int:
if n == 1:
# can not make a cut
return 1
elif n == 2 or n == 3:
# 2 = 1 + 1, product = 1 x 1 = 1
# 3 = 2 + 1, product = 2 x 1 = 2
... |
6a77ae5017b3b746c7e893620917a6d0291f22ef | bhupesshhh/Guess-Your-Number | /main.py | 1,730 | 4.25 | 4 | import random
# Game Initiation
print("GUESS YOUR NUMBER!!!\n")
print("Computer will try to guess your number.\n")
print("Number should lie between (1-100)\n")
limit = input("Have you picked your number? (yes/no)")
if limit.lower() == "yes":
# Start the game with Yes only
gameplay = True
gameon = True
print("... |
7abb552522a2e8b68db231f1b6ebac06078b644f | Praveen-ghostProtocol/Class11-12 | /Program13.py | 606 | 4.25 | 4 | # Write a program that reads a limit and stores the Fibonacci series in a list and display. Input
# the index N within the limit and find the corresponding Fibonacci number.
n = int(input("Enter the value of 'n': "))
fiblist = []
a = 0
b = 1
sum = 0
count = 1
# print("Fibonacci Series: ", end = " ")
while(count <= n):... |
a8306588afcfb114e1653e079d7a2186ad0ce7d9 | Dongtengwen/7-12-practice | /19.py | 376 | 3.6875 | 4 | height=int(input('请输入身高(cm)'))
price=int(input('请输入身价'))
score=int(input('请输入颜值分'))
if height>180 and price>1000000 and score>99:
print('高富帅')
elif price>1000000 and score>99:
print('富帅')
elif score>99:
print('帅')
elif price<100 and score<60 and height<160:
print('矮穷挫')
else:
print('你是个普通人')
|
f91d47047a5b5bf2aace76fee32407c1d6c13818 | AnkitNigam1985/Data-Science-Projects | /Courses/DataFlair/pandas_pipe.py | 2,450 | 4.3125 | 4 | import numpy as np
import pandas as pd
#Pipe() used to apply any operation on all elements of series or dataframe
#Creating a function to be applied using pipe()
def adder(ele1, ele2):
return ele1+ele2
#Series
print("\nSeries:\n")
dataflair_s1 = pd.Series([11, 21, 31, 41, 51])
print("Original :\n",dataflair_s1)... |
74578d9bd2d52f06eb3bac8cf499a78e990f7fe7 | ivan-yosifov88/python_oop_june_2021 | /testing/vehicle/test/test_vehicle.py | 3,177 | 3.828125 | 4 | import unittest
from project.vehicle import Vehicle
class TestVehicle(unittest.TestCase):
def test_class_attributes__should_default_fuel_consumption_to_be_set(self):
default_fuel_consumption = 1.25
self.assertEqual(default_fuel_consumption, Vehicle.DEFAULT_FUEL_CONSUMPTION)
def test_init_met... |
96ec91de2e55573f80fd0eb8dc89f9a1752d026c | katolikyan/Walking-Marvin | /Marvin.py | 9,444 | 3.625 | 4 | import gym
import sys
import math
import matplotlib.pyplot as plt
import numpy as np
import time
import random
from colors import *
env = gym.make('Marvin-v0')
actions_len = 20 # number of actions each Marvin has
population = 20 # number of marvin in each generation
gener... |
65924c5b9a611a0abd633bdaea0ef6e9679cdc3f | bookstein/Exercise7 | /word_count.py | 813 | 3.90625 | 4 | def main():
script, filename = argv
print_and_sort_file(read_file(filename))
def read_file(filename):
word_count = {}
text = open(filename)
for line in text:
line = line.rstrip().lower()
for punc in string.punctuation:
line= line.replace(punc," ")
words... |
8bb255d42a37da386dfdf3459d4dd8077d217075 | ITBOX-ITBOY/learningRepository | /官网pythoni学习/python介绍/test/code.py | 248 | 4.125 | 4 | '''
用户手动输入,来计算用户所输入值
num1=input("请输入num1");
num2=input("请输入num2");
sum=float(num1)+float(num2);
print("{0}和{1}的总和是{2}".format(num1,num2,sum));
'''
#for循环
for i in range(0,20):
print(i); |
3e1d1bd843eccfe472873236ac0c3d88503be440 | rodrigosantosti01/LingProg | /Exercicio3/atv10.py | 1,192 | 4.09375 | 4 |
# 10.
# Faça um Programa para um caixa eletrônico. O programa deverá perguntar ao usuário a valor do saque e
# depois informar quantas notas de cada valor serão fornecidas. As notas disponíveis
# serão as de 1, 5, 10, 50 e 100 reais. O valor mínimo é de 10 reais e o máximo de 600 reais.
# O programa não deve se pr... |
04db278b9792401e6647aa48c1e018643e8bbff0 | kitrix/my_homeworks | /Python_hw_6/hw6_var3.py | 3,677 | 3.75 | 4 | import random
# открывает файл, разбивает на строки
def open_file():
f = open("words.txt", 'r', encoding = "utf-8")
text = f.readlines()
f.close()
return(text)
# находит строку с нужной категорией слов, составляет массив
def find_words(word,text):
for i in range(len(text)):
line ... |
6b5a82c26ff8f1f79df3b4874f63b7a810233c75 | tcbongers/mathematics | /project-euler/65.py | 442 | 3.609375 | 4 | from fractions import Fraction as frac
# Generate the representation
repr = [1]
for j in range(1, 40):
repr += [2*j, 1, 1]
#print(repr[0:20])
one = frac(1, 1)
current = frac(repr[-1], 1)
conv = 100
for r in repr[conv - 3::-1]:
current = one/current + frac(r, 1)
current = one/current + one + one
... |
94b339f7433d6843fbbe941856bf2ec561720c89 | ryosuke071111/algorithms | /AtCoder/ABC/addition_n_sub.py | 88 | 3.53125 | 4 | a,b,c = input().split()
a,c = int(a),int(c)
if b =='-':
print(a-c)
else:
print(a+c)
|
b8db265fbfad658e0ec6eba74c3036d888f85eb5 | alicesilva/P1-Python-Problemas | /repeticao7.py | 121 | 3.921875 | 4 | #coding: utf-8
numeros = []
for i in range(5):
numero = float(raw_input())
numeros.append(numero)
print max(numeros)
|
60969dd44b1374cde9d7fe71571ad23b91806a95 | krristi427/TicTacToeAI | /TicTacToe02.py | 4,905 | 3.875 | 4 | class TicTacToe:
def __init__(self):
self.board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
self.playerSymbol = ""
self.playerPosition = []
self.aiSymbol = ""
self.aiPosition = []
self.winner = None
self.scoreBoard = None
self.... |
8aed16d883586bd52cdd2de2b3ddb3e248790022 | hfgem/Computational_Neuroscience | /Hodgkin_Huxley_Model/HH_Example.py | 2,676 | 3.578125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: hannahgermaine
This code calculates the membrane potential and gating variable dynamics,
in a Hodgkin-Huxley model simulation, given a set of conditions. The code
outputs a plot of the applied current and resulting membrane potential to
the user's desktop.
""... |
50bcb61c949430771521264a538cd95794a1ae9c | balaji-senthil/program1_part1 | /project1_funs.py | 3,301 | 3.671875 | 4 | '''
Programming Assignment 1 - Part1
Submitted by Balaji Senthilkumar
'''
#The funtion to load the board (.txt to 2Dlist/array)
def loadBoard(board):
inputFile = open(board, 'r')
myBoard = []
for row in inputFile:
myBoard.append(row.split())
return myBoard
#THE FUNCTION TO PRINT 'myBoa... |
207b0b8d682652eb10cebda5a5e0b817f7279f7f | AruIbu/ADV-152 | /ADV-152.py | 709 | 3.703125 | 4 | from tkinter import *
root=Tk()
root.title("Multidimensional Arrays")
root.geometry("500x500")
label= Label(root)
array_1d = ["John", "James" ," Thomsan"]
print( array_1d[0] )
array_2d = [["john","A"], ["james", "B"],["Thomson","C"]]
print(array_2d[0][1])
array_3d = [[["John","A+","Excellent"],["Jame... |
ac097d2e55f9d21a7f51382e1a0d71db32fcb2df | shelvaldes/PlatziCodingChallenge | /rpsls.py | 3,262 | 4.21875 | 4 | """
Rock, Paper, Scissors, Lizard, Spock.
Scissors cut paper,
paper covers rock,
rock crushes lizard,
lizard poisons Spock,
Spock smashes scissors,
scissors decapitates lizard,
lizard eats paper,
paper disproves Spock,
Spock vaporizes rock,
and —as it always has— rock crushes scissors.
"""
import random
print("\nRoc... |
30d1ced5ce9df313b3cb8d27cbaf09eb587991ed | allenling/my_leetcode | /easy_level/invert_binary_tree.py | 895 | 4.21875 | 4 | # coding=utf-8
'''
翻转二叉树
'''
import binary_tree_utils
def invert_binary_tree(root):
if not root:
return root
nodes = [root]
while nodes:
node = nodes.pop()
if node:
node.left, node.right = node.right, node.left
nodes.extend([node.left, node.right])
retur... |
24eb744cfc3e8ae7bb8fe6e6a35f70ded97f5af6 | BHSB/chess | /position.py | 406 | 3.6875 | 4 | class Position:
def __init__(self, position=(0,0)):
self.position = self.inside_board(position)
def inside_board(self, position):
if all(x >= 0 for x in position) and all(x <=7 for x in position):
return (position)
else:
print("Position: Invalid move")
def... |
e7d077a6f6b5e97d4298d141e1bf35963ab75265 | AgamGhotra19/Calculator-Python | /Calculator.py | 7,538 | 3.515625 | 4 | from tkinter import *
def center(win):
win.update_idletasks()
width = win.winfo_width()
frm_width = win.winfo_rootx() - win.winfo_x()
win_width = width + 2 * frm_width
height = win.winfo_height()
title_bar_height = win.winfo_rooty() - win.winfo_y()
win_height = height + title... |
c6d1369dc3d8f9ff033b7efbf6a5b9ec8aab0ecc | xmlhh/pystudy | /1.python基础/4.高级变量类型/字符串/string_base.py | 5,136 | 4.09375 | 4 | #! /usr/bin/python3
#-*- coding:utf-8 -*-
"""
#文件名称:string_base.py
#编写人员:LHH
#项目组:系统组
#创建日期:2020/07/02
#功能描述:字符串的基础、基本操作、切片
#修改描述:
#备注:
"""
repeat_num = 45
print("****************1.字符串的基础*****************")
"""
字符串的定义:
可以使用双引号"",单引号''定义一个字符串;
如果字符串内部需要使用", 则可用''定义字符串;
如果字符串内部需要使用', 则可用"... |
cc85d28f57cb9d8971c50a22e02f30404b844595 | ztw11ll/data-mining | /Numeric Data Analysis.py | 4,950 | 3.84375 | 4 | ######################################## BM489E HW NO.1 ##############################################
## ALi KARATANA ##
## 121180043 ##
###########... |
40f27688e885a4f1bb54e3f1ce68638f0f233a89 | tlima1011/python3-curso-em-video | /ex113_solucao_guanabara.py | 1,004 | 3.84375 | 4 | def leiaInt(msg):
while True:
try:
n = int(input(msg))
except (ValueError, TypeError):
print('\033[31mERRO: por favor, digite um número inteiro válido.\033[m')
continue
except (KeyboardInterrupt):
print('\033[31mEntrada de dados interro... |
6a3b90ccd373ae78707026453b30d41266d7eba5 | Kaushal196/python-practice | /oop/class.py | 600 | 3.9375 | 4 | class Employee:
def __init__(self, fname, lname, age):
#instance var unique for each instance
self.fname = fname
self.lname = lname
self.email = self.fname + '.' + self.lname + '@company.com'
self.age = age
def fullName(self):
return f'{self.fname} {self.lname}'... |
107db592ed941d5b89c10cb6ff4692bb84b83568 | kil23levrai/kil23levrai.github.io | /scripts/sierpinski.py | 1,028 | 3.609375 | 4 | import turtle
turtle.tracer(0,0)
turtle.screensize(2000,2000)
turtle.pu()
turtle.goto(-500,0)
turtle.pd()
def dessiner(courbe, longueur, angle):
print("chaine finale " + courbe)
for caractere in courbe:
if caractere == '+': turtle.left(angle)
elif caractere == '-': turtle.right(angle)
... |
e68428b8f1940a06f3fb934012da7cbff9899103 | charliealpha094/Introduction-to-Python-Programming-for-Business-and-Social-Sciences-Applications | /Chapter_2/End_of_chapter_2/2_1.py | 249 | 4.03125 | 4 | # Done by Carlos Amaral (2020/09/17)
value = input("Please, enter an integer between 1 and 100: ")
def number(value):
return (int(value))
print("The entered value is: ", number(value), ".", "The square of entered value is: ", number(value)**2)
|
fd76226d22bb9d3d1fe3b590f173ffac5a0f6fc0 | smileyoung1993/python_practice | /practice01_2.py | 254 | 3.65625 | 4 | ##q2
num = input("수를 입력하세요:")
try:
num = int(num)
if isinstance(num,int):
if num % 2 == 0:
print("짝수")
else:
print("홀수")
except ValueError:
print("정수가 아닙니다.")
|
675cab25b795ce494e4e3881ea8802b07bb45574 | JackyXiong8/Dojo_Assignments | /Python/dictionaryBasics.py | 178 | 4.125 | 4 |
info = {"Name":"Jacky","Age":"19","Country of birth":"China","favorite language":"Python"}
print (info.items())
for key, data in info.items():
print ("My",key,"is",data) |
3a6a2079749eda524dca598a35a84c24dfa7f4bc | pronob1010/Data_Science_Project_with_Edu_data | /problem solve/venv/hkch9.py | 204 | 3.53125 | 4 | student_marks = {}
for i in range(int(input())):
n = input().split()
scores = list(map(float, n[1:]))
student_marks[n[0]] = sum(scores)/float(len(scores))
print("%.2f"%student_marks[input()]) |
4c17c718374acbeee6cce24d5d8f2c45e5e0b886 | jeffsnguyen/Python | /Level_5/Homework/Section_5_2_Decorators/Exercise_3/loan/loan_base.py | 14,710 | 3.71875 | 4 | # Type: Homework
# Level: 5
# Section: 5.1: Date/Time
# Exercise: 6
# Description: This contains Loan class methods, modified to handle exception
# Modify your Loan classes to take a loan start date and loan end (maturity) date instead of a term
# parameter. Create a term method that calculates and returns the ... |
028f094cab468d133674b6854822b1a06ec6b860 | brufino/YHack-Chug2Puff | /water_vis_app_skeleton.py | 1,381 | 3.875 | 4 | import time
def calc_water_goal():
# Calculate the water goal
# return water_goal
# If a water value is entered into the GUI, store value
def water_input(ml):
current_intake += ml
return current_intake
# Changes the puffer fish image depending on water intake
def fish_change(water_goal, cur... |
d5b09854525690c951348dc2f883d53e87bbd5fe | Riley-Kilgore/IrisDataSet | /main.py | 699 | 3.515625 | 4 | import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
import numpy as np
'''The following is the training of a logistic regression model upon the iris dataset. Only 70% of the data
is used and there are no predictions made within this file.'''
da... |
f3ef56322a500563561dd7dfe3e40b4897d41019 | jiangh2/01-IntroductionToPython | /src/m6_your_turtles.py | 1,736 | 3.65625 | 4 | """
Your chance to explore Loops and Turtles!
Authors: David Mutchler, Dave Fisher, Vibha Alangar, Amanda Stouder,
their colleagues and Hao Jiang.
"""
###############################################################################
# TODO: 1.
# On Line 5 above, replace PUT_YOUR_NAME_HERE with your own name... |
6fac13bc2aca27233aadb3546ff629a9448784c9 | eun2ce/TIL | /algo/recurrence_relation.py | 508 | 3.921875 | 4 | def factorial1(n):
if n == 0 :
return 1
else:
return n * factorial1(n-1)
def recursive0(n):
if n == 0 :
return 1
else:
# reference loop0.py
loop3(n)
return n*n*recursive0(n-1)
def recursive1(n):
if n == 0 :
return 1
else:
loop3(n)... |
c61d3b8f54c6c5300d9bbd9f1c983efb7ce5eec0 | mahalakshmima/python1 | /g4.py | 110 | 3.953125 | 4 | ma1=input()
if(ma1 >='a' and ma1 <='z') or (ma1 >='A' and ma1 <='Z'):
print("Alphabet")
else:
print("No")
|
847a916a086113a0904eae26b8fcbef98ba8c61c | lpmg11/ejercicios_python | /sumaYMedia.py | 338 | 3.953125 | 4 | suma = 0
c = 0
def numeros(suma, c):
n = int(input("Ingrese un numero: "))
if n !=0:
suma = suma + n
c = c + 1
numeros(suma,c)
else:
print("La suma de los numeros ingresados es: ", suma)
print("La media de los numeros es: ", suma/c)
if __name__ == "__main__":
n... |
3e37382832e6d9ea23efeb6508716a25b1b411ae | CutiePizza/holbertonschool-higher_level_programming | /0x10-python-network_0/6-peak.py | 522 | 3.859375 | 4 | #!/usr/bin/python3
"""
Find peak
"""
def find_peak(list_of_integers):
"""
method to find peak
"""
if len(list_of_integers) == 0:
return (None)
peak = list_of_integers[0]
for i in range(1, len(list_of_integers)):
try:
if (list_of_integers[i] > list_of_integers[i + 1] ... |
1997edf45ae984c10dd2edec0042c04e5a2200ca | willbaschab/COOP_2018 | /Chapter03/U03_EX09_TriangleSideArea.py | 1,107 | 4.375 | 4 | # U03_EX09_TriangleSideArea.py
#
# Author: Will Baschab
# Course: Coding for OOP
# Section: A2
# Date: 27 Sep 2018
# IDE: PyCharm
#
# Assignment Info
# Exercise: 09
# Source: Python Programming
# Chapter: 03
#
# Program Description
# Determines the area of a triangle given the side lengths inputted b... |
1bd4b6b20a5c0db89bffa592e64f685af7d614e4 | AaronYXZ/PyFullStack | /Leetcode/leetcode/editor/en/[915]Partition Array into Disjoint Intervals.py | 959 | 3.5 | 4 | #Given an array A, partition it into two (contiguous) subarrays left and right so that:
#
#
# Every element in left is less than or equal to every element in right.
# left and right are non-empty.
# left has the smallest possible size.
#
#
# Return the length of left after such a partitioning. It is guaranteed th... |
8d92c3b5aa62b0046c955649f954c6526a6bb48e | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/word-count/fe243d8f65ef4a898a512fe9da9744ef.py | 211 | 3.765625 | 4 | from collections import Counter
def word_count(text):
stripped_text = ''.join([c for c in text.lower()
if c.isalnum() or c.isspace()])
return Counter(stripped_text.split())
|
0a52118a705597fc8a7f157ac73264ac5e9155fc | maleksal/holbertonschool-higher_level_programming | /0x01-python-if_else_loops_functions/5-print_comb2.py | 246 | 3.734375 | 4 | #!/usr/bin/python3
def two_digit(num):
if num <= 9:
return 0
return ""
def space(num):
if num == 99:
return "\n"
return ", "
for i in range(100):
print("{}{}{}".format(two_digit(i), i, space(i)), end="")
|
6cbf8b5115cb0a054edeaf127471a223913574cf | rniemeyer07/public | /ipython_notebooks/rbm_find_grid_cell.py | 746 | 3.78125 | 4 | #!/usr/local/anaconda/bin/python
#script to enter a lat/lon and program will return lat/lon of grid cell that point resides in
# run the code like this: ./rbm_find_grid_cell.py 35.011301 -85.697354
import numpy as np
import os
import sys
def find_125_grid_Maurer(lat, lon):
'''Find the 1/8 grid cell that a (lat... |
31fead7baa2506702627cc3aab1e931c6ae689e5 | fearlessdinosaur/Algorithms | /Python/Sorts.py | 653 | 3.90625 | 4 | def Bubble(x):
print (x)
for i in range(0,len(x)):
y = []
#checks if changes have stopped
if( y == x):
break
y = x
#bubble sort loop
for j in range(1,len(x)):
if(x[j-1] > x[j]):
temp = x[j]
x[j] = x[j-1]
... |
6634c0f5455ebecc6dc74d99a55b30f5960f3d16 | DIRT-X/dirtx | /codes/example_solver.py | 4,171 | 3.609375 | 4 | """This is the example_solver.py script for solving 1D hydraulics."""
import math as m
def calc_discharge(b, h, m_bank, S, k_st=None, n_m=None, D_90=None):
"""
Calulate discharge in SI units. Provide one of the optional parameters k_st, n_m, or D_90.
Arguments:
b (float): width (m)
h (flo... |
770375871053b9e8ffc9ec196045490a6e2b098a | andre-williamson/the-FizzBuzz-game.py | /main.py | 228 | 3.96875 | 4 | #Write your code below this row 👇
nums = 0
for nums in range(0,101):
print(nums)
if nums % 3 == 0 and nums % 5 ==0:
print("fizzbuzz")
if nums % 5 == 0:
print("buzz")
if nums % 3 == 0:
print("fizzbuzz") |
b47408b342fefb753fc30041e9d41d49c06057a9 | kosemMG/gb-python-basics | /1/1.py | 370 | 4.1875 | 4 | print('Hello world!')
first_name = input('Enter your name: ')
surname = input('Enter your surname: ')
print(f'Hello, {first_name} {surname}! I am happy to meet you!')
age = int(input('How old are you? '))
if age < 18:
print('I am sorry, you are not allowed to buy cigarettes.')
else:
print('You can buy cigare... |
372733844f4725aae9a41467877a646b0ee4aad4 | achntj/2-semesters-of-python-in-HS | /same tuple.py | 403 | 4.25 | 4 | #Write a program to input a tuple and check if it contains all elements as same.
n=int(input("Enter number of characters in tuple: "))
t=(tuple())
for i in range(0,n):
a=int(input("Enter value for tuple: "))
t+=(a,)
c=t[1]
count=0
for k in range(0,len(t)):
if t[k]==c:
count+=1
if count==len(t):
... |
b33e49a14e1e0ecbbf9ca87aafc2566bebf572ba | brenuvida/cursoemvideo | /Aula10/exercicio_30.py | 218 | 3.96875 | 4 | from time import sleep
num = int(input('Digite um número inteiro: '))
num = num % 2
print('Analisando o número digitado')
sleep(3)
print('O número digitado é PAR'if num == 0 else 'O número digitado é IMPAR')
|
625868fef52804bff95d2071754d3cc10c864767 | DevBaki/Python_Examples_Basic | /25_PersonInstance.py | 215 | 3.9375 | 4 | class Person:
name = "Person"
def __init__(self, name=None):
self.name = name
baki = Person("Bake")
print(Person.name, baki.name)
issa = Person()
issa.name = "Issa"
print(Person.name, issa.name)
|
369def91ed15352d48060c55741b48bf34d1d307 | jeengland/Data-Structures | /lru_cache/lru_cache.py | 2,208 | 3.84375 | 4 | from doubly_linked_list.doubly_linked_list import DoublyLinkedList
"""
Our LRUCache class keeps track of the max number of nodes it
can hold, the current number of nodes it is holding, a doubly-
linked list that holds the key-value entries in the correct
order, as well as a storage dict that provides fast access
to eve... |
9bc9e958fca5a0bbf0bae45066d7b1753518b5c0 | buwangkehan/CS132 | /hwk6code/hwk6.py | 6,819 | 3.984375 | 4 | import numpy as np
import sys
import matplotlib as mp
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import obj2clist as obj
####################################################
# modify the following 5 functions
# all functions assume homogeneous coordinates in 3D
###########################... |
a8ef368dd368cf9556a49719830768c44611fec7 | hazharaziz/algorithmus-prime | /1-sorting/insertion_sort/python/test_insertion_sort.py | 1,069 | 3.671875 | 4 | import unittest
from unittest import result
from insertion_sort import *
class TestInsertionSort(unittest.TestCase):
def test_empty_list(self):
numbers = []
insertion_sort(numbers)
self.assertIsNotNone(numbers)
self.assertEqual(0, len(numbers))
def test_single_elem... |
a0b37deb29c1a16ca1c1f547e5467ea96d1a5412 | ifscher/python-library | /aweefa.py | 437 | 3.875 | 4 | '''
USER INPUT e FORMAT
'''
# nome = input('Digite seu nome: ')
# n1 = int(input('Número 1: '))
# n2 = int(input('Número 2: '))
# t = n1 + n2
# print('Vsf, {1}. Azar. {0}'.format(nome, t))
'''
ORDEM DE PRECEDËNCIA
1. ()
2. ** (potëncia)
3. * / // % (últimos são divisão real e e resto)
4. + -
'''
pqp = 10 / 3
pri... |
60d5c3fa275689796deb4ed8fcaaef7a689b7958 | OctavianusAvg/Donny | /43.py | 1,593 | 3.53125 | 4 | '''
Задано два натуральних числа a і b. Змінній w привласнити значення
істина, якщо в одновимірному цілочисельному масиві є хоча б один елемент, кратний а
і не кратний b.
Виконав : Канюка Р. 122В
'''
import numpy as np
import random
def numUserInput(arr, message):
'''Ініціалзіцая масиву дійсних чисел користувачем.
... |
bc4109711eea49ded422877d3360313e4fd5cc68 | CHANDUVALI/Python_Assingment | /python2.py | 180 | 4.28125 | 4 | #Implement a program for finding a square of a number. (without using standard api)
num = float(input("Enter number: "))
mul = float(num*num)
print("Square of the number:",mul)
|
3973932e2f02a967fe86d89c8309fede51fc921a | Shalini-dixit/PythonRepository | /ListAssignment/functions/ThreeIntegerNumber.py | 285 | 3.9375 | 4 | def add(num1, num2):
return num1+num2
def subtract(num1, num2):
return num1-num2
def add_and_subtract(num1, num2, num3):
temp=add(num1,num2)
return subtract(temp,num3)
print(add_and_subtract(23,6,10))
print(add_and_subtract(1,17,30))
print(add_and_subtract(42,58,100)) |
bc926b95d2e450f384c167a83bd0c78b3e42d4ab | OlegSudakov/Programming-Problems | /hackerrank/coding_interview/strings_anagrams.py | 733 | 3.765625 | 4 | # https://www.hackerrank.com/challenges/ctci-making-anagrams
def number_needed(a, b):
aLetters = {}
bLetters = {}
for char in a:
if char in aLetters:
aLetters[char] += 1
else:
aLetters[char] = 1
for char in b:
if char in bLetters:
bLetters[cha... |
d97a859623ad0af1ee130c77bb83a8be8fceda27 | BiYuqi/daily-practice | /Python/Python-Base-Practice/oop-high-level/use__slots__.py | 1,171 | 4 | 4 | # coding=UTF-8
# 继承方法
class MyMethod(object):
def __init__(self, options=None):
self.options = options
def is_object(self, t):
if isinstance(t, dict):
return 'yes'
obj = MyMethod()
L = {
"name": "test"
}
print(obj.is_object(L))
def get_list(*kw):
for i in kw:
... |
eccf2a66b9a15a994e85fd0d2b0259b0db73b937 | Ilyalya/learning | /lesson_003/01_days_in_month.py | 1,275 | 4.0625 | 4 | # -*- coding: utf-8 -*-
# (if/elif/else)
# По номеру месяца вывести кол-во дней в нем (без указания названия месяца, в феврале 28 дней)
# Результат проверки вывести на консоль
# Если номер месяца некорректен - сообщить об этом
# Номер месяца получать от пользователя следующим образом
user_input = input("Введите, пож... |
df0d51c15b652a780c56e720a010c04c7a2be403 | anberns/TSP---Christofides | /submittedFiles/Archive/twoOpt/twoOPT.py | 5,731 | 3.75 | 4 | import sys
import math
import time
#code is influenced and inspired by this sites java implementation.
#http://www.technical-recipes.com/2017/applying-the-2-opt-algorithm-to-traveling-salesman-problems-in-java/
#as well as this site
#http://on-demand.gputechconf.com/gtc/2014/presentations/S4534-high-speed-2-opt-tsp-sol... |
fbb50c60a18a2ac14463c9b4fef1b16c05edf481 | akshay-sahu-dev/PySolutions | /DS ALGO/Linked List/FInding the kth element from last.py | 1,281 | 3.9375 | 4 | ## FInd the kth element from last
class Node:
def __init__ (self, data = None):
self.data = data
self.next = None
class linked_list:
def __init__(self):
self.head = Node()
def push(self, data):
new_node = Node(data)
new_node.next = self.head
self.head = ne... |
11f5ce4487042ff6383e443d548f5f6942e5c18e | FisicaComputacionalOtono2018/20180816-clase-diagramadeflujoparprimo-jordetm5 | /test.py | 267 | 3.71875 | 4 | #Jorge Dettle Meza Dominguez
#16 de agosto del 2018
#
s=12
p=input("dame un numero :")
a=0
m=1
while s==0:
while p<s:
s=s*p
p=p+2
if p%2==0:
p=p+1
else :
while a<(p-1):
a=a+1
r=p%a
if r==0:
m=0
if m==0:
s=s-1
print(p)
|
3f531645ddad044b4d531539e4aef5db942c58ad | Timi-chen/TestDemo | /homework5.py | 351 | 3.546875 | 4 | import random
x=eval(input(""))
y=random.randint[0,30]
i=0
while(x!=y):
if(x<y):
print("遗憾!太小了")
i+=1
x=eval(input(""))
else:
print("遗憾!太大了")
i+=1
x=eval(input(""))
else:
print("预测{}次,你猜中了!".format(i))
print("I like zhbit")
print("我是大帅哥")
|
b6353eff9e1b91d62de897a4cbfc8931626f8b29 | 22Rahul22/Hackerrank | /Lists.py | 413 | 3.609375 | 4 | t = int(input())
b = []
for _ in range(t):
a = input().split()
s = a[0]
arr = a[1:]
if s == 'insert':
b.insert(int(arr[0], 10), int(arr[1], 10))
elif s == 'print':
print(b)
elif s == 'append':
b.append(arr[0])
elif s == 'remove':
b.remove(arr[0])
elif s ==... |
58a3527773f959036753865fbce0339de9a64edd | anu-coder/Basics-of-Python | /scripts/L2Q15_mathstring.py | 392 | 3.96875 | 4 | '''
Question: Write a program that computes
the value of a+aa+aaa+aaaa
with a given digit as the value of a.
Suppose the following input is supplied to the program:
9
Then, the output should be:
11106
'''
def mathstring(a):
s = 0
for i in range(1, 5):
s = s + int(a*i)
return s
if __name__==... |
88eb086f37a158134a204b8a4716f7e2fdc6c578 | abhishek2829/Python | /DictionaryExercise.py | 518 | 4.03125 | 4 | #Create a Dictionary and take input from the user and return the meaning of the word from the dictionary
d1={"abandon":"give up completely",
"Immutable":"Something that cannot be changed",
"Mutable":"Something that can be changed",
"RPA":"Robotic Process Automation"}
print("Please Input Your word f... |
9675d1c1ec03153aafa3db65b2f765e029ecd4ed | cielavenir/procon | /codingame/old/onboarding.py | 241 | 3.515625 | 4 | #!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input
while 1:
n=int(raw_input())
mi=9999999
name=''
for i in range(n):
enemy,dist=raw_input().split()
if mi>float(dist):
mi=float(dist)
name=enemy
print(name) |
5665d46e0080a141052b521715d70bfc414c4bef | joaquimbermudes/ProjectEulerPython | /Problema2.py | 252 | 3.53125 | 4 | # Problema 2
# Encontrar a soma de todos os valores pares de uma sequencia de Fibonacci até 4.000.000
x1 = 1
x2 = 1
x = 0
s = 0
while x < 4000000:
x = x1 + x2
x2 = x1
x1 = x
if x % 2 == 0:
s = s + x
print(s)
|
e8ba941914d7f69388f8a16cf23e87d384f4c885 | romrell4/470-AI | /Reversi/Square.py | 1,653 | 3.71875 | 4 | import Enums
from Enums import Color, Direction
class Square:
def __init__(self, x, y, value):
self.x = x
self.y = y
self.value = value
self.piece = Color.EMPTY
self.neighbors = [None, None, None, None, None, None, None, None]
def canFlip(self, color, direction):
... |
f4b8f6fd676c6c5f6970c98261e50f65cce6b925 | ThorsteinnAdal/webcrawls_in_singapore_shippinglane | /db_to_file_helpers/test_textLines_to_file.py | 3,247 | 3.546875 | 4 | __author__ = 'thorsteinn'
import unittest
from textLines_to_file import line_in_file, remove_line_from_file, add_unique_line_to_file
class Test_textLines_to_file(unittest.TestCase):
def setUp(self):
with open('unit_test_file.txt','w') as f:
f.write('this is the first line\n')
f.wr... |
52b3dbd9cf16c3e549099e0cfaf2af51cfce7773 | maggielaughter/tester_school_dzien_5 | /list_test1.py | 358 | 4.0625 | 4 | numbers=[1,'foo',62,15,34]
"""for i in range(len(numbers)):
print(numbers[i])
print(' ')
for value in numbers:
print(value)
print(' ')
"""
for i in range(len(numbers)-1,-1,-1):
print(numbers[i])
print(' ')
for value in reversed(numbers):
print(value)
print(' ')
for idx, value in enumerate(rever... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.