blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
0d0d845e08700da9b62f0670006921fc2913e2e0 | liguowang/FusionVet | /lib/vetmodule/Overlap.py | 780 | 3.578125 | 4 | def is_overlap(chr1, st1, end1, chr2, st2, end2):
'''
Check if two regios are overlap.
Parameters
----------
chr1 : str
Chromosome ID of the first genomic region
st1 : int
Start coordinate of the first genomic region
end1 : int
End coordinate of the first genomic region
chr2 : str
Chromosome ID of th... |
75f72b06a5f8849d2c1c4fcd126930c256b8ab8e | Richardtlawer/python | /evens2.py | 81 | 3.765625 | 4 | def is_even(i):
return (i%2==0)
def sum_even(nums):
sum=0
sum=num + num
|
ffaefb5dbb07772e2271f0886dc3e4480272a44a | cromox1/KodPerang_kata | /4kyu_next_smaller_number_same_digits_2.py | 2,235 | 3.671875 | 4 | def next_smaller(n):
print(n)
chars = list(str(n))
print(chars)
print(sorted(chars))
print(sorted(chars, reverse=True))
uniq = list(set(chars))
print(uniq)
limit = int(''.join(sorted(chars))) - 1
for i in range(n - 1, limit, -1):
if sorted(list(str(i))) == sorted(chars) and i... |
63d21dc759931998e65dda7f77662e9794c903f3 | prakashmngm/Lokesh-Classes | /Modified_Fibonacci.py | 1,109 | 4.0625 | 4 | '''
Problem : Modified Fibonacci Sequence
Given first three numbers of the sequence : 1, 1, 2
‘N’ number is = addition of the previous three numbers.
Input : ‘n’ ( no. of terms to print. n>0 )
Input : 5
Output : 1, 1, 2, 4, 7
---
Pseudo code :
1. Take the input variable num
2. Initiate the initial variables v... |
9995b8ed3e2842de4d583f2f5c0da6acd0dffafd | blueLibertas/BOJ | /Python/#2447 별 찍기 -10.py | 513 | 3.625 | 4 | # 문제 출처: https://www.acmicpc.net/problem/2447
# 풀이: 2021.01.26
def check_star(X, Y, N):
if N == 1:
check[X][Y] = 1
return
for i in range(3):
for j in range(3):
if i != 1 or j != 1:
check_star(X-N//3*i, Y-N//3*j, N//3)
N = int(input())
check = [[0 for x in r... |
a86c50e1283ef17445a778f4d37b3b2c2e59cfce | MarTecs/python-introducing | /尹成Python/day01plus/21money.py | 247 | 3.71875 | 4 | # -*-coding:utf-8-*-
# Author: sivan
# computer: notebook
# description: 咪西银行钱财(通过转分来实现)
money = eval(input("请输入转账的钱财:"))
money = ( money * 10 - (int)(money * 10) ) / 10
print("米西了。", money)
|
5275cbc49633d9b8e3ceaf1a712f1a3fab2554a6 | Fulvio7/curso-python-guppe | /guppe/exercicios_secao_6/ex_20.py | 474 | 3.8125 | 4 | """
20- Leia uma sequência de números inteiros. O processo termina
quando for informado o valor 1000. Imprima quantos números foram
lidos e quantos são pares.
"""
total_pares, total_numeros = 0, 0
while True:
numero = int(input('Digite um número inteiro: '))
total_numeros += 1
if numero % 2 == 0:
to... |
055d86ae3c6bde04725bf619b201e8a7e98ffe97 | sxuya/summary_machineLearnig | /miniProgect_naiveBayes_optimalClassifier.py | 3,753 | 3.953125 | 4 | #------------------------------------------------------------------
#
# Bayes Optimal Classifier
#
# In this quiz we will compute the optimal label for a second missing word in a row
# based on the possible words that could be in the first blank
#
# Finish the procedurce, LaterWords(), below
#
# You may want... |
79a6223cf3fa51acfb86e5f360ff2d943d45d852 | Phred7/CSCI442-ComputerVision | /OpenCV/ImageTranslationDemo.py | 462 | 3.5625 | 4 | import cv2 as cv
import numpy as np
src = cv.imread("japaneseflowers.jpg", 1)
if src is None:
print("missing image")
else:
cv.imshow("windowM", src)
rows,cols = src.shape[:2]
#shifting the image 100 pixels in both dimensions
#make sure you import numpy
M = np.float32([[1,0,-100],[0,1,-... |
87c7a2d011d0ba91e9ef8ba37080a2b7b334cdc3 | padamcs36/Introduction_to_Python_By_Daniel | /Chapter 9 GUI's Programming Using TKinter/Process Event File in Class.py | 644 | 3.5 | 4 | from tkinter import *
import sys
class ProcessButton:
def __init__(self):
tk = Tk()
btOk = Button(tk, text="Ok", command=self.Ok,
font='Courier 20 bold italic overstrike underline')
btCancel = Button(tk, text="Cancel", command=self.cancel, font='Times 10 bold'... |
09718fd91dc53317462fb9609921775148d39f22 | guam68/class_iguana | /Code/nathan/pythawn/lab_14_pick6.py | 1,225 | 3.515625 | 4 | import random
def pick6():
nums = []
for i in range(6):
nums.append(random.randint(1, 99))
return nums
winning_numbers = pick6()
balance = 0
for i in range(100000):
ticket_number = pick6()
balance -= 2
# print(winning_numbers)
# print(ticket_number)
# find the number of matche... |
4736f933c33b8d54335a6c7579c736c53129ce16 | riyarai13/image_silder | /myslider.py | 2,212 | 3.96875 | 4 | """import modules tkinter creates application window ,provides functions to develop gui
cycle provides an iterator object to iterate through lists of images """
import tkinter as tk
from itertools import cycle
from PIL import ImageTk, Image
"""main class it creates the window"""
class App(tk.Tk):
de... |
5c91fca01fe79c532670f452d5574d89f94d1ee1 | Sidhus234/Python-Dev-Course | /Codes/Session 14 Regular Expressions/Session 14 Regular Expressions II.py | 548 | 3.921875 | 4 | import re
# More details can be found here: https://www.w3schools.com/python/python_regex.asp
# Regular Expressions come useful for advanced patterns
# search for a-z(lower or capital) followed by any char and then small 'a'
pattern = r'[a-zA-Z].([a])'
string = 'Hey how are you!?'
a = re.search(pattern, str... |
559a4228fba9161bb91a6f1303c1a2cf79d8af08 | BryanDawson/Practice | /WordReverse.py | 626 | 4.125 | 4 | """
Simple Word reverse practice program.
Solution for:
http://www.practicepython.org/exercise/2014/05/21/15-reverse-word-order.html
"""
def revstr(fstr):
"""Returns the input string in reversed order"""
tmp = fstr.split()
print(tmp)
tmp = tmp[::-1]
return ' '.join(tmp)
def main():
""" ... |
e75fb4e46b344edd6a368f2b48e5a4687411c0cd | jal347/gene_demo | /utils.py | 259 | 3.671875 | 4 | def set_key(dictionary, key, value):
if key not in dictionary:
dictionary[key] = value
elif type(dictionary[key]) == list:
dictionary[key].append(value)
else:
dictionary[key] = [dictionary[key], value]
return dictionary |
dbe6dc5ba21a5555e86dace2f1805d1e07279f0e | nklang02/comp110-21f-workspace | /exercises/ex01/relational_operators.py | 613 | 4.15625 | 4 | """Learning to program with relational operators."""
__author__ = "730418254"
value_1: str = input("Left-hand side: ")
value_2: str = input("Right-hand side: ")
value_1_int_form: int = int(value_1)
value_2_int_form: int = int(value_2)
print((value_1) + " < " + (value_2) + " is " + str((value_1_int_form) < (value_2_int_... |
02e65374a12a1f46fcbbcb70e73b668689b8a3b0 | jiikoojii/Practice-Python | /Calculator.py | 1,406 | 3.9375 | 4 | import sys, time
x = 0
y = 0
def add():
print("Give the first number")
x = int(input())
print("Give the second number")
y = int(input())
z = x + y
print("Addition of", x, " and ", y, "equals =", z)
time.sleep(1)
#time.sleep is so the answer is clearly visible for a moment before selection c... |
4cb95b35710b19f65088450d818c9121c3f653e2 | datawisdomx/DataScienceCourse | /Part1-MachineLearningandDataAnalytics/Examples/Chapter1_PythonProgramming/Chapter1_PythonProgramming_OOPS.py | 926 | 3.703125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 19 13:31:39 2021
@author: nitinsinghal
"""
# Chapter 1 – Programming – Python
# OOPs - Classes, Objects, Inheritance
class Book:
def __init__(self, title, author):
self.title = title
self.author = author
def details(self):
... |
cdbae2655f8ae88399d5014469590890eee0a9f6 | ticotheps/Hash-Tables | /resizing_hashtable/my_r_hashtables.py | 2,939 | 4.15625 | 4 | # '''
# Linked List hash table key/value pair
# '''
class LinkedPair:
def __init__(self, key, value):
self.key = key
self.value = value
self.next = None
def __str__(self):
return f'key: {self.key}, value: {self.value}'
# '''
# Fill this in
# Resizing hash table
# '''
class Has... |
6165c98e582e2c3da4c647bdfe57069b6b566d8f | kevinjzheng/Data-Structures | /Homework/Homework5/kjz233_hw5_q1.py | 1,991 | 3.90625 | 4 | class Empty(Exception):
pass
class ArrayStack:
def __init__(self):
self.data = []
def __len__(self):
return len(self.data)
def is_empty(self):
return len(self) == 0
def push(self, val):
self.data.append(val)
def top(self):
if (self.is_empty()):
... |
2abef6276161a6329821a8040fc280b68f52b135 | phy234/FirstPythonSteps | /Quadrat.py | 2,350 | 3.59375 | 4 | # Autor: Alexander Herbrich
# Wann: 03.02.2016
# Thema: Programm zum loesen des magischen Quadrats erstellen
def quadrat():
# DIESES PRORAMM ENTHAELT NOCH FEHLER!!!!!
# A + B + C = S
# D + M + d = S
# a + b + c = S
# A + D + a = S
# B + M + b = S
# C + d + c = S
# A + M + c = S
# C + M + a =... |
22410bee74e1de80043a9aa6c254ac686b980fde | jxhangithub/lintcode | /Stack/494.Implement Stack by Two Queues/Solution.py | 1,027 | 4.09375 | 4 | from collections import deque
class Stack:
"""
Initialization
"""
def __init__(self):
self.q1 = deque([])
self.q2 = deque([])
"""
@param: x: An integer
@return: nothing
"""
def push(self, x):
# write your code here
self.q1.append(x)
"""
@re... |
e9bad7d5e64d38bf6575d69c03ab00ecfff1bcde | maistrovas/My-Courses-Solutions | /Coursera An Introduction to Interactive Programming in Python (Part 1, 2)/5_Memory/user40_b5KkJIsI0O_2.py | 2,290 | 3.59375 | 4 | # implementation of card game - Memory
import simplegui
import random
deck = range(0,8) * 2
num_cards = len(deck)
deck_width = 800
deck_height = 100
card_width = deck_width / num_cards
print len(deck)
# helper function to initialize globals
def new_game():
global shuffle_list, turns, exposed_list, se... |
fc5560073789863afa0453542c18eb01f39a4a8d | aabishkaryal/exercism-python | /grade-school/grade_school.py | 1,760 | 3.84375 | 4 | from typing import List
from dataclasses import dataclass
class School:
def __init__(self):
self.students: List[Student] = []
def add_student(self, name: str, grade: int) -> None:
"""
Add student to the school at grade
"""
print(self.students)
new_student = S... |
3c2ed0f17a7e642936cecffe9788c511e16276f1 | SathriMamatha123/EDUYEAR-PYTHON---20 | /Day2.py | 438 | 3.953125 | 4 | Name='Stella'
Marks=90
Balance =30864.89
AccNo =13786431991
print("My name is {}, and I got {} Marks in ComputerScience".format(Name,Marks))
print("My Account Number {}, and my Balance is {}" .format(AccNo,Balance))
print("My name is",Name,"and I got" ,Marks, "Marks in ComputerScience")
print("my name is... |
ea6791a35ae6d656670dc46458dc2b3e0d7024d9 | GerardoLSJ/matplotlibBASIC | /sort.py | 584 | 3.984375 | 4 | def insertionSort(n_lista):
for index in range(1,len(n_lista)):
actual = n_lista[index]
posicion = index
print("valor a ordenar = {}".format(actual))
while posicion>0 and n_lista[posicion-1]>actual:
n_lista[posicion]=n_lista[posicion-1]
posicion = posicion-1 ... |
9b8f5df871d152c688c8118dfdd0e7f7bca4aac1 | Saugat00/Sorting-Visualisation | /SortingVisualizer.py | 2,576 | 4.53125 | 5 | import random
import matplotlib.pyplot as plt
import matplotlib.animation as anim
import bubbleSort
import mergeSort
import quickSort
import selectionSort
import countingSort
import insertionSort
import sys
#creating the random unsorted list
def random_Number(unsortedList, number):
#user input for range of number for... |
f92645bb2325c95750e4f864645448d2d31889dc | roiei/algo | /leet_code/1684. Count the Number of Consistent Strings.py | 502 | 3.71875 | 4 | import time
from util.util_list import *
from typing import List
class Solution:
def countConsistentStrings(self, allowed: str, words: List[str]) -> int:
cnt = 0
for word in words:
if len(set(word) - set(allowed)) == 0:
cnt += 1
return cnt
st... |
fef3076ff69efa47353c61d2b5e9c4bd6a2fb652 | bhatiakomal/pythonpractice | /Udemy/Accessor_And_Mutator_Method.py | 574 | 3.90625 | 4 | #Accessor Method Or Getter Method:
'''class Mobile():
def __init__(self):
self.model="RealMe"
def get_model(self):
return self.model
realme=Mobile()
m=realme.get_model()
print(m)
#Mutator Method Or Setter Method:
class Mobile():
def __init__(self):
self.model="RealMe"
def set_mo... |
1b7c7a53eb27b7551c253090f0f82203b6a8ddac | cristi161/searching_algorithms | /algorithms/minmax.py | 564 | 3.5625 | 4 | def minimax(current_depth, node_index, max_turn, scores, target_depth):
if current_depth == target_depth:
return scores[node_index]
print(scores)
if max_turn:
return max(minimax(current_depth + 1, node_index * 2, False, scores, target_depth),
minimax(current_depth + 1, nod... |
7b205bd4e8de530460e210e794598008fe1b5760 | colebrookson/Prey-Switching-Under-CLimate-Change | /Code/Spatially-Implicit-IBM/spatially_implicit_ibm.py | 2,761 | 3.546875 | 4 | ##################################
##################################
### This script is for a spatially-implicit individual-based model comprising
### part of an overall project addressing prey switching as a function of both
### traits and climate
##################################
##################################
... |
a64ab3b879e579e2669aacb8825d2bc91a1a1c5c | TejasSheth104/APSITSkills-Project | /Part_5.py | 3,464 | 4.15625 | 4 | # Write a Python Game ->
# Guess the NUmber and Check your Luck.
import random
def level():
while True:
print('\n\t5. Guessing the Number Game')
print('\nEnter \'-1\' to GO BACK.')
print('1. EASY')
print('2. MEDIUM')
print('3. EXTREME')
try:
select = int... |
14fcaf8668c1540bba337c766c83d15b929d66e0 | HaiFongPan/LeetCode | /python/LRU Cache/Solution.py | 909 | 3.640625 | 4 | # -*- coding: utf-8 -*-
class LRUCache:
# @param capacity, an integer
def __init__(self, capacity):
self.cache = {}
self.record = []
self.capacity = capacity
# @return an integer
def get(self, key):
if self.cache.has_key(key):
self.record.remove(key)
... |
cdc3484d26715634213bd813b49ce3e12d0dcac7 | kaladhar-mummadi/hackerrank | /Contests/101/Points on a line.py | 417 | 3.75 | 4 | #!/bin/python3
import sys
n = int(input().strip())
vertical = True
horizontal = True
x1,y1 = input().strip().split(' ')
x1, y1 = [int(x1),int(y1)]
for a0 in range(n - 1):
x,y = input().strip().split(' ')
x,y = [int(x),int(y)]
vertical = True if vertical and x == x1 else False
horizontal = True if hor... |
f4891c92ba34699fe80a9d71f66a6ae13c39a75f | JosueOb/Taller1 | /Ejercicios/Ejercicio4-6.py | 1,577 | 4.15625 | 4 | from tkinter import *
root = Tk()
v = IntVar()
Label(root,
text="""Choose a programming language:""",
justify = LEFT,
padx = 20).pack()
Radiobutton(root,
text="Python",
padx = 20,
variable=v,
value=1).pack(anchor=W)
Radiobutton(root, text="Perl",
... |
9e707b515ac89fc895a9fd95e605eedd0e9e557a | evgenyneu/image_compressor_python | /src/power_method.py | 1,364 | 4.15625 | 4 | """
Calculate eigenvalues and eigenvectors of a matrix using the power method.
"""
from linear_algebra import matrix_size, dot_product
import numpy as np
ZERO_NUMBER = 1e-20 # Values smaller than this numbers are considered to be zero
def dominant_eigen_system(matrix, iterations):
"""
Calculates the domin... |
f98c30ffe9c37d00da0853a84b3fbbb1f7fa286c | digantkumar/Syracuse-Collatz-Sequence | /Syracuse.py | 1,033 | 4.3125 | 4 | # Digant Kumar
# Syracuse Sequence / Collatz Sequence
# Returns n//2 if the user enters a positive even number and 3*n+1 if the user enters a positive odd number
def syracuse_fn(n):
if n<0:
n = int(input("Enter a positive number: "))
if n == 1:
return 1
if n%2 == 0:
return... |
26904b24f5a7d9f16f4382f9044247249899a56c | NontandoMathebula/AI-futuristic | /Loops.py | 629 | 4.25 | 4 | #Working with loops
def main():
x = 0
#while loop
while(x<10):
x = x + 1
print(x)
#for loop
for x in range(5, 10):
#if(x == 8):break #break statement is used to break the execution of the loop if a condition is met
if(x % 2 ==0):continue
print(... |
6d5b8e4478c98af92b79e9b361b19e19b469bdea | Gendo90/HackerRank | /Graphs/primMSTSubtree.py | 7,861 | 3.546875 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
import numpy as np
import time
import heapq
import sys
#Enhanced heap data structure that uses a map to store value indices and
#remove elements in O(log(n)) time - as compared to O(n) removal time for
#regular heaps, including python's builtin... |
3ff7578b84f44264fe9f6764139598c49f03a5e9 | LeeWoojin-99/Algorithm | /20210411 Daily Algorithm Coding.py | 2,496 | 3.828125 | 4 | '''
2021. 04. 11.
Daily Algorithm Coding
1. disjoint sets structure realization algorithm
2. kruskal's algorithm
3. topology sort algorithm
'''
from collections import deque
#disjoint sets structure realization algorithm code
def ds_find(parent, x):
if parent[x] != x:
parent[x] = ds_find(parent, parent[x])
return ... |
2aa0ccd4a947d8a268c1908adbe95082f31e64d9 | trandominique/Girls-Who-Code-CHS | /simonSays.py | 2,333 | 3.9375 | 4 | import random
import time
import tty
import sys
import os
def numToLetter(num):
if (num == 0):
return 'r'
elif (num == 1):
return 'b'
elif (num == 2):
return 'g'
else:
return 'y'
def letterToColor(letter):
if (letter == 'r'):
return 'red '
elif (letter == 'b'):
return 'blue '
... |
46062e50b046eb0b13f8743c4e7f029a721ceced | PetraVidnerova/euler | /4.py | 252 | 3.78125 | 4 | def is_palindrom(number):
s = str(number)
return s == s[::-1]
palindroms = []
for i in range(111,1000):
for j in range(111,1000):
x = i*j
if is_palindrom(x):
palindroms.append(x)
print(max(palindroms))
|
16a194abad1aa1d028306b1ad9ae084ea6fa6d6f | luciosp/HackerPy | /Strings/SuperReducedString.py | 461 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Apr 6 17:40:38 2017
@author: Lúcio
"""
# Take inputs
#s = list(input().strip())
# Testcases
#s = ['a', 'a', 'a', 'b', 'c', 'c', 'd', 'd', 'd']
s = ['b', 'a', 'a', 'b']
s = ['b', 'b']
#Algorithm
i = 0
while i < len(s) and len(s) != 0:
if i != len(s)-1 and s[i] == s[i+1... |
e4b825f084c45bc4c3bdf57d2b7fc0b5fe0818bb | FX196/Coding-Practice | /Python/LeetCode/472-Concatenated Words.py | 505 | 3.578125 | 4 | from functools import lru_cache
from typing import List
class Solution:
def findAllConcatenatedWordsInADict(self, words: List[str]) -> List[str]:
s = set(words)
@lru_cache(None)
def iscat(word):
for i in range(1, len(word)):
pre, suf = word[:i], word[i:]
... |
ace934b7a14a0f45e6e8a3c45fe8d8317009ca68 | andrewwang2015/Caltech-CS1 | /lab4/lab4_d2.py | 1,046 | 3.984375 | 4 | from Tkinter import *
def draw_square(canvas, color, sideLength, positionTuple):
''' This function takes four arguments: canvas, color, side length of
square, and a tuple of the position of the center of the square
and will draw the corresponding square and return the handle of the
rectangle that was... |
ff19623b5c634d4f9ae02f48d0f33c6be8a02bd4 | ykyasin/qa-python-exercises | /programs/isbn.py | 589 | 3.75 | 4 | # isbn = input("Input the isbn number (no dashes or spaces): ")
# E.g. input: 978030640615
def checkNum(isbn):
isbn = list(isbn)
check = 0
for i in range(len(isbn)):
c = int(isbn[i])
if i % 2 == 1:
x = c*3
check = check + x
elif i % 2 == 0:
check... |
289bd0afebbd721127d88feb051a4cdd9879b475 | JRBarreraM/Algo2 | /Algo2PrimerParcial.py | 11,521 | 3.65625 | 4 | def linear_search(A=str, x=str):
for i in range(len(A)):
if A[i]==x:
return i
i=i+1
return -1
def binary_search(A=str, x=str):
start = 0
end = len(A) -1
while start < end :
mid = (start+end)/2
if A[mid]==x:
return mid
elif x>A[mid]:
start=mid+1
elif x<A[mid]:
end=mid-1
if A[start]==x:
... |
d7f92129766654a287886a1f401fdeb612bb82ff | superwenqistyle/1803 | /08day/作业.py/王者第三个做法.py | 637 | 3.5625 | 4 | account = "liangwenqi"
passwd = 123456
i = 1
a_ccount = input("请输入账户")
p_asswd = int(input("请输入密码"))
if (a_ccount == account) and (p_asswd == passwd):
hero = int(input("请输入英雄的范围: 1.ADC 2.肉 3.法师"))
if hero == 0:
print("鲁班大师")
elif hero == 1:
print("程咬金")
elif hero == 2:
print("王昭君... |
d76195614056ceeb020ca330303e4438efe59d8d | loganfreeman1/Vigenere | /randomDictCheck.py | 542 | 3.65625 | 4 | import DictionaryCheck
import random
import string
import numpy
def getRandomString(length):
letterSet = string.ascii_lowercase
return ''.join(random.choice(letterSet) for i in range(length))
def randomPercentageCheck(depth, maxSize):
i = 0
averageWords = []
while i<depth:
num = numpy.random.randint(2,maxSize)... |
e790f1ab31b34b02fd9982d909bc71a68cf2fe07 | FlorianTSUALA/data-structures-and-algorithms | /redblacktrees/red_black_bst.py | 8,561 | 4.15625 | 4 | """
Problem: Build a Red-Black Tree
Remember, we need to follow the red-black tree rules, on top of the binary search tree rules. Our new rules are:
- All nodes have a color
- All nodes have two children (use NULL nodes for missing children)
- All NULL nodes are colored black
- If a node is red, its children must be ... |
1292f118584e315dda9b94a79cde42ab6ea76562 | nachiketpatel138/Python_Thread | /Thread_communication_Condition.py | 781 | 4.09375 | 4 | from threading import Thread,Condition
from time import sleep
# notify(n=1)--> this method is used to immediately wake up one thread waiting on the condition.where n is number of thread need to wake up (by default value is 1)
# notify_all()--> this metohd is used to wake up all threads waiting on the condition
... |
033eb75ff94f5fc7ea4acf48e953bd973d3c00e4 | wilsonestrada1974/sesion8 | /ejercicio1.py | 339 | 4 | 4 | #Dado los valores ingresados por un usuario (base,, altura), calcular y mostrar en pantalla el area de un triangulo
print("Por Favor Ingrese la medida de la base del triangulo:")
base=int(input())
print("Por favor ingrese la altura del triangulo:")
altura=int(input())
area=float((base*altura)/2)
print("El area del tr... |
74d6c09e424261af7d9588aa99878a8f41dde763 | mohammadsh97/Prework_1 | /hwltd/organization.py | 3,797 | 3.5625 | 4 | from workers.person import Person, Phone, StreetAddress, PobAddrees
from workers.structure import Worker, Engineer, SalesPerson, Team
class Employees:
dict_of_all_employees = {}
def add_employees(self, name, email):
if email in self.dict_of_all_employees.keys():
raise Exception("the email... |
fbc817b2a6de0ad44453082afb3893959ab27c26 | A-Purple-Wolf/python-num-games | /number-games/number_guess.py | 2,054 | 4.0625 | 4 | import random
num = str(random.randrange(10, 100))
guess = "0"
guess_count = 1 # The guess the player is on. Will be used for divisibility.
is_prime = False
# print(num) --- Used for testing purposes
while guess != num and guess.isdigit():
if is_prime == False: # Will always be false before 4 guesses.
... |
dc2112cd7d9c14b98146f5a12810a4fbdf9a74db | GustavoCunhaLacerda/URI | /URI/Python/Multiplos.py | 148 | 3.75 | 4 | inf = [int(x) for x in input().split()]
if inf[0]%inf[1] == 0 or inf[1]%inf[0] == 0:
print("Sao Multiplos")
else:
print("Nao sao Multiplos") |
9f5524e36e9b393f818c5bacc8803f5e07474d62 | jkheang/waduHEK | /diceroll.py | 424 | 3.859375 | 4 | import random
game_start = input("would u like to roll the dice?")
def dice_roll():
print("ur number is" + str(random.randint(1,6)))
global play_again
play_again = input("would u like to play again?")
if game_start == "yes":
dice_roll()
while play_again == "yes":
dice_roll()
elif game_star... |
438ae9c23162572052b747d290dbc699b6fd2c15 | jgalcantara/hyperskill | /rock_paper_scissors.py | 1,748 | 4.09375 | 4 | # Write your code here
import random
def player():
namex = input("Enter your name: ")
print(f"Hello, {namex}")
return namex
def ratings(rating):
scoreboard = {}
for line in rating:
name_, score_ = line.split()
scoreboard[name_] = int(score_)
return scoreboard
def choices():... |
e2d7adf7c5f1f398058c60f7a5125c46bfcc6507 | diediediedie/homework | /hw3-2.py | 218 | 3.703125 | 4 | #!/usr/bin/env python
# -*- coding: utf8 -*-
x=input('input a number:')
for y in range(2,x):
if(x%y==0):
prime=0
break
else:
prime=1
if(prime==0):
print u'不是質數'
else:
print u'是質數'
|
239a390d410852b2b3e1e2b758845778dda73da2 | AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges | /Challenges/cousinsInBinaryTree.py | 2,194 | 3.78125 | 4 | """
Counsins In Binary Tree
In a binary tree, the root node is at depth 0, and children of each depth k node are at depth k+1.
Two nodes of a binary tree are cousins if they have the same depth, but have different parents.
We are given the root of a binary tree with unique values, and the values x and y of two diffe... |
065811516c3018071392af4dc13595c8704a5d72 | Soohee410/Algorithm-in-Python | /book/2. Implementation/4.1.2. 시각.py | 220 | 3.8125 | 4 | N = int(input())
num =0
for hour in range(N+1):
for minute in range(60):
for sec in range(60):
time = '%d%d%d' %(hour,minute,sec)
if '3' in time:
num += 1
print(num)
|
96fd32d53c06bb46a5b064537709b03138c6a454 | 1HIRENSIDDARTH/PROJECT97 | /ngg.py | 583 | 4.21875 | 4 | import random
number = random.randint(1,9)
chances=0
print("number guessing game")
print("guess a number between 1-9")
while chances < 5:
guess = int(input("Enter your guess:- "))
if guess == number:
print("Congratulations!! YOU WIN ")
break
elif guess < number:
... |
b1505ed4ccb574d1fbc4c126e297673f6b6ab822 | IgnasiCrespi/pythonProject | /ex2.py | 298 | 3.953125 | 4 | def mcd(a, b):
res = 0
while(b > 0):
res = b
b = a % b
a = res
return a
# solicitamos los dos números
num1 = int(input("Introduce el primer numero: "))
num2 = int(input("Introduce el segundo numero: "))
print("El máximo común divisor de ", num1," y ", num2," es ", mcd(num1, num2))
|
d4ff01c1631bb7e207d2b317cdbe16e984c396f8 | joonjCode/algorithm-study | /leetcode-py/day12.py | 636 | 4 | 4 | '''
Best time to buy and sell stock
link : https://leetcode.com/problmes/best-time-to-buy-and-sell-stock
Things to study
- Kadane's Algorithm
- Descriptive Statistics
- For max, min size of a variable use : float('inf'), math.inf, sys.maxsize
'''
from typing import List
import math
def max_profit(prices: List[int... |
27967df18348c36c1f47ffc89a4509c57f1ab7d3 | ashwin2401/greyatom-python-for-data-science | /student-management-system/code.py | 1,050 | 3.828125 | 4 | # --------------
# Code starts here
class_1 = ['Geoffrey Hinton', 'Andrew Ng', 'Sebastian Raschka', 'Yoshua Bengio']
class_2 = ['Hilary Mason', 'Carla Gentry', 'Corinna Cortes']
new_class = class_1+class_2
print(new_class)
new_class.append('Peter Warden')
print(new_class)
new_class.remove('Carla Gentry')
print(new_cla... |
3426a90a2654c78fac90d498a9603438f4f69e9b | vanderfreitas/network_robustness | /input_data/flow_matrix.py | 1,290 | 3.546875 | 4 | import numpy as np
def generate_flow_matrix(file_name):
# As the lines do not have the same separation pattern, one must deal with each one separately
file = open(file_name, 'r')
lines = file.readlines()
cities_flow = []
codes = []
# For each file line, discard the text and keep only the numbers of city code... |
20f8533c34d9096626e6e0e796807c228873a576 | LuisTarma/random-python-scripts | /permutaciones.py | 1,634 | 4.1875 | 4 | #!/usr/bin/env python
#-*-coding:utf-8-*-
def combinacion(combinar, lista):
"""
Esta funcion combina los elementos de la lista "combinar" con los elementos de la lista
"Lista"; toma cada elemento de combinar y le adjunta un elemento respectivo de "lista" a menos
de que el elemento de "Lista" este repetido e... |
38cbf27797ab0f898d10c4adf2b784b4fcc67fea | adam-rumpf/combat-turtles | /game/tcgame.py | 17,537 | 3.890625 | 4 | """Defines the main game driver class."""
import tkinter as tk
import game.tcturtle
import ai
from .obj.arena import Arena
from .obj.missile import Missile
class TurtleCombatGame:
"""A class to act as the main driver for a game of Turtle Combat.
This class acts as a container for all game objects (such as th... |
0f9607c78baa0bb006d7fce184324d7026e5e072 | namanofficial10/pymycaptainnaman | /fibbonaci.py | 171 | 3.90625 | 4 | a = int(input("Enter the number of terms: "))
fterm = 0
term = 1
for i in range(a):
print(fterm)
temp = term
term = fterm + term
fterm = temp
|
98d968c317b3adce92efcb4d87b3ff4895b6fc44 | AriesPlaysNation/PythonProjects | /m04_Lab.py | 1,867 | 3.984375 | 4 | # Author: Brad W. Botteron
# Date Written: 2/5/19
# Script: M04_Lab
# Description: Organism Spawn Rate Per Day With Linear Growth
# Initialize constants
MAXINCREASE = 2.0
MAXDAYS = 90
# Initialize variables
maxDays = 0
startingOrgs = 0
dailyIncrease = 0
days = 1
totalOrgs = ... |
178884082f68c1a8f8b9ba30c31a28a0f9fe94d6 | KESH-Sentiment-Analysis/KESH-CommentAnalysis | /modules/preprocessor/preprocessor.py | 2,362 | 3.578125 | 4 | # this module processes the text into an appropriate format
# import nltk
# import string
# from nltk.corpus import stopwords
# from pymystem3 import Mystem
from modules.preprocessor.punctuation_and_whitespace import remove_punctuation
from modules.preprocessor.punctuation_and_whitespace import remove_whitespace
impor... |
d51dcefdb9531628f13af07caec9d363daf8fecb | yaggul/Polinominals | /monom.py | 1,257 | 3.65625 | 4 | class Monom:
def __init__(self, coeff, value, power):
self.coeff = coeff
self.value = value
self.power = power
self.string = ''
def __str__(self):
if self.coeff > 1:
self.string = '{}'.format(self.coeff)
if self.power > 0:
if self.coeff >... |
bbdea0407e715a7d2ffe023c3af90655b9b2a74e | renyuanL/cguTranslate | /tc_Demo/wikipedia_example/tc_wikipedia4.py | 1,436 | 3.625 | 4 | """ turtle-example-suite:
tdemo_wikipedia4.py
This is the fourth of a series of 4 examples
inspired by the Wikipedia article on turtle
graphics. (See example wikipedia1 for URLs)
First we create (ne-1) (i.e. 35 in this
example) copies of our first turtle p.
Then we let them perform their steps in
para... |
731f70fe3f6e568cfc9edebba76c0b3baa006cea | ddh/codewars | /python/number_of_trailing_zeros_of_n.py | 1,218 | 4.15625 | 4 | """
Write a program that will calculate the number of trailing zeros in a factorial of a given number.
N! = 1 * 2 * 3 * ... * N
Be careful 1000! has 2568 digits...
For more info, see: http://mathworld.wolfram.com/Factorial.html
Examples
zeros(6) = 1
# 6! = 1 * 2 * 3 * 4 * 5 * 6 = 720 --> 1 trailing zero
zeros(12) ... |
326593e48a06945585bfa9486aa7fb270910e184 | LucasNoga/Workspace-Python | /DUT/DUT_TP/TD 3/Exercice 3.py | 302 | 3.765625 | 4 | Z=0
Cpt=0
while Z<=10:
Y=0
while 10*Z+5*Y<=100:
X=0
while 10*Z+5*Y+2*X<=100:
if 10*Z+5*Y+2*X==100:
print(X,Y,Z)
Cpt=Cpt+1
X=X+5
Y=Y+2
Z=Z+1
print("Il éxiste",Cpt,"manières de faire un franc")
|
3f85bd42b08bdb27f9599871ad9a7f7528038ec9 | VeeraPrathapSelenium/WeekEndPythonBatch | /LoopingStatements/WhileLoop.py | 65 | 3.515625 | 4 |
i=1
while i<=20:
if(not i%2==0) :
print(i)
i+=1
|
f2155933f967611af9cde83411da38c89cec3c6d | asperaa/programming_problems | /dp/maximum_product_subarray_linear_time.py | 516 | 3.734375 | 4 | """Maximum product subarray. Linear time"""
def max_pro(nums):
if not nums:
return 0
length = len(nums)
maxx = nums[0]
minn = nums[0]
total_max = nums[0]
for i in range(1, length):
temp_maxx = maxx*nums[i]
temp_minn = minn*nums[i]
maxx = max(temp_maxx, temp_minn, ... |
2288bca6004d3b1c1b1497cabe64ba88bf055075 | ksummer/pygames | /ksummer_euchre.py | 4,306 | 4.125 | 4 | # Playing Cards
# Demonstrates combining objects
class Card(object):
""" A playing card. """
RANKS = ["A","9","10","J","Q","K"]
SUITS = ["c","d","h","s"]
def __init__(self, rank, suit):
self.rank = rank
self.suit = suit
def __str__(self):
rep = self.rank + self.suit
... |
0ac690ceef1a04e9a267f8595fa581b2df1668a9 | ivaylo-n/python-essential-training | /Structured Data/dictionaries.py | 421 | 3.921875 | 4 |
def main():
animals = dict(kitten='meow', puppy='ruff', lion='grrr',
giraffe='I am a giraffe', dragon='raw')
animals['monkey'] = 'haha'
print('lion' in animals)
print('found!' if 'godzilla' in animals else 'nope!')
print(animals.get('godzilla'))
print_dict(animals)
def print_dict... |
0c322aafed3fd5a1a31e782ff0b6502e66df6a87 | tkaderr/python_fundamentals | /call_center.py | 1,071 | 3.671875 | 4 | class call(object):
def __init__(self,unique_id,caller_name,phone_number,time_call,reason_call):
self.unique_id=unique_id
self.caller_name=caller_name
self.phone_number=phone_number
self.time_call=time_call
self.reason_call=reason_call
def displayInfo(self):
print... |
5d5e005c5a102c067f1117165df1398463e4e342 | JIsernhagen/Python_Programming_Zelle | /sphere.py | 352 | 4.0625 | 4 | import math
def sphere_area(radius):
sphere_area = 4*math.pi*radius**2
return sphere_area
def sphere_volume(radius):
sphere_volume = (4 / 3) * math.pi * radius ** 3
return sphere_volume
def main():
radius = eval(input("Input radius:"))
print("Volume: ", sphere_volume(radius))
print("Area:... |
3c721a5e1fa9a756d6df0f1870fc45e97b174e54 | jeffkt95/ProjectEuler | /problem0009.py | 573 | 3.59375 | 4 | import sys
import os
import math
def main():
for b in range(999, 1, -1):
for a in range(b-1, 0, -1):
result = 1e6 - 2000 * a - 2000 * b + 2 * a * b
if (result == 0):
c = 1000 - a - b
if (c > b):
print("Found the answer! a is " + str(a) + " b is " + str(b))
print(" c is " + str(c))
pri... |
ddbe68cdb6709fcf448624496e124562d1cf2b11 | maryamatif/Election-analysis | /PyPoll.py | 4,700 | 3.765625 | 4 | # The data we need to retrieve
#1. The total number of votes casted
#2. A complete list of candidates who received votes
#3. The % of voest each candidate won
#4. The total number of votes each candidate won
#5. The winner of the election based on popular vote.
# Import the datetime class from the datetime module.
# im... |
4b640a1e8149d8eca48bdaf483d68b6e5b742e5c | abeaumont/competitive-programming | /hackerrank/cracking-the-coding-interview/ctci-balanced-brackets.py | 585 | 3.890625 | 4 | #!/usr/bin/env python2
# https://www.hackerrank.com/challenges/ctci-balanced-brackets
def is_matched(expression):
open = []
for c in expression:
try:
index = ['}', ')', ']'].index(c)
if not open or open.pop() != ['{', '(', '['][index]:
return False
except:... |
c95890539e618bff543209392f01433502e4f0d3 | sainihimanshu1999/Arrays-LeetCode | /BuySellStock.py | 344 | 3.625 | 4 | '''
This question is pretty easy, in this we create two variable and count min price and max profit
'''
def buyandsell(self,prices):
max_profit,min_price = 0, float('inf')
for price in prices:
min_price = min(min_price,price)
profit = price - min_price
max_profit = max(max_profit,profi... |
e4af51237b78376ad82b3ccc2572d765dfbf32b5 | jpages/twopy | /benchmarks/for_loops.py | 326 | 3.6875 | 4 | def fact(n):
if n<2:
return 1
else:
return n*fact(n-1)
def foo(n):
res = 0
for i in range(n):
res = 4 + 5
fact(10)
res = 5 + 8
fact(10)
res = 7 + 9
fact(10)
res = 3 + 3
fact(10)
res = 6 + 2
foo(10000000)
foo(1000... |
7590151a2866dcbaf472640f93f318c355705c8d | kzh980999074/my_leetcode | /src/dynamicP/312. Burst Balloons.py | 1,383 | 3.703125 | 4 | '''
Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums.
You are asked to burst all the balloons.
If the you burst balloon i you will get nums[left] * nums[i] * nums[right] coins. Here left and right are adjacent indices of i.
After the burst, the left and... |
a12b722090a61081c9181bfe4eb8308d4331028b | mogubess/python_test | /nyumon/4chapter/01python.py | 223 | 3.953125 | 4 | '''
Python入門 ジェネレータ
'''
def myrange(first=0, last=10, step=2):
number = first
while number < last:
yield number
number += step
range = myrange(1,10)
for x in range:
print(x)
|
71268ad9bf2997af877231ab987b769805e0353a | Marco1704/mundo-python | /Mundo_1/ex017.py | 364 | 4.0625 | 4 | #'''a = float(input('Enter the lenth of side A: '))
#b = float(input('Enter the lenth of side B: '))
#c = math.sqrt(a**2 + b**2)
#print(f'The triangle hypotenuse lenth is {c:.2f}')'''
import math
a = float(input('Enter the lenth of side A: '))
b = float(input('Enter the lenth of side B: '))
c = math.hypot(a,b)
print(... |
17e01a0678c9b03924a381fb889099ff9de36e10 | erdogancelik/eniyiben | /Class_Coding/plate.py | 846 | 3.890625 | 4 | user_plate = str(input('Please enter your plate'))
our_plate = 'AAA-111'
if '-' in user_plate:
total_accurate_char = 0
for i in user_plate:
if i in our_plate:
total_accurate_char += 1
if total_accurate_char == 7:
print('This is the correct plate number')
elif total_accurate... |
6bc7b9448690c0cea7ad959aacecbaba2b4a3230 | ashish-c-naik/leetcode_submission | /110. Balanced Binary Tree.py | 679 | 3.796875 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def isBalanced(self, root):
"""
:type root: TreeNode
:rtype: bool
"""
def r(root,... |
eda6ec455970701c6165b9d56e169d763de9ab69 | therogerwang/COMP576-Intro-to-Deep-Learning | /HW01/n_layer_neural_network.py | 6,684 | 3.875 | 4 | import numpy as np
from sklearn import datasets, linear_model
import matplotlib.pyplot as plt
from HW01 import three_layer_neural_network
def generate_data():
'''
generate data
:return: X: input data, y: given labels
'''
np.random.seed(0)
X, y = datasets.make_gaussian_quantiles(n_features=2, n_... |
6bdf1f6bec5aace5c0ba524cb5fce613f93cd255 | limkeunhyeok/daily-coding | /programmers/Level_2/N개의 최소공배수/solution.py | 267 | 3.671875 | 4 | def solution(arr):
answer = arr[0]
for i in range(len(arr) - 1):
answer = lcm(answer, arr[i + 1])
return answer
def gcd(a, b):
if a == 0:
return b
else:
return gcd(b % a, a)
def lcm(a, b):
return a * b / gcd(a, b) |
640f21bfc461e30d3b1b321b938dab02c14255d1 | garladinne/python_codetantra | /format_for.py | 178 | 3.921875 | 4 | n=int(input("Please enter an integer: "))
print("Decimal \t Binary \t Octal \t Hexadecimal")
b = bin(n)
o=oct(n)
h=hex(n)
print("{0} \t {1} \t {2} \t {3}".format(n,b,o,h))
|
d79c39dca6a76d74b9b7d49e4b1fe94b9ef56c96 | sunshineaqu/python-challenge | /PyBank/main.py | 1,959 | 3.875 | 4 | import os
import csv
#set path for file
csvpath = os.path.join("Resources", "budget_data.csv")
#open the file
with open(csvpath, newline="") as csvfile:
csvreader = csv.reader(csvfile, delimiter=",")
#read the header row first
csv_header = next(csvfile)
monthList = []
profitList = []
prof... |
da773bcbedaad3517933fb0627d6a51ae9a6f2e0 | Exrun94/Delta | /StockCheck.py | 753 | 3.953125 | 4 | #! Python 3
'''
The purpouse of this program is to read from a daily CSV report of avaiable stock
and return randomly selected parts for counting.
'''
# Fieldnames = "[0]Store","[1]Part","[2]Description","[3]Lot Ref","[4]Lot Line","[5]Lot Qty","[6]UOM","[7]Bin Qty","[8]Part Cost"
import csv
import random
impo... |
9c30843cd3c0e9d6fec645fe418ad6f709a35a8f | PoojaHerath/pythonBasics | /ifFunction3.py | 164 | 3.78125 | 4 | num = int(input("Enter Marks: "))
if 100 >= num >= 0:
if num >= 50:
print("PASS!")
else:
print("FAIL!")
else:
print("INVALID MARKS!")
|
9bcecaa20377f71a1bdd0fefdaf377634e2ac7aa | yuvraj77/Python-assignment-resubmission | /list_element.py | 163 | 4.0625 | 4 | list=['i','am','yuvaraj','from','sois']
a=input("enter the element to search in list\n")
if a in list:
print("sois is present")
else:
print("element not found") |
18f54046af1d28aa9de12a1eba6b0ac319d36066 | Harshitsavager1/assignment | /alpha version.py | 90 | 3.71875 | 4 | x=str(input("enter a string"))
print("here we go for slicing of your string",x[-1:0:-2])
|
1d12d8472b1a5b9f4d8369c5ec321f1c7a4ca3da | jideabdqudus/python101 | /Class_Inheritance.py | 608 | 3.6875 | 4 | class Animal:
def __init__(self):
self.eyes = 2
def breathe(self):
print("Inhale, Exhale.")
class Hustle:
def __init__(self):
pass
@staticmethod
def hunger():
print('Always hungry')
class Fish(Animal, Hustle):
def __init__(self):
super().__init__()
... |
4df2b04c1304e9e5fc40487602247a3dec6f400f | arsamigullin/problem_solving_python | /leet/facebook/strings_arrays/letter_case_permutation.py | 1,282 | 3.59375 | 4 | # Algo
# if char is numeric
# just got to the next char
# otherwise we want to transform
class Solution:
def letterCasePermutation(self, S: str) -> list:
res = []
arr = list(S)
print(arr)
def permute(i):
if i == len(S):
res.append(''.join(arr))
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.