blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
c9c26d101422deb7b9e96351e97edf2fd2ff5497
akyyev/My_python
/day07_iterables_iter_next/iterator_next.py
609
4.1875
4
# define a list my_list = [4, 7, 0, -1] # get an iterator using iter() my_iter = iter(my_list) # iterate through it using next() print(next(my_iter)) # 4 print(next(my_iter)) # 7 print(next(my_iter)) # 0 print(next(my_iter)) # -1 my_iter = iter(my_list) print(my_iter.__next__()) print(my_iter.__next__()) print...
9e965d07f408236868c1200237ddc5732b43fa1f
akyyev/My_python
/day04_dictionaries/sort_and_sorted_methods.py
678
4.28125
4
my_list = [1, 5, 3, 7, 2] my_dict = {'car': 4, 'dog': 2, 'add': 3, 'bee': 1} my_tuple = ('d', 'c', 'e', 'a', 'b') my_string = 'python' print('original', my_dict) my_list = [1, 5, -3, 7, -2] print(sorted(my_list, key=abs)) print(my_list) # my_list is still not sorted my_list.sort() my_list.reverse() print('now it i...
8b581175df14720043f8352a90cb9e8b7e2125f2
akyyev/My_python
/day03_identity_equalency/word_game.py
1,781
4.09375
4
import random words = ["salam", "eggplant", "python", "turtle", "milkyway", "computer", "galaxy", "desk", "podcast", "resolution", "yahoo", "program", "dictionary", "revolution", "son", "daughter", "software", "sweethome", "firetruck", "car", "food", "coronavirus", "contagious", "coding", "water", "r...
c733248c12b6a12dfa0feab759f62844863814dd
akyyev/My_python
/day01/for_loop.py
445
4.125
4
for i in range(5): print(i) print("--------") # 1 to 5 for i in range(1, 6): print(i) print("--------") # target = 10 # while True: # num = int(input("Number: ")) # if num > target: # print("Too high!") # elif num < target: # print("Too low!") # else: # print("Correct!"...
963c4952a2a3d4b2080132f0aa94f7cdc44df961
akyyev/My_python
/questions/code_tasks.py
5,692
4.40625
4
# Write a program which accepts a sequence of comma-separated numbers # from console and generate a list and a tuple which contains every number. # Suppose the following input is supplied to the program: # 34,67,55,33,12,98 # Then, the output should be: # ['34', '67', '55', '33', '12', '98'] # ('34', '67', '55', '33', ...
fb6775b04aa29e093706d063bacafade9fc8cac8
akyyev/My_python
/day06_OOP_concepts/practice01_constructors.py
996
3.734375
4
import math class ComplexNumber: name = "Complex Number" def __init__(self, a=0, b=0): self.real = a self.imaginary = b def getData(self): print(f"{self.real}+{self.imaginary}i") def get_distance(self, comp_num): return math.sqrt(math.pow(self.real - comp_num.real, 2...
5ae588e8d5f5876a5158654e851aa1acbd1e60ed
mehmethilmidundar/gaih-students-repo-example
/Homeworks/HW1.py
3,439
4.15625
4
#Explain your work Homework 1 1) How would you define Machine Learning? 2) What are the differences between Supervised and Unsupervised Learning? Specify example 3 algorithms for each of these. 3) What are the test and validation set, and why would you want to use them? 4) What are the main preprocessing steps? Expla...
7efd2fac11e36cbfef427eb0e97e1a7a5a0e319c
SVLaursen/aau-ai-mini-project
/main.py
4,945
4.15625
4
# 1: Print out map and ask the player to move in direction # 2: Player moves in direction # 3: Agent comes out of waiting state # 4: Agent calculates path to player # 5: Agent moves one tile towards the player # 6: Agent goes into waiting state again and the cycle continues unless a goal has been met from MapConversio...
101238fa9afaa72482bf5704006be7300170b1e3
itsrbpandit/fuck-coding-interviews
/problems/tests/test_contains_duplicate.py
843
3.671875
4
# coding: utf-8 import unittest from problems.contains_duplicate import Solution from problems.contains_duplicate import Solution2 class TestCase(unittest.TestCase): def setUp(self): self.solution = Solution() def test(self): nums = [1, 2, 3, 1] self.assertEqual(self.solution.contain...
29de64f5c8e4c9cb02b2a9cf2cc61aaae984b093
itsrbpandit/fuck-coding-interviews
/data_structures/sets/quick_find_union_find.py
1,619
3.625
4
# coding: utf-8 """ Union-Find (Disjoint Set) https://en.wikipedia.org/wiki/Disjoint-set_data_structure """ class QuickFindUnionFind: def __init__(self, union_pairs=()): self.num_groups = 0 self.auto_increment_id = 1 self.element_groups = { # element: group_id, } ...
ea54a685dc8e31c0fe37a3f39bcbcabe27f2ed1e
itsrbpandit/fuck-coding-interviews
/data_structures/trees/binary_search_tree.py
15,432
3.828125
4
# coding: utf-8 """ Binary Search Tree https://en.wikipedia.org/wiki/Binary_search_tree A binary search tree is a special binary tree which satisfies following properties: - Every node has at most two children, left and right. - Elements in left subtree of a node are less than the node. - Elements in right subtree of ...
885f2fbd55f126c1925b6cff6f2b2a7e1c8a84a5
itsrbpandit/fuck-coding-interviews
/data_structures/graphs/adjacency_map_directed_weighted_graph.py
12,190
3.8125
4
# coding: utf-8 """ Graph https://en.wikipedia.org/wiki/Graph_(abstract_data_type) https://en.wikipedia.org/wiki/Directed_graph https://en.wikipedia.org/wiki/Adjacency_list Assume that we have V vertices and E edges in the graph G. """ from collections import defaultdict import heapq from data_structures.sets.quick_f...
fe4921ec9ad81e918b879a5712bae7a37eb10488
itsrbpandit/fuck-coding-interviews
/problems/tests/test_best_time_to_buy_and_sell_stock.py
2,010
3.546875
4
# coding: utf-8 import unittest from problems.best_time_to_buy_and_sell_stock import Solution from problems.best_time_to_buy_and_sell_stock import Solution2 from problems.best_time_to_buy_and_sell_stock import Solution3 class TestCase(unittest.TestCase): def setUp(self): self.solution = Solution() d...
f4f7acfe498446f685a75f055b27ab6471cbdfdb
itsrbpandit/fuck-coding-interviews
/data_structures/queues/doubly_linked_list_based_deque.py
2,858
3.984375
4
# coding: utf-8 class DoublyListNode: def __init__(self, value, next=None, previous=None): self.value = value self.next = next self.previous = previous # Also see: https://github.com/vinta/fuck-coding-interviews/blob/master/data_structures/linked_lists/doubly_linked_list.py # This implemen...
eb39c19847dec9dd4f6c3376728e79e86768cd2a
itsrbpandit/fuck-coding-interviews
/problems/tests/test_remove_nth_node_from_end_of_list.py
2,413
3.671875
4
# coding: utf-8 import unittest from problems.remove_nth_node_from_end_of_list import Solution from problems.remove_nth_node_from_end_of_list import Solution2 from problems.utils.leetcode import list_to_listnode from problems.utils.leetcode import listnode_to_list class TestCase(unittest.TestCase): def setUp(sel...
631d6078082d82ba3b82194a2c3ed6cdc8d5f718
itsrbpandit/fuck-coding-interviews
/problems/tests/test_missing_number.py
1,145
3.53125
4
# coding: utf-8 import unittest from problems.missing_number import Solution from problems.missing_number import Solution2 class TestCase(unittest.TestCase): def setUp(self): self.solution = Solution() def test(self): test_array = [ {'nums': [3, 0, 1], 'expected': 2}, ...
22a938e2fea8c2c9ea8bd70a8621ace42215f777
itsrbpandit/fuck-coding-interviews
/problems/tests/test_hackerrank_in_a_string.py
682
3.65625
4
# coding: utf-8 import unittest from problems.hackerrank_in_a_string import hackerrankInString class TestCase(unittest.TestCase): def test(self): array = [ {'s': 'hereiamstackerrank', 'expected': 'YES'}, {'s': 'hackerworld', 'expected': 'NO'}, {'s': 'hhaacckkekraraannk...
8ca50a17d94125ae5545b07ddbd8446bfe7497cd
itsrbpandit/fuck-coding-interviews
/problems/simple_text_editor.py
1,509
4.0625
4
#!/bin/python3 """ https://www.hackerrank.com/challenges/simple-text-editor/problem """ class SimpleTextEditor: def __init__(self): self.s = '' # It works as a stack for storing full copies of previous s. # However, it might take too much memory resource if s is huge. self.s_histo...
3d85431bf42909e2a836ea4a14c6a5d204aaa5ad
itsrbpandit/fuck-coding-interviews
/problems/tests/test_valid_parentheses.py
791
3.609375
4
# coding: utf-8 import unittest from problems.valid_parentheses import Solution class TestCase(unittest.TestCase): def setUp(self): self.solution = Solution() def test(self): test_data = [ {'s': '()[]{}', 'expected': True}, {'s': '{[]}', 'expected': True}, ...
6901fe3db84ae1773ad320f7585fca0171af503d
itsrbpandit/fuck-coding-interviews
/problems/serialize_and_deserialize_binary_tree.py
1,844
3.625
4
# coding: utf-8 """ https://leetcode.com/problems/serialize-and-deserialize-binary-tree/ """ from collections import deque class TreeNode: # pragma: no cover def __init__(self, x): self.val = x self.left = None self.right = None # Also see https://github.com/vinta/fuck-coding-interviews...
46dd79f9cde9eedd3eaed3f5332f49e3adb14174
itsrbpandit/fuck-coding-interviews
/problems/implement_strstr.py
742
3.65625
4
# coding: utf-8 """ https://leetcode.com/problems/implement-strstr/ """ class Solution: def strStr(self, haystack: str, needle: str) -> int: if not needle: return 0 n_length = len(needle) for i in range(len(haystack)): if haystack[i:i + n_length] == needle: ...
56c039adbf20afbebfeb5820a92896f3eaed62a9
itsrbpandit/fuck-coding-interviews
/problems/container_with_most_water.py
1,281
3.765625
4
# coding: utf-8 """ https://leetcode.com/problems/container-with-most-water/ """ from typing import List class Solution: def maxArea(self, height: List[int]) -> int: max_area = 0 for i, h1 in enumerate(height): for w, h2 in enumerate(height[i + 1:], 1): h = min(h1, h2) ...
369e54ad7d20c2e3e67fd5c67bb5537b8b46e1e5
itsrbpandit/fuck-coding-interviews
/problems/validate_binary_search_tree.py
2,413
3.890625
4
# coding: utf-8 """ https://leetcode.com/problems/validate-binary-search-tree/ """ import sys class TreeNode: # pragma: no cover def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def isValidBST(self, root: TreeNode) ...
0c302c0ca7523a0817f09458775bfbc797529c8a
itsrbpandit/fuck-coding-interviews
/problems/tests/test_middle_of_the_linked_list.py
1,553
3.59375
4
# coding: utf-8 import unittest from problems.middle_of_the_linked_list import Solution from problems.middle_of_the_linked_list import Solution2 from problems.utils.leetcode import list_to_listnode from problems.utils.leetcode import listnode_to_list class TestCase(unittest.TestCase): def setUp(self): se...
266ea53d5f28557041027b059df08f1b23692d5d
itsrbpandit/fuck-coding-interviews
/algorithms/searching/tests/test_linear_search.py
765
3.578125
4
# coding: utf-8 import random import unittest from algorithms.searching.linear_search import linear_search class TestCase(unittest.TestCase): def test(self): array = [random.randint(-100, 100) for i in range(10000)] target = random.choice(array) expected = array.index(target) self...
09446661518d1eebcf3601a6c7ea8962c192eda0
itsrbpandit/fuck-coding-interviews
/problems/jumping_on_the_clouds.py
709
3.875
4
#!/bin/python3 """ https://www.hackerrank.com/challenges/jumping-on-the-clouds/problem """ import math import os import random import re import sys def jumpingOnClouds(c): steps = 0 i = 0 length = len(c) while i < length - 1: # We can jump by either 1 or 2 clouds. if (i + 2) < length: ...
fafb8612001c58fdba28139321d4932060c91444
itsrbpandit/fuck-coding-interviews
/problems/shuffle_the_array.py
710
3.828125
4
# coding: utf-8 """ https://leetcode.com/problems/shuffle-the-array/ """ from typing import List class Solution: def shuffle(self, nums: List[int], n: int) -> List[int]: if not n: return nums def gen_list(): nums1 = nums[:n] nums2 = nums[n:] for i, ...
060d72e9b79d7bc1e246284365c68d9205bb9768
Gadhy/trabajo-n-7
/bucles-iteracion/bi5.py
328
3.671875
4
import os #DECODIFICAR MENSAJE ENCRIPTADO #input msg=os.sys.argv[1].upper() #bucle for letra in msg: if letra=="A": print("Hola") if letra =="B": print("Mi amor") if letra=="C": print("Te quiero") if letra=="D": print("Mucho") #fin literador print("\n") print("fin del ...
2fcdfc4471752718d59efdbacbd741c60914bc73
Gadhy/trabajo-n-7
/bucles-iteracion/bi3.py
312
3.71875
4
import os #DECODIFICAR MENSAJE ENCRIPTADO #input msg=os.sys.argv[1].upper() #bucle for numero in msg: if numero=="6": print("Ariana") if numero=="7": print("Quiere") if numero=="8": print("A su") if numero=="9": print("Mama") print("\n") print("fin del bucle")
7dc1bdbee50bedbb291320bb8554ad7c3dad3a4f
VleuDive/Euler
/P_Euler_3.py
744
3.75
4
import math as m def findPrimeList(limit): prime_list=[2] if_prime=True for num in range(3,limit+1): if_prime=True for div in range(2,m.ceil(num**0.5)+1): #분모 range 설정 주의! if(num%div==0): if_prime=False break #여기서 break가 안되고 끝까지 훑고 지나가야만 소수! ...
c1de6c63f2738430a315e75270c66b43b8851bea
Katherinelove/ModeDemo
/LiaoXueFeng/myClass/Demo_case4.py
4,533
3.6875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Python的class允许定义许多定制方法,可以让我们非常方便地生成特定的类。 定制类--相当于实习对应的interface 1.__str__与__repr__ 两基佬同时存在 相当于tostring() 2.__iter__ 与__next__ 目的是为了迭代 如果一个类想被用于for ... in循环,类似list或tuple那样,就必须实现一个__iter__()方法,该方法返回一个迭代对象, 然后,Python的for循环就会不断调用该迭代对象的__next__()方法拿到循环的下一个值,...
3662a15c2833b52fee778d0a6f0fd75ba0086e35
Tefuko/reversi2020
/reversi/legacy.py
4,786
3.828125
4
import random # # オセロ(リバーシ) 6x6 # N = 6 # 大きさ EMPTY = 0 # 空 BLACK = 1 # 黒 WHITE = 2 # 白 STONE = ['□', '●', '○'] #石の文字 # # board = [0] * (N*N) # def xy(p): # 1次元から2次元へ return p % N, p // N def p(x, y): # 2次元から1次元へ return x + y * N # リバーシの初期画面を生成する def init_board(): board = [EMPTY] * (N*N) c = ...
0816d4526de0c6aaa45ef905c58629134caa19da
larobitrumpet/Board_Game
/Board_Game.py
5,141
3.78125
4
import random import DiceRoll import DisplayBoard P1Place = 0 P2Place = 0 r = 0 i = 20 s = 0 P1vPlace = None P2vPlace = None print("") print("Welcome.") print("In this game, two players roll a dice and") print("move along the game board.") print("Who ever gets to the last space") print("first wins!") pr...
d5763d0aa1ae5b230f5c4cbcdcb3efb32d84b877
childrenyoo/py_code_reposity
/剑指OFFER/18.输出链表的节点.py
590
3.890625
4
#题目:在O(1)时间内删除链表节点 #给定单项链表的头指针和一个节点指针 class ListNode(object): def __init__(self, x): self.val = x self.next = None #不需要获得被删除节点的上一个节点,只要得到它下一个节点,并将其赋值给被删除节点即可 #需要调用者确保delete确实在以head为头的链表中 def deleteNode(head,delete): nextNode=delete.next if nextNode==None: delete=None ...
928cbc93e804a34e06d1b740d123993ad8027cbe
childrenyoo/py_code_reposity
/DynamicProgramming/leetcode53.py
325
3.640625
4
class Solution(object): def maxSubArray(self, nums): """ :type nums: List[int] :rtype: int """ for i in range(1,len(nums)): nums[i]=max(nums[i-1]+nums[i],nums[i]) return max(nums) numc=[-2,1,-3,4,-1,2,1,-5,4] s=Solution() print(s.maxSubArray(n...
527f08bfeb64b7ce8f4c0c2b1cc3fd117b8263ca
childrenyoo/py_code_reposity
/sort/sort_bubble.py
331
3.875
4
#冒泡排序 def sort_bubble(nums): j=len(nums)-1 while j>0: i = 0 while i<j: if nums[i]>nums[i+1]: temp=nums[i] nums[i]=nums[i+1] nums[i+1]=temp i+=1 j-=1 return nums nums=[4,5,8,1,2,2,3] sort_bubble(nu...
5ee15dcbfca6000a145f1b4fa36247a9240ad4eb
arslanmanzoorr/Pythonprojects
/mac_changer with input.py
468
3.59375
4
#!/usr/bin/env python import subprocess interface = input("Interface Name : ") new_mac = input("Enter New Mac Adress : ") print("--------------- Changing mac ----------------") subprocess.call("ifconfig " + interface + " down" , shell=True) subprocess.call("ifconfig " + interface + " hw ether " + new_mac , shell=Tr...
e149a3569856bb6cb1fa8e68016add463fc72be3
branislav1991/MLPlayground
/logistic_regression.py
3,226
3.796875
4
"""Performs logistic regression using stochastic gradient descent.""" import numpy as np NUM_CLASSES = 2 NUM_FEATURES = 3 NUM_EPOCHS = 100000 NUM_EXAMPLES = 10 LEARNING_RATE = 0.001 LOSS_DISPLAY_FREQUENCY = 1000 def logistic(x): # logistic function return 1.0 / (1.0 + np.exp(-x)) def gradxentropy(y_hat, y): ...
476f6e1e6b68dddc87d86bbaf901dd4145c452bc
Lexkane/ComputerScience
/Tasks_3_Week/Task_03_Integrals/IntSqr.py
413
3.84375
4
def main(): def integral_square(): def function(x): return x * x with open("input.txt") as file: lines = file.read().strip() a=lines[0] b=lines[1] n=lines[2] h=(b-a)/n for i in range (1,n): s += function(a + i * h) return ((function(a)+function(b)+2*s)* h/2) with open('output.tx...
5f27280c58733033ef7f3a207d4cb620fd762d17
Prasanna1112/Simple-Bank-Transactions-using-MongoDB
/BankTrans.py
2,971
3.609375
4
def new_acct(): # print("here") name = input("Enter your name: ") mob = int(input("Enter your phone number: ")) email_id = input("Enter your email: ") if "@gmail.com" in email_id: pass else: print("Incorrect email!") email_id = input("Please re-enter your email: ") aadhar = int(i...
642483e0cc7fabc477eefe28e1a553170be4a754
arkanttus/Minicurso_ChatBot
/chat_ListTrainer/bot.py
415
3.515625
4
from chatterbot import ChatBot from chatterbot.trainers import ListTrainer chatbot = ChatBot("Meu chat") conversation = [ "Ola", "Oi!", "Como voce esta?", "Eu estou bem", "Que bom", "Obrigado.", "Por nada" ] trainer = ListTrainer(chatbot) trainer.train(conversation) while True: user ...
a3d513db11ff6e3f7511fce7a1f2d5305e1d7bb6
pengjingwei/store
/ListFlip.py
412
4.25
4
# 实现列表的数据翻转 List = [1,2,3,4,5,6,7,8,9] print("[::-1]方式翻转列表:",List[::-1]) l = reversed(List) print("reversed()方法翻转列表:",list(l)) # 统计列表中的每个数字出现的次数 List = [1,4,7,5,8,2,1,3,4,5,9,7,6,1,10] setL = set(List) # print(setL.pop()) for i in range(len(setL)): view = setL.pop() print("{0}出现了{1}次。".format(view,List.count(v...
47825d3af56edfcd3e4887ca3569ea858b95bb35
sandra2018/testRepo
/Python/TestPrep/plot/plotTest.py
315
3.65625
4
from matplotlib import pyplot import random x_values =[0, 4, 7, 20, 22, 25] y_values = [random.randint(0, 30) for i in range(len(x_values))] #y_values = [0, 2, 4, 6, 8, 10] pyplot.plot (x_values, y_values, 'o-') pyplot.ylabel('Values') pyplot.xlabel('Time') pyplot.title('Test plot') pyplot.show() print("hello")
57f4728757b8acbdb01b7297a19af4458a3aa9a9
itwuhao/py
/1.4.py
162
3.984375
4
#simple while x_int =0 #test loop-control variable at beginning of loop while x_int <10: print(x_int) x_int =x_int +1 print('final value of x_int:',x_int)
c9e2ab53c716de6b9938fe1c735b9fcb349b2e9f
huonglarne/info-security
/mod-exp.py
435
3.953125
4
# convert the exponent to binary # return a list of its bits def to_binary(n): return [int(i) for i in bin(n)[2:]] # x is the base # e is the exponent # n is the modulo def sq_mul(x, e, n): result = x bin = to_binary(e) for i in bin[1:]: # ignore the first bit result = result**2 % n ...
e940bad9595d61534dbb092ac59e277e5def4e05
christianparker512/ProjectFlow
/searching.py
508
3.921875
4
shopping_list = ["apples", "grapefruit", "coffee", "brisket", "tortillas", "peppers", "onions"] item_to_find ="albatross" found_at = None # for index in range(6): #for index in range(len(shopping_list)): # if shopping_list[index] == item_to_find: # found_at = index # break if item_to_find in shopping...
85b7f8793d3681f4ff18597713f311498fb500e4
nacho6699/tarea1
/ejercicio4/ejercicio4.py
285
3.8125
4
def ValorCadena(cadena1,cadena2): if len(cadena1)>len(cadena2): print cadena1 elif len(cadena1)<len(cadena2): print cadena2 else: print cadena1+cadena2 print "inserta primera cadena" a=raw_input() print "inserta segunda cadena" b=raw_input() ValorCadena(a,b) raw_input()
50723889d7e2a11872f7bc81a6dd4ac22eb12153
qq604395564/Guess-the-number-game
/Guess-the-number-game/game/game.py
1,294
3.765625
4
import random import time number = random.randint(0,199) print("----------猜数字小游戏----------") num=0 temp = input("小猪猪,猜一下我心里的数字吧(0 to 199,七次机会),:") if temp == number: print("哇,不愧是我心里的小蛔虫,太厉害啦,一下子就猜中了!") print("End") else: while temp!= number: while not temp.isdigit(): temp = input("...
97ef4f1c16e0ae9e1889cc9b2c0c5ba02d9d618f
deivid-a1/estagio-PF
/Questao-2.py
1,312
3.765625
4
#É usado para manipulação dos registros a biblioteca pandas. import pandas as pd data = pd.read_csv('arquivo.csv',sep = ';') #Aqui nós usamos a funçãoo read_csv para ler o csv que foi criado, em forma de separação em ponto e vírgula. data = data.sort_values(by=['nome']) #Aqui nós organizamos tudo em função dos nomes,...
5cd6c888bccbc230c956c0974fe7a9231ad8eac8
ntduong/ML
/Feed-Clustering/feedCluster.py
3,348
3.734375
4
import math import random from collections import defaultdict import myfeeder def edist(p, q): """ Compute the Euclidean distance between two points p, q. """ if len(p) != len(q): raise ValueError, "lengths must match!" sqSum = sum(map(lambda x,y: (x-y)**2, p, q)) return math.sqrt(...
21d6442c8baa1641bc5235f92cd65d4e6c376e7b
pythonhan/practice
/air_quality/air_quality_v4.0.py
3,704
3.6875
4
""" 作者:pythonhan 版本:V2.00 日期:09/10/2017 功能:空气质量计算 介绍csv文件和JSON数据文件 将 JSON数据文件转换成CSV文件 CSV是一种通用的,相对简单的文件格式,在商业和科学领域上广泛使用 规则:一行为单位,每行表示一条记录,以英文逗号分割每列数据(若数据为空,逗号也要保留),列名通常放置在文件的第一行 import csv csv.writerow(list) 将列表中的元素写入文件的一行中 读取已经获取的JSON数据文件 并将AQI前5的数据输出到另外一个文件中 JSON ...
672e5c199d23348ac4eb4bbafdb8d9d5694ce7ba
pythonhan/practice
/judge_whichday/judge_whichday_v4.0.py
3,400
4.0625
4
""" 作者:pythonhan 版本:V4.0 日期:28/09/2017 功能:输入某年某月某日,判断一个日期属于这一年的第几天 2.0新增功能:用列表list来替代元组tuple 3.0新增功能:将月份划分为不同的集合 4.0新增功能:把天数和月份放在一起,字典的方式,是一个键值对的组合,dict()输出的为{}和set()输出都是{},字典类型通过映射查找数据项,字典是无顺序的key-value,dict['key']=value {'a':12, 'b':15} d['a'] 删除 del d['a'] 检查某个key是否在字典...
6648264b8891c66d836bf863df77b94dbb2a0750
pythonhan/practice
/money_save/money_save_v1.0.py
688
3.890625
4
''' 作者:pythonhan 功能:52周存钱挑战 版本:V1.0 日期:27/09/2017 ''' def main(): ''' 主函数 ''' money_per_week = 10 #每周存入的金额 i = 1 #记录周数 increase_money = 10 #递增的金额 total_week = 52 #总共周数 saving = 0 #账户累计 while i <= total_week: # 存钱操作 saving +...
2450b27a70f5680ceb463189a0e892fd21768629
pythonhan/practice
/turtle_picture/pentagram_v1.0.py
1,316
4.0625
4
''' 作者:pythonhan 功能:五角星的绘制(使用turtle模块) 日期:27/09/2017 版本号:V1.0 turtle模块常用函数: turtle.forward(distance):向前移动一段距离,X坐标轴的正方向 turtle.backward(distance):向后移动一段距离,X坐标轴的负方向 turtle.left(degree):向左旋转一定的角度,从X坐标轴的正方向到Y坐标轴的正方向 turtle.right(degree):向右旋转一定的角度,从X坐标轴的正方向到Y坐标轴的负方向 turtle.exitonclick...
679ecef5fa4b30ee1c3874835f1355a45e5b3157
dhaarmaa/python
/prueba3/pancho.py
2,662
3.71875
4
import os lista_pizza= [] lista_precio = [] ejecutar= True while ejecutar: try: os.system('cls') print("== Hola bienvenidos a pizza duoc==") print("1.Opciones de pizza\n2.Pagar\n3.Anular pedido\n4.Salir") opcion=int(input("Ingrese opción:")) while opcion<1 or opcion>3: ...
d9137bc9effa44977fdaff6b9ffee7bb07a9ae4d
dhaarmaa/python
/guiaPareja/act3-caso2.py
726
3.96875
4
#Crear una salida por pantalla con la siguiente información: #i. ¿Cuál de los siguientes animales vive en el agua? #1. Perro #2. Cocodrilo #3. Conejo #4. Tiburón #ii. Si la respuesta es Cocodrilo, asignar +0.5 a puntaje, si la respuesta es Tiburón asignar +1.0 a puntaje, del cualquier otro caso, no asignar valor, final...
e2c056534ed38e85c0b3898dbe8913471d359391
dhaarmaa/python
/menu/menu.py
3,602
3.609375
4
import os import time option = 1 userOne = None userTwo = None userThree= None passwordOne = None passwordTwo = None passwordThree = None while option!= 3: try: print("**********************************************************") print(" * MENU * ...
2fe89a6f7250e47363326760b8445fd7ec8c1254
dhaarmaa/python
/funciones/trabajoGrupal/caso3.py
512
3.609375
4
from random import * import os os.system('cls') list =[] def number(): for i in range(5): alzNumber = randint(1, 10) list.append(alzNumber) print(f"-{i}") print("tenemos 5 numeros al azar entre el 1 y el 10") def numberFound(): ingFoundNum = int(input("ingrese u...
f0eb7816aa5d5fec7204cb37fd8ce3781b817489
dhaarmaa/python
/Listas/guia1/caso2.py
524
3.859375
4
import os os.system('cls') #from typing import List list = [] answer = "si" while answer!="no": name= input("ingrese un nombre: ") list.append(name) answer = input("Desea agregar otro nombre? si/no: ").lower() list.sort() for i in range(len(list)): print(f"nombre es : {list[i]}") lessCharacters = li...
80f82cb78aeee0fb9ce22f5cb312e9960504a24b
dhaarmaa/python
/Listas/listas.py
1,027
3.96875
4
import os #edfonir lista list=[] list.append("dharma") list.append("ali") list.append("vale") list.append("mati") list.append("ricardo") list.append("pancho") list.append("jose") for dato in list: print(f"nombre: {dato}") print("************************") list.insert(0, "profe claudio") for dato in list: print...
0db6098a093b0b6ed846fe4c404f4c8b84c69526
darkn3rd/oop-tut
/python/j00.abstract/demo.py
595
3.78125
4
#!/usr/bin/env python from Triangle import Triangle # include Triangle.py from Rectangle import Rectangle # include Rectangle.py from Circle import Circle # include Circle.py # create new objects and initialize data triangleObject = Triangle(4, 5) rectangleObject = Rectangle(4, 5) cirleObject = Circle(...
b41636e68644927c082c5e82339630a532e74b2a
darkn3rd/oop-tut
/python/c10.properties/demo.py
323
3.890625
4
#!/usr/bin/env python from Person import Person # include Person.py # initialize data through mutator (set) captain = Person() # instantiate new object captain.name = "Jean-Luc" # mutator # access and print data through accessor (get) name = captain.name # accessor print "Name of the Person:\n\t" + na...
42b363cc67fc975777b910fc23529d49d3255c8b
darkn3rd/oop-tut
/python/e30.dynamic/demo.py
778
3.8125
4
#!/usr/bin/env python from Person import Person # include Person.py # initialize data through different constructors (overloading) captain = Person("Jean-Luc") officer = Person(21) ensign = Person("Wesley", 15) print("") # retrieve string from captain object name = captain.name # accessor age = captain.a...
68ab32e813805a2d485511f188e090bd6710a07e
rahmanshah/learn
/third.py
464
3.859375
4
name1 = input("Enter first person name: ") name2 = input("Enter second person name: ") combined = name1+name2 combined_lower = combined.lower() t = combined_lower.count("t") r = combined_lower.count("r") u = combined_lower.count("u") e = combined_lower.count("e") l = combined_lower.count("l") o = combined_lower.co...
6faf723f5ef931de7cc6fb5781727c77cd8eec98
JustgoodDeal/Different-tasks
/HomeWork/Examples/TaskExamples_3.py
1,744
3.921875
4
# Устанавливаем атрибут floor только на чтение class Elevator: def __init__(self, floor = 1): self._floor = floor # Так как есть '_', то при иницализации __init__ (сразу при создании экземпляра) заходит в getter(@propety), # а в setter не заходит. Если бы подчеркиания ...
f6c3df760f6daf4b85198985ac8195daa1e8aee0
JustgoodDeal/Different-tasks
/HomeWork/Class 5/Mod/module_2.py
368
3.671875
4
def count_if(A,p1,p2): count_sum = 0 for i in A: for j in i: if p1<=j<=p2: count_sum += 1 return count_sum def Test_count_if(): assert count_if([[4,10,3,6],[8,7,-3,-5],[4,-8,6,-1]],5,15)== 5,'Тест провален' assert count_if([[4,10,3,6],[8,7,-3,-5],[4,-8,6,-1]],0,...
3742ffe09082977745af1e08aaa90c8c0e49ad79
JustgoodDeal/Different-tasks
/HomeWork/Class 6/Task0.py
1,108
3.953125
4
# Написать программу, запрашивающую у пользователя строку с текстом и разделитель. # Необходимо вывести список слов с их длиной в начале слова, например, 5hello. # # Для каждой из пользовательских функций написать функцию-тест. def len_word(spisok): spisok = spisok.replace(' ', '') # чтобы из элемента списка...
3408528a234a81954fd770be2a0345c09313e8ff
JustgoodDeal/Different-tasks
/HomeWork/Class 4/Task1.py
1,199
3.671875
4
# Определить, является ли введенное слово идентификатором, т.е. начинается ли оно # с английской буквы в любом регистре или знака подчеркивания и не содержит других символов, # кроме букв английского алфавита (в любом регистре), цифр и знака подчеркивания. def identificator (word): a = 'abcdefghijklmnopqrstuvwxy...
bdb37d4b31d2be06a8e320d63f92eee4d1d2f380
fyrtoes/project_01_Stage_Reader
/colconverter.py
3,647
4.375
4
# GCAV Information # 1/22/2015 FINISHED on 1/25/2015 # The purpose of this program is to convert the column index from Meyer's into a number. A = 1, B = 2, etc. ''' print "\n" # Here is where I will ask the user to provide the column, from where I will store it. column = raw_input('Enter the column index (a, b, ac, e...
1798b7c084ca33926891a0657506eb60fb8acfd1
SushilPudke/PythonTest
/Recursion/multi.py
325
4.03125
4
# Generating 10 multiples of given no using recursion def multi(n,x): if x==0: return else: print(n," * ",(11-x)," = ",n*(11-x)) x-=1 multi(n,x) # recursive call to multi def Main(): n=int(input("Enter any no for multiples")) multi(n,10) if __name__=="__main__": Main...
5fa3bbc52a54a4f066abd1b1d10420348db757ef
SushilPudke/PythonTest
/Prg2.py
313
4.15625
4
#use of type to know the type of data a=input("Enter your name ") b=int(input("Enter your age")) c=float(input("Enter Floating value")) # print o/p of variable data print("a :",a,"b :",b,"c :",c) #print type of data print("a data type ",type(a)) print("b data type ",type(b)) print("c data type ",type(c))
3662b4ec7a071f5f678a204a2b037b8f2c547e4e
SushilPudke/PythonTest
/Inheritance/Exercise.py
1,511
3.921875
4
class X(object): def __init__(self, a): self.num = a def doubleup(self): self.num *= 2 class Y(X): def __init__(self, a): X.__init__(self, a) def tripleup(self): self.num *= 3 obj = Y(4) print(obj.num) obj.doubleup() print(obj.num) obj.tripleup() print(obj.num) # Base or Super class cla...
3fa1e9f558e41cc6f990963b96d89c6c24ddd966
SushilPudke/PythonTest
/Array/array1.py
526
4.59375
5
# Python program to demonstrate # Creation of Array # importing "array" for array creations import array as arr # creating an array with integer type a = arr.array('i', [1, 2, 3]) # printing original array print ("The new created array is : ", end =" ") for i in range (0, 3): print (a[i], end =" ") print(...
8eb23116e5351ed3dfcf9b2ab67a387f152c83c3
SushilPudke/PythonTest
/testage.py
248
4.125
4
# pro for read name ,age checking for eligibility nm=input("Enter Your Name ") age=int(input("Enter Your age")) print("Name ",nm,"Age",age) if age>=18: print(nm,"You are eligible to vote") else : print(nm,"You are not eligible to vote")
8cec167032dc7cc3936a40777cbf964512b15587
SushilPudke/PythonTest
/Exercise-2/arraymin.py
466
4.28125
4
# program to find minimum # in arr[] of size n # python function to find minimum # in arr[] of size n def smallest(arr,n): # Initialize maximum element mn = arr[0] # Traverse array elements from second # and compare every element with # current min for i in range(1, n): if arr[i] < mn: mn = a...
b0d031fd94e221f29f327250ee4b329ee3f3dcfe
SushilPudke/PythonTest
/demo/prg1.py
334
3.796875
4
# demonstrating main() funciton in python def f1(): print("I am in f1 definition ") print(chr(65)) def facto(n): f=1 while n>0: f=f*n n=n-1 return f def main(): print("I am in main Funtion") f1() n=5 print("Factorial of ",n,"==",facto(n)) if __name__=="__main__...
fecd2a849aa5742b7668f316a9761b9797411f13
yuanwb1984/leetcode
/172.FactorialTrailingZeroes.py
469
3.5625
4
# -*- coding: utf-8 -*- """ Created on Wed Jun 22 12:44:47 2016 累加5**n的个数 @author: 06210 """ class Solution(object): def trailingZeroes(self, n): """ :type n: int :rtype: int """ if n < 5: return 0 sum = 0 i = 1 m = 1 while m != 0: ...
715c026c9a34c745b8fcaeb379b15e306ace8fc6
andilabs/python-cookbook
/src/1/grouping-records-together-based-on-a-field/grouping.py
2,117
4.09375
4
""" Make an iterator that returns consecutive keys and groups from the iterable. The key is a function computing a key value for each element. If not specified or is None, key defaults to an identity function and returns the element unchanged. Generally, the iterable needs to already be sorted on the same key functi...
99338b87e92ac6d995862eaea8fe8093e5ce07c0
BenCradick/cs3130Project2
/CRAB2A.py
18,333
3.8125
4
#Ben Cradick #cs3130 #10-19-18 from random import randint import math import sys import time #super danger don't do this if you can't afford to crash sys.setrecursionlimit(20000) sys.stdout = open("CRAB2A.py", "a") def selection_sort(arr): for i in range(len(arr)): # Find the minimum element in remainin...
900f4a9983c5f6650d222744059539baa82f7f6a
themagicbean/automate_the_boring_stuff
/ListExercises.py
1,396
3.5
4
''' Created on Jan 24, 2019 @author: darrenbean ''' """ spam = ['apples', 'bananas', 'tofu', 'cats'] numberage = ['1', '2', '3', '4', '5', '6'] def listToString(list_to_be_strung): listlen = len(list_to_be_strung) listbeforeand = listlen - 2 listendage = listlen - 1 listitem = 0 whil...
0bbd8a520a15e8083796cada1f0cd5586be772e4
jangbigom91/Python
/Ch04/4-1.py
865
3.984375
4
""" 날짜 : 2020/06/23 이름 : 최정한 내용 : 함수 교재 p150 """ # 함수정의 def f(x): y = 2 * x + 3 return y # 함수호출 r1 = f(1) r2 = f(2) r3 = f(3) print('r1 :', r1) print('r2 :', r2) print('r3 :', r3) # 타입1 - 매개변수 O, 리턴값 O def type1(x, y): z = x + y return z # 타입2 - 매개변수 X, 리턴값 O def type2(): tot = 0 ...
b972783f626728de5cfa7ec22c92a01813d49d85
da-ferreira/algorithms
/Estruturas de Dados/pilha.py
1,043
4.09375
4
""" Autor: David Ferreira de Almeida Implemetação da estrutura de dados Pilha """ class Stack: def __init__(self): self.stack = [] self.size = 0 # Adiciona um elemento no topo da pilha def push(self, elemento): self.stack.append(elemento) self.size += 1 ...
05d4676dbcdc977f0a27f89084063c3d0e359b9c
da-ferreira/algorithms
/Ordenação/mergesort.py
1,358
4.125
4
""" Autor: David Ferreira de Almeida Algoritmo Merge Sort Categoria: Divisão e conquista Complexidade: O(n.log(n)) """ def mergesort(lista, inicio=0, fim=''): """ :param lista: A lista a ser ordenada :param inicio=0: O indice do começo da lista :param fim='': O indice do fim da lista ...
bfc0b3c125c88e59e60caae6730b73c7233a6b4c
da-ferreira/algorithms
/Ordenação/selectionsort.py
594
3.703125
4
""" Autor: David Ferreira de Almeida Algoritmo de ordenação Selection Sort Complexidade: O(n²) Categoria: Algoritmo Guloso """ def selection_sort(array): """ :param array: lista a ser ordenada :return: None """ for i in range(len(array)): posicao_menor = i ...
1b9d33d9745a8c819a471b8d282501a35868510d
YusraMasoodUIT/Detailed-Assignment-3
/Ex 3.33.py
285
4.15625
4
print("Yusra Masood , 18B-093-CS ,Section A") print("Ex 3.33") print("Function that reverse a string") sen = input("Enter a three letter string to reverse ") def reverse_string(sen): x = sen[0] y = sen[1] z = sen[2] print(z + y + x) reverse_string(sen) input()
05df9d8e054c25279240a3e1d0696995c832b6dc
YusraMasoodUIT/Detailed-Assignment-3
/Ex 3.38.py
301
3.8125
4
print("Yusra Masood , 18B-093-CS ,Section A") print("Ex 3.38") print("Program that takes a day of theweek as input and returns its two-letter abbreviation.") day = input("Enter a day of the week ") def abbreviation (day): x = day[0] y = day[1] print(x + y) abbreviation(day) input()
cb942efa59c17a9ed650e7471c1c96dd65acffaa
YusraMasoodUIT/Detailed-Assignment-3
/Ex 3.23.py
428
4.0625
4
print("Yusra Masood , 18B-093-CS ,Section A") print("Ex 3.23") print("for loop for the function range") for a in range(0 ,2): print(a) print("End") for b in range(0 ,1): print(b) print("End") for c in range(3 ,7): print(c) print("End") for d in range(1 ,2): print(d) print("End") for e...
768fccd9c41a9d258cf11b4267ee46e38eca4a93
RachelGHogan/coding-challenge
/Problem 9 (Music).py
791
3.8125
4
testCases = int(input("Input the number of words to find frequencies of: ")) array = [] lyrics = [] occurance = 0 result = 0 for i in range (testCases): array.append(input("Input the word: ")) num = int(input("Input the number of lyrics to add to the index: ")) for i in range (num): lyrics.append(input("Inpu...
f2f73e538fc63527282f7cf572beda18cd74399e
zappyfish/Python-Reminders
/reminder_setup.py
1,865
3.578125
4
import shelve class shelveWith(object): def __enter__(self,filey): self.open(filey) def __exit__(self, type, value, traceback): self.close() class assignment(object): def __init__(self, name, due_date): self.name = name self.due_date = due_date # date should be a tup...
826fac7bee2b658e9a9a9a23198bacf9d65b2d03
suneetfcc/dailycodingproblem
/1.py
1,593
4.125
4
''' This problem was recently asked by Google. Given a list of numbers and a number k, return whether any two numbers from the list add up to k. For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17. Bonus: Can you do this in one pass? ''' from bisect import bisect_left def binary_search(a...
c39f11f5276877365179b04ac45e15c182d2ae2a
Jaina16/ATBSWP
/characterPictureGrid.py
1,181
4.0625
4
#!/usr/bin/env python3 grid = [['.', '.', '.', '.', '.', '.'], ['.', 'O', 'O', '.', '.', '.'], ['O', 'O', 'O', 'O', '.', '.'], ['O', 'O', 'O', 'O', 'O', '.'], ['.', 'O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O', '.'], ['O', 'O', 'O', 'O', '.', '.'], ['.', '...
b8f02baa17cccc042bc75d314a0ccb6b7f3d19ab
mn4774jm/PycharmProjects
/Pycharm_files/Midterm_Complete/Midtermlast/midtermlastpractice.py
4,477
4.0625
4
# #Basics # # print('Welcome to Bob\'s Diner!') # # meal = input('Enter the price of your meal: ') # meal = float(meal) # tip_percent = input('Enter tip percent -> .15, .20, etc.: ') # tip_percent = float(tip_percent) # # tip_value = (meal*tip_percent) # tax = (meal * 0.075) # total = tip_value + tax + meal # # print('...
be2d5bb07e9380b15e70e0358339e1f2b119346a
mn4774jm/PycharmProjects
/Pycharm_files/Midterm_Complete/Midtermreviewdeepdive/HW1.1.py
582
4.03125
4
#gasCalc.py milesTraveled = float(input('How many miles did you travel? ')) gasUsed = float(input('How many gallons of gas did you use? ')) gasPrice = float(input('What is the current price of gas?' )) tripCost = gasPrice * gasUsed MPG = milesTraveled/gasUsed print('Welcome to the Gas Calculator program') print('The...
87aa7103e57b68167b3ff486f767427605b64994
mn4774jm/PycharmProjects
/Pycharm_files/week_15_midterm_practice/program1.py
1,867
4.0625
4
'''Thomas Mullins Date: 5/2/19 practice-1.py Definition: Write a program to ask for a 3 digit number. Then provide data for several user input descriptions''' #import regex for validation import re while True: try: #Print welcome print('Welcome to the digit processing machine!') #Set Regex...
f09e1e576fca1959d609286e7fb19703b99cbccb
mn4774jm/PycharmProjects
/Pycharm_files/Validation/CoinCounter.py
2,180
4.25
4
'''Author: Thomas Mullins Date: 2/11/19 CoinCounter.py Definition: A coin jar usually has mixed coins. Write a program that asks the user how many 25c quarters they have in a jar, and how many 10c dimes, 5c nickels, and 1c pennies. ''' #Variables and input # Can avoid Validation if int(input() is used instead; in thi...
4dafa0f78e686ceed24bfe6e410241fb49391a8b
mn4774jm/PycharmProjects
/Pycharm_files/Loops_ranges1/venv/loop-2.py
1,083
3.953125
4
'''Author: Thomas Mullins Date: 2/14/19 loop-2.py Definition: Write a program which asks the user for a small number. ''' #Header print('Welcome to our counting program.\nIt also adds up the digits as you count!') while True: #Variables small = input('Please enter a small number, 0 or higher: ') large = input...
30f2b4192c1382c274e91fa77474d48621628a67
mn4774jm/PycharmProjects
/Pycharm_files/Midterm_Complete/Midtermreviewdeepdive/HW1.2.py
788
4.03125
4
'''#area.py measure = input('What is your measurement unit (in., ft., cm. etc).? ') length = float(input(f'What is the length of the rectangle in {measure}? ')) width = float(input(f'What is the width of the rectangle in {measure}? ')) total = length*width print(f'Your rectangle is {total} square {measure}.')''' '''#...
88a2494b24ef6d792850400c2ae0ebe05751a4c9
mn4774jm/PycharmProjects
/Pycharm_files/MaryBockProblems/coffee_sales_fixed.py
2,745
4.09375
4
''' Thomas Mullins coffee_sales_fixed.py Definition: calculate coffee sales for various products from user input and provide a table as output *** rewritten to include loops and lists 9/18/19 ''' def main(): while True: try: beverages, bev_totals, prices = input1() each_totals, fina...
a71ee6a5b6bb7fa451794bfafa7e585d5526b0e4
mn4774jm/PycharmProjects
/Pycharm_files/Variables/WageCalc.py
384
3.703125
4
'''Author: Thomas Mullins Date: 1/24/19 Definition: Wages for 40 hours plus ten hours of overtime ''' regularWage=float(15.34) overtimeWage=(regularWage*float(1.5)) totalWages=((regularWage*40)+(overtimeWage*10)) #print(totalWages) print('Regular Wages', format(regularWage, '12.2f')) print('Overtime Wage', format(overt...
23ce23e646f62eb5a900736d754cce1066faed45
mn4774jm/PycharmProjects
/Pycharm_files/Loops_ranges1/AvgRainfall.py
2,197
3.96875
4
'''Author: Thomas Mullins Date:2/19/19 AvgRainfall.py Definition: Write a program that collects rainfall data and calculates the average rainfall for a user-defined number of years. ''' def main(): while True: try: years = input1() totalAll, averageAll = processing1(years) ...