blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
4e8c7706f48ef1491646cf196da70e241ae28f25
epangar/python-w3.exercises
/Python_basics/11-20/18.py
251
3.953125
4
""" 18. Write a Python program to calculate the sum of three given numbers, if the values are equal then return three times of their sum. """ def sum_three(a, b, c): if a == b and a == c: return a * 9 else: return a + b + c
e3459e66daea9d2747d6b5e5f05db326b8f2a127
epangar/python-w3.exercises
/String/1-10/5.py
343
4.125
4
""" 5. Write a Python program to get a single string from two given strings, separated by a space and swap the first two characters of each string. """ def style_str(str1, str2): answer1 = str2[0:2] + str1[2:] answer2 = str1[0:2] + str2[2:] answer = answer1 + " " + answer2 return answer print(s...
32d14f8e87d546b58f70cf389699dbea39c13f73
epangar/python-w3.exercises
/Python_basics/51-60/57.py
333
3.984375
4
""" 57. Write a program to get execution time (in seconds) for a Python method. """ import time def sum_of_numbers(n): start_time = time.time() print(start_time) s = 9 for i in range(1, n+1): s += 1 print(s) end_time = time.time() return s, end_time - start_time print(sum_of...
3f12cfba4069f64e2c4218935ae0649fbb5d05bd
epangar/python-w3.exercises
/String/1-10/2.py
327
4.28125
4
""" 2. Write a Python program to count the number of characters (character frequency) in a string. """ def count_char(str): dict = {} for i in range(0, len(str)): key = str[i] if key in dict: dict[key] += 1 else: dict[key] = 1 return...
f3ffb14c141d2e1475b565241d51de402e8a2f9c
epangar/python-w3.exercises
/Python_basics/31-40/38.py
131
3.578125
4
""" 38. Write a Python program to solve (x + y) * (x + y). """ def power_of_sum(x, y): return (x ** 2) + (2 * x * y) + (y ** 2)
234739e31427ffcbeb1d3131466944b03f88d160
MaxCodeXTC/bar_chart_race
/bar_chart_race/_utils.py
7,863
3.75
4
import pandas as pd def load_dataset(name='covid19'): ''' Return a pandas DataFrame suitable for immediate use in `bar_chart_race`. Must be connected to the internet Parameters ---------- name : str, default 'covid19' Name of dataset to load from the bar_chart_race github repository. ...
40a37c97eb3037c32d7b95938cee762a0b9227c2
konicaRu/python_task
/LineAnalysis.py
704
3.53125
4
def LineAnalysis(line): arr_dot = [] arr_star = [] elem_dot = '' elem_star = '' for i in range(len(line)): if line[i] == '*': elem_star += '*' if line[i] == '.' and elem_star != '': arr_star.append(elem_star) elem_star = '' if li...
6d4aeec5f39d00da15e7ad11d59af4a4f263ecca
konicaRu/python_task
/test_Heap.py
2,350
3.671875
4
import unittest import Heap class MyTestCase(unittest.TestCase): def test_arr12(self): heap = Heap.Heap() a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] arr = heap.MakeHeap(a, 3) count = 0 for i in arr: if i !=None: count +=1 self....
f20f9e9f5339f87b623e14a3ddb5580487bdb029
konicaRu/python_task
/test_HeapSort.py
1,955
3.59375
4
import unittest import HeapSort class MyTestCase(unittest.TestCase): def test_arr_ten(self): a = [1, 1, 1, 2, 3, 4, 5, 6, 7] heap = HeapSort.HeapSort(a) self.assertEqual(heap.HeapObject == [7, 6, 4, 5, 1, 1, 3, 1, 2], True) self.assertEqual(heap.GetNextMax() == 7, True) ...
eee36f7099e3294ad84c6e4e0347b8b844327df6
pritamrajak/Python_HackerRank
/8. Power - Mod Power.py
87
3.53125
4
a, b, m = [int(input()) for _ in range(3)] print(pow(a, b)) print(pow(a, b, m))
80bdd0243adecd3f183a4c865f406bf35a1d676f
pdshah77/Python_Scripts
/Input_Not_Required/ValueEqualIndex.py
527
3.84375
4
''' A fixed point in an array is an element whose value is equal to its index. Given a sorted array of distinct elements, return a fixed point, if one exists. Otherwise, return False. Given [-6, 0, 2, 40], you should return 2 Given [1, 5, 7, 8], you should return False ''' def ValueIndex(array): # Since...
2afa17246ba3754f0694b361e4d8f6cbc0df047d
pdshah77/Python_Scripts
/Input_Not_Required/PreFixMapSum.py
776
4.28125
4
''' Write a Program to Implement a PrefixMapSum class with the following methods: insert(key: str, value: int): Set a given key's value in the map. If the key already exists, overwrite the value. sum(prefix: str): Return the sum of all values of keys that begin with a given prefix. Developed By: Parth Shah Python ...
dfe783213da29c5582f1399929035c93a2306c2a
pdshah77/Python_Scripts
/Input_Required/Fibbonaci_series.py
506
4.03125
4
''' Write a Program to Find Fibbonacci Series upto n Input: n = 5 Output: 1,1,2,3,5 Developed By: Parth Shah Python Version: Python 3.7 ''' import sys try: n = int(input("Enter Number to Find Fibonnaci Series Upto ")) except ValueError: print("Given Input is Not a Valid") sys.exit() def Fibbonacci(n): ...
4672727f90f582a1da1941396263169de90752b3
omer19-meet/yl1201718
/turtle_shapes.py
314
3.53125
4
import turtle #turtle.speed(50) #turtle.pensize(5) #a = 1 #for n in range(5): # turtle.forward(140) # turtle.right(144) # turtle.color(color_list[a]) # a += 1 #turtle.mainloop() turtle.register_shape("e3", ((0,50), (50,50), (100,25), (50,0), (0,0))) turtle.getshapes() turtle.shape("e3") turtle.mainloop()
af082c2e8d59422370246cec0abb3308698fbd1b
omer19-meet/yl1201718
/lab3.py
324
3.5625
4
import turtle # turtle.addshape("redmeat.gif") # turtle.shape("redmeat.gif") # turtle.mainloop() turtle.speed(1000) for a in range(360): turtle.pendown() turtle.right(a+1) turtle.forward(100) turtle.right(50) turtle.forward(40) turtle.right(90) turtle.forward(20) turtle.penup() turtle.home() turtle.mainloop...
cdd379204ce5c8356d70c95918dec75f83faa64a
EmaniHunter/CSE-231
/proj11.py
21,180
4.03125
4
############################################################################### # Computer Project 11 # Alogrithm # focus: practice classes and file handling # design two classes to help with reading and writing CSV files # two classes: Cell class and CsvWorker class # ...
4d913d0d3be315d5a1079b6e864fe153c854a3d7
EmaniHunter/CSE-231
/proj06.py
6,598
4.125
4
############################################################################## # Computer Project 6 # # Alogrithm # focus: tuples/lists # defined functions # define an open file function to open a data file that is found # read data function to ask for correct inp...
4b291a5471544c529f56620292513aa52a7d694c
Flact/python100
/Codes/day_25/main.py
1,551
3.890625
4
# # with open("weather_data.csv") as data_set: # # data = data_set.readlines() # # print(data) # # # # import csv # # # # with open("weather_data.csv") as data_set: # # data = csv.reader(data_set) # # temperature = [] # # for row in data: # # # print(row[1]) # # if row[1] != "temp": ...
2310cc6862d5ca08e73b1c82ec2cddcfdf2c085a
Flact/python100
/Codes/day_26/dict/dict_c.py
983
3.828125
4
# import random # # names = ["Aaaa", "Bbbb", "Cccccccc", "Ddddddd", "Eeeeeee", "Ffff"] # # student_scores = {student: random.randint(1, 100) for student in names} # # print(student_scores.items()) # # passed_students = {student: mark for (student, mark) in student_scores.items() if mark > 50} # # print(passed_students)...
35615a6933af9421794d96c35d06310a87ac0562
Flact/python100
/Codes/day_02.py
2,417
4.3125
4
# it will print "H" # print("Hello"[0]) # --------------------------- # type checking # num_char = len(input("What is your name? ")) # this print function will throw a erorr # print("Your name has " + num_char + " Characters") # ----------------------------------------------------- # print(type(num_char)) # the fi...
edd17e6ae441888ea4ea37c64c203075231f5e79
Flact/python100
/Codes/day_05/loop_with_range.py
292
4.28125
4
# for number in range(1, 10): # print(number) # this will print 1 - 9 (not include 10, but include 1) # this will print 1 - 10 numbers step by 3 # for number in range(1, 11, 3): # print(number) # total up to 100 total = 0 for num in range(1, 101): total += num print(total)
8f377b0b39b8dcd1f537b49e041218635e6da7db
Flact/python100
/Codes/day_15/coffee_machine/test.py
305
3.65625
4
for x in range(5): print(x) t = 8 print(type(t)) if type(t) == "int": print("Good") i = 100 f = 1.23 print(type(i)) print(type(f)) print(isinstance(i, int)) print(isinstance(f, int)) # a = (input("Wrong input, Do you want to start again? (y/n)").lower() in ["y", "n"]) == "y" # print(a)
90767636410c1ab95fabccdaafb22df17cfe299c
kameliacindy/labpy06
/program2/view/input_nilai.py
573
3.53125
4
def input_nama(): global nama nama = input("Nama : ") return nama def input_NIM(): global NIM NIM = input("NIM : ") return NIM def input_tugas(): global tugas tugas = int(input("Nilai Tugas : ")) return tugas def input_uts(): global uts uts = int(input("Nilai UTS : ")) re...
26ceadbc26f908353654496ca4671b32977650de
priyapriyam/practices_questions
/students_expenses.py
305
3.734375
4
user_input=input("Number of students") user_input1=input("Ek student ka kharcha") expense=0 student=0 while student <= user_input: expense=student*user_input1 student=student+1 if 50000 >= expense: print "hum budget ke andar hai" else: print "hum budget ke bahar hai"
6af171002c0464f23e5994494d370f32bcfa2d75
Nicky-he/pygorithm
/pygorithm/string/anagram.py
801
3.96875
4
# Author: OMKAR PATHAK # Created On: 17th August 2017 from collections import Counter def is_anagram(word, List): ''' ANAGRAM: An anagram is direct word switch or word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly on...
e552c06b82d9989f9bb01468c3ff067f8fc8f7e0
GuitarMusashi616/TFTP
/server.py
2,225
3.53125
4
# Austin Williams # Shawn Butler # Computer Networks # 2 October 2020 import socket from shared import * def wait_for_clients(): # setup socket port = 12345 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.bind(('', port)) print("server is ready to receive") # wait for msg msg, add...
67e904723ee9e20bd674a933999a203a58b423d2
DrBugKiller/offer
/剑指offer/第二章面试需要的基础知识/4-特殊二维数组中的查找.py
1,758
3.6875
4
# -*- coding: utf-8 -*- # @Time : 2019/7/20 11:44 # @Author : DrMa ''' 题目4-特殊二维数组中的查找: 一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序(特殊性)。 请完成一个函数,输入这样一个二维数组和一个整数,判断数组中是否含有该整数。 思路: 右上角(或者左上角)判断法,由于数组递增的特殊性,我们将target和array的右上角(左下角)比较: 1.相等,直接返回True;2.target<右上角,删除最后一列;3.target>右上角, 删除第一行. ''' #右上角比较 def array_Find_rig...
b56516b26408fb632d3efaab27035a9dce3766da
DrBugKiller/offer
/经典代码/快速排序.py
1,123
3.671875
4
# -*- coding: utf-8 -*- # @Time : 2019/7/29 19:34 # @Author : DrMa ''' 题目: 二分法完成快排 注意点: <=号或>=号的位置一定是与pivot相同的一侧. 为的是0,2,1这类,a[0]=0本来就是在目标位置的. left_index须从low开始,而不能从low+1,目的也是防止0,2,1这类,a[0]=0本来就是在目标位置. ''' def quick_sort(a,low,high): if low<high: pivot=partition(a,low,high) quick_sort(a,low,pivo...
bbfa4122bc499cef17f1ff7699474e7707be904f
DrBugKiller/offer
/经典代码/0817-2 sum问题.py
1,086
3.65625
4
# -*- coding: utf-8 -*- # @Time : 2019/8/17 19:10 # @Author : DrMa ''' 题目: 思路: 1. 两个for循环遍历, 时间是n^2, 一般不行. 2. 两遍哈希表 在第一次迭代中,我们将每个元素的值和它的索引添加到表中。 然后,在第二次迭代中,我们将检查每个元素所对应的目标元素diff=(target−array[i])是否存在于表中。 注意,该目标元素不能是nums[i]本身,换句话说, 该目标元素diff的dict[diff]!=i, 主要是应对array[2,2,3,4]中有重复数字2,那么dict[2]=1 而不是dict[2]=0 ''' def ...
4bbdc5c7b0be3b794b0553f92ef8b36e8223989c
DrBugKiller/offer
/HW/字符串展开.py
1,502
3.65625
4
#字符串展开 ''' 题目: 给定一个字符串, 然后按照给定规则展开(也就是去掉括号,但是括号前边有乘数, 按照对应倍数扩充). 例如: abc2{2[def]}=abc2{defdef}=abcdefdefdefdef 思路: Trick! 1. 栈的运用, 或者说 pop和append的运用. 2. 寻找[]对,遇到]开始找最近的[, 就是一对[]. 过程用while实现. 3. 将{},(),[]统一换成[], 在程序中没有的大小括号之分 ''' #替换括号 # input_str=input() # input_str=input_str.replace('(','[').replace(')',']')\ # .r...
cb35c02f9b32ebd7da8476f797cdb45a275d09dc
DrBugKiller/offer
/剑指offer/第二章面试需要的基础知识/3-特殊数组中的重复的数字.py
1,060
4.0625
4
# -*- coding: utf-8 -*- # @Time : 2019/7/20 11:44 # @Author : DrMa ''' 题目3-特殊数组中重复的数字: 找出某特殊数组中重复的数字.在一个长度为n的数组里的所有数字都在0~n-1的范围内(特殊性) 例如, 输入{2,3,1,0,2,5,3},输出是2或者3. 思路: 1: 遍历数组,构造字典,判断是否在字典中。时间复杂度O(n),空间复杂度O(n) 2: "重排"这个数组:遍历这个数组,如果数值value和下标i相等,那就扫描下一个;如果不相等,判断value和a[value]是否 相等,如果相等,说明重复;如果不相等,则将vaule和a[value]对...
423fbe4b2f92b5890275f4d6f2693b5bb2946de7
DrBugKiller/offer
/剑指offer/第三章高质量的代码/26-树的子结构.py
2,143
3.640625
4
# -*- coding: utf-8 -*- # @Time : 2019/7/20 12:07 # @Author : DrMa ''' 输入两棵二叉树A和B,判断B是不是A的子树. 思路: 1.在树A中找到和B的根节点的值一样的节点R 2.第二步在判断树A中以R为根节点的子树是不是包含和树B一样的结构 ''' class Tree(object): def __init__(self,root): self.val=root self.left=None self.right=None def hasSubtree(pRoot1, pRoot2):...
1039e3bd266987a3bd87c0695fd35e8de5476b6f
ivtipm/oop-lab4-DnineO
/Zabarovskij/database.py
5,154
4.09375
4
import os import csv class mydatabase(object): '''A class used to represent a database Attributes ---------- location : str path to csv file with database db : dict database Methods ------- load(location) Loads database from given location if it exists else cre...
64f44fa17672cd2e4765d542d4e30c255eed993a
advaitsharma223/pro100
/ATM.py
462
3.515625
4
class ATM: def __init__(self, cardNumber, pinNumber, balance): self.cardNumber = cardNumber self.pinNumber = pinNumber self.balance = balance def cashWithdrawal(self): Q1 = input("How much money would you like to withdraw: ") print(Q1) def balanceEnquiry(self): ...
8cad65a7fc642f8f12c05a7f0f3f6e0480e58d05
rivcah/100daysofPython
/cal.py
476
3.9375
4
import time import datetime today = datetime.date.today() now = datetime.datetime.now() print('Current date and time: ', now) print('Current year: ', today.strftime("%Y")) print('Month of the year: ', today.strftime("%B")) print('Week of the year: ', today.strftime("%W")) print('Weekday of the week: ', today.strftime...
e084786bc60c730ed6466aa176a08fe5009113ac
mgirardin/Project-Euler-Solutions
/Solutions_Python/P014.py
1,195
3.96875
4
records = [-1 for x in range(0, 1000000)] # guarda tamanhos de chains já conhecidos class collatz: # classe para guardar o número analisado e o tamanho de sua chain iterations = 0 number = 0 def apply(self): apply_collatz(self, self.number) return 1 ...
3090b9b89fa8a1d87f13390fa78b823b340b3508
mgirardin/Project-Euler-Solutions
/Solutions_Python/P002.py
528
3.859375
4
# Poderia usar programação dinâmica mas recursão funciona bem o suficiente para 4 milhões #Calcula o n-ésimo fibonacci com recursão def fibonacci(n): if n == 1: return 1 elif n == 2: return 2 else: return fibonacci(n-1)+fibonacci(n-2) #Soma os fibonaccis pares menores que end def s...
b3ae39a98b44ac5928966a2b3a690dd310060331
mgirardin/Project-Euler-Solutions
/Solutions_Python/P035.py
1,086
3.625
4
# armazena os primos primos = [] # Crivo de eratostenes para teste de primalidade def lista_primos(end): global primos primality = [1 for x in range(end+1)] primality[0] = 0 primality[1] = 0 for indice in range(end+1): if primality[indice] == 1: primos.append(indice) ...
d4eae73e0c17c7ddcf5f870fec86c8fc5aa293dd
fatihinz/Python
/Examples_1/fibo.py
151
3.5625
4
def fibo(n): if(n==0): return 1 if(n==1): return 1 return fibo(n-1)+fibo(n-2) print("fibo") print(fibo(7)) def g(x,y=3): return x+5*y print g(2)
5429058a3c13065964b196682ffcf091ba86f58a
daveygit2050/fraise
/tests/test_phrases.py
2,622
3.703125
4
import re import fraise class TestPhrases: # Should return four space seperated lowercase words def test_generate_with_no_parameters(self): passphrase = fraise.generate() match = re.match(r'^([a-z]+\s){3}[a-z]+$', passphrase) print("Generated passphrase: {}".format(passphrase)) ...
f229875b6fbae36c226b1df10b1ec46a724d3383
kalpanayadav/python
/cosine.py
802
4.34375
4
def myCos(x): ''' objective: to compute the value of cos(x) input parameters: x: enter the number whose cosine value user wants to find out approach: write the infinite series of cosine using while loop return value: value of cos(x) ''' epsilon=0.00001 multBy=-x**2 term=1 ...
c1ecd8ff1004f78181fe5f059a9f5f068a60ac6e
jocontreras/wwcode-python
/jocontreras_exercise01.py
426
4
4
""" The Challenge Author: Jennifer Contreras Description: Aling Nena’s Sari-sari store wants a robot that will ask the customer their total bill and payment amount and tell them their change (for now, we can allow negative change). """ total_bill = input('How much is your total bill? ') payment = input('How mu...
c368bfb6f82878d396b5e901574a265642dc7831
IsaacAlvrt/Python-mini-projects
/cajero.py
1,568
3.921875
4
#Cajero Automatico #Siempre dará la minima cantidad de billetes class billete: def money(self): # v = valor, c = cantidad print("ATM") print("ATM") #Billete de $50 b50 = billete() b50.v = 50 b50.c = 10 #Billete de $20 b20 = billete() b20.v = 20 b20.c = 15 #Billete de $10 b1...
9e6673ee77cfef995f94f6c25a9022e7c684be04
techshivang/pythondemo
/firstcode.py
240
3.71875
4
print("Hello") print("Bye") print("Testing") print("Done") print("Some changes from telusko") print("hello navin its shivang") print("i will make a small program using list comprehension:") l=[1,2,3,4,5,6] even=[i for i in l if i%2==0] print(even)
63d57cf6568c5d1e51b1da441eb25de1c1269432
coderzyt/leetcode
/homework/Solution_Week03.py
629
3.90625
4
from typing import List class Solution(object): def search(self, nums: List[int]) -> int: if not nums: return None left = 0 right = len(nums) - 1 while left <= right: mid = left + (right - left) // 2 if nums[mid - 1] > nums[mid] < ...
f689a0a36e04a49f1256821f2e74e3dae87ef77b
coderzyt/leetcode
/python/ReverseKGroup.py
1,864
3.828125
4
from python.ListNode import ListNode from python.Node import Node class ReverseKGroup(object): def reverseKGroup(self, head, k): dummy = jump = ListNode(0) dummy.next = l = r = head while True: count = 0 while r and count < k: # use r to locate the ra...
ad629a5577560e98a191fee45d0e80c414d96116
coderzyt/leetcode
/interview/LeetCode_2.py
1,082
3.75
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: result = ListNode(0) sumNode = result flag = 0 while l1.val >= 0 ...
67df2f206a5d51faa59a6a37a24bc4258c80673c
coderzyt/leetcode
/review/Solution.py
1,880
3.640625
4
from typing import List from python.TreeNode import TreeNode class Solution(object): def binaryTreeInorderTraversal(self, root: TreeNode) -> List[int]: if not root: return None WHITE, GREY = 0, 1 stack = [(WHITE, root)] result = [] while stack...
97644d7f62075d1a99031b8ec47356011422e26d
coderzyt/leetcode
/python/ThreeNumSum.py
2,028
3.671875
4
class ThreeNumSum(object): # 无法去重 def three_num_sum(self, nums: list) -> list: if nums is None or nums.__len__() < 3: return [] length = nums.__len__() index = 0 result = [] for index in range(0, length): i = 0 while i <...
5c60ad334847291cf1b154aef0ec4b25dbc51840
coderzyt/leetcode
/python/ListNodeHasCycle.py
1,292
4.03125
4
from python.ListNode import ListNode class ListNodeHasCycle(object): def hasCycle2(self, head: ListNode) -> bool: if head is None or head.next is None: return False slow = head fast = head.next while slow != fast: if fast is None or fast.next is ...
692062401ab014913173d654758be7b263d4f6cc
pooryork/python_summer2019
/Блок 8/ex8.2-24.py
699
4.0625
4
#24. Выполнить обработку элементов прямоугольной матрицы , #имеющей n строк и m столбцов. Найти наименьшее значение среди #средних значений для каждой строки матрицы. import numpy as np import random def mean(a): return (sum(a)/len(a)); n = int(input('n = ')); m = int(input('m = ')); a = np.empty ((n, m), dtype...
93f2b0140f9c70ba9598da6dc38c9f2bacfd98a8
pooryork/python_summer2019
/Блок 4/ex4.1-24.py
419
3.8125
4
#24. Дана строка. Вывести первые три символа и последние три символа, #если длина строки больше 5. Иначе вывести первый символ столько #раз, какова длина строки. str = input('String: '); n = len(str); if (n>5): str_ans = str[:3]+str[-3:]; else: str_ans = str[:1]*n; print(str_ans);
0268d09ab25ddff1b4ca2653b4a7ed5424d3faa8
pooryork/python_summer2019
/Блок 1/ex1.1-24.py
124
3.5625
4
a = float(input('a = ')); b = float(input('b = ')); c = ((a+b)*(a+b)*(a+b) - a*a*a)/(3*a*b*b + b*b*b + 3*a*a*b); print(c);
4908dfc614bb85ad7036f94f78db22e23ba1a2fa
pooryork/python_summer2019
/Блок 9/ex9.2-24.py
688
3.578125
4
#Для построенного в задании 1 графика измените: цвет линии, #тип линии и маркеров, шаг выборки данных. Сохраните полученный #график в файл import numpy as np import matplotlib.pyplot as plt import math x = np.linspace(-2 * np.pi, 2 * np.pi) y = 1/2*np.cos(2*x+1) #изменение шага выборки plt.xticks(np.arange(min(x), m...
fbd3ea34f6e92f524c52792e52a5622ff0d96051
BrianWilkinsonSSFS/py_unit_two
/triangle.py
216
3.765625
4
base = 10 height = 5 # Please fix the expression below with the correct formula for the area of a triangle. area = # This statement should print 25 when the program is run print("The area of the triangle is", area)
2492448582c1779675ffe16099cf95f918ceb755
pmdinay/ejercicio3
/range.py
181
4
4
data = list for indice in range(5): data.append(float(input("Siguiente dato?: "))) for dato in data: print("Dato: ", dato) for i in range(10, 100, 10): print("i: ", i)
94b50f6ea62a0b22ace4a237b39f3a4b2be96538
qcware/fenestrate
/fenestrate/selectors.py
893
3.65625
4
"""A collection of common selectors """ import datetime from enum import IntEnum from fenestrate.fenestrate import Selector class Weekday(IntEnum): MONDAY = (0,) TUESDAY = (1,) WEDNESDAY = (2,) THURSDAY = (3,) FRIDAY = (4,) SATURDAY = (5,) SUNDAY = 6 def daily() -> Selector: """Alwa...
794cf6f3411a27fea2bd5702304703e6c1fb4074
vojha-code/Algorithm-Complexity
/py_complexity.py
797
3.921875
4
import numpy as np import time ''' x : takes an input array of intager return : a float value of even sum ''' def evenSummation(x): evenSum = 0 # OP1: initializing sum temp variable n = len(x) # OP2: find array length for i in range(n): # iterating array n times if np.mod(x[i],2) ...
bece162206d281e4abeeaedffdc5a938538a8e71
arrebole/Web-Application-by-flask
/src/service/session.py
1,563
3.5
4
# this is session module, Used for login sessions import os, time, random, string class User: def __init__(self, userName, password): self._userName = userName self._password = password self._sessionID = "" self._expires = 0.0 def userName(self): return self._userName ...
c9050f889ad71879fd71e8d103232d8505223dbf
sedona9/CSE163-Final-Project
/plot.py
4,376
3.59375
4
''' CSE 163 Final Project Alex Hayes Sedona Munguia Creates data visualizations ''' import pandas as pd import plotly.graph_objects as go import matplotlib.pyplot as plt from Clean_Data import data def resample_data(data): """ Takes in data and returns the data grouped by city resampled...
91556089e400cd90ab55f495d2103f93eed3da35
namratab94/LeetCode
/flipping_an_image.py
1,428
4.125
4
''' Problem Number: 832 Difficulty level: Easy Link: https://leetcode.com/problems/flipping-an-image/ Author: namratabilurkar ''' ''' Example 1: Input: [[1,1,0],[1,0,1],[0,0,0]] Output: [[1,0,0],[0,1,0],[1,1,1]] Explanation: First reverse each row: [[0,1,1],[1,0,1],[0,0,0]]. Then, invert the image: [[1,0,0],[0,1,0],[...
5ec8eb2dfeb59346b13e418ef049cf080b204e99
namratab94/LeetCode
/sort_colors.py
622
3.734375
4
''' Problem Number: 75 Difficulty level: Medium Link: https://leetcode.com/problems/sort-colors/description/ Author: namratabilurkar ''' class Solution(object): def sortColors(self, nums): i = 0 j = -1 k = 0 for _ in range(len(nums)): if nums[k] == 0: nu...
518b06bf3ff1dc0f2f665dc4ecd0900df4764a11
namratab94/LeetCode
/largest_number_atleast_twice_of_others.py
1,028
4
4
''' Problem Number: 747 Difficulty level: Easy Link: https://leetcode.com/problems/largest-number-at-least-twice-of-others/ Author: namratabilurkar ''' ''' Example 1: Input: nums = [3, 6, 1, 0] Output: 1 Explanation: 6 is the largest integer, and for every other number in the array x, 6 is more than twice as big as x...
b9f7b02593f3bc8d19ab6a41c9cd80b7890d1b8a
bestasoff/Programming
/Python3/input_.py
1,059
3.625
4
import sys import typing as tp def input_(prompt: tp.Optional[str] = None, inp: tp.Optional[tp.IO[str]] = None, out: tp.Optional[tp.IO[str]] = None) -> tp.Optional[str]: """Read a string from `inp` stream. The trailing newline is stripped. The `prompt` string, if given, is printed to `o...
088af08d6fd37cd7832f922abc986ee2d742363a
alesbolka/advent2020
/tasks/day06/day06_functions.py
776
3.609375
4
def count_total_sum(raw_input): res = 0 group_str = "" for row in raw_input: group_str += row if len(row) < 1: res += len(set(group_str)) group_str = "" if len(group_str) > 0: res += len(set(group_str)) return res def count_group_common(raw_input): res = 0 group_count = 0 grou...
671a25962d01dee25f6c54dedaf93b844dc27354
4ster/skillsmart-algo2
/t1/tree_test.py
9,366
3.796875
4
import unittest from trees import SimpleTreeNode, SimpleTree class SimpleTreeNodeTestCase(unittest.TestCase): def test_add_child_for_existing_parent(self): # создаем дерево parent_node = SimpleTreeNode(0, None) tree = SimpleTree(parent_node) # создаем и добавляем дочерний узел ...
5eea6c767938f2599f4cef18c1fe1d6b746aa3e1
Hollow-user/Stepik
/unit3/task6.py
515
4.15625
4
""" Напишите программу, которая подключает модуль math и, используя значение числа π из этого модуля, находит для переданного ей на стандартный ввод радиуса круга периметр этого круга и выводит его на стандартный вывод. Sample Input: 10.0 Sample Output: 62.83185307179586 """ import math r = float(input()) p = ma...
e0df6a9d40cc836d996d6c0a517a9d8d5ee80be6
Hollow-user/Stepik
/unit2/task9.py
1,338
3.609375
4
""" Напишите программу, на вход которой подаётся список чисел одной строкой. Программа должна для каждого элемента этого списка вывести сумму двух его соседей. Для элементов списка, являющихся крайними, одним из соседей считается элемент, находящий на противоположном конце этого списка. Например, если на вход подаётся...
ddd1f3b3b9bde34d2552ad5a7deadeffe17c285f
NitishVSawant/FCI-codes
/Regression models/Chingavanam/Decision Tree.py
3,864
3.546875
4
# Importing the libraries import numpy as np import pandas as pd import statsmodels.formula.api as sm import matplotlib.pyplot as plt # Importing the dataset datasetinitial = pd.read_csv('Chingavanam Regression.csv') #Delete missing values in dataframe dataset = datasetinitial[np.isfinite(datasetinitial['Av...
ed7a6f2e0558cf9f4e286d84cb4074c379a5bcbb
jleemur/Advent-Of-Code
/2019/4.py
1,819
3.546875
4
def validate_part_one(num): atleast_2 = False num_str = str(num) prev_d = None for d in num_str: curr_d = int(d) if prev_d: # digits don't decrease if curr_d < prev_d: return False # check for consecutive digits if curr_d =...
4201638d0c51c1c264b9546e8206b7395314df45
jleemur/Advent-Of-Code
/2018/1.py
632
3.546875
4
import sys # sum of numbers def part_one(numbers): return sum(numbers) # find first value to repeat def part_two(numbers): # could improve by performing 1 iteration # calculate shift (sum at end of iteration) # finding the first value to repeat (using mod and shift) numbers_seen = [0] sum = 0 ...
56df30b7ce108da2de913765d2f28933ae9970eb
FirdausAsri99/Phyton
/Lab6.3c.py
1,231
3.609375
4
import socket import sys import os cs = socket.socket() host = '192.168.42.3' port = 8888 try: cs.connect((host,port)) print('Successfull Connect') except socket.error as e: print (str(e)) while True: print('--------------------Mathematical choice----------------------') print('1-Log expression') print('2-Squa...
d5d2077e4dce3bd49b59f35d6cc8e9258d71e81e
sw-proj-2-2017/class-4-cg140428
/week4/factorial_recursive.py
405
3.921875
4
#2017/09/25 #software_proj2_class04 #20171661 이다은 #factorial 재귀 def factorial(N): if N <= 1: return 1 else: return N*factorial(N-1) run = True while run: N = int(input("Enter your number: ")) if N >= 0: print(N,"! = ",factorial(N)) elif N == -1: run = False ...
3318199100f3d7ceb0b692a02269fd7665658544
ikemerrixs/Au2018-Py210B
/students/brandon_nguyen/session03/strformat_lab.py
2,375
4.0625
4
import unittest from decimal import Decimal #!/usr/bin/env python3 #Week3 Excercise string formating #Student: Brandon Nguyen - Au2018 #task 1 and 2 def strTask12(): strT=( 2, 123.4567, 10000, 12345.67) #formt to produce 'file_002 : 123.46, 1.00e+04, 1.23e+04' print("\'file_00{}: {:.2f}, {:.2e}, {:.2...
12fd2bc412ec822c40778d461ab1cd02d6c5200c
ikemerrixs/Au2018-Py210B
/students/rachel_s/session09/old_mailroom.py
4,212
3.890625
4
#!/usr/bin/env python3 import csv import os import datetime import sys from collections import defaultdict # Import donor data def data_import(filename): donor_info = defaultdict(list) csv_list = [] with open(filename) as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') csv_list ...
f91b796fb32f6cfa155eb94f4ac2f0f1bc30e063
ikemerrixs/Au2018-Py210B
/students/brandon_nguyen/session01/py210EnvTest.py
565
3.6875
4
#!/usr/bin/env python3 import sys import myname name = myname.get_name() print("hello {}".format(name)) print("\nThis is my first python program") #print ("test new line \n") version = sys.version_info if version.major == 3: if version.minor < 6: print("You should be running version 3.6 or 3.7") ...
cac37742d406646010b6b339f96931f390f7d86a
ikemerrixs/Au2018-Py210B
/students/timm67/session05/mailroom_part4.py
5,836
3.734375
4
#!/usr/bin/env python3 """ Tim Meese Au2018-Py210B Mailroom Part 4 assignment """ import collections from collections import defaultdict # Revised donor database uses tuples for names instead of a single string donors = { ('Jim', 'Tillson'): [5.00, 20.00], ('Barb', 'Langley'): [10.00, 20.00, 100.00], ...
16284b2b11ede01a551d57dad134c97da2f7aeba
ikemerrixs/Au2018-Py210B
/students/shawn_degraw/session07/html_render.py
3,760
3.5
4
#!/usr/bin/env python3 """ A class-based system for rendering html. """ class Element(object): """ Default Element class for rendering html """ tag_name = "html" indent = " " cur_ind = "" def __init__(self, content=None, **kwargs): self.html_content = ([content] if content else []) ...
8967563182a4074837916a98d18613789071cdb5
ikemerrixs/Au2018-Py210B
/students/jjakub/session03/list_lab.py
1,244
4.28125
4
#!/usr/bin/env python3 ### Series 1 list_fruit = ["Apples", "Pears", "Oranges", "Peaches"] print(list_fruit) user_fruit = input("Which fruit would you like to add? ") list_fruit.append(user_fruit) print(list_fruit) user_num = input("Provide the number of the fruit to return: ") print(user_num + " " + list_fruit[int(...
35fe7adbad7d0928347a52e7bc91f0fd2b4662a5
ikemerrixs/Au2018-Py210B
/students/arun_nalla/session02/series.py
1,900
4.375
4
#!use/bin/env python def fibo(n): '''Write a alternative code to get the nth value of the fibonacci series using type (list) 0th and 1st position should return 0 and 1 and indexing nth position should return SUM of previous two numbers''' if n ==0: return 0 elif n ==1: return 1 my_list = [0,1] ...
1a3bab32646bb23b44d9bc9e9831f3ec0e9f77c3
ikemerrixs/Au2018-Py210B
/students/timm67/session04/mailroom.py
2,858
3.71875
4
#!/usr/bin/env/python3 """ Tim Meese Au2018-Py210B Mailroom assignment """ import collections from collections import defaultdict # # donors dictionary has a key equal to the donor's name and value is an array of donations # donors = { 'Jim Tillson' : [5.00, 20.00], 'Barb Langley' : [10.00, 20.00, 100.00],...
c69af38ba8fc630402d9e5415d128a00948cb973
ikemerrixs/Au2018-Py210B
/students/ejackie/session04/trigrams.py
843
4.3125
4
#!/usr/bin/env python3 import sys from collections import defaultdict words = "I wish I may I wish I might".split() def build_trigrams(words): """ build up the trigrams dict from the list of words returns a dict with: keys: word pairs values: list of followers """ trigrams = defau...
3c6039e52e504e3cf27ae74516921dbb2778cbd9
ikemerrixs/Au2018-Py210B
/students/timm67/session03/strformat_lab.py
1,775
3.921875
4
#!/usr/bin/env python3 """ Tim Meese Au2018-Py210B String Formatting Lab """ # # Task One: formatted output # tuple_one = ( 2, 123.4567, 10000, 12345.67) format_str = "file_{0:03d} : {1:4.2f}, {2:4.2e}, {3:4.2e}" print(format_str.format(*tuple_one)) # # Task Two: formatted output (using keywords) # format_str_two...
595fb79ce555aa29c754ef84d55087c9fc701944
ikemerrixs/Au2018-Py210B
/students/aminavi/session02/grid3.py
439
3.875
4
def grid(x,y): for k in range(x): for j in range(y+1): if j == 0: print("+", end="") for i in range(x): print(y*"-", end='+') else: print("|", end="") for i in range(x): print(y*" ...
bf4916029d1fac0f9a3d44d8af5bfd67696b660d
ikemerrixs/Au2018-Py210B
/students/yushus/session04/trigrams.py
1,710
3.90625
4
#!/usr/bin/env/python3 """ Yushu Song Au2018-Py210B Trigrams assignment """ import collections import os import random import string import sys # Return a string of words read from file def read_in_data(filename): in_data = '' with open(filename, "r") as file: in_data = file.read() # Remove p...
dd7ba2be6de1e9c53edd033b4b895cb1481a300f
ikemerrixs/Au2018-Py210B
/students/jjakub/in_class.py
1,811
3.78125
4
int(4.5) int("345") bool("") bool(" ") " abc ".strip() 0 and 456 # both must be true, otherwise ture and returns last value; once zero is evaluated it stops; called shorcut 0 or 456 1 and 0 and (10/0) not True if 1 and 2: # 1 is evaluated first and 2 is returned a bool() if x is False: return y x,y = 0,...
1c81624c147e9de5cb1b151c27804cfe66e61f07
ikemerrixs/Au2018-Py210B
/students/YingGuo/session03/Slicing.py
1,463
3.984375
4
#hw3, slicing practice def sequence_1(sequence): """first and last items exchanged""" first = sequence[0] last = sequence[-1] rest = sequence[1:-1] new_sequence = last + rest + first return new_sequence def sequence_2(sequence): """every other item removed""" sequence = sequence[::2] ...
a322a951f878331d87c901c7cb1c423e07a5ff05
ikemerrixs/Au2018-Py210B
/students/rachel_s/session01/pp_warmup_1.py
3,128
3.734375
4
def sleep_in(weekday, vacation): if(vacation or not weekday): return True else: return False def monkey_trouble(a_smile, b_smile): if(a_smile == b_smile): return True else: return False # Given two int values, return their sum. Unless the two values are the same, # th...
091b36f1dea9fef810513ac5d98d6ea3374c1b03
jholoc/proyectoScrapy
/codigoscrap/pruebatonken.py
849
3.65625
4
#-*- coding: utf-8 -*- import nltk s = "Quito is a city of Ecuador" s = '''Jhonny Zaruma Try entering your own text in this text box to see what knowledge AlchemyAPI can extract from your unstructured data. University Tecnic of Loja is the university Catolic of Loja''' a = nltk.word_tokenize(s) b = nltk.pos_tag(a) c =...
986fa73edc3230b2389af0c8c5ccd5c3bef67410
bpetkoff/ads-labs
/ads_lab_3_ex5.py
3,216
4.0625
4
""" This file contains the reversed queue function """ class Empty(Exception): """Shows an error on attempt to access an element from an empty container.""" pass class ArrayQueue: """FIFO queue implementation using a Python list as underlying storage.""" DEFAULT_CAPACITY = 10 # moderate capacity for ...
449ce5cf818acd07244a4cbdfb332a2e6e5da10e
bpetkoff/ads-labs
/ads_lab_2_ex4.py
607
3.6875
4
import time import random # This is a list of random, shuffled numbers numbers_list = list(range(1, 1000000)) random.shuffle(numbers_list) # print(numbers_list) # Task 4 - Top three lucky numbers def top_three(input): start = time.time() top_three = [] while len(top_three)<=4: top_number = input[...
6886b16e533f10be42a0cf60f0a8381c805eb6ad
KarmanyaT28/Python-Code-Yourself
/59_loopq4.py
424
4.21875
4
# Write a program to find whether a given number is prime or not number=int(input("enter your number which has to be checked")) # i=2 # for i in range(2,number): # if(number%i==0): # break # print("Not a prime number") prime = True for i in range(2,number): if(number%i==0): pri...
812e5fb56f013781312790cd6b4a2a20cc255647
KarmanyaT28/Python-Code-Yourself
/17_playwithstrings.py
1,014
4.40625
4
# name = input("Enter your name\n") # print("Good afternoon, " + name) # --------------------------------------------------------------------------- # Write a program to fill in a letter template given below # letter = '''Dear <Name> , you are selected ! <DATE>''' # letter = ''' # Greetings from TalkPy.or...
7c00013513fdaf5b4c4a7dd4147fd6794653e492
KarmanyaT28/Python-Code-Yourself
/67_filesp.py
355
3.890625
4
f = open('sample.txt','r') # data = f.read() data = f.read(5) # reads first five characters from the file. print(data) f.close() # Modes of opening a file # r - Open for reading # w - Open for writing # a - open for appending # + - open for updating # rb will open for read in binary mode # rt will op...
027170862720a141e62cd700cc30dc11db0a3b73
KarmanyaT28/Python-Code-Yourself
/45_conditionalq3.py
542
4.25
4
# A spam comment is defined as a text containing following keywords: # "make a lot of money" , "buy now","subscribe this", # "click this". # Write a program to detect these spams. text= input("Enter the text") spam = False if("make a lot of money" in text): spam = True elif("buy now" in text): sp...
1e70a7b93a3d823fa8434bf4ca414f8d9602f817
KarmanyaT28/Python-Code-Yourself
/12_averageoftwo.py
110
3.8125
4
a=int(input("Enter first number")) b=int(input("Enter second number")) average = (a+b)/2 print(average)
b1e07dfbf541a8b3595ddfca4d6c394947247cb4
QuantEcon/QuantEcon.py
/quantecon/_lae.py
2,065
3.984375
4
r""" Computes a sequence of marginal densities for a continuous state space Markov chain :math:`X_t` where the transition probabilities can be represented as densities. The estimate of the marginal density of :math:`X_t` is .. math:: \frac{1}{n} \sum_{i=0}^n p(X_{t-1}^i, y) This is a density in :math:`y`. Refer...
83e7a072bc6b58793831e25ab4df667bad20d046
QuantEcon/QuantEcon.py
/quantecon/_ivp.py
8,993
3.78125
4
r""" Base class for solving initial value problems (IVPs) of the form: .. math:: \frac{dy}{dt} = f(t,y),\ y(t_0) = y_0 using finite difference methods. The `quantecon.ivp` class uses various integrators from the `scipy.integrate.ode` module to perform the integration (i.e., solve the ODE) and parametric B-spline...
71a82d2e14d9a32244762d8c62ae5dd96e7dd842
QuantEcon/QuantEcon.py
/quantecon/_estspec.py
4,820
3.65625
4
""" Functions for working with periodograms of scalar data. """ import numpy as np from numpy.fft import fft def smooth(x, window_len=7, window='hanning'): """ Smooth the data in x using convolution with a window of requested size and type. Parameters ---------- x : array_like(float) ...
0e5e5f1e5d16de5eb630f0d69f7435b6e405e0e2
Mistry-Vivek/Code-Think-Work-Experience
/Advent For Code 17/Day 3/Day 3A.py
421
3.640625
4
END_STOP = 500 import math # Square all odd numbers between 1 and END_STOP ls = [math.pow(x,2) for x in list(range(1,END_STOP)) if x % 2 == 1] # Loop through, look for value closest to 312051 for ls in ls: print("") # Then break when you've got the closest one. # Use your defined find function to find the dista...