blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
4425aa8decb6aad48ce51fa05f1237692a74fb50
sandrastokka/phython
/day4/pulse.py
1,331
4.03125
4
import turtle def setupTurtle(): myTurtleInsideTheFunction = turtle.Turtle() myTurtleInsideTheFunction.penup() myTurtleInsideTheFunction.setpos(-300,0) myTurtleInsideTheFunction.pendown() myTurtleInsideTheFunction.color('green') myTurtleInsideTheFunction.pensize(3) return myTurtleInsideThe...
046ad4ed59497af37ea61f00ef1957d9c0edcc2e
genych/pygamecardstuff
/simple_cards_gui.py
2,243
3.5625
4
""" Simple game. Deck deals cards. Some cards can be flipped. Some can't (see MAGIC_CARD) """ import pygame from simple_cards import Deck, Card WINDOWWIDTH = 800 WINDOWHEIGHT = 600 FPS = 60 MAGIC_CARD = Card('Hearts', '7') class Game(object): def __init__(self): self.screen = pygame.display.set_...
5ac5408831557ec98439f22e1cc6bf78b60bdcaa
sebahattinozdemir/PYTHON
/1-temelVeriYapilariveObjeler/HipotenusBulma.py
240
3.65625
4
print("Hipotenua bulma programi...") print("Dik ucgenin dik olan iki kenarini giriniz...") a = int(input("1.kenari giriniz:")) b = int(input("2.kenari giriniz:")) hipotenus = (a**2 + b**2)**0.5 print("hipotenus:{}".format(hipotenus))
222cce7dde561f77c3457764b33b2bd2659a9ff2
sebahattinozdemir/PYTHON
/4-Fonksiyonlar/E.B.O.B.py
533
3.875
4
def ebob(number1,number2): temp = 0 if(number1>=number2): for i in range(1,number2+1): if(number2%i == 0 and number1%i==0): if(temp<i): temp = i else: if (number2 > number1): for i in range(1, number1+1): if (number2 % i == 0 and num...
160a9e826a8edac3b55d73637f9f5a76b1075d4a
sebahattinozdemir/PYTHON
/1-temelVeriYapilariveObjeler/AracOdeme.py
266
3.765625
4
print("Aracinizi kac kilometre gittigini ve km basina ne kadar yaktigini giriniz:") kurus = float(input("Kilometerede ne kadar yakiyor(ie:0.22) :")) kackm = int(input("Kac km yol yaptiniz :")) res = kurus*kackm print("Odemeniz gereken tutar :{}".format(res))
d96bb1f922a149783d0ed3a489c7b6e1ab51356d
TaranisenNaik2005/python-project
/po3.py
800
3.953125
4
print ('%20s' %"Rules") print ("1. The amount should be a positive integer") print ("2. the amount should be a multiples of 100") inp = int(input("\nEnter the amount :")) if inp>=2000: a = int(inp/2000) b = inp%2000 if b>=500: c = int(b / 500) d = b % 500 if d >= 100: e =...
62795e5c13db2d7293f9031fa28e66d0e80cf754
Estevam2302/Calculadora-de-IRPF-
/Script.py
1,728
3.90625
4
print('Bem vindo(a) ao "Devo pagar IRPF?"') print('Para saber se você deve ou não declarar imposto de renda responda algumas perguntas.') print('OBSERVAÇÕES: Caso não tenha recebido algum valor questionado digite 0') condição1 = float(input('Qual o valor obtido com venda de veículos ou imóveis? ')) if condição1 > 0: p...
73114535c8b80b31ff7986e01e6e25308a572f17
gresy06/python-programs
/time.py
120
3.859375
4
hours = int(input(enter your hours")) minutes = hours * 60 print(minutes,"minutes")
32aa8d814ed0276d4762835126f308a8d6bf8c4f
postfly/geekbrains
/python/lesson_7/hw_2.py
603
3.90625
4
from abc import ABC, abstractmethod class Clothes(ABC): def __init__(self, param): self.param = param @staticmethod def sum_cons(x, y): return x + y @abstractmethod def consumption(self): pass class Coat(Clothes): @property def consumption(self): return ...
35dabc066911987db032eb80337e9e6e9ad9ffe5
postfly/geekbrains
/python/lesson_3/hw_5.py
315
4.03125
4
def user_sum(): total = 0 working = True while working: numbers = input('Enter some numbers or q to exit: ') for num in numbers.split(): if num == 'q': working = False break total += float(num) return total print(user_sum())
6b568eb49138d63e712f8ed745cf977d3e393ae5
maiali13/cs-module-project-hash-tables
/applications/crack_caesar/crack_caesar.py
1,194
3.84375
4
# Use frequency analysis to find the key to ciphertext.txt, and then decode it. # need 2 fxns # 1st to encode char frequency # 2nd to decode text # List of alphabet letters in order of expected frequency, from most to least frequent frequency_list = ['E', 'T', 'A', 'O', 'H', 'N', 'R', 'I', 'S', 'D', 'L', 'W', 'U', ...
96f8e5677f44e3932f59c6d42f7d96903668678c
Lukeshark001/Pyhton-Work
/Pupils and sweets.py
192
3.78125
4
number_of_pupils = 16 number_of_sweets = 47 print("Please enter the number of pupils") try: number_of_pupils = int(input) if number_of_pupils <= 0:
0cd47d2458430fe21f3f9d022924960367f9ff1c
full-time-april-irvine/kent_hervey
/python/python_fundamentals/function-practice.py
82
3.734375
4
def add(a,b): x = a + b return x new_value = add(3,5) print(new_value)
6db336d85ca50ed47c03d654b23042187aff29bc
full-time-april-irvine/kent_hervey
/python/python_fundamentals/submission_functions_basicII.py
2,061
4.28125
4
#1 Countdown - Create a function that accepts a number as an input. Return a new list that counts down by one, from the number (as the 0th element) down to 0 (as the last element). #Example: countdown(5) should return [5,4,3,2,1,0] def countdown(top_number): out_list = [] for counter in range(top_number, 0-1...
fa9942918e905535089ba053d911f912b9791d52
full-time-april-irvine/kent_hervey
/python/python_fundamentals/submission_selection_sort.py
658
4.0625
4
def selection_sort(some_list): print("starting array ", some_list) for j in range(0, len(some_list)): min_value =some_list[j] min_index =j i=0 for i in range(j, len(some_list)): if some_list[i]<min_value: min_value = some_list[i] min_...
ee7ada3a920ba3845a85269550790240c0cadc83
tiejiang/python-learning
/loop
392
3.640625
4
#!/usr/bin/env python3 #-*-coding:utf-8-*- print("循环") sum=0 for n in range(101): sum=sum+n print('sum= ',sum) s=0 sum = 0 while s<5: sum = sum + s s = s+1 print("sum=", sum) print("loop test") i=0 s=["adfad","fadfa","adfafda","fadfadf"] while i<len(s): i=i+1 if i==1: continue if ...
d04323c63487797cefd1db8fbf9f84b11494d76f
WilliamLukeQA/QACWork
/Python/numbers.py
848
3.828125
4
number = int(input("Enter a number between 1-9999 ")) ones_list = {0: "zero", 1: "one", 2: "two", 3: "three", 4: "four", 5: "five", 6: "six", 7: "seven", 8: "eight", 9: "nine"} teens_list = {1: "ten", 2: "eleven", 3: "twelve", 4: "thirteen", 5: "fourteen", 6: "fifthteen", 7: "sixteen", 8: "seventeen", 9: "eigthteen...
5200bcf7021881d279be589ed7eb38b1325d65a6
WilliamLukeQA/QACWork
/Python/salary.py
706
4.09375
4
Salary = input("Enter Salary") Grade = input("Enter Grade") Dept = input("Enter Department") salary = int(Salary) grade = int(Grade) dept = Dept if salary > 15000: if dept == "IT": if grade < 11: tax = 9 if grade > 10: tax = 15 if grade == "CTO": ...
89a18199af09abe5f4e7c3767844252157bd0ea3
afcarl/Tictactoe_ENN
/Neuron.py
1,817
3.546875
4
# -*- coding: utf-8 -*- __author__ = 'Chason' import math class Neuron: def __init__(self,layer_num , node_num, value = -1, ): self.value = value self.input_neurons = [] self.theta = [] self.layer_num = layer_num self.node_num = node_num self.threshold = 0.5 def ...
416c56cf440b6ce010a48107c56e7e9145998825
zzploveyou/dictionary
/lib/parser.py
1,408
3.609375
4
"""parse dic txt file.""" import os import re def parse_dic(filename): """获取单词对应文本库中内容, 返回一个单词到释义的映射""" dic = {} if os.path.exists(filename): content = open(filename).read() # regex extract. for res in re.findall("#([^#]+?)\n([\s\S]*?)#|#([^#]+?)\n([\s\S]*)", ...
ac1428034d45bff85b9f796239140fdf5a2a1d17
Shah-Shishir/URI-Solutions
/1048 - Salary Increase.py
598
3.6875
4
x = float(input()) if 0.00 <= x <= 400.00: new_sal = x + x * 0.15; money = 0.15 * x; per = 15; elif 400.01 <= x <= 800.00: new_sal = x + x * 0.12; money = 0.12 * x; per = 12; elif 800.01 <= x <= 1200.00: new_sal = x + x * 0.1; money = 0.1 * x; per = 10; elif 1200.01 <= x...
e07531757d18d65656b850a79c0c12e306438eca
Shah-Shishir/URI-Solutions
/1044 - Multiples.py
134
3.5625
4
a,b = input().split() a,b = [int(a),int(b)] if b % a and a % b: print("Nao sao Multiplos") else: print("Sao Multiplos")
626577e92ffc57b7ecfbffc66abaeac4797982e8
Shah-Shishir/URI-Solutions
/1071 - Sum of Consecutive Odd Numbers I.py
147
3.625
4
a = int(input()) b = int(input()) if a > b: a,b = b,a sum = 0 for i in range(a+1,b,1): if i % 2 == 1: sum += i print(sum)
5cfcc1bca2e1adbd664cec157a17811f881db7dd
genfu94/Programming-Fundamentals-Course-Homeworks
/Homework2/program01.py
783
3.640625
4
'''Write a function stat(lst, first, last) that returns a list of length n = last - first + 1 such that its value at position k is the number of occurrences of the integer first + k in the list lst. It is assumed that lst is a list of integer and that first <= last. Example: stat([3, 0, 2, 78, 5, 3, 12, 10, 23, 7, 2...
6d120bf9177afc8e089793f66ee89f92e3f2db09
dliang2/csci127-assignments
/exam_01/compress.py
635
3.90625
4
def compress_word(w): compressed = w[0] # keep first letter for letter in w[1:]: # don't touch first letter if letter not in "aeiouAEIOU": # if not vowel, add letter compressed += letter return compressed print(compress_word('halloween')) print(compress_word('Special')) print(compr...
c4fd28c4b9f903d47d9a6a8e0afb00916220a86b
dliang2/csci127-assignments
/hw_02/pig.py
260
4.09375
4
# Darren Liang, Darren Zou vowels = ["a", "e", "i", "o", "u"] def piglatinify(word): if word[0].lower() in vowels: return word + "ay" else: return word[1:] + word[0] + "ay" print(piglatinify("Cake")) print(piglatinify("Apple"))
59f17ea4cfa2456d2d461f87ae64d0d2b8997a5a
dliang2/csci127-assignments
/exam_01/cake.py
421
3.625
4
def cake(A, B, u): slice = A / B # units of cake slice_count = u / slice # how many slices available invite_count = int(slice_count) # never round up return invite_count print(cake(5, 10, 1)) # expect 2 | .5 units per slice, 1 cake, 2 people print(cake(10, 5, 7)) # expect 3 | 2 units per slice, 7 c...
d0db0d3c1c163d779b1235948e91db3bd383c327
liupeng0606/SARAS-ESAD-Baseline
/modules/__init__.py
534
3.828125
4
class AverageMeter(object): """Computes and stores the average and current value""" def __init__(self, momentum=0.95): self.momentum = momentum self.reset() def reset(self): self.val = 0 self.avg = 0 self.count = 0 def update(self, val, n=1): if ...
3f9fde1ab34c7c38215c4a8851d1fc13e70563fb
RodrigoSierraV/holbertonschool-interview
/0x09-utf8_validation/0-validate_utf8.py
656
4.1875
4
#!/usr/bin/python3 """ Module to determine if a data set represents a valid UTF-8 encoding""" def validUTF8(data): """ A character in UTF-8 can be 1 to 4 bytes long The data set can contain multiple characters The data will be represented by a list of integers Return: True if data is a valid UTF-8...
93a9f412c74520ca2989a3d8a7004bfac48aca12
MartinTrojans/Leetcode-Python
/Remove Nth Node From End of List.py
847
3.625
4
__author__ = 'Martin' class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def removeNthFromEnd(self, head, n): """ :type head: ListNode :type n: int :rtype: ListNode """ num = 0 p = head ...
34cf271a19480ff2bc7b8071c8da4b8246d5298d
MartinTrojans/Leetcode-Python
/symmetric tree.py
744
4.03125
4
__author__ = 'Martin' # 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 isSymmetric(self, root): """ :type root: TreeNode :rtype: bool ...
468d695aef5ed3a1ad42202f0deea9da9e9f61f8
MartinTrojans/Leetcode-Python
/Min Stack.py
900
3.921875
4
__author__ = 'Martin' class MinStack(object): def __init__(self): """ initialize your data structure here. """ self.stack = [] self.minstack = [] def push(self, x): """ :type x: int :rtype: nothing """ self.stack.append(x) ...
bd5d06fdc0f12139ddbbb1099d59110b0a8ce50c
MartinTrojans/Leetcode-Python
/Missing Number.py
333
3.546875
4
__author__ = 'Martin' class Solution(object): def missingNumber(self, nums): """ :type nums: List[int] :rtype: int """ l = len(nums) sum = l * (l+1) // 2 x = 0 for i in nums: x += i return sum - x s = Solution() print(s.missingNum...
7cc75535117e12725bb3c3c9c997fecfdd9fd8d5
MartinTrojans/Leetcode-Python
/Range Sum Query - Immutable.py
820
3.640625
4
__author__ = 'Martin' class NumArray(object): def __init__(self, nums): """ initialize your data structure here. :type nums: List[int] """ i = 0 self.sum = [i for i in range(len(nums)+1)] self.sum[0] = 0 for i in range(len(nums)): self.sum...
7ce54428c9f433cfd93cf906b9c4a8669f2bbe08
1026minjae/BaekjoonAlgorithm
/2753.py
125
3.609375
4
year = int(input()) if year%4: print(0) elif year%400==0: print(1) elif year%100==0: print(0) else: print(1)
dd59d2f7b16929e4624c18373f7dcbd4707758f8
Th3lios/Python-Basics
/9.3 modulosYPaquetes.py
6,512
3.546875
4
#!/usr/bin/python # Trabajar con módulos es útil para mantener un programa ordenado y además para la reutilización de código más # sencilla # Para utilizar un Módulo hay que utilizar "import" import nombreMódulo ################################ IMAGINA QUE ESTE ES OTRO ARCHIVO ###### NBRE DEL ARCHIVO :...
cfbbc60c00935816419cdc6f348a8eab7803c78b
nikasnizhko/python_beetroot
/lesson5_homework.py
475
3.578125
4
# Task.1 Exclusive common numbers import random list_1 = [random.randint(1, 10) for number in range(0, 10)] list_2 = [random.randint(1, 10) for number in range(0, 10)] print(list_1) print(list_2) list_3 = set(list_1).intersection(list_2) #list_3 =list(set(list_1).intersection(list2)) print(list_3) # Task.2 Ex...
f28dbbc8eeede546e7f9ce9cf0fdae719fa1ec88
brian86258/Programming
/Python/pass_value_test.py
271
3.6875
4
arr = [] def modify_array(arr2): # will modify arr # arr2 += [3,3,3,3] # will also modify arr2.extend([4,4,4,4,4]) print('local arr2', arr2) def function1(arr): modify_array(arr) print('int function1',arr) function1(arr) print(arr)
f3ab64dace6c05f757a5081339b5d5c2bafeb961
romildodcm/learning_python
/python_for_Beginners/aula12_a.py
483
4.0625
4
#pi = 3.14159 #print(pi) first_num = 2 second_num = 6 # + addition on print ir concaten print(first_num + second_num) print(first_num ** second_num) #Esse inút mesmo teclando numero o python vai interpretar como string #e dará erro, explicado a seguir nos print a = input('First number: ') b = input('Second number: '...
6353cfea36d8df37214fd0b54d6844357086c6a9
romildodcm/learning_python
/extra_codes/chapter_3/exercise_3_2_2-5.py
672
4.1875
4
''' This function receives two arguments (a function and a variable) and runs twice the function with the parameter/variable: ''' def do_twice(function, argument): function(argument) function(argument) ''' A function presented in this chapter for printing twice, do_twice ismore general than print_twice: ''' d...
662af8302092b2814cb149b91b004960773ef781
romildodcm/learning_python
/more_python_for_Beginners/more_py_6_7_Classes.py
2,269
4.40625
4
""" Classes define data structures and behavior Why use classes - Creat reusable components - Group data and operations together Moving parts - Classes are nouns - Properties are adjectives - Methods are verbs """ # Creating a class # In Pyton by convention uses PascalCasing for classes names, # capital letter # cl...
5a5340fd15d1e3804156d2747909b67f4f3c3875
romildodcm/learning_python
/GUI/5_GUI_disable_button_widget.py
640
4.0625
4
import tkinter as tk from tkinter import ttk from typing import Text w = tk.Tk() w.title("Text box widget") def click_me(): action.configure(text = "Hello " + name.get()) # Changing our label ttk.Label(w, text="Enter a name: ").grid(column=0, row=0) # Adding a text box entry widget name = tk.StringVar() name_en...
fc7f620d4f9ab034e0827d47fa9f85db898b691e
romildodcm/learning_python
/python_for_Beginners/algoritmomenor30.py
356
3.84375
4
total = 0 contadorDeValoresInseridos = 0 while (total<30): totalMenorQueTrinta = total valor = float(input("Insira um valor: ")) total = total+valor if (total<30): contadorDeValoresInseridos = contadorDeValoresInseridos+1 print(f'Foram inseridos {contadorDeValoresInseridos} valores, somados to...
d986002b6459d0a8b239e81c9d4ce9b8ffafa6cb
Teja2229/3_assignment-321810305020-
/marks.py
146
3.828125
4
passmarks=35 print("passmarks=",35) usermarks=int(input("enter the usermarks:")) print("usermarks is greater than passmarks:",passmarks>usermarks)
9ad4e82b0b7d7d9d05b656070225bff4663728af
Robin329/Python3
/python_lab/1_3python_project/Chapter1/bitwise/bits.py
1,574
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Mar 5 22:37:25 2019 @author: Robin.J E-mail: jrb1451144759@gmail.com To: Life is short, I am learning python. """ ''' Functional wrapper around the bitwise operators. Deisgned to make their use more intuitive to users not familiar with the underlyin...
c1f6c3ba1d715092059842b9be7bb0d8f2041125
Robin329/Python3
/python_lab/1_1door/hello.py
381
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jan 1 15:31:50 2019 @author: apple """ #1.input输入例子 temp = input("请输入:") #helloguess = int(temp) if temp == 'hello': print("ok") else: print("error") print("game end!") #2.while例子 count = 0 while (count < 9): print('The count is:', count)...
2fcc2caca039ece7509ae42e04be6bf64d5ad41e
den01-btec-2020/text-based-adventure-Scott3142
/src/main.py
2,792
4.125
4
def main(): user_name = input('Welcome to this game! What is your name? ') print(f'\nWelcome {user_name}! We have a task ahead of us! The base is about to explode. You must collect the four hidden items and bring them back here. Each item will give you part of a code to enter in the final challenge. If you ...
79cbf4455af3632788d303384f98883a455dab08
lindsaymarkward/in_class_2019_2
/week_01/warm_up.py
432
4.0625
4
""" Warm up for 01 - Beginnings Write pseudocode to ask the user for their age and tell them if they are an adult or child Write Python code for that """ """ get age if age > 18 print adult else print child """ AGE_THRESHOLD = 18 age = int(input("Age: ")) if age >= 18: print("Adult") else: print("Ch...
96df454ebe0b5c643f46e5b1e0ed24afab6f5e12
lindsaymarkward/in_class_2019_2
/week_02/warm_up.py
822
4.15625
4
""" Ask the user to guess a number between 1 and 10 and keep asking until they get it right. Use a CONSTANT for the secret number Just use "? " as the prompt for now """ # SECRET_NUMBER = 6 # number = int(input("? ")) # while number != SECRET_NUMBER: # print("No") # number = int(input("? ")) # print("Right") ...
40bfce0e79080d5b867955be1ba561396edfa229
roshstar1999/Daily-Leetcode
/String_to_integer.py
1,766
3.53125
4
class Solution: def myAtoi(self, s: str) -> int: num="" try: #if string is already an integer x=int(s) #check if it is within the bound limits given in ques if x<(-2)**31: return (-2)**31 elif x>(2**31)-1: ...
04ce8d118e8ad9071541e9591c394576b8c843c8
CosyCagesong/PythonCrashCourse
/02helloworld01.py
524
4
4
string = "HeLLo woRld!" print(string.title()) print(string.upper()) integer = 18 flt = 3.141 format_string = f"a{string}b{integer}c{flt}" print(format_string) print("A very long string " "can be put into several lines. " f"Hi, {string}" ) message = "Another long message" message += "\n placed across several lines." rm_...
deded80f1e1348085b1a14eb9737a2970b702650
CosyCagesong/PythonCrashCourse
/11testing_your_code01.py
1,245
4.25
4
import unittest#The module <unittest> provides tools for testing your code. from mymodule import factorial#The function factorial is to be tested. class FactorialTestCase(unittest.TestCase): #We create a class that inherits from <unittest.TestCase> #This test case has three unit cases, each of which implemented by a m...
1e82fb613331ec78f1a2e84e44f5418bb4114695
hongseunggi/Python_Algorithm
/day1/OptimizationCalculatePrimeNumber.py
1,107
3.6875
4
"""Normal Calculation""" counter = 0 ptr = 0 prime = [] prime.append(2) ptr += 1 prime.append(3) ptr += 1 for n in range(2, 1001): for i in range(2, n): counter += 1 if n % i ==0: break #else : # print(n) print(f'counter = {counter}') """First Optimization Normal Calcul...
7d0027bed711edb86d7098fa939223b250bc1e94
Ashkan-Soleymani98/ComputerSimulation---Fall2018-2019
/Assignments/Assignment2/Q2.py
1,889
3.65625
4
import random import numpy as np import math print("Please Enter the Poisson Parameters List Size:") n = int(input()) print("Please Enter the Poisson Parameters in this Format: Time Parameter ") print("Such as:") print("0 0.066") print("30 0.2") print("40 0.142") print("...") times = [] parameters = [] for i in ran...
45ca892f2d10a278746d91278c02774e6beff00e
JeongMin-98/algorithm
/.vscode/list2/이진검색.py
376
3.875
4
def binarySearch(a, key): start = 0 end = len(a)-1 while start <=end: middle = start + (end - start) // 2 if key == a[middle]: return True elif key < a[middle]: end = middle - 1 else: start = middle + 1 return False list1 = list(ra...
c352c7a36e80f2c11e389097d631a2b23e36c47f
blackadar/shepherd
/server/processor.py
1,102
3.671875
4
""" Defines an Interface for a Data Processor. This interface will receive data updates from all Nodes, when the Collector receives them. """ import abc class Processor(abc.ABC): """ Guarantees the availability of the following for an implementation. Called by Collector with new data. """ @abc.ab...
36b392b51d46249018f6cd4ffaf05e37742e8580
bawejagb/Artificial_Intelligence
/Heuristic_Search/Best_First_Search.py
3,337
3.53125
4
''' Q1- 8 puzzle problem (BEST FIRST SEARCH) Made By: Gaurav Baweja ''' import copy as cp def Show(arr): print("------") for lis in arr: for elm in lis: print(elm,end="|") print() print("------") def Position(val,arr): for i in range(len(arr)): for j in range(len(a...
2214d6e0c7ba028105abbd47c1fc9d0b161f6652
bbrayan/Cryptography-Library
/cryptography_library.py
111,279
3.53125
4
# author Brayan Boukhman import math import string import mod import matrix import utilities # ----------------------------------------------------------- # Parameters: fileName (string) # Return: contents (string) # Description: Utility function to read contents of a file # Can be used to read...
2e7493f85e9d50b5b6dc37245ab6ed1530a2a99a
kruthikaneelam/programs
/que10.py
207
3.90625
4
x=(input("enter num")) y=(input("enter num")) z=(input("enter num")) def sum(x,y,z): if x==y: return 0 elif x==z: return 0 elif y==z: return 0 else: return x+y+z v=sum(x,y,z) print(v)
92c3e8354c2a1fee1d66700ea1956356ba233a0b
Pumpel/Data-Structure-and-Algorithms
/2.1 Algorithmic Toolbox/Week 3 Greedy Algorithms/02_greedy_algorithms_starter_files/different_summands/different_summands.py
436
3.65625
4
# Uses python3 import sys def optimal_summands(n): summands = [1] Test = 2 Total = 3 while (Total <= n): summands.append(Test) Test += 1 Total += Test summands[-1] += n - (Total - Test) return summands if __name__ == '__main__': input = sys.stdin.read() n = int(...
30da8067c7d90c1e29f79738921c82d6df556d53
Pumpel/Data-Structure-and-Algorithms
/2.1 Algorithmic Toolbox/Week 3 Greedy Algorithms/02_greedy_algorithms_starter_files/fractional_knapsack/fractional_knapsack.py
865
3.609375
4
# Uses python3 import sys def get_optimal_value(capacity, weights, values): value = 0. # write your code here vpw = [x/y for x, y in zip(values, weights)] vpw, weights, values = zip(*sorted(zip(vpw, weights, values), reverse=True)) print(vpw) print(values) print(weights) rem = capa...
19f39aa1837eb808406d23618b87c2766f5be5c7
Faraz126/Python-translation-of-Tin-Man
/TinMan/Geometry/Vector2.py
2,320
3.515625
4
from Geometry import angles import math class Vector2: epsilon = 0.0001 def __init__(self,x,y): #constructor self.x = x self.y = y #Static Utility Mehtods def get_dot_product(a,b): return a.x*b.x + a.y*b.y #End #Properties def __get_is_zero(self): ...
0917e3fc8b0000895014a2b291578a1788acddf5
FrankieVN/CapStone2
/taskplay.py
5,231
3.78125
4
import pygame import random # Initializing pygame modules. pygame.init() # Creating the game screen and adding height and width values to it. screen_width = 1900 screen_height = 1024 screen = pygame.display.set_mode((screen_width, screen_height)) # Loading images for each of my objects in the game. player = pygam...
cdbc518ac9e948ab878e5648a833c75ad17ae9df
aniw565/progress-evaluation-of-startups
/progress evaluation of startups/50startupprogress1.py
1,018
3.828125
4
#importting the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd #importing the dataset dataset = pd.read_csv('50_Startups.csv') X = dataset.iloc[:, :-1].values y = dataset.iloc[:, 4].values # Encoding categorical data from sklearn.preprocessing import LabelEncoder, OneHotEn...
e82b7e6d9750ef824eac5393bc384e8e62eb70e8
skilbjo/google-challenges
/2. zombit/solution.py
556
3.765625
4
def answer(intervals): time_arr = [] for interval in intervals: start = interval[0] end = interval[1] hours = [hour for hour in range(start,end+1)] for hour in hours: if hour not in time_arr: time_arr.append(hour) time_arr.sort() return time_arr[len(time_arr) - 1] - time_arr[0] def test(fn,input...
155550dc4121b734ae388d6f3aa0215bac7558dd
Amudha2019/INeuron-Assignment-1
/Ass1pg2.py
202
3.8125
4
#Python program to find numbers divisible by 7 not multiple of 5 between 2000 and 3200 a1=[] for y in range(200,3201): if(y%7==0) and (y%5!=0): a1.append(str(y)) print(','.join(a1))
28de15f117119af78ee86e5da386c4d4520ac2dd
rowdynagi/nagendra-reddy-.k
/K.Nagendrareddy.py
1,340
4.1875
4
K.Nagendrareddy.py import random min = 1 max = 6 roll_again = "yes" while roll_again == "yes" or roll_again == "y": print "Rolling the dices..." print "The values are...." print random.randint(min, max) print random.randint(min, max) roll_again = raw_input("Roll the dices again?") Recommended Py...
ec7a704d1e81a59c69c9a15be2b7096fe1fa1415
wrCisco/adventcode2020
/day08/day08.py
1,673
3.515625
4
#!/usr/bin/env python3 class Computer: def __init__(self): self.accumulator = 0 self.pointer = 0 self.ops = { 'acc': lambda v: (self.accumulator + v, self.pointer + 1), 'jmp': lambda v: (self.accumulator, self.pointer + v), 'nop': lambda v: (self.accumu...
cef358072a209036b21daadfef08c635c432c36a
kongkongNG/OO-Beat-Detector-of-Expression-Derivation
/judge.py
429
3.859375
4
from sympy import * import sys x = Symbol("x") mystr = input() anstr = input() if (mystr==anstr): print(True) sys.exit(0) mystr = mystr.replace("^", "**") #change '^'into'**' for recognition anstr = anstr.replace("^", "**") anexp = eval(anstr) myexp = eval(mystr) # turn str into expression if (is...
8b4ebbf004b25b64cd6f6738d3103f5f9a5603e6
basakulcay/Python_Fundamentals
/x_file.py
559
3.84375
4
# Write your x_length_words function here: def x_length_words(sentence,x): word=sentence.split(" ") lengths=[] for w in word: length=len(w) lengths.append(length) counter=0 for i in lengths: if i>=x: counter+=1 if counter==len(word): return True else: return False #if lengt...
6083f4cf20710f1361b21b22ce7b39abcd81cf79
basakulcay/Python_Fundamentals
/medical_insurance.py
1,876
3.53125
4
# Add your code here medical_costs = { "Marina":6607.0,"Vinay":3225.0 } medical_costs.update( {"Connie":8886.0,"Isaac":16444.0,"Valentina":6420.0} ) print(medical_costs) medical_costs.update({"Vinay":3325.0}) print(medical_costs) total_cost = 0 for i in medical_costs.values(): total_cost+=i print("The tota...
9cbabe6d4f95864b9e1d9043090add3a3089174e
maayanbrodsky/simple-bank-system
/Topics/Class/The housing problem/main.py
205
3.5625
4
# definition of the class class House: def __init__(self, construction): self.construction = construction self.elevator = True # object of the class House new_house = House("building")
99aedf020676fc4e4dd9f7d928037296ab19c458
johnsocf/3308_Lab_5
/python_code_kata/arrays_and_strings/substring_w_max_k_chars.py
336
3.796875
4
# Given a string, find the length of the longest substring T that contains at most k distinct characters. # ex1. Input: s = "eceba", k = 2 Output: 3 Explanation: T is "ece" which its length is 3. # ex2. Input: s = "aa", k = 1 Output: 2 Explanation: T is "aa" which its length is 2. # test with examples and explai...
7da5eef918f6d76f90cff4c7283b91e35dbe1754
amol-a-kale/sele_python
/pytestfunctions/arithmetic_module.py
341
3.84375
4
def add(x, y): print('adding two numbers {} &{}'.format(x, y)) res = x + y return res def mod(x, y): print('Mod two numbers {} &{}'.format(x, y)) res = x % y return res # output = mod(20, 10) # print(output) def product(x, y): print('product two numbers {} &{}'.format(x, y)) res = ...
c72f1b9dee59fc4645dfcddb3eaacbd0ac926e8e
HafizaSanam/SP
/python1stLab/t3.py
238
3.84375
4
num = raw_input("Enter Comma numbers") list1 = [] tup = () str1 = '' for i in range(0 , len(num)): if num[i] == ',': list1.append(str1) str1 = '' else: str1 += num[i] list1.append(str1) tup = tuple(list1) print list1 print tup
2b49717b6bcbbc2c245cd62416b338f2b5962aa9
VatsalP/maze_generation
/prims_algorithm.py
4,013
3.875
4
#!/usr/bin/env python # coding: utf-8 # # Maze generation using Prim's algorithm # In[7]: import time import numpy as np from matplotlib import pyplot from numpy.random import randint, shuffle, seed # The following maze generation is of passage carver type i.e. it starts with filled space and carves passage. # ...
5b96c2dab2536173e9384654ef392cd666f97235
tawanchaiii/01204111_63
/ELAB08/rr.py
171
4
4
s = int(input()) m = int(input()) if m-2 <= s - (2*m-2) < m : print("Surprising") elif m-1 <= s - (2*m-1) < m : print("Surprising") else : print("Not surprising")
437d6fe8a8097983b70ad98418d9a5c6ccee36db
tawanchaiii/01204111_63
/ELAB03/03-08.py
315
3.625
4
arr = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'] n = 1 while True: dec = int(input("Input Decimal: ")) if dec == -1 : print("Good bye.") break else : octal = '' while dec > 0: octal = arr[dec%16] + octal dec = dec // 16 print(f"Hex: {octal}")
329e8f82cb90619c9d0d6940cf1168d7acbedab3
tawanchaiii/01204111_63
/ELAB04/04-10.py
161
3.5
4
x = input() c = True for i in range(len(x)) : y = input() if (x[i] != y) : print("Fail!!") c = False break if (c) : print("Succeed!!")
45c40c7caefad7fb585b66b5e387c29c6c09195b
tawanchaiii/01204111_63
/ELAB11/11-02.py
391
3.796875
4
import csv def fu(name): with open(name) as file: reader = csv.reader(file) next(reader) A = list() for row in reader : A.append(float(row[4])) print(f"Minimum: {min(A):.2f}") print(f"Maximum: {max(A):.2f}") print(f"Average temperatur...
0a4c7aeb252b490ea26bc1e5994c8547a615dfc9
tawanchaiii/01204111_63
/ELAB01/01-12.py
325
4.03125
4
a = int(input()) b = int(input()) c = int(input()) if a>=b: if b>=c: print(f"{c} {b} {a}") else: #b < c if a>=c: print(f"{b} {c} {a}") else: print(f"{b} {a} {c}") else: if a>=c: print(f"{c} {a} {b}") else: #a < c if c>=b: print(f"{a} {b} {c}") else: print(f"{a} {c} {b...
bf9a4ba727c94c6c2d124c503b5a2e2ec7552cbb
tawanchaiii/01204111_63
/ELAB06/lab06_01.py
535
3.890625
4
def zero(n): m = [] for i in range(n): b = [] for j in range(n): b.append(0) m.append(b) return m def plus_matrix(A,B) : arr = zero(3) for i in range(3): for j in range(3): arr[i][j] = A[i][j]+B[i][j] return arr def print_matrix(A): for i in ran...
4fa747b52cb828076c8ad45024dcf85bb9124304
tawanchaiii/01204111_63
/ELAB12/12-07.py
192
3.96875
4
def gcd(a,b): if (b != 0) : return gcd(b, a % b) else : return a a = int(input("a : ")) b = int(input("b : ")) print(f"GCD : {int(gcd(a,b))}") print(f"LCM : {int(a*b/gcd(a,b))}")
3b56cf4524436c2f3486f17fed2f90e43bc48f27
tawanchaiii/01204111_63
/ELAB12/12-06.py
319
3.515625
4
n = int(input("n: ")) A = [[False]*n for _ in range(n)] x = int((n-1) /2 ) for i in range(n): A[i][i] = True A[i][n-1-i] = True A[i][x] = True A[x][i] = True for i in range(n): for j in range(n): if A[i][j] == True : print("+",end='') else : print(" ",end='') print()
49ba3f1eccfe857f8f677b8a464c6c11583ff402
tawanchaiii/01204111_63
/ELAB02/02-02.py
402
4.21875
4
w = int(input("Weight: ")) h = int(input("Height: ")) bmi = w/((h/100)*(h/100)) if bmi < 18.6 : print(f"Your BMI is {bmi:.1f} You're in the underweight range.") elif bmi < 25: print(f"Your BMI is {bmi:.1f} You're in the healthy weight range.") elif bmi < 30: print(f"Your BMI is {bmi:.1f} You're in the overwe...
198b4d436e94f8d7f671472e418dd3523a9e8c5a
tawanchaiii/01204111_63
/ELAB08/08-02.py
675
3.5
4
def func(file): data = file.read() a = data.split('\n') lis = [i.split(' ') for i in a] b1 = [] for i in range(len(data)): if data[i] == '.' and i != len(data)-1: if ord(data[i+1]) >= 48 and ord(data[i+1]) <= 57 and ord(data[i-1]) >= 48 and ord(data[i-1]) <= 57: ...
c49c7bb3b8c38a0b17bb3b5b2a0919b6c9d4da3f
tawanchaiii/01204111_63
/ELAB04/04-03.py
650
3.625
4
jum1 = ['A','2','3','4','5','6','7','8','9','10','J','Q','K'] jum2 = [0 for i in range(13)] def add(s): for i in range(0,13) : if (s == jum1[i]) : jum2[i] += 1 card = list(map(str,input("Cards: ").split())) for i in card : add(i) four = False three = False two = 0 for i in jum2: ...
023ee306d63f190415deeae632b135b91e9fb670
pasternakmaxim/fit122
/calculator.py.py
770
4.3125
4
what = input ("Выберите знак (+,-,/,*,**,//,%): ") a = float( input("Введите первое число:") ) b = float( input("Введите второе число: ") ) if what == "+": c = a + b print("Результат: " + str(c)) elif what == "-": c = a - b print("Результат: " + str(c)) elif what == "/": c = a / b print("Результ...
7e96fdc558398102e7dbb3dc72ad9fa15bdb8996
pdvelez/miscellaneous_exercises
/operations_with_strings/anagram_detection.py
1,756
4.15625
4
""" This exercise can be found at http://interactivepython.org/runestone/static/pythonds/AlgorithmAnalysis/AnAnagramDetectionExample.html """ def anagram_solution_1(s1, s2): """ O(n^2) operation """ alist = list(s2) pos1 = 0 still_ok = True while pos1 < len(s1) and still_ok: pos2 = 0 ...
7bf82798a1dbab298e163c3fc5425ac33da2fd20
Shamitbh/ITP-115
/Assignments/ITP115_a3_Bhatia_Shamit/ITP115_a3_Bhatia_Shamit.py
3,757
4.15625
4
# Shamit Bhatia # ITP 115, Fall 2016 # Assignment 3 # Shamitbh@usc.edu # Part 1: Translate an English word into Pig Elvish: import random # Welcome message print("\n\nWelcome to the Pig Elvish translator!\n") # Use while loop to ask user to enter word in English repeat = True while (repeat == True): engWord ...
7c63933eef2e991f804fc055d8333e3e7de06560
Shamitbh/ITP-115
/Lecture Notes/Lecture Notes 9-15-16.py
716
4.375
4
# Lists are mutable # Can make slices i.e [1:4] goes to number - 1 nums = [3, -12, 5] nums[0] = 46 # now list is [46,-12,5] nums[0:2] = [7,9] #subsitute 0 and 1 index as 7 and 9 -> list is now [7,9,5] nums[0:2] = [13] # now list is [13,5] # List Methods: # someList.append(value) #Adds value to end of a list # some...
27c7081eaa45e79372ebdbc78157f3e3dbad8f93
Shamitbh/ITP-115
/Lecture Notes/Pokemon.py
576
3.703125
4
def main(): # get filename from user fileName = input("Enter a pokemon file: ") # open the file fileIn = open(fileName, "r") # read file count = 0 pokemonList = [] for line in fileIn: line = line.strip() # print(line) count += 1 if line[0].lower(...
29d1a5325e550948e59a0012deb3f333e3cc05ad
Shamitbh/ITP-115
/Assignments/ITP115_a10_Bhatia_Shamit/Human.py
723
3.65625
4
from Being import Being class Human(Being): def __init__(self, name, quarts, bloodType): # call parent constructor super().__init__(name, quarts) # set up new attribute representing human's blood type self.__mBloodType = bloodType def getBloodType(self): return self....
c3f07d07eadcafcbe9e7cc9c3839ac612a5c2404
Shamitbh/ITP-115
/Labs/ITP115_l4_Bhatia_Shamit.py
1,497
4.375
4
# Shamit Bhatia # ITP 115, Fall 2016 # Lab L4 # Shamitbh@usc.edu print("\nWould you like to: \na) See the ASCII code for the alphabet\nb) Translate a word into its ASCII code") choice1 = input("Select a or b: ") #choice1 either a or b (user input not case-sensitive) while(choice1.lower() != "a" and choice1.lower() !...
51075afc9e1f4e9809ef8e821ddd3fc0e0461d2e
Shamitbh/ITP-115
/Assignments/ITP115_a1_Bhatia_Shamit/ITP115_a1_Bhatia_Shamit.py
1,052
4.09375
4
""" Shamit Bhatia ITP 115 Assignment 1 9/1/2016 Description: This program creates a Mad Libs Story """ animalPlural = input("Enter an animal (plural): ")# adjectiveOne = input("Enter an adjective (emotion): ")# adjectiveTwo = input("Enter another adjective (color): ")# verb = input("Enter a present-tense verb ending ...
e20c6d1a516e943e18fce14d1374703e9adedc90
Shamitbh/ITP-115
/Lecture Notes/Lecture Notes 9-22-16.py
945
3.8125
4
# Functions, continued # Scope (if a variable is in a function, its local to only that function # Constants are ALL_CAPS_WITH_UNDERSCORES # Global constants are created in global namespace # They are defined on left side (not in functions) # Will not change value once they are assigned # Main() function is o...
4706233853956008c08fbbd8dcf0546960e31c4c
Shamitbh/ITP-115
/Assignments/ITP115_a7_Bhatia_Shamit/ITP115_a7_Bhatia_Shamit.py
5,512
4.125
4
# Shamit Bhatia # ITP 115, Fall 2016 # Assignment 7 # Shamitbh@usc.edu # Purpose: Create a program simulating a user's music library with Dictionaries. import pickle import random def main(): # loadlibrary musicDCT = loadLibrary("music_library.dat") # loop through menu loopControl = True while ...
ffa8ff24d96d92149cdf4416a8d41cee2775fa61
Ten-Point-Touchdowns/Football-Analyses
/test.py
3,437
3.5
4
#!/usr/bin/env python # charles mceachern # summer 2015 # json football data sanity check import json # for accessing the data files import os # for navigating directories # note: team names are not always 3 characters. use split(). def main(): # navigate to the root of the data directory os.chdir('../F...
3cd49a0e2c79eeb54d6b3494c14de2c0fa030ac4
anupjungkarki/IWAcademy-Assignment
/Assignment 1/DataTypes/answer34.py
183
3.703125
4
# Write a Python script to merge two Python dictionaries. dic1 = {'name': 'Anup', 'address': 'kathmandu'} dic2 = {'age': 21, 'occupation': 'programmer'} dic1.update(dic2) print(dic1)
54868e7ba14d983e178095b8b9183dbaff420abb
anupjungkarki/IWAcademy-Assignment
/Assignment 2/answer10.py
804
4.09375
4
# Write a function that takes camel-cased strings (i.e.ThisIsCamelCased), and converts them to snake case (i.e. # this_is_camel_cased). Modify the function by adding an argument,separator, so it will also convert to the kebab case # (i.e.this-is-camel-case) as well. def change_case(str, separator): res = [str[0...