blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
ab65f0304d4408675e7ce7baac0f66415c859afc
joshyou/comp_bio
/hmm.py
8,189
3.5625
4
import math import random import re import sys ''' This class implements the Viterbi algorithm for finding the best state path of a Hidden Markov Model. find_prob recursively computes the probability that the sequence up to the given index ended in a given state. This updates the table state_probs storing these re...
6fc969b1a196b6998b130b39631f6bb82f02a123
srikantviswanath/Algo-Practice
/subsets/find_subsets.py
657
3.78125
4
import copy def find_subsets_iterative(nums): all_subsets = [[]] for num in nums: next_level = copy.deepcopy(all_subsets) for subset in all_subsets: subset.append(num) next_level.append(subset) all_subsets = next_level return all_subsets def find_subsets_r...
431eb71f33427378078c1b847980b372619c76de
ksayee/programming_assignments
/python/CodingExercises/PrintLeafNodesLeftToRightBinaryTree.py
1,759
3.984375
4
# Sum of all elements in a binary tree class Node(object): def __init__(self,value): self.value=value self.left=None self.right=None class BinaryTree(object): def __init__(self,root): self.root=Node(root) def preorder(self,start,traversal): if start!=None: ...
a6d1b0f41f8357652b78543f6ad0d81871b22a0d
GAYATHRIalagar/PythonProgramming
/Other Programs/greater.py
141
3.984375
4
x=input() y=input() z=input() if(x>y and x>z): print("x is greater") elif(y>x and y>z): print("y is greater") else: print("z is greater")
d55c5bff63d9d915bf765d8f9d3f640175ce1112
alexp01/trainings
/Python/5_Advance_buily_in_functions/502_Iterator_class_example/prime_number_example_2.py
1,394
4.125
4
# https://www.udemy.com/course/the-complete-python-course/learn/quiz/4902698#questions class GenPrime: def __init__(self, bound): self.number = 3 self.bound = bound def __next__(self): if self.number < self.bound: for y in range(2, self.number): if self.num...
7c7b86d658fb8d30f44bf793a5d41bda8bcc084f
AlvarocJesus/Exercicios_Python
/AulaTeorica/exerciciosModulos/exercicio4/verificaSenha.py
728
3.640625
4
# Pelo menos 8 caracteres def tamanhoMin(senha): if len(senha) >= 8: return True else: return False # Pelo menos uma letra maiúscula def letraMaiuscula(senha): maiuscula = 0 for i in range(len(senha)): if senha[i].isupper(): maiuscula+=1 if maiuscula >= 1: return True else: return...
e65fe7919f53dcd5a457a96837b83dc4bf4154b4
Cationiz3r/C4T-Summer
/Session-6 [Absent]/dictionary/listDict.py
913
3.859375
4
book = { "name": "The Deventure of The Normie", "pubyear": "20XX", "characters": ["Stephen", "Dan", "Zane"], } book["manufactor"]= "Xapploie" book["country"]= "The Publica of Boardein" for k, v in book.items(): print(k, "-", v) print() # Update List book["characters"]= ["Anne", "Bran", "Cessi"] # C...
1abcf6a38374157fe012025d151a506fe32b5d6f
NewAwesome/Fundamental-algorithms
/LeetCode/80. 删除有序数组中的重复项 II/Solution.py
1,002
3.6875
4
from typing import List class Solution: # 条件: # 1、数组 2、原地修改 ————> 双指针 # 双指针: # slow 指向本次要放置元素的位置 # fast 向后遍历所有元素 def removeDuplicates(self, nums: List[int]) -> int: slow = 0 for fast in range(len(nums)): if slow < 2 or nums[fast] != nums[slow - 2]: ...
c9a16a1c85e1473d6737fb16f1f307e9a425e6a8
garima0106/Python-basics
/conversation-simulator.py
266
4
4
from random import choice questions =["Why is it a holiday?", "Why is it so hot?", "Why are you mad at me?"] question=choice(questions) answer=input(question).strip().lower() while answer!='just because': answer=input("why?: ").strip().lower() print("Oh ok..")
b265199e5dee4234474949e3baa14a34df57cd73
8Gitbrix/Coding_Problems
/IIT_cs331_fall2015_mps/03/sort_algs.py
1,303
4.34375
4
def insertion_sort(vals): """Insertion sort implementation""" for j in range(1, len(vals)): to_insert = vals[j] i = j - 1 while i >= 0 and vals[i] > to_insert: vals[i+1] = vals[i] i -= 1 vals[i+1] = to_insert def merge(l1, l2): """Merges two sorted li...
98bfea8df835689bcf55cb01152696d3f1edd672
brk9009/superchargedPython
/chapter1/forLoops.py
443
3.84375
4
# my_lst doesn't get affected by for loop my_lst = [10,15,25] for thing in my_lst: thing *= 2 #print(thing) print("Unaffected list: " + str(my_lst)) # double each element in list my_lst = [10,15,25] for i in [0, 1, 2]: my_lst[i] *= 2 print("Affected list: " + str(my_lst)) # Best way to double list my_lst...
ec35ddacf8dd14315f4500c340ad9eebecfa1c42
BJV-git/leetcode
/string/count_binary_substr.py
732
3.703125
4
# logic: the counting starts at 01 or 10 def count_binary_packed(s): slen=len(s) count=0 if slen < 2: return 0 i=0 while i < slen-1: if (s[i] == '0' and s[i+1]=='1') or (s[i] == '1' and s[i+1]=='0'): count+=1 start = i-1 end = i+2 i...
6a290dac0a2dd84f53464d15297bc289bf99fd14
cbuffalow/BookStore
/BookStoreList.py
6,190
3.84375
4
def main(): import pickle run = True cashBalance = 1000 bookstore = titles, authors, prices = [], [], [] while run: mainmenu = input('''What would you like to do? A. Add Book S. Sell Book ...
6f141c34a8c3696f527075633f2d667618f810d6
slaash/scripts
/python/fp/prime.py
546
3.53125
4
#!/usr/bin/python import math, sys #def get_divisors(x): # return filter(lambda j: x % j == 0, range(2, int(math.sqrt(x)+1))) #def is_prime(x): # if len(get_divisors(x)) == 0: # if len(filter(lambda j: x % j == 0, range(2, int(math.sqrt(x)+1)))) == 0: # return True #def get_primes(min, max): # return filter(is_pri...
b31d2e0e5f2b2de480fdf48643dba1c9509931e8
bugagashenki666/lesson11p
/procvesses_class.py
851
3.515625
4
from multiprocessing import Lock, Process import os from time import sleep class MyProcess(Process): def __init__(self, begin, end, timeout, lock): super().__init__() self.begin = begin self.end = end self.timeout = timeout self.lock = lock def run(self): while...
47529d43606dd9d7acf5c721fed6efdf837b15d1
evasu9582/python
/countofday.py
228
3.671875
4
def countofdays(trips): cou=[] for i in trips: a,b=i count=0 for k in range(a,b+1): count+=1 cou.append(count) return sum(cou) a=countofdays([[10,15],[35,45]]) print(a)
cee8559b41b47adfdb45345e37173388d4c191b9
knittingarch/Zelle-Practice
/Exercises/3-1.py
363
4.28125
4
''' A program that calculates the volume and surface area of a sphere by Sarah Dawson ''' import math def main(): print "This program will caluclate the volume and surface area of a sphere with your help!" r = eval(raw_input("Please enter the radius of your sphere: ")) volume = 4.0/3.0 * math.pi * r**3 area = 4 * ...
12a816ec8c784e2960a1c9837aa599f7d44f7945
zdenek-nemec/sandbox
/binec/tools/get_longest_line.py
721
3.96875
4
#!/usr/bin/env python3 import argparse DEFAULT_FILENAME = "get_longest_line.py" def main(): parser = argparse.ArgumentParser(prog="get_longest_line") parser.add_argument('--filename', '-f', default=DEFAULT_FILENAME) filename = parser.parse_args().filename with open(filename, "r") as input_file: ...
d589fc75b266c420a3f94939e0cfe35cc97f9ee5
RioterTrov97/Audio-Chatbot
/Source Code/calc.py
6,248
3.796875
4
def calculate(q): import main import speaker data_length = main.voice_data.split(" ") length = len(data_length) if length > 3: opr = main.voice_data.split()[-2] ppr = main.voice_data.split()[-4] if opr == '+' or opr == 'plus' or ppr =...
92109a5e3f6767cc208605736f17b0771c0629f3
sgnn7/sandbox
/fizzbuzz/fizzbuzz.py
884
4
4
#!/usr/bin/env python3 # Fun solution - list comprehension # print('\n'.join(["FizzBuzz" if not (num % 3 or num % 5) # else "Buzz" if not num % 5 # else "Fizz" if not num % 3 # else str(num) for num in range(1,101)])) # Fun solution2 - zipping list_ran...
98f29fc1c4d236ccef650d9a24a2f9d7afc2e5b8
krishnx/codes
/crud_tree.py
2,686
3.859375
4
class Node: def __init__(self, x): self.data = x self.left = None self.right = None class Tree: def __init__(self, root): self.root = root def insert_node(self, data): if not self.root: self.root = Node(data) else: tmp = self.root ...
a978d4b39fe70c81ebd35d2160e4744d3713a2fe
andybloke/python4everyone
/Chp_3/Chp_3_ex_1_pay.py
253
4.125
4
hours = input("Enter hours: ") rate = input("Enter rate: ") hours = float(hours) rate = float(rate) if hours > 40.0: extra = hours - 40 pay = (hours - extra) * rate + extra * 1.5 * rate print("Pay:", pay) else: pay = hours * rate print("Pay:", pay)
2078a44d9b08b9ba3c8ed8c486feb78d5d0ff8dc
greenfox-zerda-lasers/t2botond
/week-03/day-1/11.py
113
3.75
4
k = 1521 # tell if k is dividable by 3 or 5 if k%3==0 or k%5==0: print("True") print(k%3) print(k%5)
c09ffa3c43618e25c9c23dd3455ded95d207f6f2
Ashutosh-gupt/HackerRankAlgorithms
/Funny String.py
1,179
3.9375
4
# -*- coding: utf-8 -*- """ Problem Statement Suppose you have a string S which has length N and is indexed from 0 to N−1. String R is the reverse of the string S. The string S is funny if the condition |Si−Si−1|=|Ri−Ri−1| is true for every i from 1 to N−1. (Note: Given a string str, stri denotes the ascii value of t...
d1130c50efbab250fbe60c3532679e05d30b5651
harshidkoladara/Python_Projects
/Project Modules-20200331T061028Z-001/Project Modules/demo.py
777
3.71875
4
from tkinter import Tk,Text,Label from tkinter import ttk from PIL import ImageTk,Image t = Tk() t.title('EVA') t.geometry('500x300') img1 = ImageTk.PhotoImage(Image.open('YOU.png')) img2 = ImageTk.PhotoImage(Image.open('EVA.png')) you_tn = Label(t,image = img1) eva_tn = Label(t,image = img2) you_txt = Label(t,text = '...
b43bbe0238176fd2b95a5da61dc00f0186a4e2c6
AK-1121/code_extraction
/python/python_28698.py
258
4.125
4
# How can I delete the letter that occurs in the two strings using python? def revers_e(s1, s2): print(*[i for i in s1 if i in s2]) # Print all characters to be deleted from s1 s1 = ''.join([i for i in s1 if i not in s2]) # Delete them from s1
b2f3cd7eac1231bc837001bce73b3d56ce4590f9
Jadouille/Kithub
/GithubSearch/process_files.py
8,671
3.546875
4
import json import os import yaml import argparse import javalang def process_file(filepath): """ Process the code file and extract the parsed tree and tokens :return the parsed tree, tokens, lines and comments """ with open(filepath, 'r') as f: content = f.read() with open(filepath, '...
383f2948699888210ba5031e9b77dcf1009435cd
erjan/coding_exercises
/maximum_value_after_insertion.py
2,075
3.953125
4
''' You are given a very large integer n, represented as a string,​​​​​​ and an integer digit x. The digits in n and the digit x are in the inclusive range [1, 9], and n may represent a negative number. You want to maximize n's numerical value by inserting x anywhere in the decimal representation of n​​​​​​. You canno...
6257674866e32bf4412641715edd26bfe07c551d
zachfeld/data-structures-algorithms
/Assignment-1/MaxSubarray.py
1,501
4.125
4
# A python program for finding the largest sum in an array of values def maxSubarray(arr): #working set of variables and finalized set of variables currentMax = float('-inf') startIndex = 0 endIndex = 0 maxStart = 0 maxEnd = 0 workingMax = float('-inf') for i in range (len(arr)): ...
21c0d2942d3c03711ce6373d59e82013c060594e
MaxDunsmore/Prac08
/blockBuilding.py
480
3.921875
4
""" CP1404 Prac 08 - Recursion""" def main(): number_of_blocks = int(input("Please enter the number of rows: ")) pyramid_block_builder(number_of_blocks) def pyramid_block_builder(number_of_blocks): total_blocks = 0 if number_of_blocks == 0: print(total_blocks) return if number_of_...
63c31b426d7c5d4bea5a801cd9e67afd07bb194d
224nth/leetcode
/apple/reverse_linked_list.py
735
4
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next from common.linked_list import build_linked_list_with_ListNode, ListNode class Solution: def reverseList(self, head: ListNode) -> ListNode: stack = [] ...
bdc856dc28bf7988bbadcfe149fa3d3906eda2f2
SelahittinSaytas/IntroToPythonProgramming
/Sentdex/PythonFundamentals/Basics/28-ListManipulation/tut.py
462
4.0625
4
x = [1,2,3,4,5,6,7,8,9,10,11] y = ["Janet","Jessy","Kelly","Alice","Joe","Bob"] x.append(13) x.insert(11,12) x.remove(x[5]) print(x) print(x[11]) print(x[2:5]) #Slicing - to access a slice print(x[-1]) #To access the lass element of the list print(x.index(1)) #To find the index number of a list item print(x.count(13...
b16627179e29d0922468169526f511e67fb160a0
swikot/DatabaseProject
/ProjectFile.py
6,062
3.875
4
__author__ = 'swikot' # delete the existing database and CSV file and run program again import sqlite3 import csv from datetime import date, datetime db_connection=sqlite3.connect("FLAPPY.db",detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) db_cursor=db_connection.cursor() print("WELCOME TO OUR COURIER ...
3b9bb0b6d61b23c6663e8b22e1cb2a3278273871
tonyfrancis1997/Lane_detection
/exp_01_28_lane_detection.py
2,205
3.53125
4
import cv2 import numpy as np from matplotlib import pyplot as plt # LOading the image img = cv2.imread('road1.jpg') # Converting to RBG format to display in pyplot img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # Finding height and width height = img.shape[0] width = img.shape[1] # defining variables for regio...
dd4cb7464a53868b9e6488a83248818a6d5eaf14
emirarditi/IEEEPythonDersleri
/Lecture3/FirstCalculator.py
840
3.859375
4
while True: deniz = input("Lütfen bir işlem girin: ") if deniz == "-1": print("Goodbye!!!") break karakterler = deniz.split(" ") ilk_sayi = float(karakterler[0]) ikinci_sayi = float(karakterler[2]) islem = karakterler[1] result = None if islem == "+": result = ilk...
18cfb77c6446b34575ea92d962e26fa5e461c7f0
ashwani8958/Python
/PyQT and SQLite/M3 - Basics of Programming in Python/program/function/5_global_vs_local_variable.py
441
3.78125
4
age = 7 def a(): print("Global varible 'age': ", globals()['age']) #now modifying the GLOBAL varible 'age' INSIDE the function. globals()['age']=27 print("Global variable 'age' modified INSIDE the function: ", globals()['age']) #now creating a LOCAL variable, 'age' INSIDE the function. age = ...
446114f7f8bf7a2627b3d075d8d8e1b3f33726d0
trunghieu11/PythonAlgorithm
/Contest/CodeFights/LCM.py
289
3.640625
4
__author__ = 'trunghieu11' def gcd(a, b): while b != 0: a, b = b, a % b return a def LCM(n): answer = n for i in range(1, n + 1): answer = answer * i / gcd(answer, i) return answer if __name__ == '__main__': n = int(raw_input()) print LCM(n)
8789bf4a1396c91a40ae8b8ba1b577ea14dc149a
AMFeoktistov/infa_2019_ivanov
/Turtle/11.py
283
3.625
4
import turtle import math turtle.shape('turtle') turtle.rt(90) def two_circles(): for i in range(60): turtle.fd(step) turtle.rt(6) for i in range(60): turtle.fd(step) turtle.lt(6) step = 5 for i in range(10): two_circles() step += 1
19839565401520cf2a2dac8b1ba04fb854215962
17766475597/Python
/part1.py
1,273
4.34375
4
#字符串 car = ['Honda','Toyota','Benz','BMW']; #列表方括号 car.insert(1,'Hyundai'); #插入元素 print(car); car.append("append"); #追加元素 print(car); del car[0]; #删除元素 print(car); pop_ele = car.pop(); #弹出最后一个元素 print(car); print(pop_ele); pop_eler = car.pop(0); #弹出任意位置元素(下标从0开始) prin...
e29c7453fa68601fb48ff06a5a910866888901f6
bphillab/Five_Thirty_Eight_Riddler
/Riddler_17_12_22/Riddler_classic.py
1,054
3.59375
4
import numpy.random as random def __initialize_game(num_players, num_dollars): return [num_dollars for i in range(num_players)] def __eliminate_dead_players(players): return [i for i in players if i > 0] def __pass_dollars(players): players = __eliminate_dead_players(players) for i in range(len(pl...
f513399fc4a9705588a25d10044b631a6282d1a1
mcgettin/ditOldProgramming
/yr2/sem1/euler/eu3.py
490
3.671875
4
#euler3: prime factors of 600,851,475,143 def isPrime(num): for i in range(2,int(num/2)+1): if not num%i: return False return True def getNextFactor(fac,num): for i in range(int(fac)+1,int(num/2)+1): if (not num%i): return i return int(num/2)+1 ...
df9b4835f76dc671b7c6742dc531114bf56bf85f
razzaksr/SasiPython
/basics/SeriesFibo.py
224
4.21875
4
# Fibonacci series: 0 1 1 2 3 5 8 13 21 ,,,,, num1=0 num2=1 print(num1,num2,end=" ") for temp in range(2,int(input("Tell us count of fibonacci: "))): sum = num1 + num2 num1=num2 num2=sum print(num2,end=" ")
1a26e81cf9d4be8f32592f62c09fddbb4aff2469
ohentony/Aprendendo-python
/Funções em python/ex003.py
1,234
4
4
# Faça um programa que tenha uma função chamada contador(), que receba três # parâmetros: início, fim e passo. Seu programa tem que realizar três contagens # através da função criada: # a) de 1 até 10, de 1 em 1 # b) de 10 até 0, de 2 em 2 # c) uma contagem personalizada from time import sleep def contador(início, fi...
9fba7032b14e2da452a67c948352348fe63cab79
StephanJon/Interpolation
/src/SeqADT.py
2,806
3.984375
4
## @file SeqADT.py # @author Stephanus Jonatan # @date January 21, 2018 ## @brief SeqT is a class that creates an empty list/sequence. # @details SeqT has a constructor, and a few accessors and mutators. class SeqT(object): ## @brief Initializes an empty Sequence. def __init__(self): self.S...
3a802048836cd531f75a30f45370fd1aa6690336
buhuipao/LeetCode
/2017/tree/Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.py
1,632
4
4
# _*_ coding: utf-8 _*_ ''' Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. ''' # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # ...
9d7bb54a0ec3a35509948b0c0e7bc23830207d72
asset311/leetcode
/linked lists/merge_two_sorted_lists.py
1,863
3.984375
4
''' 21. Merge Two Sorted Lists https://leetcode.com/problems/merge-two-sorted-lists/ Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing together the nodes of the first two lists. ''' class ListNode: def __init__(self, val=0, next=None): self.val = val...
22be27924e29e5c616bd06534db8680c70eb861c
wmm98/homework1
/7章之后刷题/9章/有理数加法.py
773
4.0625
4
'''【问题描述】 定义有理数类,定义计算两个有理数的和的方法。程序输入两个有理数,输出它们的和。 【输入形式】 输入在一行中按照a1/b1 a2/b2的格式给出两个分数形式的有理数,其中分子和分母全是正整数。 【输出形式】 在一行中按照a/b的格式输出两个有理数的和。注意必须是该有理数的最简分数形式,若分母为1,则只输出分子。 【样例输入】 1/3 1/6 【样例输出】 1/2''' from fractions import Fraction class yl_shu: # def __init__(self, x, y): # self.x = x # self.y = y ...
60d9b1aafb2cba74dca0478679f6ae9c5c860081
chenxu0602/LeetCode
/1793.maximum-score-of-a-good-subarray.py
1,558
3.65625
4
# # @lc app=leetcode id=1793 lang=python3 # # [1793] Maximum Score of a Good Subarray # # https://leetcode.com/problems/maximum-score-of-a-good-subarray/description/ # # algorithms # Hard (46.06%) # Likes: 220 # Dislikes: 14 # Total Accepted: 5.6K # Total Submissions: 12.2K # Testcase Example: '[1,4,3,7,4,5]\n3'...
af74640d6908675f7991c40401a9f4045ca4c6bb
hkpcmit/AlgThink
/proj2.py
1,502
3.765625
4
"""Algorithm Thinking: Project 2.""" from collections import deque import copy def bfs_visited(ugraph, start_node): """Return set of nodes visited from start_node.""" visited = set([start_node]) queue = deque([start_node]) while queue: node = queue.popleft() for neighbor in ugraph[nod...
1e59d9d806484bc213cd02ab062d37174f07e6a1
Samyuktha-ch/Assignment-6
/assignment 6.py
771
3.96875
4
#Greatest Common Divisor t=0 gcd=0 a=int(input("Enter the value of a:")) b=int(input("Enter the value of b:")) x=a y=b while b!=0: t=b b=a%b a=t gcd=a print("The GCD of",x,"and",y,"is:",gcd) #Reverse a string by input from user def reverse(s): str=" " for i in s: str=i+str return str s...
23ad38b6cb2464d076b0bd96f03b9bb7ccbdcfdd
ccc013/DataStructe-Algorithms_Study
/Python/Leetcodes/linked_list/jianzhi_offer_25_mergeTwoLists.py
1,230
3.765625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2021/2/10 6:18 下午 @Author : luocai @file : jianzhi_offer_25_mergeTwoLists.py @concat : 429546420@qq.com @site : @software: PyCharm Community Edition @desc : 剑指 Offer 25. 合并两个排序的链表 https://leetcode-cn.com/problems/he-bing-liang-ge-pai-xu-de-lian-...
a92d8a5558ddd2a3e32b90745acf4ce82b4037ed
tng10/sitemap-generator
/parsers.py
1,216
3.640625
4
from urlparse import urlparse from HTMLParser import HTMLParser class URLParser(object): def __init__(self, url): self.url = url self.parsed_url = urlparse(self.url) def get_domain(self): """ Extracted domain from the URL (e.g berlin.de) """ return self.parsed...
971b9d6d5f2c486c8a87183b2e61bfa05bc25ca3
AbelNyc/Desktop-Database-Application
/table.py
3,199
4.125
4
""" The database can store book information Title, Year ,Author , ISBN User can : Add a book, View all books in the database Search for a book, Update a book info, Delete a book, Close """ import tkinter as tk import storage from tkinter import * from tkinter import ttk def lookup(): lst.delete(0,END) ...
a390a8e4c203b5fa01979ee8fd3dcca586d0f9e0
toddlerya/Core-Python-Programming-Homework
/Chapter_2/2-11.py
1,475
3.9375
4
#! /usr/bin/env python #coding: utf-8 """ 带 文本菜 单 的程序 写一个 带 文本菜 单 的程序,菜 单项 如下(1)取五个数的和 (2) 取五个 数的平均 值 ....(X)退出。由用 户 做一个 选择 ,然后 执 行相 应 的功能。当用 户选择 退出 时 程序 结 束。 这 个 程序的有用之 处 在于用 户 在功能之 间 切 换 不需要一遍一遍的重新启 动 你 的脚本。 ( 这 对 开 发 人 员测试 自己的程序也会大有用 处 ) """ while True: usr_choice = raw_input("请输入你的选项:\n (1)计算五个数字的加和\n (2)计算五个数字...
a5bd29992170419773ac00968c7d95e1313ab7b5
18965050/python-advanced
/finalgenerator/generator101.py
238
3.796875
4
def countdown(n): while n > 0: yield n n -= 1 if __name__=='__main__': for x in countdown(10): print('T-minus', x) c = countdown(3) next(c) next(c) c.__next__() # next(c) # next(c)
f9b8b19065cb6458f17e6f0803965775c3895d09
JeanneBM/Python
/Owoce Programowania/R07/09. Insert_list.py
489
4.25
4
# Ten program pokazuje przykład użycia metody insert(). def main(): # Utworzenie listy wraz z przykładowymi imionami. names = ['Jakub', 'Katarzyna', 'Bartosz'] # Wyświetlenie listy. print('Lista przed wstawieniem nowego elementu:') print(names) # Wstawienie nowego elementu w indeksie 0. n...
003e664680cd3395c78e2f4e04a8a8047cc826f4
BelenSolorzano/UNEMI---POO
/CicloFor.py
3,604
3.640625
4
class For: def __init__(self): pass # ciclo repetitivo de incrementos o decrementos se ejecuta por verdadero (mientras tengo valores) def usoFor(self): nombre = " Marcos" datos = ["Marcos", 28 , True] numeros = (2,5.6,4,1) docente = {'Nombre': 'Marcos', 'Edad':28 ,...
fd69d180689caf8ef8a7640ab5ed5686d99718a9
rodrilinux/Python
/Python/_2.9-composicao.py
430
3.546875
4
# coding: iso-8859-1_*_ ''' Uma das caractersticas mais prticas das linguagens de programao a possibilidade de pegar pequenos blocos e combin-los numa composio. Por exemplo, ns sabemos como somar nmeros e sabemos como exibi-los; acontece que podemos fazer as duas coisas ao mesmo tempo: ''' print(17 + 3) a = 30 pri...
79f204f464eecb9112af84fa59c9e3235272dcb4
ShyamPraveenSingh/Python-Basic-Tasks
/wordDocumentCreator.py
504
4.21875
4
#Prpgram to create a new Word document and save the inputs in it given by the user. #This is a third party module install it by typing 'pip install python-docx' #import the 'python-docx' import docx #inputs from the user print('Enter your name: ') name = input() print('Enter your age: ') age = input() #Opening a ...
e10066740fdea7f507aa65d11c409827cc037871
rchaud03/my_Pycharm
/learn_Python3/03.8-Strings 2.py
439
4.21875
4
""" Strings """ a = "this is a string" b = "alsoAString" c = "im a string 2" d = "string4" e = "This string will contain 'apostrophes' or single quotes to distinguish from double quotes" f = "THis string will contain \"double quotes\" preceeded by a forward slash to tell python to treat them as part of the string" pr...
1cae773196abe6a5798288078736e2f2dab9bfc5
rashidbilgrami/piaic_studies
/binary_to_decimal.py
702
4
4
''' This code is for the study purpose the code is developed by Rashid Imran Bilgrami, If you have any concerns please email me at rashidbilgrami@hotmail.com or comments on GITHUB ''' # Print Welcome Message print("###### Welcome to Binary to Decimal Program ####") # Getting input from the user, \n is using ...
903d628315415b6e7207e5683ed53468a85c634a
Gabrielcarvfer/Introducao-a-Ciencia-da-Computacao-UnB
/aulas/aula7/palavras_alice.py
247
3.5
4
file = open('alice.txt') dictionary = {} text = file.read() words = text.split() for word in words: if word not in dictionary.keys(): dictionary[word] = 1 else: dictionary[word] += 1 print(dictionary) pass
ad0936a6e1459ba0310054b2743e46dbfd7213fb
promoscow/stepik_python
/stepik_ex_4.py
2,619
3.640625
4
n = int(input()) games = [] teams = dict() def fill_games(): for i in range(n): entry = input().split(';') game = dict() game[entry[0]] = entry[1] game[entry[2]] = entry[3] games.append(game) if not teams.__contains__(entry[0]): teams[entry[0]] = [] ...
adc727beaa7f8946f526b975d08cdec3efe85593
ayanuchausky/TP_algo
/test_ahorcado.py
6,637
3.828125
4
""" Parte hecha por Agustín Esteban Conti - Etapa 1 Esta parte del codigo es la estructura principal del juego. """ """palabra_a_adivinar = "auto" #palabra usada para testear""" def palabra_insertada_a_interrogacion(palabra_a_adivinar, letras_usadas): # Agustín Conti: Crea una cadena de interrogaciones igual de ...
cbd928cae24bbd74b46ba80f7f1bb564e9285c2c
hogitayden/nguyenhoanggiang-fundametal-c4e22
/Session1/homework/c2f_hws1.py
113
3.65625
4
C = input ("Enter the temperature in Celsius? ") F = 33.8 * float(C) F = round(F,2) print (C, "(C) = ", F, "(F)")
ef7895ee1ce8f1726ee8fdf6a01fdb8434defc89
jayske/VYA_test
/vya_luhn.py
855
3.703125
4
def sum_luhn(total): if (total % 10 == 0) and (total > -1): return "the number is valid" else: return "the number is invalid" # 371612019985236 def do_luhn(lst): sum = 0 for index in range(len(lst)): if (index%2 != 0) and (int(lst[index]) >= 0): x2value = int(lst...
1fcbf47cf0079779779dca9485fa384d928a4531
alexsorr-it/Gruppo11
/Esercizio3Intracorso/due_otto_tree.py
32,025
3.71875
4
from collections.abc import MutableMapping class MapBase(MutableMapping): """Our own abstract base class that includes a nonpublic _Item class.""" # ------------------------------- nested _Item class ------------------------------- class _Item: """Lightweight composite to store key-value pairs as...
442d1a1a4fb1855fb2f496e8bb52f7ff24740829
Md-Monirul-Islam/Python-code
/Numpy/Array Manipulation - flatten and ravel.py
259
3.546875
4
import numpy as np #flatten a = np.array([[1,2,3],[4,5,6],[7,8,9],[10,11,12]]) print(a) print(a.flatten()) print(a.flatten(order='F')) print(a.flatten(order='A')) #ravel b = np.array([[1,2,3],[4,5,6]]) print(b) print(np.ravel(b)) print(np.ravel(a,order="F"))
28434868c192a8380b854c521745b9d3517c17f5
carlcrede/python-elective
/ses9/small_exercises.py
842
3.90625
4
from datetime import datetime """ Write a decorator that writes to a log file the time stamp of each time this function is called. Change the log decorator to also printing the values of the argument together with the timestamp. Print the result of the decorated function to the log file also. Create a new functio...
e83232ea26dc85c2a212f25f77d885d47f8923b5
E2394/python_assignments
/prime.py
360
4.21875
4
# for theory, check out https://en.wikipedia.org/wiki/Primality_test number= float(input("Enter a number..:")) root = number**(1/2) rootint = round(root) divisors = [] for i in range(2,rootint+1): if (number % i) == 0: divisors.append(i) i+=1 if not bool(divisors): print(f"{number} is prime.") el...
014fb1b4bc3d182cabf34eeb7fd7c84b7d405ecf
choroba/perlweeklychallenge-club
/challenge-214/sgreen/python/ch-2.py
1,354
4.15625
4
#!/usr/bin/env python import sys def shrink_list(array): '''Shrink the list if it has consecutive numbers''' new_array = [] for i in array: number, count = i if len(new_array) and new_array[-1][0] == number: new_array[-1] = (number, count + new_array[-1][1]) else: ...
2305c477b3c04ce193486ac6c7d27dfaffc90877
aashya/Reinforcement-Learning
/Reinforcement Learning.py
5,611
3.578125
4
#!/usr/bin/env python # coding: utf-8 # In[22]: import numpy as np import matplotlib import matplotlib.pyplot as plt # Epsilon Greedy class Bandit_eps: # print("Bandit") def __init__(self,m): self.m = m self.mean = 0 self.N = 0 def pull(self): return np.random.r...
b54872107fbfebcdd4c469addf986255026d22cb
rm-hull/luma.core
/tests/baseline_data.py
975
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2017-18 Richard Hull and contributors # See LICENSE.rst for details. def primitives(device, draw): padding = 2 shape_width = 20 top = padding bottom = device.height - padding - 1 draw.rectangle(device.bounding_box, outline="white", fill...
d0f6b35ff7ac0aa0978eeecd3e0f73d5510b92f7
Crazybus/pumbaku
/pumbaku_test.py
1,322
3.65625
4
from pumbaku import find_haiku def test_a_valid_haiku(): message = find_haiku('An old silent pond. A frog jumps into the pond. Splash silence again') assert message == ( 'AN OLD SILENT POND\n' 'A FROG JUMPS INTO THE POND\n' 'SPLASH SILENCE AGAIN' ) def test_a_valid_haiku_with_new_l...
4686e97717b169d60c13f4fa741e30611ad8a95e
Swagatamkar/Restaurant_Management_System
/Tkinter project 1.py
6,143
3.8125
4
price={'Rice':150, 'Daal':100, # in this dict items stored as key and price of that item as value ' Kadai Paneer':130, 'Butter paneer':150, 'chicken Kasa':190, 'Butter Chicken':200, 'None':0} def click(): # this func will be called when submit but...
4e120180809eb65a203cdafc570e39afbc2c8f46
EdwinVan/Python
/Python Homework/20-10-09-week05/4-6.py
4,622
3.71875
4
# 4-6.py 验证羊车门更换选择是否会增加猜中汽车的机会demo # fyj # 2020/10/11 num_times = 100000 from random import * nochange_success = 0 change_success = 0 nochange_loser = 0 change_loser = 0 for times in range(num_times): print("**********{}**********".format(times+1)) list = ["sheep","sheep","sheep"] # 初始化,每个门后都为羊 num = ...
9258aaf8d5248e37ee7000bf99a877c50ed1819a
Panda-Lewandowski/Programming-in-Python
/first semester/lab2.py
5,395
3.9375
4
from math import sqrt x1, y1 = map(int, input('Введите координаты вершины А ').split()) x2, y2 = map(int, input('Введите координаты вершины B ').split()) x3, y3 = map(int, input('Введите координаты вершины C ').split()) print(''' B /\\ / \\ ...
f89edc2d4a13a522d2980e561017ae2c0542e9fc
plutmercury/OpenEduProject
/w05/task_w05e12.py
855
3.96875
4
# Дана строка. Выведите слово, которое в этой строке встречается чаще всего. # Если таких слов несколько, выведите то, которое меньше в лексикографическом # (алфавитном) порядке. # # Sample Input: # # apple orange banana banana orange # # Sample Output: # # banana words = input().split() word_count = {} for word in w...
03e2b82c00d1b11ed410e5f17e62769eacf14956
vhsw/CodeMasters_Tourney
/Python 3/chessKnight.py
927
3.65625
4
# Given a position of a knight on the standard chessboard, find the number of different moves the knight can perform. # The knight can move to a square that is two squares horizontally and one square vertically, or two squares vertically and one square horizontally away from it. # The complete move therefore looks like...
9b6665f7499292214f365aa7395844881c060d4b
SkiMsyk/AtCoder
/BeginnerContest104/b.py
298
3.609375
4
s = list(input()) def conditionA(s_list): return s[0] == "A" def conditionC(s_list): return "C" in s_list[2:-1] def conditionLower(s_list): return sum([e.isupper() for e in s_list]) == 2 if conditionA(s) and conditionC(s) and conditionLower(s): print("AC") else: print("WA")
7f188d0ab7afebe5db88e78549cd01705820f86f
FangShinDeng/LeetCodeLearning
/1047LeetCode刪除重複項.py
273
3.859375
4
def removeDuplicates(S: str) -> str: stk = list() for ch in S: if stk != [] and stk[-1] == ch: stk.pop() else: stk.append(ch) return "".join(stk) S = 'abbaca' ans = removeDuplicates(S = S) print('ans: ' + ans)
711c4e8ca5707482ec28ec16884609c4091650ec
zikingwang/data-structure-in-py
/search/search.py
1,333
3.796875
4
# -*- coding: utf-8 -*- def index_of_min(lyst): """ Returns the index of the minnum item. 搜索列表的最小值 O(n) :param lyst: :return: """ min_index = 0 current_index = 1 while current_index < len(lyst): if lyst[current_index] < lyst[min_index]: min_index = current_i...
e4751dfd454d6817fd46084d1ce17ecbb0f599d7
EphTron/neural-acw
/neural_acw_part1.py
7,938
3.96875
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt from matplotlib.patches import Rectangle import math from math import floor import random def sigmoid(input_value): return 1.0 / (1.0 + math.exp(-input_value)) def step_func(input_value): return 0 if input_value > 0 else 1 class Percep...
71c72cedb6bee19ab5eab50e25c47b631cf9ceee
excid3/neon
/apps/graph_app.py
1,064
3.71875
4
import random from neon import NeonApp class GraphApp(NeonApp): """This is a simple example application that draws 6 moving bar graphs""" def on_init(self): self.graphs = [400, 1000, 600, 900, 800, 1200] self.colors = [(0.1, 0.8, 0.1), (0.8, 0.1, 0.1), ...
ef0b1b6e9def3922934ad312e26291aee43bd73e
eladkehat/soong
/soong/dml.py
3,442
3.640625
4
"""SQL DML (data manipulation language) helper functions that minimize boilerplate code. These functions support the most common scenarios of data manipulation - insert, update and delete, while saving you from writing the boilerplate code around connections and cursors, or even writing the SQL itself. """ from typin...
0558be126544b48654f350b2ee573a9b9e03853a
ekmahama/Mircosoft
/backtracking/wordSearchII.py
1,349
3.734375
4
class Solution(object): def findWords(self, board, words): """ :type board: List[List[str]] :type words: List[str] :rtype: List[str] """ def backtrack(board, i, j, word): if len(word) == 0: return True if i < 0 or i >= len(board...
a1e1e9fac578d8f1339a85c64afe5a537a8d97e6
SymJAX/SymJAX
/docs/auto_examples/01_nns/plot_comparison.py
5,492
3.65625
4
""" Image classification, Keras and SymJAX ====================================== example of image classification with deep networks using Keras and SymJAX """ import symjax.tensor as T from symjax import nn import symjax import numpy as np import matplotlib.pyplot as plt import sys sys.setrecursionlimit(3500) def ...
5a1358311cbb0bdc66db0346198758492b3f9355
rohan9769/Python-Coding-and-Practice
/PythonBasicPractice/41.Tuples 2.py
197
3.859375
4
my_tuple = (1,2,3,4,5) new_tuple = my_tuple[1:2] print(new_tuple) x,y,z,*other = (6,7,8,9,10,11) print(other) #Tuple Methods print(my_tuple.count(3)) print(my_tuple.index(4)) print(len(my_tuple))
f22d7bc8f70fafc2f801c74c343b99369a9f27d7
joelapsansky/election-analysis
/Python_practice.py
5,980
4.53125
5
print("Hello World") counties = ["Arapahoe", "Denver", "Jefferson"] if counties[1] == "Denver": print(counties[1]) # This will give an index error so comment out if counties[3] != 'Jefferson': print(counties[2]) # Break temperature = int(input("What is the temperature outside?")) if temperature > 80: pr...
ba350761e59eb2c8ada4590d245e68d107f00a5c
RahulBalu31/Python-projects
/division.py
117
4
4
num = int(input("Enter a Number :")) if(num%6==0): print("Yes") else: print("No")
4d6c46f0d4bd91c13fd6f8b6c2fe134e35d460e1
xndong/ML-foundation-and-techniques
/Decision stump/old_compute_gini_and_information_gain.py
4,226
3.640625
4
# -*- coding: utf-8 -*- """ @author: Dong Xiaoning """ # compute information gain from gini index or entrophy ''' gini index and entrophy---> measure the impurity of a group. In two or more groups(eg a dataset is splited into two groups), we weightly add gini index from coresponding group together to compu...
cf24e6acc35ab91e205abc1cca8837cd28ca2d3a
kkkansal/FSDP_2019
/DAY 03/answer/teen_cal.py
1,346
3.875
4
""" Code Challenge Name: Teen Calculator Filename: teen_cal.py Problem Statement: Take dictionary as input from user with keys, a b c, with some integer values and print their sum. However, if any of the values is a teen -- in the range 13 to 19 inclusive -- then that value counts as 0, ex...
4966b9b8544ce2cc9f88e9470c04fa95487243a8
sjraaijmakers/informatica
/Programmeertalen/python2/LS.py
5,732
4.03125
4
# -*- coding: utf-8 -*- # Student: Steven Raaijmakers # Number: 10804242 # Desc: Programma tekent figuur op basis van het Lindenmayer systeem # from graphics import * from math import sin, cos, pi class LS: def __init__(self, defstep, defangle): self.rules = {} self....
d8f860240cff0ade0950173dca7eeb29e6181e04
gunzigun/Python-Introductory-100
/12.py
616
3.859375
4
# -*- coding: UTF-8 -*- """ 题目:判断101-200之间有多少个素数,并输出所有素数。 程序分析:判断素数的方法:用一个数分别去除2到sqrt(这个数),如果能被整除,则表明此数不是素数,反之是素数。 """ from math import sqrt nAllNum = 0 for num in range(101,201): nNumqrt = int(sqrt(num+1)) isSu = True for i in range(2,nNumqrt+1): if num % i == 0: isSu = False ...
2f5df7a655a39a7b305d5b33382197059bae02e0
panyanyany/Python_100_Exercises
/exercises_011_to_020/016/m3.py
288
3.78125
4
score = int(input('输入成绩:')) # 仅对 Python 3.7 及以上版本有效 standard = { 90: 'A', 60: 'B', 0: 'C', } grade = None for key_score in standard: if score >= key_score: grade = standard[key_score] break print('%d 属于 %s' % (score, grade))
6c8856de70f85b1cdae1d07edca7771cc4c80f3c
serosc95/holbertonschool-higher_level_programming
/0x0B-python-input_output/7-save_to_json_file.py
211
3.578125
4
#!/usr/bin/python3 """ Module """ import json def save_to_json_file(my_obj, filename): """ Function save_to_json_file """ with open(filename, 'w') as myFile: myFile.write(json.dumps(my_obj))
5467db72b7d48e677fa07200179c5dbd657974ee
aumit210780/Practice-Python
/Sequences and for loop.py
146
3.6875
4
data = [1,2,3,4,5] for i in range(0,len(data)): print(data[i]) data2 = "Hello" print() for i in range(0,len(data2)): print(data2[i])
e5e17a3e91c4d88b6220b830b1f2dc54d37ff7e7
4ndrewJ/CP1404_Practicals
/prac_03/password_check.py
714
4.09375
4
""" Password check program from prac 3 CP1404 """ MIN_LENGTH = 8 def main(): """ Tests get_password() and print_password_asterisks() """ password = get_password() print_password_asterisks(password) def print_password_asterisks(password): """ Prints asterisks of same length as password ...
867ba60789651014d061517b4fd178ad8c5e6c78
yibwu/box
/max_two_sum.py
452
4.0625
4
def max_two_sum1(x, y, z): if x < y and x < z: return y + z if y < x and y < z: return x + z if z < x and z < y: return x + y # beautiful and elegant def max_two_sum2(x, y, z): if x < y and x < z: return y + z else: return max_two_sum2(y, z, x) if __name__...
b4e216e8e03dee354dc734b5d21da38c460d02dd
takadhi1030/class-sample
/customer.py
538
3.765625
4
class Customer: def __init__(self, first_name, family_name, age): self.first_name = first_name self.family_name = family_name self.age = age def full_name(self): return self.first_name + self.family_name def display_profil(self): print(f"Name: {self.full_name()}, Ag...