blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
9a344db804b8959521af0d6d980358775c1db0ce | yuriyshapovalov/Prototypes | /Rosalind/dna.py | 1,138 | 3.734375 | 4 | # Counting DNA Nucleotides
# rosalind.info/problems/dna
import sys
class dna:
def main(self, dna_seq):
if not dna_seq:
raise Exception('ERROR: File is empty.')
nucleotide = {}
for i in dna_seq:
if i in nucleotide:
nucleotide[i] +=... |
bc7c638605938bb34a57cfa35b76f067d0d9e943 | yuriyshapovalov/Prototypes | /ProjectEuler/python/prob27.py | 849 | 3.875 | 4 | # projecteuler.net/problem=27
def main():
answer = QuadraticPrimes()
print("Answer: {}".format(answer))
def QuadraticPrimes():
a, b = 1,1
highest = 1
for i in range(1, 1000):
for j in range(1, 1000):
k = 0
while True:
... |
9a3a4826922606ece42aea5d59a48cc0761cc573 | yuriyshapovalov/Prototypes | /ProjectEuler/python/prob44.py | 532 | 3.5625 | 4 | # projecteuler.net/problem=44
def main():
answer = PentagonNum()
#print("Answer: {}".format(answer))
def PentagonNum():
pennum = []
for i in range(1, 10000):
n = int(((3 * (i * i)) - i) / 2)
pennum.append(n)
for i in pennum:
for j in pennum:
s... |
c801bf4e42882f11ce898d2105a87ec78a281ec5 | yuriyshapovalov/Prototypes | /ProjectEuler/python/prob63.py | 422 | 3.578125 | 4 | # projecteuler.net/problem=63
def main():
answer = PowerfulDigitCounts()
print(answer)
def PowerfulDigitCounts():
count = 0
for i in range(1, 20):
for j in range(1, 30):
res = pow(i, j)
if len(str(res)) == j:
count += 1
pri... |
fbdc5ca8a0df55b7730005cf6c49676bbfe89930 | haffedali/Algorithms | /leaderboard.py | 1,670 | 3.75 | 4 | def sorting(arr,score,low,high):
# partition = (len(arr) - 1) // 2
position = 0
finished = False
partition = ((low - high) // 2) + high
poormanslen = low - high
if poormanslen == 1:
if score > arr[high]:
finished = True
position = high - 1
# high = 0
... |
9384446e890bf53f023bf81ba13871f04e834d9d | haffedali/Algorithms | /jumpingOnClouds.py | 350 | 3.515625 | 4 | def jumpingOnClouds(c, k):
e = 100
n = len(c)
pos = 0
last = 0
flag = False
while flag == False:
last = pos
pos = (last + k) % n
if c[pos] == 0:
e -= 1
else:
e -= 3
if last >= pos:
flag = True
print(e)
jumpingOnCl... |
4314d602519186a70df9a738a129a9f46264f38f | tishacodes/Algorithms | /stock_prices/stock_prices.py | 1,624 | 4.3125 | 4 | import argparse
def find_max_profit(prices):
max_profit_so_far = 0
max_profit = -9999999
smallest_value_so_far = prices[0]
smallest_value = prices[0]
smallest_index = 0
#using python's built in function to find the minum number in the list and it's index
"""smallest_value = min(prices)
smallest_... |
f6e69ebd17ee8684810f856caa58a14b92c3b0aa | vinilinux/python-mundo01 | /execicios/desafio034.py | 251 | 3.75 | 4 | salario = float(input('Informe o salário: '))
if salario > 1250:
aumento = (salario * 10)/100
else:
aumento = (salario * 15)/100
print(f'O seu salário é R${salario} então teve um aumento de R${aumento} \nValor final R${salario + aumento}') |
d09d434f5e366b9716e964504e1353ecb9f7bc7b | vinilinux/python-mundo01 | /execicios/desafio020.py | 286 | 3.578125 | 4 | from random import shuffle
aluno1 = str(input('Primeiro aluno: '))
aluno2 = str(input('Segundo aluno: '))
aluno3 = str(input('Terceiro aluno: '))
aluno4 = str(input('Quarto aluno: '))
ordem = [aluno1, aluno2, aluno3, aluno4]
shuffle(ordem)
print(f'A ordem de apresentação é {ordem}') |
fbd727544e30b1e2c309aea5d2e37291c6602bec | preethi101/Python-Programming-Tasks | /MyCaptain Task 8.py | 453 | 4.3125 | 4 | #Task 8: Write a python function to multiply all the numbers in a list
def multiplyFun(intarray,n):
multiply=1
for i in range(n):
multiply=multiply*intarray[i]
print('When you multiply all the elements you get ',multiply)
n=int(input('Enter the number of elements in your list'))
mylist=[0... |
13ced66dcc274202d33eb1907d8b83142cdff500 | preethi101/Python-Programming-Tasks | /MyCaptain Task 9.py | 515 | 4.1875 | 4 | #Task 9 Write a python program to count the number of odd and even numbers in a list
n=int(input('Enter the number of elements in your list'))
mylist=[0 for i in range(n)]
print('Enter the numbers in your list')
odd_count=0
even_count=0
for i in range(n):
mylist[i]=int(input())
if(mylist[i]%2!=0):
... |
f7a2e614478656f3f6eb0283200586cae87c59a4 | flymperopoulos/SoftwareDesign | /HW2/grid.py | 715 | 4 | 4 | # Exercise 3.5: Drawing of grid with three rows and three columns.
def row():
return "+ - - - - + - - - - +"
def column():
return "| | |"
print row()
for i in range(1,4):
print column()
print row()
for i in range(1,4):
print column()
print row()
# Exercise 3.5: Drawing of grid with f... |
81e5a29ddd08904c9ebaf087e0381d7f01dac893 | YiFeiZhang2/HackerRank | /Algorithms/Implementation/Modified_Kaprekar_Numbers.py | 728 | 3.765625 | 4 | #print number on a line, seperated by space if it is between
#a given upper and lower bound (inclusive)
#and if the left half + right half of the number squared is equal to the number
#if the right piece has d digits, left piece must have d or d-1 digits
lower = input()
upper = input()
counter = 0
for i in range(int(l... |
79a5ec109680e1beca1fb3ed5629594451bee34c | YiFeiZhang2/HackerRank | /python/data_and_time/Python_Time_Delta.py | 302 | 3.796875 | 4 | #!/usr/bin/local/python3
from datetime import datetime
numCase = int(input())
time_format = "%a %d %b %Y %H:%M:%S %z"
for i in range(numCase):
time1 = datetime.strptime(input(), time_format)
time2 = datetime.strptime(input(), time_format)
print(abs(int((time1-time2).total_seconds())))
|
5faa8305541303fc46ef630eb06afed6d859624b | YiFeiZhang2/HackerRank | /tutorial/30_days_of_code/day_20/day_20.py | 511 | 3.546875 | 4 | #!/usr/local/bin/python3
import sys
length = int(input().strip())
a = [int(a_temp) for a_temp in input().strip().split(' ')]
counter = 0
for _ in range(length):
for i in range(length-1):
if a[i] > a[i+1]:
first = int(a[i+1])
second = int(a[i])
a[i+1] = second
... |
e98e320c829439ff75989f616ea8ac499bf015a4 | YiFeiZhang2/HackerRank | /Algorithms/Search/Connected_Cell_in_a_Grid.py | 1,671 | 3.71875 | 4 | #!/usr/local/bin/python3
def findNumCells (cells, row_ind, col_ind, rowlen, collen):
if row_ind < rowlen and col_ind < collen and row_ind >=0 and col_ind >= 0:
#print(row_ind)
#print(col_ind)
if cells[row_ind][col_ind] == 0 or cells[row_ind][col_ind] == 2:
return 0
else:
... |
5ef5369a1c272d500eb9de12a4f2d26585867a72 | YiFeiZhang2/HackerRank | /Algorithms/Strings/two_strings.py | 303 | 3.953125 | 4 | #find if there is a common substring between two strings
#used sets, as any common substring will have at least one common letter
for _ in range(int(input())):
A = set([x for x in input()])
B = set([x for x in input()])
if len(A & B) > 0:
print("YES")
else:
print("NO")
|
3913dfaccd9331cb215ca196e53d64c61e4b8a15 | YiFeiZhang2/HackerRank | /python/collections/deque.py | 386 | 3.5625 | 4 | #!/usr/local/bin/python3
from collections import deque
d = deque()
for _ in range(int(input())):
line = input().strip().split(" ")
if line[0] == "append":
d.append(line[1])
elif line[0] == "appendleft":
d.appendleft(line[1])
elif line[0] == "pop":
d.pop()
elif line[0] == "pop... |
550f154c0a8987186664f1d35d0b21fef4399142 | YiFeiZhang2/HackerRank | /python/regex_and_parsing/findall.py | 149 | 3.71875 | 4 | import re
vowels = re.findall(r"(?<=[^AEIOUaeiou])([AEIOUaeiou]{2,})(?=[^AEIOUaeiou])", input().strip())
print('\n'.join(vowels) if vowels else -1)
|
7cf718af839a3df2d559e0960f982681ceea735a | BoksicIva/OOUP | /labos_02/task3/task3.py | 1,231 | 3.625 | 4 |
def mymax(iterable, key=lambda x :x):
# incijaliziraj maksimalni element i maksimalni ključ
max_x =max_key =None
# obiđi sve elemente
for x in iterable:
# ako je key(x) najveći -> ažuriraj max_x i max_key
if max_x is None or key(x) > max_key:
max_x = x
max_key =... |
70b9d7eac98a95970ac2c15973a08c5b6f3f2642 | mattshardman/Algorithms | /stock_prices/stock_prices.py | 753 | 3.9375 | 4 | #!/usr/bin/python
import argparse
def find_max_profit(prices):
diff = prices[1] - prices[0]
# compare each number to all previous numbers and calc difference
for i in range(len(prices) - 1):
for j in range(i + 1):
x = prices[i + 1] - prices[j]
if x > diff:
diff = x
return diff
if __n... |
013a2d7cbdf6453e387441d21121241009c1aa43 | aaron-j-d/CarltonLab_AaronD | /AAPos_updatedw:freq.py | 18,298 | 3.53125 | 4 | import os
import Bio.Seq
import collections
from optparse import OptionParser
"""
enterGFFFile
inputs: the gffFilePath and the geneID
purpose: the purpose of the function is to enter the gffFile and find the exon coordinates and strand direction for the specific geneID
output: the returnlist output is a list th... |
9d892cd6f454199a177fabbd71def4d6742300ad | carlosjimz87/PyClean | /CustomSort.py | 586 | 3.65625 | 4 | from functools import cmp_to_key
# nums = [4, 3, 2, 1]
# sorted(nums, key=cmp_to_key(lambda a, b: a - b))
nums = [6, 4, 8, 2, 6, 9, 5, 7]
colors = ["red", "blue", "green", "violeta", "yellow", "cyan", "brown"]
def compare(c1, c2):
return 1 if (c1) > (c2) else -1
if __name__ == '__main__':
snums = sorted(nu... |
c531d712a36ae5814b5d5208b6abc34674366b32 | lucaschf/python_exercises | /exercise_4.py | 1,181 | 3.890625 | 4 | # Crie uma função que recebe uma lista de strings e
# a. retorne o elemento com mais caracteres
# b. retorne a média de vogais nos elementos (nº de vogais de cada elemento/nº de
# elementos)
# c. retorne o número de ocorrências do primeiro elemento da lista
# d. retorne a palavra lexicograficamente maior
# e. conte o ... |
03041511c2b49bbf6b17e2b325cc38ab9b7b0d23 | bseverino/Intro-Python-I | /src/16_prime.py | 187 | 3.75 | 4 | def prime(num):
if (num <= 1):
return False
for i in range(2, num):
if (num % i == 0):
return False
return True
print(prime(11))
print(prime(8))
|
c6212002f2afa5a1467fb3cffb35cf27694e8c87 | dzzgnr/lab10 | /1.3.1_1.py | 916 | 3.90625 | 4 | #Вычисление факториала итерационным методом
#Бондаренко Даниил 122В
#функция для вычисления факториала
def factorial(n):
#еслит n = 0
if n == 0:
return 1 #функция возвращает 1
result = 1 #переменная для записи результата
for i in range(2, n + 1): #i от 2 до n
result *= i #домножаем те... |
3a512475b70936d8136149213d3250cd8e11b520 | yasnakateb/MIPSProcessor | /MipsAssembler/mipsdecoder.py | 2,088 | 3.5625 | 4 | # Converts MIPS instructions into binary and hex
from instructiondecode import instr_decode # converts the instruction part of a line of MIPS code
from registerdecode import reg_decode # converts the register and immediate parts of the MIPS code
# the main conversion function
def convert(code):
code = code.repla... |
3e924b772a9b0a2c6b387822aba43778f97d7a34 | WesPereira/EP2-MAP3122 | /tentandoep2.py | 7,309 | 3.5625 | 4 | ################################################################################
## Métodos Numéricos e Aplicações ##
## Exercício Computacional ##
## ... |
585d3b707fe0affa18efa00ff52d20b30b28baf1 | Nassim-L/Hangman | /hangman_main.py | 815 | 3.75 | 4 | import random
import hangman_fonction as test
import hangman_wordlist as list
import pyfiglet
ascii_banner = pyfiglet.figlet_format("HANGMAN")
print(ascii_banner)
print('''
version : 0.0.1
Developed by Nassim.L
github : https://github.com/Nassim-L
''')
lives = 7
a = list.word_list
b = random.choice(a)
k = ... |
7e80673164bbe89b4ebff607000633407cfe4ac5 | JLionPerez/cs325 | /week6/bfs_vs_hs.py | 3,304 | 3.640625 | 4 | # Title: HW 5 - Babyfaces vs. Heels
# Description: Determines whether it is possible or impossible to designate each wrestlers with rivals.
# Author: Joelle Perez
# Date: 16 February 2020
import sys
# Function name: No def functions, one driver.
# Purpose: To go through each line of a file to gather wrestlers and as... |
c6fbf930550e1b5e26f704f6ab7eab4e44200376 | JLionPerez/cs325 | /week1/mergesort.py | 2,529 | 4.3125 | 4 | # Title: HW 1 - Merge Sort
# Description: Sorts through arrays in a file and output results into a new file.
# Author: Joelle Perez
# Date: 15 January 2020
# Function name: mergSort()
# Purpose: Sort a passed array using an merge sort.
# Arguments: integer array
# Returns: none
# Citation: https://runestone.academy/ru... |
dd8def9031075aabbfa07009d51036cf026eb606 | wpersmile/leetcode | /my_code/day14.py | 1,902 | 3.671875 | 4 | # -*- encoding: utf-8 -*-
"""
@File : day14.py
@Time : 2021/5/5 17:02
@Author : WPER_SMILE
@Info : count_prime
"""
import time
def count_prime_num(num):
count = 0
for i in range(2, num + 1):
flag = False
for j in range(2, i):
if i % j == 0:
flag = True
... |
c00c0d5720a5128f22b6dcc30ed8cdd0e5f8c175 | wpersmile/leetcode | /my_code/day2.py | 586 | 3.796875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time : 2020/7/8 22:49
# @Author : wperSmile
# @Subject : https://leetcode-cn.com/problems/reverse-integer/
def reverse(x):
max_num = 2 ** 31 - 1
min_num = -2 ** 31
flag = 1
rs = 0
if x < 0:
flag = -1
x = -x
while x != 0:
... |
02ca5e25e43b65a2bc387d9c4a44b7ff6fce3267 | RayElg/HackInstead2020 | /main.py | 9,078 | 3.640625 | 4 | #Brython things...
from browser import document
from browser.html import P, STRONG, A
import re
#The dictionaries
averages = {}
facts = {}
#METHODS USED FOR NUMERICAL FUNCTIONS
def parseAvgs(): #Populates averages dictionary from avgs.txt
with open('avgs.txt','r') as f:
for line in f:
lst = ... |
98a0a6fcca9f9619efd123c8edf82295769fb6c2 | rthway/Manage-file-and-Folder-Python3 | /main.py | 1,471 | 3.546875 | 4 | '''
Project : Manage files in Folder
by : Roshan Kumar Thapa
Date : 29/05/2020
This program create under my training peroid for practical projects
'''
import os #import os module in python
def createIfNotExit(folder): # create createIfNotExit function for create folders under do not repeat principal
if not os.p... |
8ec0253d5145b617cc0371b290787a457132acb4 | chandanbrahma/Multilinear-regression | /Computer_Data.py | 1,472 | 3.78125 | 4 | ## importing the data
import pandas as pd
data= pd.read_csv('E:\\assignment\\multilinear regression\\Computer_Data.csv')
data.info()
data.head()
##we have 3 columns which needs to be converted into integer
data['cd'],_=pd.factorize(data['cd'])
data['multi'],_ = pd.factorize(data['multi'])
data['premium'],_ = ... |
819a08e1d130efd65c9d468b1d21955ed1b474e3 | Algumi/Tic-tac-toe | /tic-tac-toe.py | 22,998 | 4.1875 | 4 | from random import randint
class Game(object):
def __init__(self, game_mod, board_size, complexity):
self.game_mod = game_mod
self.board_size = board_size
self.complexity = complexity
board = []
turn = 0 # the current turn of the game
bot_turn = "O"
player_turn = "X"
... |
128b2aab748911af21fbe2a8da3025bbf9779786 | hatmahat/probability_and_statistics | /random-2-dice.py | 342 | 3.546875 | 4 | import numpy as np
die, probabilities, num_dice = [1, 2, 3, 4, 5, 6], [1/6, 1/6, 1/6, 1/6, 1/6, 1/6], 2
outcomes = np.random.choice(die, size=num_dice, p=probabilities)
if outcomes[0] == outcomes[1]:
answer = 'win'
else:
answer = 'lose'
print('The dice show {} and {}. You {}!'.format(outcomes[0], o... |
1ecbcedb78435002eb5163af69535b15dba6ca8c | wangkunhao/ichw | /plants.py | 1,351 | 3.671875 | 4 | #!/usr/bin/env python3
"""planets.py: Description of the moving plants around the sun.
__author__ = "WangKunhao"
__pkuid__ = "1800011715"
__email__ = "1800011715@pku.edu.cn"
"""
import math
import turtle
Mercury=turtle.Turtle()
Venus=turtle.Turtle()
Earth=turtle.Turtle()
Mars=turtle.Turtle()
Jupite... |
ba286984a6a1c65d020a53f0b9adee444eeefe9e | armalux/astra | /astra/framework/proc.py | 5,924 | 3.640625 | 4 | """
This file contains classes to handle threading, callbacks, and forking.
"""
import os
import threading
class Threader(threading.Thread):
"""
If the first argument of target is 'threader', will pass a copy of the threader object to the target.
Will also call self.stop_callback before joining the thread... |
e9d3a61847a8a2ede855910d373d20e0134aad12 | renta0903/hungman | /hangman.py | 2,260 | 3.78125 | 4 | import random
def hangman(word):
wrong = 0
stages = ["",
"______ ",
"| ",
"| | ",
"| O ",
"| /|~ ",
"| / ~ ",
"| ",
]
re... |
2565f3bee3e699944a8b10cd7fc11f3c55f75f23 | ImOnALampshade/py-async-await-actions | /code/set_action.py | 1,649 | 4.09375 | 4 | from action import action
def check_continue_and_end(action):
"""
Checks if an action should continue, and if it should not, ends the action
action:
The action to check
return:
False when the action is over
True when the action should continue
"""
if action.is_over():
action.e... |
593a8bb7504966c581fd5f3542e8862040ab75d8 | EddBonilla18/Practica_2 | /Tarea_1_2.py | 1,416 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Feb 6 00:08:02 2020
@author: booed_000
"""
print('Tarea 2, Practica_02')
class Restaurant():
def __init__(self, nombre, tipo_Restaurante):
self.nombre = nombre.title()
self.tipo_Restaurante = tipo_Restaurante
def describe_restaurant(s... |
cc01085631e361e7e517587f9e3dba87f8d26453 | trivedi/notes | /n | 3,041 | 3.546875 | 4 | #!/usr/bin/env python
# Author: Nishad Trivedi
# TODO
# Use file w/out python in front [x]
# Create/write custom file [x]
# Read custom file [x]
# Delete custom file []
# Delete file [x]
# implement colors?? []
# NOTES: http://stackoverflow.com/questions/1466000/python-open-built-in-function-di... |
fec53abbbd18231ec8275446cfa8450bb26bf73a | billyateallcookies/python | /Heapsort/heapsort.py | 927 | 3.921875 | 4 | """
Basic Heapsort program.
"""
def heapify(arr, n, i):
"""
Heapifies subtree rooted at index i
n - size of the heap
"""
largest = i
l = 2 * i + 1
r = 2 * i + 2
# see if left child of root exists and is
# greater than root
if l < n and arr[largest] < arr[l]:
largest =... |
c9a3acafac5809710dc661dcbc3b46bdb591b4ea | ChenAvra/Machine-learning | /preProcessing.py | 1,282 | 3.8125 | 4 | from tkinter import messagebox
import pandas as pd
import numpy as np
#read the file with the data
def readData(path):
try:
df = pd.read_excel(path)
return df
except:
messagebox.showinfo("error","Invalid path, pleae enter a new path")
# df = df.to_csv("C:\\Users\\Chen\\Desktop\\Datase... |
a0ab10f227314313909e589d460c8d22100635cc | alexdrane/3D-engine | /trig.py | 768 | 3.5625 | 4 | import math
def fsin(x):
if x == 180 or x == 360:
return(0.0)
else:
return(math.sin(x*(math.pi/180)))
def fcos(x):
if x == 90 or x == 270:
return(0.0)
else:
return(math.cos(x*(math.pi/180)))
def f_sin(x):
return(math.asin(x)/(math.pi/180))
def f_cos(x):
return(math.acos(x)/(math.pi/180))... |
ba55a301391a2052b5c2d736dcd8200f3dae0605 | LampshadeSoftware/Planit | /API/Schedule.py | 4,428 | 3.59375 | 4 | from API.Time_Block import *
class API_Schedule:
"""
Represents a specific potential schedule, with a set of class sections that
do not conflict with each other.
"""
def __init__(self):
self._sections = set()
self._num_credits = 0
def add_section(self, new_section):
"""
Attempt to add a new section to ... |
d2684c7fd9693d5feef059cce22e9b8ab5a90dad | SaiCharanB/Algorithms-Semester4 | /Ex10 - Floyd Warshall/Reachability.py | 409 | 3.734375 | 4 | import numpy as np
v = int(input())
e = int(input())
adjacency = np.array([[False for j in range(v)] for i in range(v)])
for edge in range(e):
ip = tuple(map(int,input().split(' ')))
adjacency[ip[0] - 1][ip[1] - 1] = True
for k in range(v):
for i in range(v):
for j in range(v):
adjac... |
ec6d032823d9b6c7e84c3c83d12ed124f6a008eb | SaiCharanB/Algorithms-Semester4 | /Ex3 - Out Of Order Pairs/OutOfOrderBoth.py | 1,954 | 3.859375 | 4 | import random
def out_of_order(arr):
#Algo works only on arrays tuples
assert (type(arr) == list or type(arr) == tuple)
count = 0
for i in range(len(arr)):
for j in range(i+1,len(arr)):
if arr[j] < arr[i]:
count += 1
return count
def out_of_order_imp(... |
513aa7b13383ee5e4d16b0a4d8b9969c6435b55d | borgr/intro2cs | /ex03/ex3.py | 9,714 | 4.5625 | 5 | #############################################################
# FILE : ex3.py
# WRITER : Leshem Choshen + borgr + 305385338
# EXERCISE : intro2cs ex3 200132014
# DESCRIPTION: A pack of functions to help with pensions'
# calculations.
#
#############################################################
def constan... |
9e46bb76327c237fa6f39f99a54a6f7f8826b9cc | Pierre-siddall/Codewars | /create_phone_number.py | 170 | 3.5625 | 4 | def create_phone_number(n):
for count in range(len(n)):
n[count]=str(n[count])
return "("+n[0]+n[1]+n[2]+")"+" "+n[3]+n[4]+n[5]+"-"+n[6]+n[7]+n[8]+n[9] |
c86efd1504271494d471d05f6c919ce8a50f967b | raheemtaha11/python | /Chapter_2/ComputeLoan.py | 673 | 4.25 | 4 | # Enter annual interest rate as a percetage, e.g., 7.25
annualInterestRate = (input("Enter annual interest rate, e.g., 7.25:"))
monthlyInterestRate= annualInterestRate/1200
# Enter number of years
numberOfYears=(input("Enter number of years as an integer,e.g.,5:"))
# Enter loan amount
loanAmount = (input(... |
4003b3c6efa4e10c88c7d37ca039dca0d184ef3d | raheemtaha11/python | /Chapter_2/21.py | 162 | 3.75 | 4 | Celsius=eval(raw_input("Enter a degree in Celsius:"))
fahrenheit= (9.0/5.0)* Celsius + 32
print(Celsius,"degrees Celsius is",fahrenheit,"degrees Fahrenheit")
|
7e6afa30733165bbf14c19f4f1eb7691bc81cbd8 | raheemtaha11/python | /Chapter_2/23.py | 95 | 3.8125 | 4 | feet=input("Enter a value for feet:")
meters=feet*0.305
print(feet,"feet is",meters,"meters") |
17841aef67f78660d82646de53e3eafa9369c160 | raheemtaha11/python | /Chapter_5/414.py | 193 | 3.90625 | 4 | import random
random.randint(0,1)
guess= input("Choose,heads or tails(0 or 1)?")
both =random.randint(0,1)
if guess == both:
print("you are correct !")
else:
print("wrong")
|
1f5ffcd3d6ca60d0d791b5308d317e0185a98552 | raheemtaha11/python | /Chapter_5/536.py | 1,896 | 4.0625 | 4 | import random
rock = 2
paper = 3
scissors = 1
you = input("rock, paper, scissors:")
bro = random.randint(1,3)
x = 0
y = 0
z = 0
if you == bro:
print("Draw")
z += 1
if (you == rock) and (bro == paper):
print("You are rock, the Computer is paper.")
print("You lose")
y += 1
if (you... |
78a4c4b539d2067af169acdc07ddcee3306d17a5 | raheemtaha11/python | /Chapter_5/5.5.py | 194 | 4.3125 | 4 | number = input("Enter an integer:")
max = number
while number != 0:
number = input("Enter an integer:")
if number > max:
max = number
print ("max is",max)
print("number",number) |
5002cb48735977c7ac93ed0bb89adde41004d26d | raheemtaha11/python | /Chapter_5/414 (3).py | 228 | 3.5 | 4 | import random
random.randint(0,1)
both =random.randint(0,1)
heads = 0
tails = 0
for x in range(1,1000000):
x += 1
heads += 1
tails += 1
if x == 1000000:
break
print("heads -",heads,\
"tails -", tails)
|
4561a2c4ff253bb7be703a0a2c83e03ea412093d | raheemtaha11/python | /Chapter_3/ComputeDistanceGraphics.py | 599 | 4.34375 | 4 | import turtle
# Prompt the user for inputting two points
x1, y1 = (input("Enter x1 and y1 for point 1 :"))
x2, y2 = (input("Enter x2 and y2 for point 2 : "))
# Compute the distance
distance= ((x1 - x2)**2 + (y1 - y2)**2)** 0.5
# Display two points and the connecting line
turtle.penup()
turtle.goto(x1,... |
7aa5094000ac268371b8a93de5bc6b9ac77b0c2c | guohaoyuan/leetcode | /py/10.py | 1,178 | 3.640625 | 4 | # 1. 不考虑正则符号情况下如果是普通字符串进行比较,利用递归思想进行,只编写第一个字母是否匹配的程序,然后进行递归
class Solution(object):
def isMatch(self, s, p):
"""
:type s: str
:type p: str
:rtype: bool
"""
if p is empty:
return s is empty
first_match = (s not empty) and p[0] == s[0]
retur... |
d63a74e49be01f372ba8e8a536646c554b6f4dbc | RohithPrasanna/Machine-Learning | /kyphosis_predictor.py | 1,360 | 3.5 | 4 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import classification_report
#Reading the Data
df = ... |
37ccfca0762123a3c460a49917abdb693e6df353 | ig2gi/philo_graph | /attic/Untitled.py | 200 | 3.59375 | 4 | class Point:
def __init__(self, x, y):
"""docstring for __init__"""
self.x = x
self.y = y
l = [Point(34,4),Point(34,2),Point(3,50),Point(6,78),Point(3,40)]
print min(p.x for p in l) |
4766fc2ab88b8a050fe479ce53af4d6347a6a2c8 | abhilashKotagiri/python | /logical_operators.py | 264 | 4.125 | 4 | # logical operators and or not;
age = eval(input("enter your age: "))
if age < 5:
print("Too young!!!")
elif age == 5:
print("Go to Kindergarten")
elif (age >= 6) and (age <= 17):
print("Go to grade {}".format(age - 5))
else:
print("Go to College") |
e3f186d511fcf3cd8bbf1c0052152a7b36b81272 | abhilashKotagiri/python | /PineTree.py | 320 | 3.78125 | 4 | n = input("How tall the tree has to be ? ")
n = int(n)
i = 1
h = 1
s = n-i
stump_space = s
while n != 0 :
for i in range(s):
print(" ", end="");
for i in range(h):
print("#", end="");
print()
s -= 1
h += 2
n -= 1
for i in range(stump_space):
print(" ", end="")
print("#"); |
41f06fdf013f365209d15b98bbd2c90c2b59cc5a | TimeSeriesProject/tensorflow2x-learn | /apps/0-base_kw/02-预备知识/02-np.random.py | 413 | 3.53125 | 4 |
import numpy as np
# ************* np.random.RandomState.rand() ***********
# 返回一个[0, 1]之间的随机数
# np.random.RandomState.rand(维度) # 维度为空, 返回标量
# 设置随机种子,可以保证每次运行的结果一直
rdm = np.random.RandomState(seed=1)
a = rdm.rand() # 返回一个随机标量
print(a)
b = rdm.rand(2, 3) # 返回一个维度为2行3列的随机矩阵
print(b)
|
329defff03bb26389116bb58548f50b7498dbf42 | jontreynes/python_second_minmax | /second_minmax.py | 1,083 | 4 | 4 | # the commented prints were helpful for me to ensure the logic was stepping
# in the right conditional
if __name__ == "__main__":
array = [80, 60, 70, 2, 3, 3, 20, 50]
first_largest = 0
second_largest = 0
first_smallest = array[0] # b/c largest will be checked on first
second_smallest = array[... |
e8f78af7f1a9a92ac6eb7660177f6990a0cba5ca | kennyjeong/line | /day_18/day_18.py | 589 | 3.8125 | 4 | #!/usr/bin/python3
#Day 18 Problem solving, coming from https://www.hackerrank.com/challenges/30-nested-logic/problem
day={}
month={}
year={}
line=input().split()
day[0]=int(line[0])
month[0]=int(line[1])
year[0]=int(line[2])
line=input().split()
day[1]=int(line[0])
month[1]=int(line[1])
year[1]=int(line[2])
#Select M... |
5df46a44451d26e9ba63e9806b7e036dea106fc6 | kennyjeong/line | /day_12/day_12.py | 501 | 3.71875 | 4 | #!/usr/bin/python3
# Day 12 problem solving, coming from https://www.hackerrank.com/challenges/30-sorting
import sys
n = int(input().strip())
a = list(map(int, input().strip().split(' ')))
# Write Your Code Here
swap_count = 0
for i in range (n-1):
for j in range (i,n):
if a[i] > a[j]:
temp = ... |
0ba7fc3b4e44ef9d52cd8b124ba83da54b5ad26d | littletreeeeeee/PythonCourse37 | /demo25_list_operation.py | 398 | 3.796875 | 4 | dayOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
lengthArray = []
for day in dayOfWeek:
lengthArray.append(len(day))
print (lengthArray)
print ([len(day) for day in dayOfWeek])
print ([day for day in dayOfWeek if len(day) > 6])
print ([len(day) for day in dayOfWeek if len(... |
90f95fd8263751aeb5e6315b506ef842fcf359b8 | mla96/Computer-Vision-Algorithms | /greyscale_to_BW_thresholds.py | 3,973 | 3.765625 | 4 | # Thresholding greyscale images to BW
from PIL import Image, ImageFilter
import matplotlib.pyplot as plt
import numpy as np
# Transform greyscale image to BW using threshold between 0 and 255
def binary_image_threshold(my_image, threshold): # Threshold should be integer from 0 to 255
if threshold < 0 or thres... |
89bf12047985c3da763fe3c2470ae92c53063fdf | hejk2008/Homework-of-python-course | /assign3-1/assign3-1/narcissus.py | 648 | 3.640625 | 4 | #! /usr/bin/env python3
# coding:utf-8
#水仙花数是一个n(n大于等于3)位数字的数,它等于每个数字的n次幂之和。
#例如,153是一个水仙花数,因为153=1**3+5**3+3**3。
#求所有3位数中的水仙花数。
#方法1:用列表推导式,将下一行补充完整。
narcissus_list = [n for n in range(100,1000) if n == (n//100)**3 + (n//10%10)**3 + (n%10)**3]
print(narcissus_list)
#方法2:用生成器推导式,将下一行补充完整。
narcissus_gen = (n for n in... |
8b81eccf7a08dba785d613f61cbf312f7ed1c282 | hejk2008/Homework-of-python-course | /assign6-2/assign6-2/assign6_2.py | 403 | 3.609375 | 4 | #! /usr/bin/env python3
# coding:utf-8
def main():
#answer = [(a, b, c) for a in range(21) for b in range(34) for c in range(101-a-b)
# if a*5 + b*3 +c/3 == 100 and a+b+c == 100]
#print(answer)
for a in range(21):
for b in range(34):
c = 100-a-b
if a*5 + b*3 +c... |
cc53123dba5bcdacd038b5694ddc04ce198e4709 | serinamarie/CS-Algorithms | /sliding_window_max/sliding_window_max.py | 2,897 | 3.984375 | 4 | '''
Input: a List of integers as well as an integer `k` representing the size of the sliding window
Returns: a List of integers
'''
# def sliding_window_max(nums, k):
# max_list = []
# for i in range(len(nums) - (k-1)):
# max_list.append(max(nums[i:i+k]))
# return max_list
# time: 19 seconds
# de... |
4383f30ed75581ef966d9134540cb6a88da1f559 | luid95/Python-Django | /python/functions.py | 625 | 3.84375 | 4 | def my_func(param1="default"):
print("My first python function! {a}".format(a=param1))
def hello():
return "Hello"
def addNum(num1, num2):
return num1+num2
my_func()
my_func("thanks")
r = hello()
print(r)
r2 =addNum(2,3)
print(r2)
print(type(r2))
##################################33
#Lambda Expression
... |
aa593cdb43da874ea059056a3955f94e18062437 | mathunit1/homework | /CS.Homework.5.py | 1,749 | 4.0625 | 4 |
# Operation code to mnemonic dictionary
# You can use this to lookup the machine code
# and translate it to the mnemonic instruction
INS_REF = {
1: "ADD",
2: "SUB",
3: "STA",
5: "LDA",
6: "BRA",
7: "BRZ",
8: "BRP"
}
def disassemble(operation_code):
# this function should take in an int... |
fe65972728e42527cbdeb60adbc11eab0fd52c06 | Jraspy/Project | /Python_code/Homework/lesson1/hm1_6.py | 1,371 | 4.40625 | 4 | # Спортсмен занимается ежедневными пробежками.
# В первый день увеличивал результат на 10% относительно предыдущего.
# Требуется определить номер дня, на который результат спортсмена составит не менее b километров.
# Программа должна принимать значения параметров a и b и выводить одно натуральное число — номер дня.
# ... |
249324109cb67f227d61e3db1b6969d0622d0bea | theKyrgyz/SublimeTextCS550 | /ListProblems/ListProblem2.py | 410 | 3.71875 | 4 | # ListProblem2.py
# Used official Python data structure documentation for this one: https://docs.python.org/3.7/tutorial/datastructures.html
# Prints the numbers one through one hundred, ordered randomly (shuffled)
import random as ra
thatList = [x for x in range(1,101)]
ra.shuffle(thatList)
print(*thatList[:20],"\n"... |
abd30c508fccd262ddc6235bfd0e85e83ef9747e | theKyrgyz/SublimeTextCS550 | /listDemo.py | 470 | 4 | 4 | # listDemo.py
# empty list
a = []
print(a)
a.append(5)
a.append(3)
a.append(8)
a.append(8)
print(a)
# ADDING STUFF MORE EFFICIENTLY
a += [1,2,3,4,5]
# will return [5, 3, 8, 8, 1, 2, 3, 4, 5]
a.insert(0,7)
print(a)
# a way to insert multiple values at the left-most point:
a = [1,2,3,4,5] + a
if a.pop() == 5:
... |
d609064fbdfddff7f323d7f216a2a732bb588685 | theKyrgyz/SublimeTextCS550 | /DollarsToYen.py | 128 | 3.796875 | 4 | # currency.py for class
import sys
# Dollars to Yen
dollars = input("Dollars: ")
yen = dollars * 111.61
print("Yen:" + yen)
|
36cabd854c7c70aabe121ed60fd95636073f9d01 | hoatd/Ds-Algos- | /GeeksforGeeks/Random-problems/run_length_encoding.py | 729 | 3.609375 | 4 |
def run_length_encoding(s):
tmp = ""
cnt = 0
i = 0
p = len(s) - 1
while i < p:
cnt = 0
c = s[i]
if s[i] == s[i+1]:
while (i < p) and (s[i] == s[i+1]):
cnt += 1
i += 1
cnt += 1
i += 1
tmp += c
... |
7eeb3eba0e67dc16cfecc947663d7565850da496 | alexs2307/Python | /9_Conditions and Loops/Calculator.py | 317 | 4.375 | 4 |
num1 = int(input("Enter first number: "))
operator = input("Enter operator (+ , - , * , / ): ")
num2 = int(input("Enter second number!!: "))
if operator == "+":
print(num1 + num2)
if operator == "-":
print(num1 - num2)
if operator == "*":
print(num1 * num2)
if operator == "/":
print(num1 / num2) |
86254a159b437d6cd2a240d511e75140d433fd6e | ankurg0806/Python | /DynamicProgramming/NoOfWaysToArrangeBallsSuchThatNoSameBallsAreAdjacent.py | 1,508 | 3.75 | 4 | # Number of Ways to arrange Balls such that adjacent balls are of different types
# There are ‘p’ balls of type P, ‘q’ balls of type Q and ‘r’ balls of type R and 's' balls of type S. Using the balls we want to create a straight line such that no two balls of same type are adjacent.
def helper(a,b,c,d,last):
mydic... |
f35e48025c021408e07d88e8afe2d99a6228c059 | ankurg0806/Python | /MaxIncreasingSubsequenceSum.py | 1,282 | 4.03125 | 4 | # Max Sum Increasing Subsequence
# Given an non-empty array of integers, write a function that returns an array of length 2. The first element in the output array should be an integer value representing the greatest sum that can be generated from a strictly-increasing subsequence in the array. The second element shoul... |
09fa73456bda896793e0343c13f438118a1224d6 | ankurg0806/Python | /NumberOfDecodingWays.py | 651 | 4 | 4 | # Given the mapping a = 1, b = 2, ... z = 26, and an encoded message, count the number of ways it can be decoded.
# For example, the message '111' would give 3, since it could be decoded as 'aaa', 'ka', and 'ak'.
# You can assume that the messages are decodable. For example, '001' is not allowed.
def helper(myStr, k... |
e0fd55b76a93ea43313a45235bfaec59b1cca05d | ankur8/python | /programs/sortdwords.py | 111 | 3.71875 | 4 | my_str = "Hello this Is an Example With cased letters"
my=my_str.split()
my.sort()
for i in my:
print(i) |
3785f639e6d1f54da71290245f13a1ce5c3c5e3d | JaredJHZ/funcional_programming | /menu_r.py | 204 | 3.9375 | 4 | def fibonacci(size,anterior,actual):
if size == 1:
return anterior
else:
print(anterior)
return fibonacci(size - 1, actual, anterior + actual )
if __name__ == "__main__":
print(fibonacci(5,0,1)) |
f87accd4445dc69e30f805d1cbf6ecd9312bdb73 | JaredJHZ/funcional_programming | /Operaciones/operaciones/operaciones.py | 507 | 3.71875 | 4 | def crear_funcion(operador):
if operador == '+':
def suma(val1,val2):
return val1+val2
return suma
elif operador == '-':
def resta(val1,val2):
return val1-val2
return resta
elif operador == "*":
def multiplicacion(val1,val2):
return val1*val2
return multiplicacion
elif ... |
7159c6e5daaf88b18a663402a3a1ba1810b3f3aa | Jmacklin308/PythonMegaCourse | /Section 5 Functions and Conditionals/tempChecker4000.py | 464 | 4 | 4 | import os
os.system("cls") #clear the screen at start
def tempChecker3000(temp):
if temp > 25:
return "Hot"
elif temp in range(15, 25+1):
return "Warm"
elif temp < 15:
return "Cold"
user_name = str(input("Hello there! What is your first name: \n"))
user_temp = float(input(f"Hel... |
033c3df0e70e876987e22b12d85706d75d00ed10 | faberichfuchs/Mastermind | /controller.py | 3,546 | 3.546875 | 4 | # Import the pygame library and initialise the game engine
import pygame as pg
from mastermind import Mastermind
from view import View
class Controller(object):
def __init__(self):
self.pygame = pg
self.mastermind = None
self.view = None
self.playing = None
self.carryOn = ... |
759130c68a17f4faef68430f2965d0a7ba623995 | simranbarve/Queue | /PriorityQueue.py | 384 | 3.765625 | 4 | class PriorityQueue:
def __init__(self, queue_size = 7):
self.queue_size = queue_size
self.queue = [[None]]* queue_size
self.pointer = -1
def printing(self):
print(self.queue)
return True
def isempty(self):
if self.pointer == -1:
return True
... |
60765315d0e9c3f5e1c61792e448b617960c1886 | CarolineVantiem/CMSC-201-HW | /hw5/hw5_part2.py | 1,484 | 4.40625 | 4 | # File: hw5_part2.py
# Author: Caroline Vantiem
# Date: 10/8/2017
# Section: 3
# E-mail: cvantie1@umbc.edu
# Description: Search for a word in a phrase the user wants to
# find.
############################################################
# inPhrase() Counts the instances of a word in a string #
# Input: aPhra... |
42cd58dbbc49a05d4b96eb06f93641186ea6e6eb | CarolineVantiem/CMSC-201-HW | /hw3/hw3_part2.py | 943 | 4.5625 | 5 | # File: hw3_part2.py
# Author: Caroline Vantiem
# Date: 9/25/2017
# Section: 3
# E-mail: cvantie1@umbc.edu
# Description: Calculate an answer to an exponentiation problem
# without using exponentiation.
def main():
#Ask the user for the input of the first base
numOne = int(input("Please enter ... |
bad3851961aef2f725e91d7f202a691ce106509a | CarolineVantiem/CMSC-201-HW | /hw5/hw5_part1.py | 1,296 | 4.4375 | 4 | # File: hw5_part1.py
# Author: Caroline Vantiem
# Date: 10/8/2017
# Section: 3
# E-mail: cvantie1@umbc.edu
# Description: Asks the user for a string and a letter
# and ouputs how many there are of the specified letter.
############################################################
# numLetter() counts the instances of ... |
c1038001afeb1a42a64bacf8c312cc6dfc802592 | CarolineVantiem/CMSC-201-HW | /hw3/hw3_part3.py | 1,465 | 4.4375 | 4 | # File: hw3_part3.py
# Author: Caroline Vantiem
# Date: 9/26/2017
# Section: 3
# E-mail: cvantie1@umbc.edu
# Description: Asks the user to input the time, and displays the time
# if the time is not right, asks the user to input a valid time.
def main():
print("Please enter the time: hours, then minutes... |
2d400da750faaf1a13ff6067ed0e3ecfc1b6ae44 | CarolineVantiem/CMSC-201-HW | /hw5/hw5_part5.py | 1,402 | 4.34375 | 4 | # File: hw5_part5.py
# Author: Caroline Vantiem
# Date: 10/10/2017
# Section: 3
# E-mail: Cvantie1@umbc.edu
# Description: Prints out a list of words in reverse order and backwards
# depending on what words the user inputs into the list.
#######################################################
# backwards() reverses a... |
0454a09dea2d25c1e6e09fae9cf49a8d0c1f4636 | AP-Atul/wavelets-ext | /wavelet/util/utility.py | 4,948 | 3.640625 | 4 | """Utility functions"""
from math import log, pow
import numpy as np
from ..exceptions import WaveletException
def getExponent(value):
"""Returns the exponent for the data Ex: 8 -> 3 [2 ^ 3]"""
return int(log(value) / log(2.))
def scalb(f, scaleFactor):
"""Return the scale for the factor"""
retur... |
ee53055680bc0e435d5572ca3012e85234201041 | abdulwasih/Python | /armstrong_number.py | 322 | 4.15625 | 4 | #Armstrong number
#import math
number = int(input("Enter the number : "))
temp = number
sum=0
while temp > 0:
k = temp%10
sum = sum+(k**3)
#print(sum)
temp = temp//10
#print(temp)
if sum == number:
print("The given number is armstrong")
else:
print("The given number is not armstrong")
... |
eb62f8ef617fc638cf4f23db7356fda9c260997e | Lucas42313456/ReverseString | /ReverseString.py | 405 | 4.0625 | 4 | String = input("word:")
print(len(String))
for x in String:
print(x)
gnirtS= ""
gnirtS+="!"
print(gnirtS)
#len(String)-1 is last letter
#String[0] is first letter
#loop on letters from first to last letter via: for x in range(len(String))
#empty string is gnirtS
for x in range(len(String)):
gnirtS... |
0be26fad0349707f141fe08715b9004b02e68550 | ryan-way-leetcode/python | /23_MergeKSortedLists/solution.py | 773 | 3.765625 | 4 | # Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def mergeKLists(self, lists) -> ListNode:
d = {}
for l in lists:
while l is not None:
if l.val not in d:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.