blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
f090dfa16123846ffcd342a661a8b003ebd66880 | FinnDempsey/repo1 | /assignment1ProSkills.py | 621 | 3.703125 | 4 | res1 = []
res2 = []
allVAT=0
plusVAT=0
total=0
def plusVAT():
for i in res1:
global res2
global allVAT
res2.append(i*(23/100)+i)
allVAT = allVAT + (i*(23/100))
return allVAT
for x in range (1, 100):
num=int(input('Enter a Sale Figure (Enter -1 to end): '))
... |
2c670eea4f4199b47213b50dc056acffbf175861 | justdoit0823/notes | /python/code-sample/string_search.py | 3,152 | 3.5 | 4 |
"""字符串搜索算法模块。"""
import sys
def common_index(string, sub_string):
match_idx = 0
s_probe_idx = 0
s_substr_idx = 0
while s_probe_idx < len(string) and s_substr_idx < len(sub_string):
if string[s_probe_idx] == sub_string[s_substr_idx]:
# go on matching
s_probe_idx += 1
... |
7b553b681f4449de4f7b09cfe4263b4db6e35691 | TalFurman/implicit_neural_representation_project | /colab_example/utils/dec_to_bin_utils.py | 1,778 | 3.671875 | 4 | import numpy as np
def decimalToBinary(n: int) -> str:
"""
Translate from decimal to binary representation
:param n: decimal number to translate
:return: str with binary representation
"""
bin_rep = bin(n).replace("0b","")
return bin_rep
def get_max_binary_enc_len(max_num_to_encode: int... |
c728a6a2f999b029d5ac38f202a40057446d20fd | ZhangWeiguo/Python | /leetcode/longest_substring_without_repeat.py | 879 | 4.03125 | 4 | '''
Given a string, find the length of the longest substring without repeating characters.
Examples:
Given "abcabcbb", the answer is "abc", which the length is 3.
Given "bbbbb", the answer is "b", with the length of 1.
Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer must be a substring,... |
e5a67d32954de8cd0b54c834c7436a8b74b2b71c | ZhangWeiguo/Python | /leetcode/3sum.py | 1,116 | 3.625 | 4 | '''
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0?
Find all unique triplets in the array which gives the sum of zero.
Note: The solution set must not contain duplicate triplets.
For example, given array S = [-1, 0, 1, 2, -1, -4],
A solution set is:
[
[-1, 0, 1],
[-1, -1, 2... |
b50ca5749c07ee50d1584c87ff07b5008e02af90 | ZhangWeiguo/Python | /leetcode/quick_sort.py | 726 | 3.6875 | 4 | # -*-encoding:utf-8-*-
def Partition(L1, start, end):
while start < end:
while L1[start] < L1[end] and start < end:
start += 1
if start < end:
x = L1[start]
L1[start] = L1[end]
L1[end] = x
end -= 1
while L1[start] < L1[end] and st... |
0b73ace1d7186f806b00c509240315368756e328 | wayqui/hackerrank-python | /strings/mutations.py | 380 | 3.859375 | 4 | def mutate_string(string, position, character):
# Primera forma
l = list(string)
l[position] = character
newString = ''.join(l)
# Segunda forma
newString = string[:position] + character + string[position+1:]
return newString
if __name__ == '__main__':
s = input()
i, c = input().spli... |
d9be2a224f62da987a2cff0a96ad17bdd0af6b65 | cyrt63/demos | /Experimental/trigonometry.py | 1,626 | 3.890625 | 4 | from e2ga import *
from math import pi, sqrt, cos, sin
from units import *
def showValue(name, m):
print name + " => " + str(m)
return m
def showRepr(name, m):
print name + " => " + repr(m)
return m
# Create a few unit vectors to match the "compass" terminology in the question:
zero = VectorE2(0, 0)... |
6e16c26b11810baf8962e8c01406adbc80d1d640 | cyrt63/demos | /Python/Directives.py | 375 | 3.96875 | 4 | print("hello \n")
print("\t it’s me") # tabulator
b = 73
print("decimal 73 as integer b = %d " % (b)) # for integer
print("as octal b = %o" % (b)) # octal
print("as hexadecimal b = %x " % (b)) # works hexadecimal
print("learn \"Python\" ") # use of double quote symbol
print("shows a backslash \\") # use of \\
pr... |
09aec457119ada955c64a41676439e8c22c96d80 | cyrt63/demos | /Courses/Calculus/ContourIntegral.py | 1,383 | 4.0625 | 4 | '''
Experiment with the calculation and visualization of a path integral in the complex plane.
f(z) = 1/(z(z+1)), where the contour is a circle: |z| = R > 1.
We can convert this to polar coordinates and simplify.
We can also chug through the integral using Cartesian coordinates.
'''
from cmath import *
from math imp... |
664edad9a515e3dd379f72b25f5957c6130f87dd | cyrt63/demos | /Tutorials/Lesson003.py | 756 | 3.609375 | 4 | '''
This lesson demonstrates adding a simple object to a scene.
'''
from browser import WindowAnimationRunner
from geometry import CartesianSpace, SphereBuilder
from workbench import Workbench3D
scene = CartesianSpace()
# The object is created using the builder pattern.
sphere = SphereBuilder().color(0x0000FF).build(... |
bf69b790abd1cdec14ca658e52abeca2944fa8a2 | CallMeSp/AlgorithmExercise | /Hard/4_medianOf2SortedArrays.py | 2,766 | 3.53125 | 4 | """
该方法的核心是将原问题转变成一个寻找第k小数的问题(假设两个原序列升序排列),这样中位数实际上是第(m+n)/2小的数。所以只要解决了第k小数的问题,原问题也得以解决。
首先假设数组A和B的元素个数都大于k/2,我们比较A[k/2-1]和B[k/2-1]两个元素,这两个元素分别表示A的第k/2小的元素和B的第k/2小的元素。这两个元素比较共有三种情况:>、<和=。如果A[k/2-1]<B[k/2-1],这表示A[0]到A[k/2-1]的元素都在A和B合并之后的前k小的元素中。换句话说,A[k/2-1]不可能大于两数组合并之后的第k小值,所以我们可以将其抛弃。
证明也很简单,可以采用反证法。假设A[k/2-1]大于合并之后... |
2d4cb0db46169f223bef38bba3a222c351de40f5 | initialstate/data-workshop | /variables2_answer.py | 258 | 4.09375 | 4 | # Assign a value to a new string variable
my_string = "December "
# Assign a value to a new integer variable
my_integer = 17
# Assign a value to a new floating point variable
my_float = 5.5
# Fixed
print my_string + str(my_integer) + " " + str(my_float)
|
5eabec1f26ab7c1d265d646b6fff6b98a8be61e8 | Douchebag/-FOR1T05BU | /skilaverkefni/skilaverkefni_1.py | 8,178 | 3.609375 | 4 | #31.8.2017
#Ingvar Vigfusson
#Skilaverkefni 1
from random import *
#Valmynd
valm=""
while valm !="6":
print("\n--------------")
print("Verkefni. 1")
print("Verkefni. 2")
print("Verkefni. 3")
print("Verkefni. 4")
print("Verkefni. 5")
print("Hætta. 6")
print("--------------")
valm=inpu... |
2351de502d4bccc82b65f2a2aa685797d48e7c44 | hmisonne/UdacityDSAprojects | /project3_ProblemsVsAlgorithms/Problem6_MaxAndMin.py | 1,353 | 4.0625 | 4 | def get_min_max(ints):
"""
Return a tuple(min, max) out of list of unsorted integers.
Args:
ints(list): list of integers containing one or more integers
"""
if ints == None or len(ints) == 0:
return None
if len(ints) == 1:
min_number = ints[0]
max_number = ints[0]... |
babb34b872b9175036280030f10110242c2e6923 | hmisonne/UdacityDSAprojects | /project1_UnscrambleCSProblems/Task1.py | 927 | 4.15625 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
TASK 1:
How many different telephone nu... |
91f82f627174d62cd3ee5394bce3c5d81c64dd59 | slizer98/fundamentosPython-proyectos | /bucles/cicloFor.py | 391 | 3.8125 | 4 | # Escribir numeros del 1 al 1000
# con while
# contador = 1
# print(contador)
# while contador < 1000:
# contador+=1
# print(contador)
# for contador in range(1, 1001):
# print(contador)
# for i in range(10):
# print(11 * i)
# Tablas de multiplicar
tabla = int(input('Que tabla ocupa: '))
for i in ra... |
1f642652b2648553688d1bea2665e23be901c740 | ryantharper/A-Level-CS | /HarperRyan_rw.py.py | 6,216 | 3.640625 | 4 | '''Resident Weevil
Simple FPS without using functions'''
# DEADLINE = 1st March
import random,time
guns = [] # empty list
health = 30
killed = [] # empty list
#equip with handgun
currentgun = ["Hand Gun",50]
enemies = ["zombies", "bears", "orcs"]
print("Text Based Shooter!")
print("This program is... |
88f7542852c6e9cb0359c4c6cc87f62a4917068f | pureloveljc/python_demo | /purelove/imooc/gen_func.py | 1,237 | 3.78125 | 4 | # -*- coding: utf-8 -*-
__author__ = "purelove"
__date__ = "2018/7/17 下午10:48"
# 生成器 只要有yield关键字就是生成器
def gen_func():
yield 1
yield 2
yield 3
# 惰性求值 延迟求职提供了可能
# 斐波那契 0 1 1 2 3 5 8
def gen():
return 2
def fib1(index):
if index <= 2:
return 1
else:
return fib(index-1) + fib(... |
1d0d28406c865726393ebf1e598e100a32670963 | pureloveljc/python_demo | /purelove/threading_py/thread_condition.py | 1,983 | 3.71875 | 4 | # -*- coding: utf-8 -*-
__author__ = "purelove"
__date__ = "2018/7/22 下午10:46"
# 条件变量 用于复杂的线程间同步
from threading import Condition
import threading
import time
class Xiaoai(threading.Thread):
def __init__(self, cond):
self.cond = cond
super().__init__(name="小爱")
def run(self):
with sel... |
5e83a27177d8011887734dc8ba205c5d54971aad | Kinopio-Ch/guess-number | /import.py | 819 | 4.03125 | 4 | #猜數字遊戲
import random
start = input('請決定答案最小值: ') #使用者決定最大最小值
end = input('請決定答案最大值: ')
start = int(start)
end = int(end)
##################################################################
r = random.randint(start, end)
count = 0 #猜測次數計算,寫在while迴圈外以免歸零
while True:
count = count + 1 #count = count + 1也可寫成co... |
1a3d1a4579936341e86d3755f8b799117451401b | shakyav/SSMT | /helper/helper.py | 1,031 | 3.796875 | 4 | """
helper.py contains various helper functions which can be used frequently
"""
import datetime
import os
import shutil
def store_file_in_csv(filename,mydict):
"""
Purpose: Store the retreived data in to csv file
Input: Filename and dictionary
Output: Returns csv file
"""
filename = gener... |
003790fc1ccda6c1601e3b7114aba380303d0485 | Prabhnometery/ITI1120 | /a4_300057572/a4_part2_300057572.py | 5,015 | 4.125 | 4 | #Family name: Prabh Simran Singh Badwal
# Student number: 300057572
# Course: IT1 1120[F]
# Assignment Number 4 Part 2
class Point:
'class that represents a point in the plane'
def __init__(self, xcoord=0, ycoord=0):
''' (Point, float, float) -> None
initialize point coordinates to (xcoord, y... |
77bdb2b7f8db135185f9b95ea8e36d4be2e62809 | citizendez/Python-Challenge | /Minis/HouseOfPies.py | 1,186 | 3.890625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Oct 9 09:16:00 2020
@author: citiz
"""
# %% inrto to pie store with menu items numbered
#pies = ['(1) Pecan', '(2) Apple Crisp', '(3) Bean', '(4) Banoffee', '(5) Black Bun', '(6) Blueberry', '(7) Buko', '(8) Burek', '(9) Tamale', '(10) Steak']
print('Welcome to the House ... |
fc6dc266bba6971bad4e1ae1eb7ebc69c0329b9e | xemxav/Python_Bootcamp | /Day_02/ex00/ft_reduce.py | 446 | 3.828125 | 4 | import functools
import operator
def ft_reduce(function_to_apply, list_of_inputs):
ll = list(list_of_inputs)
first = ll[0]
for elem in ll[1:]:
first = function_to_apply(first, elem)
return first
def main():
lis = [1, 3, 5, 6, 2, ]
print("The sum of the list elements is : ", end="")
... |
b678e8dee6672e167f1e7c0991f83f6d54759c46 | xemxav/Python_Bootcamp | /Day_01/ex05/eval.py | 686 | 3.875 | 4 | class Evaluator:
def zip_evaluate(coefs, words):
if len(words) != len(coefs):
return -1
res = 0
for w in zip(words, coefs):
res += len(w[0]) * w[1]
return res
def enumerate_evaluate(coefs, words):
if len(words) != len(coefs):
return -... |
3935cc7cc4b515998ab10ccfb862870ca7157491 | xemxav/Python_Bootcamp | /Day_01/ex01/game.py | 651 | 3.546875 | 4 | class GotChracter:
def __init__(self, first_name=None, is_alive=True):
self.is_alive = is_alive
self.first_name = first_name
class Targaryen(GotChracter):
"""A class representing the true rulers of Westeros"""
def __init__(self, first_name=None, is_alive=True):
super().__init__(f... |
e2980f980551cffef92c721cbb6d81673d34e300 | xemxav/Python_Bootcamp | /Day_00/ex06/recipe.py | 2,620 | 4.0625 | 4 | cookbook = {
'sandwich': {
'ingredients': ["ham", "bread", "cheese", "tomatoes"],
'meal': "lunch",
'prep_time': 10,
},
'cake': {
'ingredients': ["flour", "sugar", "eggs"],
'meal': "dessert",
'prep_time': 60,
},
'salad': {
'ingredients': ["avoca... |
3232b6e698b90f6c9a2b8657871553eedc8592bd | ianfixes/ZenGardenTable | /a_star.py | 2,086 | 3.53125 | 4 | import operator
import heapq
class PriorityQueue:
def __init__(self):
self.elements = []
def empty(self):
return len(self.elements) == 0
def put(self, item, priority):
heapq.heappush(self.elements, (priority, item))
def get(self):
return heapq.heappop(se... |
05f68d924f022a536d16f6a441ac6b227c44df22 | utsavnetops/Backup | /send/class.py | 318 | 3.953125 | 4 | class A(object):
def __init__(self, a):
self.num = a
def mul_two(self):
self.num *= 2
class B(A):
def __init__(self, a):
X.__init__(self, a)
def mul_three(self):
self.num *= 3
obj = B(4)
print(obj.num)
obj.mul_two()
print(obj.num)
obj.mul_three()
print(obj.num)
|
fae92bbea40c609cb73f659d5024378d175018d3 | JacksonJ01/Play_Brick_Breaker | /Play_Brick_Breaker.py | 15,232 | 3.625 | 4 | # jackson J.
# 5.21.2020
# Taking what I learned yesterday with Play_Pong, I will try to make brick breaker.
# This will be a lot harder because i will have to find the right window size, and I will have to create a lot of
# Turtle objects that will be destroyed when the ball hits it#
from turtle import *
from random i... |
efc6b35af6312b1bfa654c19509cc622346cc725 | chauxp/2524_P3 | /DirectoryTree_P3.py | 4,763 | 3.75 | 4 | #!/usr/bin/env python
#Created by Pierre Chaux
#ECE 2524 Project 3
#A Program for a Directory Tree GUI that i show all the subdirectories and files down from a directory. It begins with the home directory and any directory clicked will be the root in a new window
import os
import tkinter as tk
#from tkinter import tt... |
fa2bb802983221dd278446e1592c83dd65c4ce06 | PotOfPetunias/CrookFunProjects | /pet_name_gen/sounds.py | 2,367 | 3.796875 | 4 |
class Sound:
cons = "consonant"
vowel = "vowel"
def __init__(self, symbol, pronounce, sound_type):
self.symbol = symbol
self.pronounce = pronounce
self.sound_type = sound_type
def __str__(self):
return self.symbol + " (" + self.pronounce + ")"
def is_conson... |
cfb9c6672093ecf067550b03b3f7e0fada9db328 | Soerty/Python-2017-HW | /linked_list.py | 2,195 | 4.03125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
class Node:
__slots__ = ['data', 'next']
def __init__(self, data, next=None):
self.data = data
self.next = next
class LinkedList:
def __init__(self, head=None):
self.head = head
def empty(self):
if self.head:
... |
72cedd0884e36ea1a2fc094314e293cf68ba756d | UKVeteran/Adventures-in-Python | /Adventure 1/2/story.py | 185 | 3.90625 | 4 | personName= input("Enter a name: ")
anObject=input("Enter an object: ")
place=input("Enter a place: ")
story = personName + " was walking through " + place + "."
print (story)
|
fc979d2219c47b0cbe2baf9a437a026e934106ec | UKVeteran/Adventures-in-Python | /Adventure 4/2/clickspeedgame.py | 640 | 3.59375 | 4 | import tkinter as tk
import time
window = tk.Tk()
clicks = 0
start = 0
goal = 10
def buttonClick():
global clicks
global start
if clicks == 0:
start = time.time()
clicks = clicks + 1
elif clicks + 1 >= goal:
score = time.time() - start
label.config... |
3083caa61e4d0a15f8b40df1e333a9b8d49af568 | Minsc016/ggstudy | /py/第三章:数字日期和时间/3_8_分数运算.py | 796 | 4.34375 | 4 | #########################################################################
# File Name: 3_8_分数运算.py
# Author: Crow
# mail:qnglsk@163.com
# Created Time: Fri Dec 13 10:47:54 2019
#########################################################################
#!/usr/bin/env python3
# 小学家庭作业 //// 木工工厂的测量值 分数运算
# fracti... |
5eb4df654e78dcfeebcb07450d63a2549ed2da36 | Minsc016/ggstudy | /py/第一章:数据结构和算法/1_12_序列中出现次数最多的元素.py | 1,437 | 3.890625 | 4 | #########################################################################
# File Name: 1_12_序列中出现次数最多的元素.py
# Author: Crow
# mail:qnglsk@163.com
# Created Time: Thu Oct 24 09:58:06 2019
#########################################################################
#!/usr/bin/env python3
# collections.Counter 类
# most_commo... |
a8c066abb969740a69d6c23059fdd8a3a89f6abc | Minsc016/ggstudy | /py/第五章:文件与IO/5_1_读写文本数据.py | 4,108 | 3.78125 | 4 | #########################################################################
# File Name: 5_1_读写文本数据.py
# Author: Crow
# mail:qnglsk@163.com
# Created Time: Fri Jan 17 10:12:33 2020
#########################################################################
#!/usr/bin/env python3
# 读写各种不同编码的文本数据,比如ASCII,UTF-8,UTF-16编码等。
#... |
711d6be3ea9d3ea97be7e637d2e15ef14f1b4e62 | Minsc016/ggstudy | /py/第二章:字符串和文本/2_14_合并拼接字符串.py | 3,494 | 3.703125 | 4 | #########################################################################
# File Name: 2_14_合并拼接字符串.py
# Author: Crow
# mail:qnglsk@163.com
# Created Time: Thu Nov 14 19:54:34 2019
#########################################################################
#!/usr/bin/env python3
# 将几个小的字符串 合并为 一个大的字符串
# 如果 需要 合并的字符串 在一... |
07cfa608a5d8d8133bb8b91df59cc7bb864a1b47 | Minsc016/ggstudy | /py/第一章:数据结构和算法/1_11_命名切片.py | 1,037 | 3.703125 | 4 | #########################################################################
# File Name: 1_11_命名切片.py
# Author: Crow
# mail:qnglsk@163.com
# Created Time: Wed Oct 23 17:39:03 2019
#########################################################################
#!/usr/bin/env python3
# 硬编码下标 清理 成 命名切片
record = '.................. |
e37c93e6c753f581e9f92996fdebf9872b2e2244 | deba999/InterviewBit | /Binary Search/rotated_sorted_array_search.py | 1,205 | 3.890625 | 4 | # Rotated Sorted Array Search
# https://www.interviewbit.com/problems/rotated-sorted-array-search/
def find_pivot(lst, low, high):
if high < low:
return -1
if high == low:
return low
mid = (low + high) / 2
if mid < high and lst[mid] > lst[mid + 1]:
return mid
if mid > low an... |
80c51e858fec7f4205f63bc746246ebd78c4b03a | deba999/InterviewBit | /Linked Lists/swap_list_nodes_in_pairs.py | 784 | 3.984375 | 4 | # Swap List Nodes in pairs
# https://www.interviewbit.com/problems/swap-list-nodes-in-pairs/
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# @param A : head node of linked list
# @return the head node in th... |
0d9121ca5197fa1efa9e4280ba2e553812a8242b | deba999/InterviewBit | /Arrays/pascal_triangle_rows.py | 1,008 | 3.734375 | 4 | # Pascal Triangle Rows:
# https://www.interviewbit.com/problems/pascal-triangle-rows/
def _generate_row(row_above, row_index):
row = []
# num of ints in each row == row_index + 1
num_elements = row_index + 1
for elem_index in xrange(num_elements):
if elem_index == 0 or elem_index == num_element... |
124e0e2281bed39c6dae948c086a86592628c685 | Carolmbugua/Bootcamp | /atm.py | 2,106 | 3.953125 | 4 | # class Atm_card:
# Bank_name ="Welcome to KCB Bank"
# balance = 0
#
# def __init__(self,pin,balance,color):
# self.p = pin
# self.b = balance
# self.c = color
# # def enter_pin(self):
# # if self.p == 5666:
# # return self.p, "Pin Accepted!"
# # else:... |
a2d156e9308bf845f23240b438085f9231b729d9 | Siddu02june/HackerRank-Sets | /Set_intersection().py | 273 | 3.5 | 4 | #Set_intersection()
E = int(input())
English = list(input().split()[:E])
F = int(input())
French = list(input().split()[:F])
print(len(set(English) &s et(French)))
'''
Input (stdin)
9
1 2 3 4 5 6 7 8 9
9
10 1 2 3 11 21 55 6 8
Your Output (stdout)
5
Expected Output
5
'''
|
cfc311c077a70c0c224c569f263864e120aef0b0 | amberrevans/IS_201 | /pythonProject/homework 5 problem set 4/PB14-amber.py | 241 | 4.21875 | 4 | #valid triangle by angles
print ('Enter the three angles of your triangle: ')
a = int(input())
b= int(input())
c = int(input())
if ((a + b >c) == 180):
print ('Your triangle is valid.')
else:
print ('Your triangle is not valid.')
|
0ca192c7dc4dd8006b2a4f34a050b610410b2d32 | amberrevans/IS_201 | /pythonProject/homework-3/RPS-amber/nxtProg.py | 312 | 3.859375 | 4 | import random
def roll_dice ():
dice1 = random.randint(1,6)
print ('First dice:',dice1)
dice2 = random.randint(1,6)
print ('Second dice:',dice2)
total = dice1 + dice2
print ('total is',total)
if (total ==7):
print ('Winner!')
else:
print ("You lost.")
roll_dice() |
fd977ad972f71116c2bb3d3339492ed681469029 | amberrevans/IS_201 | /pythonProject/homework-3/exercise11.py | 251 | 4.03125 | 4 | #convert mpg to L/100km
mpg = int(input('Please enter the Miles per Gallon you wish to convert: '))
print ('You entered', mpg)
#formula for conversion
km = mpg*235.215
print ('The conversion of', mpg,'miles per gallon to L/100km is', km,'L/100km')
|
cd02337434eed0a62fd0f5964e3b2ff2c245a354 | amberrevans/IS_201 | /pythonProject/classWork.py | 475 | 3.8125 | 4 | #amber evans
#problem 10
#running problem
start_time=(6*3600)+52*60
easy_pace_miles_sec=2*(8*60+15)
temp_pace_miles_sec=3*(7*60+12)
print(start_time,easy_pace_miles_sec,temp_pace_miles_sec)
final_seconds=start_time+easy_pace_miles_sec+temp_pace_miles_sec
print(final_seconds)
finish_hours=final_seconds//60
remaining... |
b9bec3835f215f82af681e81d7af7fe09d27bdff | amberrevans/IS_201 | /pythonProject/homework-3/exercise15.py | 261 | 4.03125 | 4 | #feet, inches, yards, and miles
feet = int(input('Enter the distance in feet: '))
inches = feet *12
print('The distance in inches is',inches)
yards = feet/3
print ('The distance in yards is', yards)
miles= feet/5280
print ('the distance in miles is',miles)
|
447f0a37f2968da6a32ce9a9a88195b7af891dba | amberrevans/IS_201 | /pythonProject/homework 5 problem set 4/PB11-amber.py | 383 | 4.21875 | 4 | #input week number and print weekday
weekDay = int(input('Enter the weekday day number (1-7): '))
if weekDay ==1:
print ('\nSunday');
elif weekDay == 2:
print ('\nMonday')
elif weekDay ==3:
print ('\nTuesday')
elif weekDay == 4:
print ('\nWednesday')
elif weekDay ==5:
print ('\nThursday')
elif wee... |
dbe2c21215ee9fa08f1a84afb019d6dfa709fd55 | gizemt/CodingChallenge | /LeetCode/234-palindrome-linked-list.py | 675 | 3.625 | 4 | ''' Leetcode 234: palindrome-linked-list
# Question : Given a singly linked list, determine if it is a palindrome.
# Link : https://leetcode.com/problems/palindrome-linked-list/
# Runtime : 60 ms - 97%
# Memory : 24.1 MB - 59%
'''
# Definition for singly-linked list.
# class ListNode:
# def __init__(... |
6205704285137c5e4a3dc162d7bcc0bcb3e28be9 | gizemt/CodingChallenge | /LeetCode/009-palindrome-number.py | 702 | 3.859375 | 4 | ''' Leetcode 009: palindrome-number
# Question : Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.
Follow up: Could you solve it without converting the integer to a string?
# Link : https://leetcode.com/problems/palindrome-number/
# Runtime : 3... |
8a424b3a4942152878e28a2bcb6631a4100a6560 | chlngr/scrapr | /Archive/georequest.py | 1,043 | 4 | 4 | #! /usr/bin/env python3
# this establishes a function to take a latitude and longitude and makes an API call to google maps api
# returning a json
# documentation for google maps API at https://developers.google.com/maps/documentation/geocoding/start\
# google maps API key for my project on Alex's account = 'AIzaSyA5Q5... |
e6fc7c739a02209194d00b8795faac1ed3f9bed1 | liam-fletcher1/ICS3U-Unit4-07-Python-Integer_Count | /integer_count.py | 550 | 4.3125 | 4 | #!/usr/bin/env python3
# Created by: Liam Fletcher
# Created on: Oct 2021
# This program uses a nested loop to print integers from 1000-2000
def main():
# this function uses a nested loop to print integers
# loop var
integer_count = 1000
# process & output
for integer_count in range(1000, 2000 ... |
27a32fc212a7c071f3914d24ae3cc82fe07d9668 | arzanpathan/Projects-On-Python | /Dice Game Project/Dice.py | 2,080 | 3.734375 | 4 |
#For Dice Values
def Dice_Value(d):
for i in range(0,11):#For Rows
for j in range(1,15):#For Columns
# For Dice Case
if (i==1 or i==4 or i==7 or i==10) and (j==3 or j==7 or j==11):
print('_',end='')
elif (i>1 and (j==1 or j==5 or j==9 or j==1... |
84c1e0e8ec2a873d79c76896b7dc26e72efe9e8c | Dirac156/alx-higher_level_programming | /0x0A-python-inheritance/1-my_list.py | 199 | 3.609375 | 4 | #!/usr/bin/python3
""" This is a function """
class MyList(list):
""" print new list """
def print_sorted(self):
"""Methot that sorted a list"""
print(sorted(list(self)))
|
c4a90332964bc43a2bba4ff5555354550ffa928a | yqt2016/python2 | /Student.py | 445 | 3.5 | 4 | #!/usr/bin/env python
#FileName:Student.py
#config:utf-8
class Student(object):
def __init__(self,name,score):
self.name=name
self.score=score
def print_score(self):
print '%s:%s'%(self.name,self.score)
def get_grade(self):
if self.score>=90:
return 'A'
elif self.score>=60:
return 'B'
el... |
dce17b7c67d04662f5bfaffc3ce28d964a34f60a | yashpatel123a/Mini-Projects | /Next Prime Number/primenumber.py | 742 | 4.21875 | 4 | def isprime(number):
if number <= 1:
return False
if number <= 3:
return True
if (number%2 == 0 or number%3 == 0):
return False
i = 5
while i*i <= number:
if (number%i == 0 or number%(i + 2) == 0):
return False
i += 6
return True
if __name__ =... |
e43bd05280bb297873869a4689f6fb86ba367813 | yashpatel123a/Mini-Projects | /Closest pair problem/closestpair.py | 1,633 | 3.671875 | 4 | def sortX(points):
points.sort(key = lambda x:x[0])
return points
def sortY(points):
points.sort(key = lambda x:x[1])
return points
def compareX(a,b):
return a[0] - b[0]
def compareY(a,b):
return a[1] - b[1]
def distance(a,b):
return ((a[0] - b[0])**2 + (a[1] - b[1])**2)**0.5
def brutef... |
674381efa10fa0c9083d99e5db62d5ada7eaa73f | plegrone/Exercise-11.1- | /Exercise 11.1 Final.py | 1,350 | 4.3125 | 4 | #Set the count value to zero and open the text file containing the words that will be used as keys in the dictionary
count = 0
with open('words.txt') as listwords:
words_lines = listwords.readlines()
#Build a table with words from the text file by appending them into the table
words_table = []
for word in wor... |
8d9ce71ce9a247dcf0f0c4908c327cc556b6c2ac | JereMIbq1995/genie-core | /genie_core/script/clock.py | 2,128 | 4.1875 | 4 | """
Copyright 2021, BYU-Idaho.
Author(s): Matt Manley, Jacob Oliphant
Version: 1.0
Date: 27-01-2021
"""
import time
class Clock:
"""The animation clock.
The responsibility of Clock is to keep track of time in both the real
world and the animation world. See https://gameprogrammingpatterns.com/ for
... |
0905647662eab9cd954644a0b4d0b838cd44b661 | kalemaithri/racing_game | /game_python_project.py | 634 | 3.625 | 4 | import turtle
import random
import sys
n=int(input("enter the number of turtles :"))
t1=turtle.Turtle()
l=[]
turtle.screensize(400,300,"#994444")
for i in range(n):
t=turtle.Turtle()
t.shape("turtle")
t.speed(0)
t.pu()
t.setposition(-340,260-(i*100))
t.pd()
t1.pensize(3)
t... |
9f65cd8db5b338ed68ac7f9f67c0d1ebe4dfaf57 | udwivedi394/python | /huffmanCoding.py | 2,476 | 4.03125 | 4 | #Create a Node for tree, it will store the data as well as frequency
class Node:
def __init__(self, freq):
self.data = None
self.freq = freq
self.left = None
self.right = None
#LevelOrder traversal of Tree
def levelOrder(root):
tempNode = root
queue = []
while tempNode != None:
print (tempNode.data,temp... |
a7d692d8fc170419469dca4346fc95004fdfb7a8 | udwivedi394/python | /nonReaptingChar.py | 3,237 | 3.75 | 4 | import time
#Return first non-repeating character from string
#Time Complexity O(n) with only one traversal, Space complexity O(1) as fixed size array is being created
def firstNonRepeatingChar(arr):
lookup_arr = [[0,-1] for i in range(256)]
for i in range(len(arr)):
lookup_arr[ord(arr[i])][0] += 1
if lookup_ar... |
b50467ae39173c0a4b8d49a503b5c13c6b0aebb6 | udwivedi394/python | /morrisInOrder.py | 4,204 | 3.890625 | 4 | class Node:
def __init__(self, key):
self.left = None
self.right = None
self.data = key
def morris_inorder_traversal(root):
current = root
while current != None:
#if left subtree NA, print data of current node and visit right subtree
if current.left == None:
print current.data,
current = current.r... |
db1c2f4a902b5a6dd1ddef4021c839a29827d792 | udwivedi394/python | /largestSumContiguous.py | 678 | 3.515625 | 4 | #Naive solution, with three loops
def largestSumContiSubarray(arr):
max_sum = -451378945221
n = len(arr)
for i in range(0, n):
for j in range(0, i+1):
sumi = 0
new_arr = []
for k in range(j, i+1):
sumi += arr[k]
new_arr.append(arr[k])
if sumi > max_sum:
max_sum = sumi
max_sum_arr = ne... |
8d7209c60cd8fc19982f1b552f7ceeff8bcf3bbf | udwivedi394/python | /permuting2arrays.py | 515 | 3.515625 | 4 | #!/bin/python
import sys
def twoArrays(k, A, B):
A.sort()
B.sort()
B.reverse()
for i in range(len(A)):
if A[i]+B[i]<k:
return "NO"
return "YES"
# Complete this function
if __name__ == "__main__":
q = int(raw_input().strip())
for a0 in xrange(q):
n, k = raw_input().strip().split(' ')
... |
c8d6333bc78aa8533dd33ab473f48e392e131601 | udwivedi394/python | /lowestCommonAncestor.py | 2,016 | 3.78125 | 4 | class bTree:
def __init__(self,data):
self.data = data
self.left = None
self.right = None
#Time Complexity: O(n), Space Comlexity: O(log n), 2 Tree traversal
def lca(root,key1,key2):
path1 = findPath(root,key1)
path2 = findPath(root,key2)
if path1==None or path2==None:
print "Keys not Found"
return Non... |
823d6087aa28f769d58237d26184c415084d193f | udwivedi394/python | /printBinaryTree.py | 4,881 | 3.5 | 4 | import binaryHeap as bHeap
import binaryHeapUtility as bHeap2
class bTree:
def __init__(self,key):
self.data = key
self.left = None
self.right = None
def findHeightofTree(node):
if node.left == None and node.right == None:
return 1
lheight = 0
rheight = 0
if node.left:
lheight = 1 + findHeightofTree(n... |
83a17fc856cbe3c6ec711b8a7a954554aac2b13a | onesuper/design_patterns | /proxy/proxy.py | 463 | 3.609375 | 4 | #!/usr/bin/python
# Filename: proxy.py
class SchoolGirl:
name = ''
class Pursuit:
mm = SchoolGirl()
def __init__(self, mm_name):
self.mm = mm_name
def GiveFlowers(self):
print self.mm.name, 'It is a flower for you'
class Proxy:
gg = Pursuit('') #there's always a unlucky man behind a luck one
def __init__(s... |
bbe0d0b3be3bdaa2ccedf5e2d3de133b821e8db5 | diego-rapoport/basic-funcs | /hex_dec.py | 1,008 | 4.21875 | 4 | def convert_hex_to_dec(hexa):
'''
A hexadecimal to decimal converter. For now just converts the hexadecimals
like 0x0b34.
So the basic is that we take the reversed hexadecimal up to 0x, ex: 0x0b34 turns into
43b0, and each number is multiplied by 16 in the power of it's index. Then ... |
221de5d5831320e49616e6eb26a7c5992d57e90a | ashishk6/python | /dict_dict.py | 429 | 3.703125 | 4 | x=[{"id":1,"num": [25,30,31]},
{"id":11,"num": [21,22,23]},
{"id":12,"num": [1,21,31]}]
final_list=[]
for n in x:
#print(n["num"])
final_list=final_list+n["num"]
print(final_list)
final_list=list(set(final_list))
print(final_list)
my_dict={}
for list_val in final_list:
arr=[]
for n in x:
if list... |
21929992e8b13a5ba15d5011ce2216bdf4a0c240 | blakepiper/data_science_from_scratch | /matplotlib_example.py | 631 | 3.59375 | 4 | """Trying Matplot Lib"""
from matplotlib import pyplot as plt
years = [1950, 1960, 1970, 1980, 1990, 2000, 2010]
gdp = [300.2, 543.3, 1075.9, 2862.5, 5979.6, 10289.7, 14958.3]
"""Create a line chart, years on x-axis, gdp on y-axis"""
plt.plot(years, gdp, color="purple", marker="o", linestyle="solid")
plt.title("Lei... |
a80e2e721b47ff040183e44f91ff45f72222e651 | MQuaresma/MB.ioChallenge | /main.py | 4,168 | 3.703125 | 4 | #!/usr/bin/env python3
""" Mercedes Workflow Automator
This script allows the user to automate the workflow of purchasing an item of merchandise on the Mercedes-Benz online shop.
The tool searches for items matching the term "cap" and randomly selects, from the listed items, one item to add to the
shopping basket. ... |
e2e4d738438d9eaca47bc2c84be189397fb32dc2 | maieutiquer/hackbulgaria-week0 | /prime_number_of_divisors.py | 359 | 3.96875 | 4 | from sum_of_divisors import find_divisors
from is_prime import is_prime
def prime_number_of_divisors(n):
if n == 1:
return True
elif n < 1:
return False
number_of_divisors = len(find_divisors(n))
return is_prime(number_of_divisors)
def main():
print(prime_number_of_divisors(9))
... |
cbb29fa673e20502462a3d3101bb80cf214d213e | macddmac/P3PROPHET | /shekarbubblesort.py | 825 | 4.03125 | 4 | class Bubblesort:
def __init__(self, arr):
arr1 = arr.split()
arr2=[]
for x in arr1:
arr2.append(int(x))
self._oarr = arr2
self._sarr = arr2.copy()
self.bubbleSort()
def bubbleSort(self):
n = len(self._sarr)
for i in range(n-1):
... |
88bf973f97697282e329b492b9d48f3d11e4e08a | raulfm94/FrasesACodigoPY | /src/TokensToPythonCode.py | 13,051 | 3.5625 | 4 | from enum import Enum
class Modify(Enum):
INCREMENT = 1
DECREMENT = -1
nouns = ["NN", "NNP"]
def stringify(unquoted_string):
return '"' + unquoted_string + '"'
# for all format classes, string values must be passed with quotes included
# (i.e., single quote-wrapped)
# ex: instead of "happy" -> '"happ... |
816d09ea1df188ceb33f5ed938620a1e6747159d | Krondini/Practice | /Python/Random/TicTacToe/startGame.py | 1,143 | 3.9375 | 4 | import classes
def takeTurn(player: classes.Player, board: classes.Board) -> None:
viable = None
board.displayBoard()
print("{} please take your turn.".format(player.name))
while (viable == None):
row = int(input("Enter the row-coordinate for your move (ex: 0, 1, 2...): "))
col = int(input("Enter the column-... |
9e40c9add01fc6c1c23cfa7222921122de61505f | sebastian4/py-ciphers | /caesar_shift.py | 928 | 4.03125 | 4 | key = 'abcdefghijklmnopqrstuvwxyz'
def encrypt(n, plaintext):
"""Encrypt the string and return the ciphertext"""
result = ''
for l in plaintext.lower():
try:
i = (key.index(l) + n) % 26
result += key[i]
except ValueError:
result += l
return result.l... |
9c0c24a146d329e432c03dc9a5859fc0855c5c67 | adityaparab04/Python-Exercises | /ex1.py | 299 | 3.59375 | 4 | # A Good First Program
print("Hello World")
print("Hello world again")
#print("I like typing this")
print("This is fun")
print('Yay! printing')
#print("I'd much rather you 'not'.")
print('I "said" do not touch this.')
print("Manchester United is Love <3")
print("Uefa europa league Starts tonight" ) |
5bb20013cb6448afcdc718106de7ae2bf612aa0d | adityaparab04/Python-Exercises | /ex7.py | 365 | 3.78125 | 4 | # More Printing
print("Mary had a little lamb.")
print("It's fleece was white as {}.".format('snow'))
print("And everywhere that Mary went.")
print("." * 10) #add 10 dots
e1 = "C"
e2 = "H"
e3 = "E"
e4 = "E"
e5 = "S"
e6 = "E"
e7 = "B"
e8 = "U"
e9 = "R"
e10 = "G"
e11 = "E"
e12 = "R"
print(e1 + e2 + e3 + e4 + e5 + e6, e... |
4424ced888a52f803a8d3e77f2b61eb9cb6b99f6 | PiperPimientos/CursoBasicoPython | /Palindromo.py | 3,009 | 4.46875 | 4 | #Crearemos un programa que identifica si la palabra que ingresamos es un palindromo o no
# 1. Crearemos una función principal, que es la que va correr el programa al principio. Es una buena práctica en Python tener una función que es la que va correr el programa al principio. Nuestra función tendrá como nombre run, po... |
7c3dd9b0615f79e94a182378e15f8f1740c534f8 | PiperPimientos/CursoBasicoPython | /ConversorMonedasV2.py | 1,457 | 3.8125 | 4 | #Conversor de Monedas V2. Incluimos peso argentino y mexicano
#El codigo original se puede ver en el archivo ConversorMonedas.py
#Pasos: 1-Creamos un menu donde introducimos el programa y opciones
# 2-Creamos un input para elegir una de las tres opciones del menu
# 3-Introducimos las condicionales para la eleccion de ... |
ea97e558c36a9bdd2b95eb37dee68aca18b89f44 | PiperPimientos/CursoBasicoPython | /For.py | 2,354 | 4.15625 | 4 | #Veremos ahora el ciclo For, despues de haber trabajado While en Bucles.py
# El profesor nos plantea un problema: imprimir los números del 1 al 1000.
# Si lo hiciéramos de manera normal tendríamos que hacer desde print(1) hasta print(1000)
# Pero si lo queremos hacer con bucles, pues lo hacemos de esta forma
# 1. C... |
0e8a35d9e365f022ad5748a28032637836ccf15a | JSitter/cs1_eulers_code_challenges | /multiples.py | 827 | 4.09375 | 4 | '''
MULTIPLES OF THREE AND FIVE
From ProjectEuler.com Code Challenge 1
If we list all the natural numbers below 10
that are multiples of 3 or 5, we get 3, 5,
6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
'''
class NumberWang():
num_ary = []
limit = ""
de... |
17aaa3b996506ed4e740138ffde3298a875d79f0 | anik-kucse/A.-I.-Lab-Python- | /forwardChaining.py | 2,358 | 3.609375 | 4 | from itertools import permutations
from itertools import combinations
def takeStatement():
print('number of statement: ')
n = input()
listFact = []
listLeftSide = []
listRightSide = []
for i in range(int(n)):
statement = input()
statement = statement.replace(' ',''... |
9fe66a704a33d1ce745568886860ef1edf979bd5 | FCSu/interview_rakuten | /test.py | 966 | 3.53125 | 4 | import q1_reverse_string
import q2_perfect_square
import q3_insert_interval
import q4_find_word
s = 'hello'
print(s, 'reversed answer is', q1_reverse_string.reverse(s))
n = 16
print(n, 'is perfect square', q2_perfect_square.isPerfectSquare(n))
n = 14
print(n, 'is perfect square', q2_perfect_square.isPerfectSquare(n))... |
023ea0740c3feac7b631c206698bd77f9748b31d | denyadenya77/beetroot_units | /unit_2/lesson_11/presentation/1.2.py | 2,068 | 4.21875 | 4 | # # Создать классы с методами __str__, __repr__ и собственными методами классов, построить правильную иерархию классов.
# # Перечень классов: Автомобиль, Поезд, Транспортное средство, Мотоцикл.
class Vehicle:
def __init__(self, wheels, passengers):
self.wheels = wheels
self.passengers = passengers... |
d3a7fb54dc65762632abfc1374edf0cadaaddb21 | denyadenya77/beetroot_units | /unit_2/lesson_13/presentation/2.py | 803 | 4.3125 | 4 | # Пользователь вводить возраст. Написать функцию, если возраст больше 16 то объявить внутри функции функцию
# show_available_content, которая будет показывать доступные фильмы, вызвать show_available_content которая
# показывает скрытые данные. Если возраст меньше 16, вернуть сообщение что пользователю информация недос... |
6374f806c19b548bbb859bd08c2e6c63ec616189 | denyadenya77/beetroot_units | /unit_2/lesson_16/presentation/3.py | 628 | 3.90625 | 4 | # Создать генератор для итерации по солдатам.
def generate_soldiers(x):
army = ['JAMES', 'JOHN', 'ROBERT', 'MICHAEL', 'WILLIAM', 'DAVID', 'RICHARD', 'CHARLES', 'JOSEPH', 'THOMAS']
a = 0
while a < x:
yield f'soldier {army[a]} ready for battle'
a += 1
my_own_army = generate_soldiers(9)
pri... |
d411c8fcdf4222058a1dcd581fb59c004f1c1ea3 | denyadenya77/beetroot_units | /unit_3/lesson_20/lms/1.py | 637 | 3.96875 | 4 | # Memoization
from functools import lru_cache
# f_cache = {}
# def fibonacci(n):
# if n in f_cache:
# return f_cache[n]
# if n == 1:
# value = 1
# elif n == 2:
# value = 1
# elif n > 2:
# value = fibonacci(n - 1) + fibonacci(n - 2)
# f_cache[n] = value
# retu... |
f9e56006e09780a4a7663f2588cdaa4e26feff7e | denyadenya77/beetroot_units | /unit_2/lesson_11/presentation/1.1.py | 2,990 | 3.578125 | 4 | # Создать классы с методами __str__, __repr__ и собственными методами классов, построить правильную иерархию классов.
# Перечень классов: Студент, Преподаватель, Персона, Зав. кафедрой.
class Person:
def __init__(self, name, age, p_number):
self.name = name
self.age = age
self.p_number = p... |
f844ccef057be3f654b6feb59da6feea0c9020bc | denyadenya77/beetroot_units | /unit_2/lesson_16/presentation/4.py | 399 | 3.75 | 4 | # Написать генератор для чисел Фибоначчи.
def generate_fib(exit_index):
num_1 = 0
num_2 = 1
i = 0
while i < exit_index:
new_num = num_1 + num_2
yield new_num
num_1, num_2 = num_2, new_num
a = generate_fib(14)
print(next(a))
print(next(a))
print(next(a))
print(next(a))
print(next(a))
print(next(a))... |
04556cfbf677f7e4ba09b1da5c9a03598443cfe5 | denyadenya77/beetroot_units | /unit_2/lesson_15/presentation/7.py | 815 | 3.796875 | 4 | # Создать иерархию наследования классов: Человек, Мужчина, Женщина,
# Супермен (с приватным атрибутом force и методом save_world)
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
class Man(Person):
def __init__(self, name, age, beard):
super().__init__(n... |
2be90fa1153b2241185dba540c24e2dfe5a72ded | rohith788/Leetcode | /Others/29th/234. Linked List Palindrone.py | 400 | 3.65625 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def isPalindrome(self, head: ListNode) -> bool:
d = []
root = head
while(root is not None):
d.append(root.val)
... |
12efce4b1e40dc0f998720d71f4544c4bda139c8 | rohith788/Leetcode | /Amazon/Trees and Graphs/ Symmetric Tree.py | 541 | 3.921875 | 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 isSymmetric(self, root: TreeNode) -> bool:
return self.checkSym(root, root)
def checkSy... |
b80d2b6c7f94f95ed024596fed2ea591c804ce97 | popucui/Learn_Python_The_Hard_Way | /ex192.py | 550 | 3.515625 | 4 | print "We are using this formula to calculate Tm value:\ntm = 64.9 + 41*(gc_num - 16.4) / total_num\n"
primer = raw_input(">>Please input(or paste) your primer sequence:")
primer = primer.lower()
total_num = primer.count('a') + primer.count('t') + primer.count('c') + primer.count('g')
gc_num = primer.count('g')... |
a8effe80885b32a4b9e8e6bea174de8b66275365 | advvix/py-course | /2.4.py | 542 | 3.78125 | 4 | import cs50
#4 Add rounding for the above x/y operation. Round to 2 decimal points. Hint: look up in Google "python limiting number of decimals". (1p)
s=True
while s==True:
X = cs50.get_int("X: ")
Y = cs50.get_int("Y: ")
if Y==0:
print("Nie mozna dzielic przez 0")
Y = cs50.get_int("Y: ")
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.