blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
2818ebb1632099c87d7e41850042aafb210caa35 | maleficus1234/School | /COMP452TME1/COMP452TME1/Entities/MouseTarget.py | 478 | 3.65625 | 4 | from pygame import mouse
from Vector import Vector
# Acts a steering behavior target that positions itself using the mouse cursor position
class MouseTarget(object):
# Constructor
def __init__(self):
# Just set an initial value for the target position
self.position = Vector()
# Update t... |
03143053a8aa572cec1c1caaf52a1f6d8d1b970f | MarvelousLim/MarvelousHomework | /Lection1/Lection1.py | 509 | 3.578125 | 4 | # for i in range(1, 100):
# if i % 15 == 0:
# print("fizzbuzz")
# elif i % 5 == 0:
# print("buzz")
# elif i % 3 == 0:
# print("fizz")
# else:
# print(i)
#
#
#steps = [(1,0),(-1,0),(0,1),(0,-1)]
#
#def generate_walk(path, L):
# if L == 0:
# print(path)
# else:
#... |
8ce5a5f4bcc65251ccc4ac8c3603e83af89cab35 | AlehDarashenka/Coursera-Python | /HomeWork/Week1/solution.py | 138 | 3.703125 | 4 | import sys
digit_string = sys.argv[1]
def digit_sum(text):
return sum([int(digit)for digit in text])
print(digit_sum(digit_string)) |
45fd96830ca0719e54c00675aa5b68b84f91873a | brianchiang-tw/leetcode | /No_0171_Excel Sheet Column Number/excel_sheet_column_number_by_recursion.py | 1,085 | 3.78125 | 4 | '''
Description:
Given a column title as appear in an Excel sheet, return its corresponding column number.
For example:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...
Example 1:
Input: "A"
Output: 1
Example 2:
Input: "AB"
Output: 28
Example 3:
Input: "ZY"
Output: 701
'''... |
c163d392f676d764e7cb605151d32fff1d463d81 | vitoriabf/FC-Python | /Lista 1/Ex1.py | 816 | 3.953125 | 4 | somaf = 0
somam = 0
contF = 0
contM = 0
maiorSalario = 0
idade = int(input('Digite sua idade: '))
while idade >= 0:
sexo = str(input('Digite seu sexo: '))
salario = int(input('Digite seu salario: '))
if sexo == 'f':
somaf += salario
contF += 1
elif sexo == 'm':
somam += sala... |
f13ceb4386cb896cb9b812d005e78af16916ff16 | jamespolley/linear-data-structures | /doubly-linked-list/MusicPlayer.py | 5,316 | 3.53125 | 4 | # MusicPlayer Song (Node)
class Song:
def __init__(self, title, artist, duration, next=None, prev=None):
self.title = title
self.artist = artist
self.duration = duration
self.next = next
self.prev = prev
def get_next(self):
return self.next
def set_next(... |
fc60c6adfda960f26b5eea2c9b8c5131e618b61c | JHorlamide/Python-tutorial | /logical operator.py | 410 | 3.71875 | 4 | # has_height_income = False
has_good_credit = True
has_criminal_records = True
# AND: both condition must be true
# if has_good_credit and has_height_income:
# print("AND: Eligible for loan")
# # OR: At least one condition must be true
# if has_good_credit or has_height_income:
# print("OR: Eligible for loan")
#... |
5b73027472a9931869841bb84232a7bc94b7bbf6 | wmaxlloyd/CodingQuestions | /Dynamic Programming/minimumSum.py | 1,067 | 3.640625 | 4 | # Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
# Note: You can only move either down or right at any point in time.
grid = [
[1,3,1],
[1,5,1],
[4,2,1],
[1,12,3]
]
gridWidth = len(grid[0])
gridHeight = len... |
24ab1984e459445711cadf1ecef4c68d464c5568 | alejaksoto/JavaScript | /Poo/python/excersice/2.py | 152 | 3.71875 | 4 | millas = float(1.609344)
kilometros = 1
kilometros = int(input("ingrese cantidad de kilometros"))
print("kilometros en millas"+ str(millas*kilometros))
|
546fa0446e8881e00f854a6628e7a80b3bf80a30 | lackmannicholas/data-structures-and-algorithms | /bfs.py | 1,319 | 3.71875 | 4 | #Uses python3
import sys
import queue
class Graph:
def __init__(self, adj):
self.discovered = queue.Queue()
self.adj = adj
self.visited = [0 for x in range(len(adj))]
self.depth = [-1 for x in range(len(adj))]
self.isBipartite = False
def bfs(self, s):
self.vis... |
48ca12657ba2d3752de7225cf6d41165153370d9 | mdujava/PB016 | /2.7_15.py | 3,085 | 3.875 | 4 | class Node:
def __init__(self, val):
self.l = None
self.r = None
self.v = val
def delete(self):
if self.l == self.r == None:
return None
if self.l == None:
return self.r
if self.r == None:
return self.l
child = self.l
... |
898fa94da6428e44cfb6316ff18a0c3f88ffa7ed | syl0224/algorithm | /sort/quick_sort.py | 861 | 4 | 4 | class QuickSort(object):
@classmethod
def quick_sort(cls, arr, left, right):
if left < right:
index = cls.ajust_arr(arr, left, right)
cls.quick_sort(arr, left, index - 1)
cls.quick_sort(arr, index + 1, right)
return arr
@classmethod
def ajust_arr(cls,... |
0c3f5a072232aaacbdfd0f6dc2076b273f15e82c | Ender-90/python_discrete_math | /python_discrete_math/prime_factoring.py | 1,690 | 4.1875 | 4 | def input_positive_integer():
while True:
try:
int_input = int(input("Input a number: "))
if int_input > 0:
return int_input
break
else:
print("Please input a positive integer!")
except ValueError:
print(... |
f9f823ffc07dbe9f807a2b26cb094693e3e36d45 | yshshadow/Leetcode | /300-/392.py | 1,663 | 3.90625 | 4 | # Given a string s and a string t, check if s is subsequence of t.
#
# You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string, and s is a short string (<=100).
#
# A subsequence of a string is a new string which is formed from the original s... |
b448e065b37232f749099efd2766908d4f3cc7e5 | markjluo/MITOCW6.00.1x | /Week 2/W2_Lecture_Tower of Hanoi Algorithms.py | 606 | 3.765625 | 4 | def printmove(fr, to):
print('Move from', str(fr), 'to', str(to))
# Move stack of discs from one tower (fr) to another tower (to):
# n = the number of towers.
# spare = the spare tower
def Towers(n, fr, to, spare):
if n == 1:
return printmove(fr, to)
else:
# Move all the discs except the la... |
634cd85cd75e98d77562544e253fc17ae4c51ccb | Leticiacouti/Python | /tp2/ex25.py | 782 | 4.0625 | 4 | '''
Exercício Fix25
Tendo como dado de entrada a altura (h) de uma pessoa, construa um algoritmo que calcule seu peso (p) ideal,
utilizando as seguintes fórmulas:
Para homens: (72.7*h) - 58
Para mulheres: (62.1*h) - 44.7
'''
#Exercicio 5
print("Letícia Coutinho da Silva - N5752E4 - CC2A41")
print("---------------... |
808dafce1c85fe6dd6ee780c94dc9575873fcea6 | DaveZima/PycharmProjects | /Concurrency/non_locked_threads.py | 1,719 | 3.703125 | 4 | import time
import random
import queue
from threading import Thread
#from concurrent.futures import ThreadPoolExecutor
#from concurrent.futures import ProcessPoolExecutor
COUNTER = 0
# Create the JOB and COUNTER queues
JOB_QUEUE = queue.Queue()
COUNTER_QUEUE = queue.Queue()
""" Runs forever processing counter items... |
2d16baae9f084d9b0e325361ea801e71b2228149 | sindhumantri/common_algorithms | /kway_merge.py | 695 | 3.515625 | 4 | import heapq
def kway_merge(*iterables):
input_buffer = []
iterators = [iter(iterable) for iterable in iterables]
for index, iterator in enumerate(iterators):
heapq.heappush(input_buffer, (iterator.next(), index))
while input_buffer:
value, index = heapq.heappop(input_buffer)
y... |
de5d6271d81c95b1f134326fc0a568e9db2e701c | vikashkshatra/morse_code | /morse.py | 1,174 | 3.734375 | 4 |
from playsound import playsound
import time
codes = {
"A": ".-",
"B": "-...",
"C": "-.-.",
"D": "-..",
"E": ".",
"F": "..-.",
"G": "--.",
"H": "....",
"I": "..",
"J": ".---",
"K": "-.-",
"L": ".-..",
"M": "--",
"N": "-.",
"O": "---",
"P": ".--.",
"Q"... |
e6132a41ee3324b68d6ca3e7c18592b0c8a7a4a2 | MukulKirtiVerma/Python_Excercise | /12. Python_Dictionary.py | 2,460 | 3.9375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Jun 13 15:14:10 2018
@author: sky
"""
#creating dictionary
dict1={}
dict1={1:2,3:4,5:6}
dict2 = {2: [1,2,3], 'Age': 7, 'Class': 'First'}
#print value
print ( dict2['Age'])
print ("dict['Age']: ", dict2['Age'])
dict2 = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}
... |
f1e8462cb95a2a134f9600913cff3e9ca771de8a | leonardo111003/infosatc-lp-avaliativo-01 | /exercicio22.py | 101 | 3.5625 | 4 | jardas = float ( input ( "Insira o valor em jardas:" ))
metros = jardas * 0,91
print ( metros ) |
ac2a04f3490af8bf8c8c56107232a53c59fa49a7 | ppmorgoun/dspt11_3.1.1 | /mymodule/reddit.py | 1,775 | 3.671875 | 4 | admin = "petr"
class Post:
def __init__(self, up_votes, down_votes, user, body):
self.up_votes = up_votes
self.down_votes = down_votes
self.user = user
self.body = body
class User:
def __init__(self, name, karma, is_moderator=False):
"""
Create a User obje... |
b9303d5c4dbb81760e70563ed9572ef880e463f4 | ccmiller214/python_api_class | /tryExcept.py | 363 | 3.859375 | 4 | #!/usr/bin/python3
## Loop until works
while True:
try:
## Pull info from the local user
name = input('Enter a file name: ')
with open(name,'w') as myfile:
myfile.write('Well done\n')
except:
print('Error in creating that file...try again!')
else:
print('... |
b54896e1374239a7f6ac66c3987ab4475a3262b2 | alistairpott/intaka | /docbuilder.py | 3,346 | 3.78125 | 4 | class DocBuilder:
"""A class for construcing documents ready to be converted to ebooks."""
def __init__(self, title, filename='output'):
"""Setup the document builder using input parameters
title = The title out the output document
filename = Optional filename of... |
4faed6f5261879ded97652d712bb6863ddfe73f9 | TianyaoHua/LeetCodeSolutions | /Unique Binary Search Trees.py | 753 | 3.78125 | 4 | # Definition for a binary tree node.
class Solution(object):
def generateTrees(self, n):
"""
:type n: int
:rtype: List[TreeNode]
"""
if n < 1:
return []
table = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
table[i][i] = ... |
8b9e4443eb0106157f79d42c0c45be2a3f7d03a7 | lusifer65/algorithms | /Python3/TowerOfHanoi.py | 541 | 3.765625 | 4 | i=0
def towerOfHanoi(disks, source, auxiliary, target):
global i
if disks == 1:
print("Move disk 1 from tower {} to tower {}.".format(source, target))
i+=1
return
towerOfHanoi(disks - 1, source, target, auxiliary)
print("Move disk {} from tower {} to tower {}.".format(disks, so... |
dace2c927744f4c001540a8a42f56caba8829748 | MrHamdulay/csc3-capstone | /examples/data/Assignment_8/hrrbha001/question1.py | 261 | 4.1875 | 4 | def palindrome (s):
if len(s) < 2:
return True
elif s[0] == s[-1]:
return palindrome (s[1:-1])
else:
return False
str = input ("Enter a string:\n")
if (palindrome (str)):
print ("Palindrome!")
else:
print ("Not a palindrome!") |
2d1f3698a1a6520972dd29420e3ae41638cd406a | rrnewton/MandelMicrobench | /mandel_test.py | 262 | 3.5625 | 4 |
def mandel(depth, c):
count = 0
z = complex(0,0)
while (True):
if (count == depth): break
if (abs(z) >= 2.0): break
z = z*z + c;
count += 1
return count
print(mandel(5 * 1000 * 1000, complex(0.1,0.1)));
|
39e4a5e2921dc91327c123da6266655b52b73476 | lixingyangok/learn-python-01 | /00-li-note/01-data-type.py | 430 | 4 | 4 | """
数据类型检测方法
● type(18) # <class 'int'>
● isinstance(18, int) # True
"""
name = 'Tom'
number = 18
print('name的数据类型:', type(name))
print('number的数据类型:', type(number))
typeStr = type(1)
print('type()返回的值,类型是:', type(typeStr))
print('■'*20)
print('查看18是不是整型:', isinstance(18, int))
print('查看18是不是浮点型:', isinstance(18... |
98d11ec72760ae2f6e8b790c1ede327480847f71 | LorenzoChavez/CodingBat-Exercises | /List-1/rotate_left3.py | 302 | 4.25 | 4 | # Given an array of ints length 3, return an array with the elements "rotated left" so {1, 2, 3} yields {2, 3, 1}.
def rotate_left3(nums):
rotated = []
iternums = iter(nums)
next(iternums)
for num in iternums:
rotated.append(num)
rotated.append(nums[0])
return rotated
|
041c74b7c351d8939c717001e933c32d1eaf9f20 | bapata/PYTHON | /sigma_and_pi.py | 820 | 3.9375 | 4 | #!/usr/bin/python
#
## Script to calculate summation and factorial of N
# ./sigma_and_pi.py 10
# Summation of 10 is 55
# Factorial of 10 is 3628800
#
import sys,os
def sum_upto_n(n):
return 0 if (n<0) else n + sum_upto_n(n-1)
def product_upto_n(n):
return 1 if (n<=0) else n * product_upto_n(n - 1)
#
## mai... |
63d6c812471c0bbab60850089ce64e53041e33c6 | decodingjourney/BeginnerToExpertInPython | /ForLoopInPython/ForLoops.py | 1,751 | 3.828125 | 4 | # for i in range(1, 12):
# print("Value of i now is {0} " .format(i))
#
#
# number = "9,123,234,345,456,567,678,789"
# for i in range(0, len(number)):
# print(number[i], end='')
#
# number = "9,123,234,345,456,567,678,789"
# print()
# cleanedNumber = ''
# for i in range(0, len(number)):
# if number[i] in '0... |
8c8a46f26b65ca5eaa9b20567d4b731d42591e7f | chanyoonzhu/leetcode-python | /529-Minesweeper.py | 1,982 | 3.578125 | 4 | class Solution:
def updateBoard(self, board: List[List[str]], click: List[int]) -> List[List[str]]:
"""
time exceeded, not know why
r, c = click
if board[r][c] == 'M':
board[r][c] == 'X'
return board
elif board[r][c] == 'E':
revealed = set(... |
e57b4bd468b823b0171c84b3afd783138e6deb93 | sankleta/glowing-funicular | /counting_letters.py | 415 | 3.84375 | 4 | from math import floor
snippet = input()
string_length = int(input())
def count_as(snippet):
a_in_snippet = 0
for letter in snippet:
if letter == "a":
a_in_snippet += 1
return a_in_snippet
a_in_snippet = count_as(snippet)
snippet_len = len(snippet)
answer = floor(string_length /... |
e3ae4778793da0c685767852ac434fd0060aad2a | talhaHavadar/daily-scripts-4-fat-lazy | /programming_questions/honeycomb.py | 1,743 | 3.78125 | 4 | """
Problem B
A bee larva living in a hexagonal cell of a large honeycomb decides to creep for a walk.
In each “step” the larva may move into any of the six adjacent cells and after n steps,
it is to end up in its original cell. Your program has to compute,
for a given n, the number of different such larva walks.
""... |
ae27fbdbb628c9a53757a92df386e965c06515d8 | inshelligent/5023-OOP-scenarios | /shapes/shapes.py | 553 | 3.8125 | 4 | import math
class Rectangle:
def __init__(self, length: float, width: float):
self.length = length
self.width = width
def calculate_area(self):
return self.length * self.width
def calculate_perimeter(self):
return (self.length * 2) + (self.width * 2)
class Circle:... |
729445df3f10dc2041a663e296c7163fd500fade | angelahe/python | /mail.py | 690 | 3.875 | 4 | #make a function called email
#received 2 parameters: first name and last name
#e.g. Larry Shumlich => larry.shumlich@evolveu.ca
#e.g. Heiko Peters => heiko.peters@evolveu.ca
#write an automated test that will check the results are what you expect
#email the test to Larry before you write the code
def make_email(firs... |
72dadbc72fcd14a0d5e6dc24ba9d19d9478804d8 | rawfighter/List | /Untitled-2.py | 226 | 3.890625 | 4 | # Conceptos condicionales y loops
print("Dame una palabra")
palabra = input()
print("Dame un numero")
numero = int(input())
if numero == 1:
print(len(palabra))
else:
for index in range(numero):
print(palabra) |
677926014c172190bafdbe242dd0c3de7cd54370 | pratham-singh-data/Python-Examples | /letter_counter.py | 1,367 | 4.03125 | 4 | def seperator():
for i in range(100):
print("*", end = '')
print()
def count_instances(string, letter):
step = len(letter)
choice = input("Enter \'y\' if cases are to be considered: ")
if choice == 'y':
pass
else:
string = string.lower()
l... |
99d028d3bd9a9f0eead2449d1c565ec582a2effa | durgadevi68/guvi | /digit.py | 110 | 3.828125 | 4 | n=int(input())
if((n%2)==0):
while((n%2)==0):
n=n/2
print(int(n))
else:
print(n)
|
602108b433ca3a7d5772f0341272f5b385ab87d5 | takisforgit/Projects-2017-2018 | /binary-tree-ex1.py | 3,668 | 4.28125 | 4 | """
https://medium.freecodecamp.org/all-you-need-to-know-about-tree-data-structures-bceacb85490c
"""
from queue import Queue
class BinaryTree:
def __init__(self, value):
self.value = value
self.left_child = None
self.right_child = None
def insert_left(self, value):
if self.left_child == No... |
ec4fa4a4fc87c44ead62cae94878e5715256dac2 | beOk91/code_up | /code_up1073.py | 133 | 3.5625 | 4 | value_list = input().split()
i=0
while True:
if value_list[i]!="0":
print(value_list[i])
else:
break
i+=1 |
b85118c72bdb579fb446115e828c8fe3ddb2313e | havenshi/leetcode | /465. Optimal Account Balancing.py | 3,301 | 3.609375 | 4 | # A group of friends went on holiday and sometimes lent each other money. For example, Alice paid for Bill's lunch for 10.ThenlaterChrisgaveAlice10.ThenlaterChrisgaveAlice5 for a taxi ride. We can model each transaction as a tuple (x, y, z) which means person x gave person y $z. Assuming Alice, Bill, and Chris are pers... |
4d825ad1dc634a990587db1bed9bbec9d8bc26fa | Avani1992/python | /chapter19_TypesofInheritance/Multiple.py | 1,016 | 4.28125 | 4 | # class Parent:
# def m1(self):
# print("Parent class")
#
# class Child:
# def m2(self):
# print("Child class")
#
# class Child1(Parent,Child):
# def m3(self):
# print("Child1 class")
#
# c=Child1()
# c.m1()
# c.m2()
# c.m3()
#2. Both class same method. First come F... |
a5468337ee495a87432bb468d2e9285ae32d9895 | sinhars/Data-Structures-And-Algorithms | /Course1/Week3/5_covering_segments.py | 792 | 3.625 | 4 | # Uses python3
import sys
from collections import namedtuple
from numpy.core.fromnumeric import sort
Segment = namedtuple('Segment', 'start end')
def optimal_points(segments):
points = []
sorted_segments = sorted(segments , key=lambda x: x.start, reverse=False)
while len(sorted_segments) > 0:
min_... |
971d2c8a7f57b4787f65fbd01acc7fbaef0eca0e | valerii2020/valerii2020 | /starter/lesson 2/Mariia Horb/task 3.py | 214 | 3.84375 | 4 | a=input("целое число a")
a = int(a)
b=input("целое число b")
b = int(b)
c=input("целое число c")
c = int(c)
sqrt=(b**2-4*a*c)**0.5
x1=(-b+sqrt)/2*a
x2=(-b-sqrt)/2*a
print(x1)
print(x2) |
9167320a70295970059c9001e352d41c596812a3 | leksiam/PythonCourse | /Practice/S.Mikheev/return_maximum.py | 472 | 4.15625 | 4 | def maximum(a, b):
return a if a > b else b
# если a == b, то в любом случае будет выведено максимальное число
a = int(input('enter the first integer: '))
b = int(input('enter the second integer: '))
print('The maximum number is {}'.format(maximum(a, b)))
# можно использовать float вместо int для того,
# что... |
24cd789f6ed4252264f86c06b103eda5fe69280c | Bawya1098/python-Beginner | /Day 2/Functions.py | 284 | 3.78125 | 4 | def sum_num(number1, number2):
print(number1 + number2)
return number1 + number2
print(sum_num((2, 2)))
print((print("hi")))
# print(input("enter the number"))
print("1,2,3,4,5,6")
print(1, "a,b")
print(type(1.0))
print(type('hi'))
print(type('print'))
print(type(print()))
|
2d4d64a610c994f914248468f90d50f121c9630a | zantelope/code_Signal_42_BishopAndPawn | /bishopAndPawn.py | 682 | 3.921875 | 4 | def bishopAndPawn(b, p):
## change input values into integers that corerspond to their position on a chessboard
## ord() function changes input to a string representing it's ascii value
## change both values to ints
b = [int(ord(b[0]) - 96), int(b[1])]
p = [int(ord(p[0]) - 96), int(p[1])]
## i... |
4d97ce5458e1087470ae9ce052f143b5b47e8da3 | abjordan/mazes-for-programmers | /cell.py | 1,885 | 3.640625 | 4 | #!/usr/bin/env python
from distances import Distances
class Cell:
row = None
column = None
my_links = None
(north, south, east, west) = (None, None, None, None)
def __init__(self, r, c):
self.row = r
self.column = c
self.my_links = {}
def link(self, cell, bidi=Tr... |
7da5f00f0c3da1c42e4a3afcf7127ed5ca902e98 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2339/60760/271002.py | 363 | 3.546875 | 4 | def func(arr:list):
cou=0
for i in range(len(arr)):
for j in range(len(arr)):
if j>i and arr[j]<arr[i]:
cou=cou+1
return cou
tests=int(input())
lists=[]
for i in range(tests):
l=input()
lists.append(list(map(int,input().split(" "))))
res=[]
for i in lists:
res... |
76728ef97952517799bb36df97b7f7239bdbcb3f | CreativeBusyBee/Hadoop | /MongoDB/for_loop.py | 143 | 4.03125 | 4 |
fruit =['apple','pears','mango','kiwi']
new_fruit =[]
for item in fruit:
print item
new_fruit.append(item)
print new_fruit
|
2f8bdab3b4235bed31cceed640737785766ba103 | arbansal/16Puzzle-and-DrivingDirectionsSearch | /part1/solver16.py | 6,807 | 3.59375 | 4 | #!/usr/bin/env python
# solver16.py : Circular 16 Puzzle solver
# Based on skeleton code by D. Crandall, September 2018
# This code has been constructed based on the structure given by Dr. David Crandall
# We have constructed two heuristic fnctions:
# a) Number of misplaced tiles
# b) Circular manhattan distance
# Base... |
3a0bbb07d325f3d66d116bfe5398ca25d6465325 | syurskyi/Python_Topics | /079_high_performance/exercises/template/Writing High Performance Python/item_25.py | 2,534 | 3.828125 | 4 | import logging
from pprint import pprint
from sys import stdout as STDOUT
# Example 1
class MyBaseClass(object):
def __init__(self, value):
self.value = value
class MyChildClass(MyBaseClass):
def __init__(self):
MyBaseClass.__init__(self, 5)
def times_two(self):
return self.value... |
60429d2e22d1e78c958fa563a6e79b0b270fc6ba | syurskyi/Python_Topics | /125_algorithms/_exercises/templates/Learn_Python_by_solving_100_Coding_Challenges/Coding Challenge No. 1 - Fizzbuzz NUKE.py | 594 | 4.375 | 4 | # Question: Write a program that prints the integers from 1 to 100.
# But for multiples of three print "Fizz" instead of the number, and for the multiples of five print "Buzz".
# For numbers which are multiples of both three and five print "FizzBuzz".
# Solution:
c_ Solution:
___ Fizzbuzz(x,z):
___ i __ r.... |
8d7034d80b93bad52eb970ca538ccbdcfa687631 | KimhabCoding/python-w3school | /exercise/0.basic.py | 238 | 3.609375 | 4 | print('Hello My Crush')
print('---*** I Love Programming do much ***---')
# This a comment line in python
print("I am so happy today")
print('Error with Semi colon'); # Error when you end with semi colon
print("Do you love your crush")
|
579da09835d8da0a67e21fffceb677f95addc605 | a-angeliev/Python-Fundamentals-SoftUni | /Text Processing - Exercise/01. Valid Usernames.py | 465 | 3.734375 | 4 | data = input().split(", ")
flag = True
for i in range(len(data)):
current_username = data[i]
if 3<= len(current_username)<= 16:
for i in current_username:
if not i.isdigit():
if not i.isalpha():
if not i == '-':
if not i =="_":
... |
226b0cf4e30c4d4ba425dddf1b405ad70c3a5552 | EstebanMongui/challenge-python-02 | /src/main.py | 1,953 | 3.8125 | 4 | # Resolve the problem!!
import string
import random
SYMBOLS = list('!"#$%&\'()*+,-./:;?@[]^_`{|}~')
def generate_password():
# Start coding here
letters_min = 'azxjclptuopwkfr'
letters_may = letters_min.upper()
symbols = SYMBOLS
password_list = []
len_password = random.randint(2,4)
for ... |
ddff13866d5787128ededa6b2d2b238e2eae8f58 | songszw/python | /python小栗子/t50.py | 314 | 3.71875 | 4 | def fab(n):
n1=1
n2=1
n3=1
if n<1:
print('wrong number')
return -1
while (n-2)>0:
n3=n1+n2
n1=n2
n2=n3
n-=1
return n3
result = fab(20)
if result != -1:
print('总共有%d对小兔崽子诞生'% result)
|
6e85eb241306588efac5cf453ae848c71795668b | montlebalm/euler | /python/problems/problem15.py | 711 | 3.609375 | 4 | """
Question:
Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
How many such routes are there through a 20×20 grid?
Answer:
137846528820
"""
from helpers.timer import print_timing
from math import factorial
@p... |
7ef2218f6a47a3f89c2e551afe6c432e317aac6c | joonluvschipotle/baekjoon | /9498.py | 133 | 3.796875 | 4 | a = int(input())
if a > 89: print ("A")
elif a > 79: print ("B")
elif a > 69: print ("C")
elif a > 59: print ("D")
else: print ("F")
|
8309c119891bf3afee64eb8ad5243895e04f8df5 | brycejh/Py-practice | /myfile.py | 249 | 3.875 | 4 | anymal = input("Please type your favorite animal: ")
if anymal != "Dogs":
print("Wrong, your favorite animal is Dogs")
else:
doggo = input("What kind of dog? ")
if doggo != "Husky":
print("Dummy")
else:
print("Good")
|
297a90e0b2703f5d25f3e3624d3d55f6883a2f53 | Tritium13/Bioinformatik | /Python etc/counting_nucleotides.py | 578 | 3.71875 | 4 | # counting nucleotides in DNA sequence
seq = str(input("DNA-sequence: "))
n = len(seq) - 1
count_A = 0
count_T = 0
count_C = 0
count_G = 0
while n >= 0:
if seq[n] == 'A':
count_A += 1
n = n - 1
elif seq[n] == 'T':
count_T += 1
n = n - 1
elif seq... |
de8fac63e0fde33298699a964c23a55e9660daf7 | EricOuma/IEEEXtremePractice | /AeneasCryptoDisc/aeneas.py | 990 | 3.78125 | 4 | #!usr/bin/python3
import re
import math
def work(filename):
angles = {}
with open(filename) as f:
radius = float(f.readline())
for _ in range(26):
# k is letter, v is angle
k, v = f.readline().split(' ')
angles[k.lower()] = float(v)
message = f.readl... |
01d58a97bfd3cac742b4dd50bedcc2a7b04712f5 | ThaliaVillalobos/code2040 | /Step3.py | 878 | 3.5625 | 4 | import urllib2
import requests
import json
def main():
#requsting information from API
payload = {'token':'', 'needle':'', 'haystack': ''}
data= requests.post("http://challenge.code2040.org/api/haystack", params = payload)
#To view the information
#print(data.text)
#Coverting JSON string into... |
85d94d9b888b8266ce62aae31c9c7b3d8c49695c | Success2014/Leetcode | /numberOf1Bits.py | 1,479 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Jun 14 15:36:12 2015
Write a function that takes an unsigned integer and returns the number of
’1' bits it has (also known as the Hamming weight).
For example, the 32-bit integer ’11' has binary representation
00000000000000000000000000001011, so the function should return... |
75d573873cf2fc3fb4509a365f12f207959d9941 | kfahad5607/Library-management-system | /lms.py | 2,965 | 4.25 | 4 | class Library:
def __init__(self, libraryname, listofbooks):
self.libraryname = libraryname
self.listofbooks = listofbooks
self.lentbooksinfo = {}
def printlentbooksinfo(self):
if bool(self.lentbooksinfo) == False:
print('No book has been lent currently.')
e... |
3af51321a5e8cfa7f75ff8898713152e13fb660d | bootphon/word-count-estimator | /wce/word_count_estimation/rttm_processing.py | 4,803 | 3.53125 | 4 | """Rttm processing
Module to extract segments of speech from the original wavs by reading its
related .rttm file and gather the results of the WCE on the segments that come
from the same audio.
The module contains the following functions:
* extract_speech - extract speech for one file.
* extract_speech_from... |
3c6fc8bd0b5f86dfa9bb339a4d9c73e61cd19605 | TimeIsOut/workplace | /Solutions/6kyu/Unique in Order.py | 280 | 3.609375 | 4 | def unique_in_order(iterable):
if not iterable: return []
check = iterable[0]
answer = [iterable[0]]
for i in iterable[1:]:
if i != check:
check = i
answer += [i]
if check != iterable[-1]:
answer += [i]
return answer |
dbb300001d54649b48fea252ce963091042baddb | green-fox-academy/ilcsikbalazs | /week-03/day-3/17exercise.py | 261 | 3.625 | 4 | from tkinter import *
root = Tk()
canvas = Canvas(root, width='300', height='300')
canvas.pack()
def lines(x,y,x1,y1):
line = canvas.create_line(x,y,x1,y1,fill="green")
return line
for i in range(150,301,15):
lines(300,i,i,150)
root.mainloop()
|
3162988778dfc6144027b48476ca1240ff5d673f | madnanit/molssi-tapia-camp | /geometry_analysis_2.py | 1,315 | 3.703125 | 4 | import os
import numpy
def calculate_distance(coords1,coords2):
# this function has two parameters. It returns the distance b/w atoms.
"""
this function has two parameters. It returns the distance b/w atoms.
"""
x_distance = coords1[0] - coords2[0]
y_distance = coords1[1] - coords2[1]
z_distanc... |
d5573caf7a665c1459145e07187e013ab50aec21 | Tymotheus/Ensimag-Python | /2_Iterations/4_Kaleidoscope/dessin.py | 762 | 3.859375 | 4 | """
File making a drawing? Generation of SVG file?
"""
import random
import triangle
def entete(width, height):
"""
Generates header of svg File
"""
print("<svg height=\""+str(height)+"\" width=\"" + str(width)+ "\">" )
def couleur_aleatoire():
"""
Returns SVG colour code (?)
"""
retur... |
221b844e361cac8765de4050424ff77290e831ff | mmontpetit/HackerRank | /diagonal_difference.py | 297 | 3.921875 | 4 | def diagonalDifference(arr):
# Given a square matrix, calculate the absolute difference between the sums of its diagonals.
primary = 0
secondary = 0
for i in range(len(arr)):
primary += arr[i][i]
secondary += arr[i][(len(arr)-i-1)]
return abs(primary-secondary) |
1e31b3b4e6b1d13c1d55ad1ddb67bcba21f9f234 | ManullangJihan/Linear_Algebra_Courses | /CH 1/CH 1 Sec 6 Part 1/part34.py | 195 | 3.5 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 16 07:21:23 2020
@author: hanjiya
"""
import numpy as np
A = np.array([[2,3],[-5,6]])
det_A = np.linalg.det(A)
print(det_A) |
a40dcdede573f1bee76e8a9d8de5dd9d580c77b0 | mymmym1/Python | /Computational Biology/Algorithms for DNA Sequencing/week3/findingOverlaps.py | 3,618 | 3.765625 | 4 | from itertools import permutations
def overlap(a, b, min_length=3):
""" Return [length of longest suffix of 'a'] matching
a [prefix of 'b'] that is at [least 'min_length']
characters long. If no such overlap exists,
return 0. """
start = 0 # search start from index = 0 of a
... |
323ddddb333ed60fa01d23d54003c2420b6162e2 | jess123000/Crazy-Eights | /CardDeck.py | 4,048 | 3.71875 | 4 | #!/usr/bin/env python
# Alex Harris
# CS160
from Card import Card
#----------------------------------------------------------------------
import random
import os
#----------------------------------------------------------------------
class CardDeck:
"""
class for representing a deck of cards... |
76843af208c92c4f9e0d049d016b6ec1a1231aa3 | Sudharshan-Sgr/MyCaptain-Python | /area_of_circleAndextension.py | 450 | 3.828125 | 4 | #Task 1
import math
radius = float(input("Input the radius of the circle: "))
area = math.pi * radius ** 2
print("The area of the circle with radius {} is {}".format(radius, area))
#Task 2
file_name = input("Input the Filename: ")
my_Dict = {".py":"Python",".cpp":"C++", ".C":"C", ".java":"Java"}
for i in range(0,len... |
65184ccaa5b506eccbcd784c9993e2dad0e12b4f | div-dos/Codewars | /kyu 6/decode_the_morse_code.py | 745 | 3.5 | 4 |
def decodeMorse(morse_code):
# ToDo: Accept dots, dashes and spaces, return human-readable message
#morse_code = morse_code.replace('.', MORSE_CODE['.']).replace('-', MORSE_CODE['-']).replace(' ', '')
words = morse_code.split(' ')
sol = []
for i in range(len(words)):
words[i] = words[i].s... |
1371ffd1bd8fb891f422900a532507940e70b8ca | sathishmanthani/python-intro | /code/Math_Operations.py | 1,132 | 3.953125 | 4 | # Addition
a = 100 + 60
print (a) # Prints value 160
# Subraction
a = 100 - 60
print (a) # Prints value 40
# Multiplication
a = 20 * 30
print (a) # Prints value 600
# Division
a = 80 / 20
print (a) # Prints value 4
# remainder
a = 51 % 2
print (a) # Prints value 0
# power
a = 20 ** 3
print (a) # Prints value 8000... |
12db99b37202419543e6dc76ab76cc1c68f206ec | yuuuhui/Basic-python-answers | /梁勇版_6.12.py | 224 | 3.796875 | 4 | def printChar(ch1,ch2,numberPerLine):
for x in range(ch1,ch2):
print(chr(x),end = " ")
if (x + 1 - ch1) % 10 == 0:
print("\n")
else:
pass
printChar(65,90,10)
|
5a2bf11d5eb53b94206bc3e70db3dc3d7fe97e5f | karollynecosta/basic_python | /Funcoes/definindo_funcoes.py | 906 | 4.25 | 4 | """
Funções
Conceito: São pequenos partes de código que realizam tarefas específicas
São inerentes a linguagem, ex.: print(), len(), max(), min(), count()
Pode ou não receber entrada de dados e retornar uma saída de dados
úteis para executar procedimentos similares por repetidas vezes
... |
014e4adfd7468d518b3cd7fae87ac08abec49d37 | PedroLSF/PyhtonPydawan | /12b - CHALLENGE_ADV/12b.3_Classes.py | 10,503 | 4.28125 | 4 | ### 1-Robot Inheritance
class Robot:
all_disabled = False
latitude = -999999
longitude = -999999
robot_count = 0
def __init__(self, speed = 0, direction = 180, sensor_range = 10):
self.speed = speed
self.direction = direction
self.sensor_range = sensor_range
self.obs... |
e471b090bb2fa09c3de60fb8ea89a8291513ce4c | debolina-ca/my-projects | /Python Codes 2/pet_conversion.py | 221 | 4.09375 | 4 | # Pet Conversion
about_pet = input("Enter a sentence about your pet: ")
if "dog" in about_pet:
print("Ah a dog")
if "cat" in about_pet:
print("Ah a cat")
if "turtle" in about_pet:
print("Ah a turtle")
|
1f509b3acd304a93fc10a2b1383cc777809f14da | JoseTarinT/PasswordManager | /database.py | 1,732 | 3.953125 | 4 | import sqlite3
# Create the queries that we will use in the functions
CREATE_PW_TABLE = "CREATE TABLE IF NOT EXISTS passwords (app TEXT, user TEXT, password TEXT);"
INSERT_DATA = "INSERT INTO passwords (app, user, password) VALUES (?, ?, ?);"
GET_ALL_DATA = "SELECT * FROM passwords;"
GET_BY_APP = "SELECT * FROM pas... |
faca5b9c5cd5f70e157342f2fbb13e22c98568b6 | elli0t-yash/DSA_with_Python | /Array/Reversed.py | 239 | 3.921875 | 4 | def ReversedArray(arr, start, end) :
while start < end :
arr[start], arr[end] = arr[end], arr[start]
start += 1
end -= 1
A = [1, 2, 3, 4, 5, 6]
print(A)
end = len(A)
ReversedArray(A, 0, (end - 1))
print(A) |
be3e3ec50b2d0be4a2b3ef8c0f49c7533dfcee44 | rehoboth23/leetcode-base | /new/subtree of another tree.py | 982 | 4 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def isSubtree(self, s: TreeNode, t: TreeNode) -> bool:
def checkSubnodes(root, target):
if (not r... |
1493e9ec78377162c601509e98822945f92b74d6 | starnowski/python-fun | /fundamentals/fundamentals/calendar/print_calendar.py | 636 | 3.53125 | 4 | import calendar
class CalendarPrinter:
def __init__(self, first_day_of_calendar = calendar.MONDAY):
self.first_day_of_calendar = first_day_of_calendar
pass
def return_calendar_string(self):
c = calendar.TextCalendar(self.first_day_of_calendar)
return c.formatmonth(2019, 1, 0,... |
59fd9ad978c793d25317c5ad94efcfca973f0f0f | banggeut01/algorithm | /code/list/5122.py | 3,141 | 3.703125 | 4 | # 5122.py 수열 편집
import sys
sys.stdin = open('5122input.txt', 'r')
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
self.tail = None
def insertLast(self, node):
if self.head is None: # 빈리스... |
9150ef237120d557b694cdd238f903325ed08dd1 | mkjmkumar/PythonCheatSheet_SampleCode | /First.py | 126 | 3.734375 | 4 | print("Hello Python")
var=10
name="Mukesh"
var1="29"
def add():
sum=var+int(var1)
print(sum)
add()
print(name) |
ca9764d778f336a59a956bd73ad61f75e0a165c5 | Larionov0/python_v1 | /task1.py | 1,037 | 3.71875 | 4 | from data import dataset
# Написати функцію, що зберігає інформацію про улюблену страву користувача у певній країні
# Викликати функцію
def addUserDish(user_name, country, dish):
if user_name in dataset:
if country in user_name:
dataset[user_name][country].add(dish)
else:
... |
d1cdae06f73600b5b75c7ff5d5487b0e21873f05 | davidmrau/trec_utils | /line2trectext.py | 862 | 3.5 | 4 | # gets one query per line as input, writes in trectext format
# example usage:
#python3 query2trectext.py filename
import sys
import json
fname = sys.argv[1]
queries = list()
count = 1
fname_pure = fname.split('/')[-1]
out_file = fname + '.trectext'
queries = list()
def make_elem(num, text):
return '<top>\n\n<nu... |
8bb707012485e30a278376e74ab908b496c2c424 | subnr01/Programming_interviews | /programming-challanges-master/codeeval/098_point-in-a-circle.py | 1,079 | 4.15625 | 4 | #!/usr/bin/env python
"""
Point in Circle
Challenge Description:
Having coordinates of the center of a circle, it's radius and coordinates of a point you need to define whether this point is located inside of this circle.
Input sample:
Your program should accept as its first argument a path to a filename. Input ex... |
e71afa11d8f3dff9b172c59c646a908c52f41091 | gerald-odonnell7/LearningToProgram | /animal.py | 605 | 3.9375 | 4 | class Animal:
'This class is designed to represent real world animals'
numAnimals = 0
def __init__(self, name, length, weight, color, sound):
self.name = name
self.length = length
self.weight = weight
self.color = color
self.sound = sound
Animal.numAnimals += 1
def eat(self):
print self.name, " is ea... |
29d2fab5f23d06fc6229042eefa81180e5d4467d | codeasitis/Python | /RecursionExample.py | 319 | 4 | 4 | def factorial(n):
if n==0 | n==1:
return 1
return n*factorial(n-1)
print(factorial(3))
def fabonacci(n):
if n==1:
return 1
elif n==2:
return 1
elif n>2:
return fabonacci(n-1)+fabonacci(n-2)
for x in range(1,10):
print(x,"",fabonacci(x))
|
32e61668c17365d89fee8262c8d235d8bd5e2ec2 | baloncek2662/advent-of-code-2020 | /solutions/day_07.py | 3,138 | 3.546875 | 4 | #!/usr/bin/env python
import time
SHINY_GOLD = 'shiny gold'
def main():
input_list = get_input_list()
solve_a(input_list)
print()
solve_b(input_list)
def solve_a(bag_list):
result = 0
for b in bag_list:
if contains_gold_bag(bag_list, b) and b.color != SHINY_GOLD:
result +=... |
a418eab99354bd0d06e66abdc044938fb17b5005 | jiangyanglinlan/Data-Structures-and-Algorithms | /剑指offer/63_数据流中位数.py | 1,432 | 3.75 | 4 | # -*- coding:utf-8 -*-
class Solution:
def __init__(self):
self.nums = []
def Insert(self, num):
# write code here
self.nums.append(num)
def GetMedian(self, n=None):
# write code here
nums_length = len(self.nums)
if nums_length & 0b1 == 1:
# 奇数
... |
d5534714e74d465a61a7059639b73f03f97ab374 | jinho6225/python_with_django | /syntax/function.py | 1,727 | 4.125 | 4 | #function
print("="*50)
# def name(params):
# do something1
# do something2
# ...
def add(a, b):
return a + b
a = 3
b = 4
c = add(a, b)
print(c)
print("="*50)
def add(a, b):
return a+b
result = add(a=3, b=7) # a에 3, b에 7을 전달
print(result)
print("="*50)
# def name(*params):
# do something... |
1d3409bb5f11b79e016f6f857f8d8d0ad15f12d3 | ckjq202682/AS01 | /main.py | 281 | 3.5625 | 4 | # AS01
mylist = [1, 5, 2, 7, 8, 3, 6, 9, 4]
for a in range(len(mylist) - 1):
for i in range(len(mylist) - 1):
if mylist[i] > mylist[i + 1]:
hold = mylist[i + 1]
mylist[i + 1] = mylist[i]
mylist[i] = hold
print(mylist)
|
dead2a31f068aca0c900ce6fd4e89f62c405c1ad | luiseleazar/curso_python_int | /lambda.py | 369 | 3.546875 | 4 | def run():
my_list = [1, 2, 3, 4, 5]
#filter
odd = list(filter(lambda x: x%2 != 0, my_list))
print(odd)
#map
square = list(map(lambda i : i**2, my_list))
print(square)
#reduce
from functools import reduce
multi = 1
multi = reduce(lambda a,b : a * b, my_list)
p... |
8609aad387b5c2712dac9c2f77fb1b44eddca3f9 | cesnik-jure/Python_SmartNinja | /Python tecaj/lesson_04/counting.py | 855 | 3.984375 | 4 | def sum_of_numbers(a, b):
c = a + b
print(c)
return c
def sum_of_lists(a, b = []):
s = 0
for num in a:
s = s + num
for num in b:
s = s + num
return s
def sum_of_seperate_lists(a = [], b = []):
sum1 = 0
sum2 = 0
for num in a:
sum1 = sum1 + num
for nu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.