blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
2480357c4ebc466a648707ca61c3438472bbce77
BIAOXYZ/variousCodes
/_CodeTopics/LeetCode/401-600/000477/TLE--000477.py
811
3.75
4
class Solution(object): def totalHammingDistance(self, nums): """ :type nums: List[int] :rtype: int """ # 该函数出自 LC461 def hamming_distance(x, y): res = 0 tmp = x ^ y while tmp: tmp &= tmp - 1 res += ...
382b82ca624a7a8e3245691fdf92347da0b229d2
ivanezeigbo/statistics
/recursive simple.py
590
4.15625
4
#Recursive function to get largest number in list list = [56, 345, 322, 6677, 798, 4, 322, 5667, 6676, 322, 7777, 566, 2322] largest = list[0] #initially assigns the first term as the largest x = 1 #index position def large_num(largest, list, x): if largest < list[x]: #compares with next largest = lis...
0c7f7b1ff04528026aa8d273281d2b63d6b203a5
mccarvik/cookbook_python
/14_testing_debugging_exceptions.py/13_profile_time_prog.py
1,525
3.546875
4
# timethis.py import time from functools import wraps def timethis(func): @wraps(func) def wrapper(*args, **kwargs): start = time.perf_counter() r = func(*args, **kwargs) end = time.perf_counter() print('{}.{} : {}'.format(func.__module__, func.__name__, end - start)) re...
c32eb6c905fd540d5d1d28d43c52a591ecd0baeb
Jameslin810/pythonFun
/fibSeq.py
241
3.875
4
def fibSequence(): n = input('enter a number here: ') if n <= 1 : print n return case1 = 0 case2 = 1 print case1 print case2 for k in range (2, n): x = case1 + case2 print x case1 = case2 case2 = x fibSequence()
3ad775823457fd51e186ac0e30f45f48ac255c9a
hanpengwang/ProjectEuler
/37 (Truncatable primes).py
955
3.640625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Nov 14 15:58:43 2019 @author: hanpeng """ def primeFactor(n): if n == 1: return 10 mover = 2 count = 0 while mover<=n**0.5: if n%mover==0: count +=1 n = n/mover mover = 2 else: mover+=1 return(count) ...
bb9cd2155ef50183d7b3981cce85814d490cfd6b
pavoljuhas/xpd-python-bootcamp-test
/py05numpy/ex02.py
1,469
4.0625
4
#!/usr/bin/env python import numpy import numpy as np '''this exercise is generally focusing on Broadcasting, element-wise operations, slices, and ranges. You can write your script here then run it. It is better to using a interactive shell, Ipython for example to do the task and see the results immediately. If you ...
259d0a608c6fcfa3da872e059f499a98d72b49ba
Intelligence-Games/Connect_four
/Week 4 - Conecta 4/games.py
981
3.671875
4
"""Games, or Adversarial Search. (Chapters 6) """ from utils import * from searches import alphabeta_search # ______________________________________________________________________________ # Players for Games def query_player(game, state): "Make a move by querying standard input." # game.display(state) ...
f92535ce08aaea0b3ded30ffaf503fab05f52ff7
huiyuandiknow/Data-Manipulation-at-Scale_systems-and-Algorithms
/Thinking in MapReduce/inverted_index.py
792
3.703125
4
import MapReduce import sys """ Create an inverted index- a dictionary where each word is associated with a list of the document identifiers in which that word appears. """ mr = MapReduce.MapReduce() # ============================= # Do not modify above this line def mapper(list): # key: text in doc # value...
6b01d4c552104cf6ded45f98192d888c6c976260
harshil1903/leetcode
/Array/1389_target_array_in_given_order.py
1,945
4.15625
4
# 1389. Create Target Array in the Given Order # # Source : https://leetcode.com/problems/create-target-array-in-the-given-order/ # # Given two arrays of integers nums and index. Your task is to create target array under the following rules: # # Initially target array is empty. # From left to right read nums[i] and in...
276041013d231458fceca93bb8d1b5f126cd2c4d
angelahyoon/LeetCodeSolutions
/validPalindrome.py
220
3.828125
4
# Valid Palindrome def isPalindrome(self, s: str) -> bool: string = "" for i in s: if (i.isalnum()): string += i.lower() return string == string[::-1]
aa1dbc137a647ffa0bfe54432169f825b551e7fe
logicalpermission7/projects
/Game.py
1,810
3.84375
4
from math import * import random from Player import Player from Student import Student # This is a "Player Object" player1 = Player("Elvis", 5, 100, 500) print(player1.power) print(player1.is_elvis()) # This is a Student Object elvis = Student("Elvis", "CSCI", 4.0, True) print(str(elvis.is_on_honers()) + " is on hone...
a554aeea8d1e4a83b9896e7bbec8738c14b516d8
guoqi228/dungeon_monster_python
/Monster.py
4,814
3.65625
4
class Monster(): def __init__(self, coords = [0, 0]): self.coords = coords def init_coords(self, rows, cols): self.coords = [random.randint(0, cols - 1), random.randint(0, rows - 1)] def check_nearby(self, rows, cols, eggs, door, monsters): go_up = True go_down = True ...
e352ac26bcc8e3ed7b79750bf056070061d79cbd
ryanlonergan/100_days_of_projects
/day_34_gui_trivia_game/quiz_brain.py
1,311
3.625
4
import html class QuizBrain: def __init__(self, q_list): self.question_number = 0 self.score = 0 self.question_list = q_list self.current_question = None def still_has_questions(self): """ Checks if there are still questions left to be asked :return: T...
aaab2fdf0f5450502d98516c24092c0a8d581971
pierre-crucifix/real-spanish
/tweepyManager.py
4,117
3.734375
4
""" Script #1 Retrieve all the latest tweets of the chosen usernames (see screen_name_list) Need to create a file called twitter_credentials.py in the same folder. This file will store the keys to log in to the twitter app """ import tweepy import pandas as pd import simplejson as json import datetime impo...
e428c29741bc3206f8ac8964f131925275a26a27
RaskovskyDavid/pong_arcade_game
/paddle.py
683
3.859375
4
from turtle import Turtle class Paddle(Turtle): def __init__(self, coordinates): super().__init__() self.color("white") self.penup() self.shape("square") self.shapesize(stretch_wid=5, stretch_len=1) self.goto(coordinates) def go_up(self): new_y = self....
59d949581e56eb8bdfa53862612dd5bcaae8091c
kenwoov/PlayLeetCode
/Algorithms/Easy/448. Find All Numbers Disappeared in an Array/answer.py
407
3.734375
4
from typing import List class Solution: def findDisappearedNumbers(self, nums: List[int]) -> List[int]: result = [] s = set(nums) for i in range(len(nums)): if i + 1 not in s: result.append(i + 1) return result if __name__ == "__main__": s = Soluti...
7f435cafd0325b74583c4f732051a30d2f412f02
dieu-pham/pythonbasic
/ngoinhamouoc.py
516
3.796875
4
# import turtle # # star = turtle.Turtle() # # for i in range(3): # star.forward(50) # star.right(144) # # turtle.done() import turtle #đặt kích thước viền cho hình tròn là 5 turtle.pensize (5) #đặt màu sắc cho viền hình tròn là màu xanh turtle.pencolor ("blue") #for outer bigger circle #đặt màu nền cho h...
2b28afffc750d08920341c8e9aa877e60810b815
food-always-food/casino-night
/sqlite-database.py
778
3.53125
4
import sqlite3 import pandas as pd def dict_factory(cursor, row): d = {} for idx, col in enumerate(cursor.description): d[col[0]] = row[idx] return d conn = sqlite3.connect(":memory:") cur = conn.cursor() cur.execute("CREATE TABLE stocks (date text, symbol text, third text)") cur.execute("INSERT I...
34fd65d0c946d2fc843455f28f8b000bc5b137eb
chipperrip/IN1900
/veke 6/f2c_shortcut_plot.py
720
3.875
4
""" Exercise 5.12: Plot exact and inexact Fahrenheit-Celsius conversion formulas A simple rule to quickly compute the Celsius temperature from the Fahrenheit degrees is to subtract 30 and then divide by 2: C = (F-30)/2. Compare this curve against the exact curve C =(F-32)*5/9 in a plot. Let F vary between -20 and 120....
88b8ef4bc7d6cf84fedbdf7604efb69f88015bd3
Feng-Xu/TechNotes
/python/geektime/exercise/9_1.py
1,101
3.921875
4
# 1.创建一个函数,用于接收用户输入的数字,并计算用户输入数字的和 def add(): nums = input("请输入两个数次,用','分隔:") print(type(nums)) # 当一些元素不用时,用_表示是更好的写法,可以让读代码的人知道这个元素是不要的 # 多个元素不用时,则使用*_ num1, *_, num2 = list(nums) print(type(num1)) print(int(num1) + int(num2)) #add() # 2. 创建一个函数,传入n个整数,返回其中最大的数和最小的数 # def find_num(list):...
4c662d843927545d38b2e33449a798af9bb4e315
allenhsu6/python_learn
/100example/12.py
491
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5 """ from math import sqrt def isprime(n): while n > 1: k = int(sqrt(n)) i = 2 while i <= k: if n % i == 0: return 0 i += 1 else: return 1 i = 2 a ...
6516d4659f2a0e580f28c1fc57a288a7cd6190e6
dml-prog/OOP
/Eception.py
404
3.59375
4
a = 5 b = 2 try: f= open("C:/Users/Nikhesh/desktop/niks.txt",'r+') k = (input("Enter what ever u want ")) f.write(k) print("Division is ",a/b) except ValueError as n: print("Invalid input") except ZeroDivisionError as e: print("Divide by zero is not poosibe") except Exception as...
f18d7113814578050defe4078b83984d0e0bbcc6
cuzai/pythonStudy
/crawling/collats.py
507
4.28125
4
def collatz(number) : if(number % 2 == 0) : return int(number / 2) else : return int(number * 3 + 1) while True : number = input("Input number") try : number = int(number) except ValueError : if number == 'exit' : exit() print("'{}'{}...
16ac3a1431faa19a11478156ab135324098c5f09
sarathchandra0007/python_practice
/python_practice/permutations.py
247
3.671875
4
import itertools def permutation(s): return list(itertools.permutations(s)) def permu(s): out=[] if len(s)==1: output=[s] else: for index,i in enumerate(s): permu('abc') print (permutation('abc'))
168706532b5e650a14d3e9acf0d6a6e0876c04ff
Henryy-rs/Subway_RIdership_COVID-19
/source.py
11,366
3.609375
4
import pandas as pd import datetime as dt import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import LinearRegression class Data: def __init__(self, date_strat, date_end): self.date_start = date_strat self.date_end = date_end self.df = pd.DataFrame() def...
bc6b064f163310628ed172b4fca7d8cfb9196205
Electrostatus/Analytic
/analytic_funcs.py
3,599
3.578125
4
# Copyright (c) 2017 - 2023, Philip Herd # This file is distributed under the BSD 2-Clause License from cmath import sqrt __doc__ = """ A collection of general purpose analytic formulas for polynomials of degree 0 through 4 Polynomials with degrees higher than four do not have analytic solutions """ def root_0(a): ...
71f0780cb08cc149a4d3d0fff97529c50b8e2735
ton4phy/hello-world
/Python/47. Logic.py
155
3.78125
4
# Exercise # Write an is_mister function that accepts a string and checks if it is the word 'Mister' def is_mister(string): return string == 'Mister'
d26337bdbdba2653c53a1116230bcee55075ef64
kcexn/coded-distributed-computing
/coded_distributed_computing.py
1,984
3.8125
4
''' coded_distributed_computing This module contains functions related to a study of the coded distributed computing model. ''' import numpy as np def encode_matrix(A: np.matrix, G: np.matrix) -> np.matrix: ''' encode_matrix Parameters: --- A: np.matrix, input matrix to code. G: np.matrix, generat...
9fd2ab9d408757a5a91e6f09a733fdd989598993
zsmountain/lintcode
/python/helper.py
10,130
3.96875
4
################################### List ################################### class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next def printList(head): while head: print(head.val, '->', end=' ') head = head.next print('None') class Link...
b12f1662741b40261c5f29a95fe891542b758bd0
pacificpatel165/MyPythonLearning
/Python_Cookbook/CookBook_7.6_Defining_Anonymous_Or_Inline_Functions.py
717
4.03125
4
""" Problem You need to supply a short callback function for use with an operation such as sort(), but you don’t want to write a separate one-line function using the def statement. Instead, you’d like a shortcut that allows you to specify the function “in line.” """ # Solution # Simple functions that do nothing more t...
3af077fa491d3f590dd12dd1ad13eba7085fcee7
hayleycd/project-polyglot
/pythonlang/problem_2_python.py
640
3.921875
4
# Even Fibonacci numbers # Problem 2 # Each new term in the Fibonacci sequence is generated by # adding the previous two terms. By starting with 1 and 2, # the first 10 terms will be: # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # By considering the terms in the Fibonacci sequence whose # values do not exceed four mi...
ef57746d123533fe33bbe1719995e11418be7c41
jpablolima/machine_learning
/python/listas_tuplas.py
319
3.703125
4
meses = ('janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', ' novembro', 'dezembro') print(meses) type(meses) alunos = ('Pablo','Luan', 'Ana', 'Raquel') print(alunos) type(alunos) len(meses) len(alunos) meses[1] alunos[3] alunos[1] = 'João Pablo' alunos.append('Julia'...
100897a70ad1ede903638eeea6e1ebe8b4fc197d
CiaranGruber/CP1404practicals
/prac_07/extension_grading.py
1,359
3.59375
4
from kivy.app import App from kivy.lang import Builder from kivy.core.window import Window class GradeChecker(App): def build(self): """ Build the Kivy GUI :return: """ Window.size = (800, 300) self.title = 'Grade Checker' self.root = Builder.load_file('exte...
09c88b40d0824b36c955f992c0d89826a376f36c
yxcui/Machine-Learning
/SimpleLinear Regression.py
812
3.921875
4
# -*- coding:utf-8 -*- import numpy as np def fitSLR(x, y): # x,y分别为自变量和因变量的样本值 n = len(x) x_mean = np.mean(x) y_mean = np.mean(y) numerator = 0 # 分子 dinominator = 0 # 分母 for i in range(0,n): numerator += (x[i] - x_mean)*(y[i] - y_mean) dinominator += (x[i] - x_mean)**2 b...
d6a5ee036ef9bd70e6495b3849638f89ed7ad91d
ajhyndman/python-guessing-game
/guessing_game.py
836
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Guessing Game from teamtreehouse.com's Python Basics course. # @author: Andrew Hyndman import random answer = random.randint(1, 10) print("I have picked a number between 1 and 10. Try to guess it!") guesses_remaining = 5 guess = 0 while g...
98b90d8e768edb4bfcf518d260525aac19d80a87
YutaLin/Python100
/Day6/string.py
850
4.15625
4
def main(): string1 = 'hello, world!' print(len(string1)) # 13 print(string1.capitalize()) # Hello, world! print(string1.upper()) # HELLO, WORLD! print(string1.find('or')) # 8 print(string1.find('shit')) # -1 print(string1.startswith('He')) # False print(string1.startswith('hel')) # True print(string...
7c3e5fdedc844e4ad185d4d4c994b5d9b5e11625
debadri16/Python-Basics
/oop/oop1.py
983
3.84375
4
import random class Bank: balance=0 def __init__(self): print('hey homie!welcome') self.account_id=random.randint(1000,10000) print('niggah ur id is',self.account_id) def menu(self): user_input=int(input('''how can we help u 1.display 2.withdraw 3.de...
660b6be3b6081acaa535cc94be750a19bf8f08dc
hamburgcodingschool/L2CX-November
/lesson 1J/p3-concatenation.py
169
3.953125
4
# Concatenation name = "Helder" age = 37 print("Hello my name is " + name + " and I am " + str(age) + " years old.") # Hello ny name is Helder and I am 37 years old.
40116939ff4e5a284a3d0d09bad006a7ec5489f6
helgaKalicz/statistics
/reports.py
3,453
3.734375
4
# Making list of the games def making_list_of_games(file_name): with open(file_name, "r") as f: i = len(f.readlines()) with open(file_name, "r") as f: games = [] for j in range(i): line = list(f.readline().split("\t")) line[len(line)-1] = (line[len(line)-1])[:-1] ...
65b4b2bff8e84479c47b6222c8d8fdbc755b413a
MikelSotomonte/mask-turret
/SpeachToText Example.py
444
3.515625
4
import speech_recognition as sr r = sr.Recognizer() ''' Euskera --> "eu-ES" ---- English --> "en-US" ---- Castellano --> "es-ES" ''' print("Speak you CrackHead") with sr.Microphone() as source: r.adjust_for_ambient_noise(source) data = r.record(source, duration=3) print("Analizando") try: ...
dad9273b740cd380e3794ee666b063f286c09cf9
anishshanmug/python-homework
/Block 2 Work/3-11.py
214
4.03125
4
num = int(input("Please Enter any Number: ")) rev = 0 while(num > 0): mod = num %10 rev = (rev *10) + mod num = num //10 print("Reverse of entered number is = %d" %rev)
c713da4a3304a6c833ac7a6ba52a3d28a16e2b99
Da1anna/Data-Structed-and-Algorithm_python
/leetcode/其它题型/字符串/common/回文子串.py
2,107
3.625
4
# -*- coding:utf-8 -*- # @Time: 2020/6/23 16:27 # @Author: Lj # @File: 回文子串.py ''' 给定一个字符串,你的任务是计算这个字符串中有多少个回文子串。 具有不同开始位置或结束位置的子串,即使是由相同的字符组成,也会被计为是不同的子串。 示例 1: 输入: "abc" 输出: 3 解释: 三个回文子串: "a", "b", "c". 示例 2: 输入: "aaa" 输出: 6 说明: 6个回文子串: "a", "a", "a", "aa", "aa", "aaa". 来源:力扣(LeetCode) 链接:https://leetcode-cn.co...
52971ea05a64cd026263d092dbe3e6bd443d3a1d
nevesjf/python
/Lista3/exercicio1.py
301
4.0625
4
#EXERCICIO 1 nota = int(input("Insira uma nota entre 0 e 10: ")) a = 0 while a == 0: if nota >= 0 and nota <= 10: print("Ok!") a = 1 else: a = 0 print("Valor invalido! Digite novamente...") nota = int(input("Insira uma nota entre 0 e 10: "))
051ebc540457a2150522fde4297ef68649f1f05b
spertus/shakespeare_conspiracy
/author_compare.py
7,147
3.546875
4
#Script to run a naive Bayes to learn two bodies of work, then compare two books to determine which is more likely written by which author. #Reference texts must be put in "Samples" directory with format "author_text.txt" import re import string import operator from prettytable import PrettyTable from sh import find im...
3a9d6b18cf61ce6da4b7f5514da8021a48c279d9
ishaan001/SPY-CHAT
/spychat/add_friend.py
2,054
4.15625
4
from default_spy_details import Spy,friends import re def add_friend(): new_friend=Spy(" "," ",0,0.0) while(True): new_friend.name= raw_input("enter your friend name :") #user regex which will ask user to add name with first letter capital only pattern_nf = '^[A-Z]{1}[a-z\s]+$' ...
8fe696ea8eddb5d2dee991e777da2277b6456ffd
668/projecteuler
/q19/q19.py
1,317
4.125
4
dayslist = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ] def is_leap(year): if year%4 == 0: if year % 100 == 0: if year % 400 == 0: return True else: return False else: ...
9abe58710a32623d1026176b9c149439da9308b0
SyreenBn/Python-Programming-Essentials-for-the-Health-Sciences
/Projects/Project two/HINF5502_GUIs.py
1,933
4.21875
4
# HINF 5502: Program snippets: GUIs # # Here are some short(ish) program snippets on Graphic User Interfaces (GUIs). # For best results, be sure to run each of them in their own # window as a program, rather than typing them in one line at a # time in IDLE's interactive window. # # A very simple GUI program, w...
d7a760a5775da3053b7fdf55d5541972d646e8fc
mgalvank/CodingChallenges
/Gigster/Question3.py
1,390
3.90625
4
import Queue def solution(a,b,floors,max_capacity,max_weight): q = Queue.Queue() weight = 0 people = 0 no_of_trips = [] trip = [] no_of_stops = 0 #Populate the queue for i in range(0,len(a)): q.put((i,a[i],b[i])) #Assuming that the weight of one person will always be low...
f946ba581d1b18048bfa2f48b899f0020f649e31
andrewwgao/R3-SoftwareTraining2-AndrewGao
/main.py
4,558
3.84375
4
# import modules import pygame import numpy import random done = False # boolean variable for checking when maze is fully generated # colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) n = random.randint(5,50) # random maze size w = 800 # width h = 800 # height sr = w/n # size of 1 cell (square) scr...
4e89006b4a0efe53303da54019e87083a9c10684
newton-li/GIS6345
/Exercise12.1.py
937
4.21875
4
english_text = 'the report was due the next day but she still chose to procrastinate' french_text = 'le rapport devait être remis le lendemain mais elle a quand même choisi de tergiverser' italian_text = 'il rapporto doveva essere consegnato il giorno successivo ma lei scelse comunque di procrastinare' def most_fr...
af202ca9d69f0288e4bb3c5e71f56b273eef48a9
emdre/first-steps
/starting out with python/ch12t2 recursive multipication.py
102
3.71875
4
def multiply(x, y): if x == 1: return y else: return y + multiply(x - 1, y)
8f47de3208833543e640537cd04d8d34420ac5c3
AnthonyBonfils3/Simplon_Brief_faur_in_rows
/Projet/connect4/player.py
5,096
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Apr 02 10:25:37 2021 @author: bonfils """ from abc import ABC, abstractmethod import numpy as np import tensorflow as tf Qlearning_model_path = './Qlearning/models/' class Player(ABC): ## la classe doit être abstraite pour pouvoir utiliser ## une ...
72c7a34605037a349a33054fe0e7653f7573e0b3
devinupreti/coding-problems
/nonAdjacentSum.py
829
4.0625
4
# PROBLEM : Given a list of integers, write a function that returns the # largest sum of non-adjacent numbers. Numbers can be 0 or negative. # For example, [2, 4, 6, 2, 5] should return 13, since we pick 2, 6, and 5. # [5, 1, 1, 5] should return 10, since we pick 5 and 5. # Can you do this in O(N) time and c...
a3d9c04c1257e83a450760fb9d4db8dcd5010f2a
pbwis/training
/HackerRank/HR_ch03/HR_ch03.py
224
3.71875
4
if __name__ == '__main__': n = int(input()) each_number = [] while n > 0: n = n - 1 each_number.append(n) each_number.sort(reverse=False) for num in each_number: print(num ** 2)
f98fe5390d6eadacac768d929588f155d0fe926a
fabriciofmsilva/labs
/python/basic/dictionary.py
197
3.53125
4
dictionary = {'code': 1, 'age': 28, 'cpf': 12312312312} print dictionary['code'] print dictionary['age'] print dictionary['cpf'] print len(dictionary) for i in dictionary: print dictionary[i]
1fe55081e35f70c6af15a7a2a8ecb05724a9dde0
SouzaCadu/guppe
/Secao_05_Lista_Ex_41e/ex_05.py
223
3.90625
4
""" Receba um número inteiro e verifique se é par ou impar """ v1 = int(input("Insira um número inteiro para saber se é par ou ímpar:")) if v1 % 2 == 0: print(f"{v1} é par.") else: print(f"{v1} é ímpar.")
33bc8c7e1766e1b7aa1892d8b4ff04e057ea8bd1
jgraykeyin/robotalker
/talkforme.py
2,924
3.734375
4
# Robotalker 0.1 by Justin Gray # Program for making your computer speak to your smart device. # Built around the pyttsx3 module: https://pypi.org/project/pyttsx3/ # Currently supported devices: Google Home & Amazon Echo import pyttsx3 # Initialize the Text-to-speech module engine = pyttsx3.init() # Select the voice ...
0a74c1a7159acb30bd11bbf47409cb8a9565dea1
yanghongkai/yhkleetcode
/pointer/reverse_string_344.py
523
3.765625
4
# 344 反转字符串 https://leetcode-cn.com/problems/reverse-string/ from typing import List class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ # left right left = 0 right = len(s) - 1 while le...
50de813bfaaa6b50adf0c6419c45b8b624009e62
solesensei/PythonCourses
/HSE Python Coursera/week 4/07-sum-no-sum.py
286
3.6875
4
import math def ssum(a, b): s = 0 if a == 0: return b if a < 0: s += ssum(a+1, b) - 1 else: s += ssum(a-1, b) + 1 return s def main(): a = int(input()) b = int(input()) print(ssum(a, b)) if __name__ == "__main__": main()
56c3109b3c8c811a23b4c9e996542316c2bed949
thanhENC/TDLT
/Tutorial #5/random_password_generator.py
888
4
4
import string import random def password_generator(length=8): LETTERS = string.ascii_letters DIGITS = string.digits PUNCTUATION = string.punctuation printable = f'{LETTERS}{DIGITS}{PUNCTUATION}' printable = list(printable) random.shuffle(printable) password = random.choices(printable, k=l...
9c1e583773f0171fcdb9f0bdd741cc9f2af7f0c6
wdjlover/Office-Administration
/app/auth/forms.py
1,932
3.515625
4
from flask_wtf import FlaskForm from wtforms import PasswordField,StringField,SubmitField,ValidationError from wtforms.validators import DataRequired,Email,EqualTo from ..models import Employee #create the RegistrationForm class #it inherits the FlaskForm class RegistrationForm(FlaskForm): #this is the form for...
225b15b7b0103434f70b0f7f78188561f8cb5399
duanyadian/PycharmProjects
/iteration factor.py
467
3.609375
4
for num in range(10,20): # 迭代10~20之间的数值 for i in range(2,num): # 根据因子迭代 if num%i == 0: # 确定第一个因子 j = num/i # 计算第二个因子 print("%d 是一个合数" %num) break # 跳出当前循环 else: ...
c62717082a369b9d69a524caa3c9e57114d76eca
Zejima/Python_Tutorials
/General-Programing-Tutorial-WIth-Python/Tutorial-3.py
881
4.21875
4
# Ask the user to user 2 values and store them in variables num1 and num2 num1, num2= input('Enter 2 numbers:').split() #.split assigns tow variables # Convert the strings into regular numbers num1=int(num1) num2=int(num2) # Add the values entered and store in sum sum = num1 + num2 # Subtract values and store in di...
492d563539a2f3e1f732bfbb8e982cd65f355584
LEXBROS/Stepik_PyCharm
/list_example_2.1.py
133
3.546875
4
n = int(input()) example = [val for val in range(1, n + 1)] result = [example[:i] for i in range(1, n + 1)] print(*result, sep='\n')
45e521c689c83141447df22d25b5506b962dd02e
BipronathSaha99/dailyPractiseCode
/try_3.py
819
4.34375
4
#---------------------------Removing elements-------------------------# #---we use pop(removes the last member) #---------remove(removes the given number)--------------------------# my_list=["earth","mars","aris","makemake","jupiter"] #--------------------Q_1-----------------------------# #---------------remove al...
1c53a0b48f06c2fcc33705d30efce602a7cbceba
susoooo/IFCT06092019C3
/GozerElGozeriano/python/20200313/for5.py
417
3.84375
4
#5-Escriba un programa que pregunte cuántos números se van a introducir, pida esos números, y diga al final cuántos han sido pares y cuántos impares. print("¿Cuantos números se van a introducir?") n1=int(input()) pares=0 impares=0 print("Pues venga: ") for n in range(0,n1): print("Número: ") num=int(input()) if(num...
1c5fa692a1dd6667083577e9daa55f092eb75cd9
arya-pv/pythonjuly2021
/oop/polymorphism/overloading_1.py
535
3.890625
4
class Person: def set(self,name,age): self.name=name self.age=age print(self.name,self.age) class Employee(Person): def set(self,salary,jobrole): self.salary=salary self.jobrole=jobrole print(self.salary,self.jobrole) obj=Employee() obj.set("ANU",23,3000,"HR") cl...
f8be967696b5d8874038ff5033ab9a54ef034025
bennettt5851/cti110
/P3LAB2A_Bennett.py
476
4.34375
4
# This program uses turtle program (for) to draw a basic square and triangle # 3/14/21 # CTI-110-0B01 # Tyler Bennett import turtle win = turtle.Screen() t = turtle.Turtle() t.pensize(5) t.pencolor("red") t.shape("turtle") for i in (1,2,3,4): t.forward(100) t.left(90) t.right(100) for i in (1,2,3): ...
c407a7edb24f7364fd7b4dcfd84562a36a803bb5
kkrugler/codecademy-validator
/bitney_adventure/game_complete_default.py
723
3.828125
4
def game_complete(): # Level - 3 global g_visited_room_names global g_score # TODO decide when to congratulate user and return True. This would # be the case for when they've visited every room. So you can either # compare their score against the sum of scores from every room, or # if the ...
d072ab11c1838e325f54c05e85033ca2c8939ba9
q10242/pythone-practice
/ch7/ch7-2.py
261
4.03125
4
x = 10 number1 = list(range(x)); print number1; y = 16 number2 = list(range(x,y)) print number2 z = 2 number3 = list(range(x,y,z)) print number3 t = 0 for numbers in number3: t= t+numbers else: #結束之後執行的區塊 print "over!" print t
5a814ad4abbd8822de6a69cb64decc060210b84c
Jochizan/courses-python
/programs-python/manager_files.py
1,005
3.625
4
from io import open archivo_texto=open("archivo.txt", "r+") # lectura y escritura # archivo_texto.write("\n Siempre es una buena ocasión para estudiar Python") # archivo_texto.close() # lineas_texto = archivo_texto.readlines() # archivo_texto.close() # print(lineas_texto) # texto = archivo_texto.readlines() # a...
7a5bf6c35433284d53d51547c3053039c6d77968
ash/amazing_python3
/299-negative-index.py
241
4.1875
4
# Negative indices when accessing # list elements data = [ 'alpha', 'beta', 'gamma', 'delta', 'epsilon' ] # Accessing the first item: print(data[0]) # Accessing the last item: print(data[-1]) # The second to last print(data[-2])
50ff8ce7a08f67f17afb1cb573763cc48fc630de
merodriguezblanco/CS6601
/assignment_1/player_submission.py
6,769
3.5625
4
#!/usr/bin/env python from operator import itemgetter # This file is your main submission that will be graded against. Only copy-paste # code on the relevant classes included here from the IPython notebook. Do not # add any classes or functions to this file that are not part of the classes # that we want. # Submissio...
3f1246385d651ac33bcb31b8e7229b160aa569c4
i0Ek3/PythonCrashCourse
/code/part1/20_while-2.py
331
3.734375
4
#!/usr/bin/env python # coding=utf-8 # Let customer to select when to quit! prompt = "\nWelcome to my world,please help youself enjoy!" prompt += "\nJust fun!\n" msg = "" while msg != 'quit': # msg = input(prompt) #python3 msg = raw_input(prompt) #python2 if msg != 'quit': #avoid to print 'quit' p...
85f40bd1070f3c7c171c270eafa4855f4bb01ff4
p3t3r67x0/vigenere_cipher
/vigenere.py
3,615
3.578125
4
#!/usr/bin/env python import re import sys import argparse from argparse import RawTextHelpFormatter def encrypt(text, key): universe = [c for c in (chr(i) for i in range(32, 127))] universe_length = len(universe) plain_text = text.read().strip() key_length = len(key) cipher_text = [] key_te...
7776b986b5893143c746d42e99974ffda823e91e
InfiniteWing/Solves
/zerojudge.tw/d329.py
223
3.734375
4
def Reverse(n): c=0 while(n>0): c=c*10 c+=n%10 n=int((n-n%10)/10) return c n=int(input()) for i in range (n): s=input() data=s.split() a1=int(data[0]) a2=int(data[1]) print(Reverse(Reverse(a1)+Reverse(a2)))
7bdf76de21aabf775c6e98b3af285294306c76ee
horacepan/ProjectEuler
/primes.py
1,492
3.90625
4
import math # return all primes up to n def populatePrimes( n ): primes = [2,3,5] if n < 2: return else: index = 1 while (6*index + 1) <= n: upperBoundA = int(math.sqrt(6*index+1)) + 1 upperBoundB = int(math.sqrt(6*index+1)) + 1 isPrimeA = True isPrimeB = True for prime in primes: if prime ...
06333996667b175122aa94f564044c7893726b8a
StudyForCoding/BEAKJOON
/05_Practice1/Step06/gamjapark.py
720
3.890625
4
n = int(input()) for i in range(n): if n % 2 == 0: #짝수 for j in range(n - 1): if j % 2 == 0: print("*", end="") else: print(" ", end="") print() for j in range(n): if j % 2 == 0: print(" ", end="") ...
e8543815a822dcc21b4c502dd1c46e2482929af0
seriousbee/UCL-Classifier
/src/simple_classifier/Classifier.py
1,177
4.0625
4
# represents a classifier system - it has a list of clusters, is able to create the clusters, and allocate an unknown # sentence to one of the clusters __all__ = ["Classifier"] class Classifier: def __init__(self, clusters): self.__clusters = clusters def classify(self, sentence): max_value ...
f0912b7a2d7b133988cef0ebf1c61e44d7cef943
erauner12/python-scripting
/Linux/Python_Crash_Course/chapter_code/chapter_04_working_lists/reference/squares.py
435
4.4375
4
# ** means to the power of # so this function will multiply every number between one and ten by the power of 2 and assign that value to every the next item in the list squares = [] for value in range(1,11): squares.append(value**2) print(squares) # using list comprehension, we can insert the values of the expr...
82d71ff20fab238d636455f1811b3a5386f3216e
arabindamahato/personal_python_program
/programming_class_akshaysir/palindrome.py
521
4.125
4
'''Very easy method''' ''' By checking reverse number and main number if the number is same then it is palindrome''' print('To reverse the given no') n=(input('Enter your no : ')) m=int(n) o=n[::-1] p=int(o) if m==p: print(' palindrome') else: print(' not a Palindrome') '''Another method''' # n=12321 # m=n ...
30960dccfab807b8c067fe51da2f9a384d526fc6
eamaccready/STP_Exercises
/python_scripts/interit_square.py
393
4
4
# Inheritance way. class Rectangle(): def __init__(self, l, w): self.length =l self.width = w def calculate_perimeter(self): return 2 * (self.length + self.width) class Square(Rectangle): def calculate_perimeter(self): return 4* self.length r1 = Rectangle(3,6) s1 = Squar...
e73500ca12e64dd1fb28043b804239c15cc25327
MayWorldPeace/QTP
/Python基础课件/代码/第七天的代码/hm_sum.py
711
3.515625
4
# 如果一个模块中使用了__all__ # 只用在__all__的列表中的字符串才可以在其他模块中使用 # 条件 其他模块必须是通过from 模块名 import * 方式导入的模块 __all__ = ["name"] # 全局变量 name = "加法运算" # 函数 def add2num(a, b): return a + b # 类 class Person(object): def eat(self): print("人会吃饭") # git 或者是 svn -> 远程仓库 # 在自己定义一个模块中 进行自测 (程序员做的事情) # 定义一个函数 -> 自测函数 d...
a1d75a44545c3953aa3facd0deaf80a0321f8ef7
mazuralexey93/python_faculty
/05102020/hw4.py
1,344
4.4375
4
""" Программа принимает действительное положительное число x и целое отрицательное число y. Необходимо выполнить возведение числа x в степень y. Задание необходимо реализовать в виде функции my_func(x, y). При решении задания необходимо обойтись без встроенной функции возведения числа в степень. Подсказка: попробу...
6608e2579cbe6bba83fcdfa8a737d76c62cae374
rupam-87/data-structure--recursion
/basepow.py
164
3.6875
4
def power(n,e): if e==1: return n else: p=n*power(n,e-1) return p n=int(input()) e=int(input()) k=power(n,e) print(k)
d2af1c60034d9e4c0c77dbcd1ef2ed24fbe22488
vaishnavi-rajagopal/Python_Code
/Exercise/matrixinverse.py
493
3.90625
4
###Q3 -2 Grading Tag matrix_inp = input("Please enter four numbers seperated by spaces : ") matrix_list=matrix_inp.split() if(len(matrix_list)==4): a=float(matrix_list[0]) b=float(matrix_list[1]) c=float(matrix_list[2]) d=float(matrix_list[3]) matrix_tup=((a,b),(c,d)) print("Matrix:"+ str(matrix_tup)) x=(1/(...
991ef3aa7d9f6f306c25835ee5e597622e8e26cd
joaovlev/estudos-python
/Desafios/Mundo 3/desafio082.py
595
3.75
4
lista = [] lista_pares = [] lista_impares = [] while True: numero = int(input('Digite um valor: ')) lista.append(numero) if numero % 2 == 0: lista_pares.append(numero) else: lista_impares.append(numero) confirmacao = input('Deseja continuar ? ').upper() if confirmacao in ['SIM', ...
11d2676e4b82e12b9c6a96ea79d8c9007c1bbe69
gschen/sctu-ds-2020
/1906101015-胡金注/homework1/1.py
197
3.53125
4
x = int(input()) wrong_nums = [1,10,20,30,40,50] def JC(x): if x == 0: return 1 else: return x*JC(x-1) if x in wrong_nums: print('wrong num') else: print(JC(x))
c4042b95934bb1585298d8c1180ebe3d64825d2f
odin2350/PCC
/Chapter 4.py
5,162
4.125
4
magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(magician.title()) magicians = ['alice', 'lavid', 'carolina'] for magician in magicians: print((magician.title()) + ", that was a great trick!") print("I can't wait to see your next trick, " + magician.title() + ".\n") magicians =...
d3991b71a8db90d43cc6dba3185948ace4760634
HemantDeshmukh96/Message-Encruption-Toolkit-Ceaser-Cipher-
/Ceaser Cipher.py
565
3.96875
4
def main( ): valid=True while valid: key=int(input("Enter the key between(1-25) :")) if key>25: valid=True else: valid=False return key def encrupt(key): inp=input("Enter the Messege to be Encrupted :") string=inp.upper() for ch in stri...
0698e5040002d77eba6fcce2e17cc48caec923fc
IonatanSala/Python
/built_in_functions/bin.py
136
3.640625
4
# bin(x) # this converts an integer number to a binary string. my_binary_string = bin(100) print(my_binary_string) # prints: 0b1100100
ec83c3c96acdcc049a2a25c6e1cbc51754568b8b
aquib-sh/classic-cs-problems
/iter_fib.py
335
4.0625
4
# Solves fibonacci iteratively def fib(n: int) -> int: if n == 0 : return n last: int = 0 # last num next: int = 1 # next num for _ in range(1, n): temp = last last = next next = temp + next return next if __name__ == "__main__": n = int(input("Enter a number: ")) ...
855892c5da60c094207f7850af7dd137bf11d252
IrenaVent/pong
/game.py
5,145
3.515625
4
import pygame as pg from random import randrange SIZE = (800,600) # we decided no parmetric screen class Movil(): #la clase padre, IMPORTANTE de ellas heredan el resto def __init__(self, x, y, w, h, color=(255,255,255)): self.x = x self.y = y self.w = w self.h = h sel...
6a449cbb00c0fadedda2a9be80df8eb0324a56ac
AlyMetwaly/python-scripts
/miscellaous/recur_fibo.py
238
4.125
4
num = int(input()) def fibonacci(n): if n<=1: return n else: return (fibonacci(n-1) + fibonacci(n-2)) if num <= 0: print("Plese enter a positive integer") else: for i in range(num): print(fibonacci(i))
2267b84aa2844b68f333e9795ee0bdc487762fdb
ranzhongsi/dacangku
/jieyue2.py
234
3.609375
4
""" 阶跃信号 """ import numpy as np import matplotlib.pyplot as plt #定义阶跃信号 def unit(t): r=np.where(t>0.0,1.0,0.0) return r t=np.linspace(-1.0,3.0,1000) plt.ylim(-1.0,3.0) plt.plot(t,unit(t)) plt.show()
6888804b0964f62d7b0d8aa48584e57f3ffce6af
Shaileshsachan/ds_algo
/array.py
610
3.90625
4
numbers = [10, 20, 30, 40, 50] print(numbers[0]) numbers[1] = 'shailesh' print(numbers) for _ in numbers: print(_) max = numbers[0] for num in numbers: if num > max: max = num print(max) from array import * print(dir(array)) array1 = array('i', [10, 20, 30, 40, 50]) for i in array1: print(i)...
92233569bb3136afc58a5e8f4f213702eea2fab2
Jorgepastorr/m03
/python/entregas/19-5-17/calendario-de-año.py
1,570
3.953125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import calendar def mi_rango(inicio,final,incremento): if inicio <= final : while inicio <= final : yield inicio inicio = inicio + incremento else: while inicio >= final : yield inicio inicio = inicio - incremento #############3 anyo=input("Indica e...
9107adea45514d778f40708a4f0e4983cc49424e
DenKarlos/ITC_Bootcamp_classes_2
/classes_2_5-7slide.py
3,284
3.65625
4
# 3)Car # Создайте класс Car. Пропишите в конструкторе параметры make, model, year, # odometer, fuel. Пусть у показателя odometer будет первоначальное значение 0, # а у fuel 70. Добавьте метод drive, который будет принимать расстояние в км. В # самом начале проверьте, хватит ли вам бензина из расчета того, что машина #...
c7f71314f3be062c920b07e9cbc529f25e665968
christinang89/baboon
/1-5.py
567
3.578125
4
import string input = "aabccccaaa" def compress(st): if len(st) <= 1: return st first = 0 last = first+1 result = "" for i in xrange(len(st)): if last >= len(st): result += st[first] result += str(last-first) elif st[last] != st[first]: ...
2816ee1a44c3e84af73955e455f08db5a2a24517
TheBitShepherd/pygame
/example_programs/snoflakes1.py
2,378
3.6875
4
import pygame import random # COLORS BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) BLUE = (0, 0 , 255) COLORS = [RED, GREEN, BLUE] def randColor(): return COLORS[random.randrange(len(COLORS))] # SCREEN WIDTH = 600 HEIGHT = 600 class Snowflake: def __init__(self, x, y, siz...