blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6a174c23bddef10fa37de05adae6ca0b6b261ff8
darkless456/Python
/方法max().py
295
4.21875
4
# max() 方法返回字符串中最大的字母。 # min() 方法返回字符串中最小的字母。 str = "this is really a string example....wow!!!"; print("Max character: " + max(str)) # 返回序号最大的 str = "this is a string example....wow!!!"; print("Max character: " + max(str))
31df1e4faf0d01b3bb70c8210ade5d8a2bcc219c
vanessalicia8/CSC365-lab01-part1
/schoolsearch.py
3,279
3.640625
4
from School import * from Student import * def prompt(): command = input("S[tudent]: <lastname> [B[us]]\nT[eacher]: <lastname>\nC[lassroom]: <number> [T[eacher]]\nB[us]: <number>\nG[rade]: <number> [H[igh]|L[ow]|T[eacher]]\nA[verage]: <number>\nAn[alytics]: G[rade]|T[eacher]|B[us]\nI[nfo]\nE[nrollment]\nQ[uit]\n") ...
c41798acf10f11e8b30c46a1fa6698ed2182d8d6
lygeneral/LeetCode
/Python/Array/middle/16_3sum-closet.py
1,318
3.921875
4
''' 16. 最接近的三数之和 给定一个包括 n 个整数的数组 nums 和 一个目标值 target。找出 nums 中的三个整数,使得它们的和与 target 最接近。返回这三个数的和。假定每组输入只存在唯一答案。 示例: 输入:nums = [-1,2,1,-4], target = 1 输出:2 解释:与 target 最接近的和是 2 (-1 + 2 + 1 = 2) 。 提示: 3 <= nums.length <= 10^3 -10^3 <= nums[i] <= 10^3 -10^4 <= target <= 10^4 ''' class Solution: d...
f8e9f980404037f5f204a8552675dd983fd699a5
hayleydoherty/hayley
/ineedtiles.py
300
4.21875
4
# This programme calculates how many tiles you # need to tile a wall or floor (m2) length = float(input("Enter room length: ")) width = float(input("Enter room width: ")) # length = 4 # width = 2 area = length * width needed = area * 1.05 print("You need", needed, "tiles in metres squared,")
31d5a3a3852d9e8de7a2035d48943f60970cbbef
aju007ak/ezii
/sddd.py
183
4.15625
4
str=raw_input("Enter string:") d=0 a=1 for b in string: d=d+1 if(b==' '): a=a+1 print("Number of words in the string:") print(a) print("Number of characters in the string:") print(d)
bba2c5b322a54434fa5133220293b0461c301426
brittanymcgarr/Bubo
/Bubo/tests/speech/test_texttospeech.py
675
3.578125
4
################################################################################ ## Text to Speech ## ## Reading the prompted string into audio format. ## #############################################################################...
41369f8fe9a88217707165a1bfd3b102202e1414
IKHINtech/kumpulan_koding_python
/aplikasi sederhana hitung mahasiswa.py
438
3.921875
4
matakuliah = input ("Masukkan nama Matakuliah=") nama = input ("Masukkan Nama Anda=") nim = input ("Masukakn NIM anda=") jawaban = "ya" hitung = 0 while(jawaban == "ya"): hitung += 1 jawaban = input ("ulangi lagi tidak?") if jawaban =="ya": matakuliah = input ("Masukkan nama Matakuliah=") nama = input ...
a374634a3b48d3287856ffb303278b0baa0205ff
osukaru16/python
/Ejercicios en Python3/EJEM3.py
88
3.78125
4
palabre = str(input("Escribe una palabra: ")) inem = 0 for item in palabra: print(item)
4ad13ff45f04c7f0e41614622b802059fa023c3d
Hambardzumian/homework
/oop_les19.py
1,532
3.5
4
import json import requests import threading class Head(): def __init__(self): # Making dictionaries dict_jpg = {} dict_png = {} # Openning json file to read what is inside it and to get photo url s with open("oop19.json","r") as file: text = json.load(file) text = text["items"] # ...
2e63ae8dd2ef0b2e636a54020c88c694034d31ba
zmh19941223/heimatest2021
/04、 python编程/day04/3-code/11-公共方法.py
629
4.09375
4
list1 = [4, 2, 5, 3] print(len(list1)) str1 = "hello" print(len(str1)) list1 = ['刘备','关羽','张飞'] print(len(list1)) # 如果len里面放的是列表,返回列表成员的个数 # 如果len里面放的是字符串,返回字符串中字符的个数 list1 = [54, 12, 78, 123, 77] print(max(list1)) str2 = "hellaz" print(max(str2)) list2 = ['abc', 'bcd', 'edf'] print(max(list2)) print(min(list1)) prin...
2b6e372133b0b09732f70597871ef0c856071226
JoseManuelMS97/SistemasGestionEmpresarial
/Python/Practica4/Ejercicio1B.py
198
3.671875
4
frase = input("Introduzca una frase: ").lower() letras = {} for i in frase.replace(" ", ""): if i not in letras: letras[i] = 1 else: letras[i] += 1 print(letras)
93eefd5b3be1014a824a06c6b0beb070024d60d8
maumneto/IntroductionComputerScience
/CodeClasses/ConditionalCodes/cod8.py
476
3.84375
4
# Escreva um programa (salario.py) que pede os seguintes dados: # Valor do salário de um funcionário # Aumento em porcentagem # Depois mostre o valor do aumento e o salário com aumento com duas casas decimais salario = float(input('Digite o valor do salário: ')) porc_aumento = float(input('Entre com o aumento: ')) au...
ec922627636bf15a31a3ed2877da95155be01b2b
Yuchen112211/Leetcode
/problem1017.py
950
3.859375
4
''' 1017. Convert to Base -2 Medium Given a number N, return a string consisting of "0"s and "1"s that represents its value in base -2 (negative two). The returned string must have no leading zeroes, unless the string is "0". Example 1: Input: 2 Output: "110" Explantion: (-2) ^ 2 + (-2) ^ 1 = 2 Example 2: Inp...
33f6f352379d9b5dcef62d1f479d98f4232beb1e
javi-air/Project-Euler
/Solved/Problem 1.py
264
4.1875
4
def multiples_sum(number1, number2, max): ''' This function will find the sum of all the natural numbers below parameter "max" that are multiples of number1 or number2 ''' return sum([x for x in range(max) if x % number1 == 0 or x % number2 == 0])
203705d171ae683d95d1bcafdc78ec110fd15424
dxj728/python_test
/problem_test/classic_test.py
2,439
3.796875
4
# --coding:utf-8-- # File: classic_test.py # Author: dxj728 # Time: 2021年02月01日23时 # 说明:经典/常见编程题或面试题解法 """GIL全局解释器锁: 特点:Cpython中独有,每个线程在执行时都需要先获取GIL,保证同一时刻只有一个线程可以执行代码,即同一时刻只有一个线程在使用CPU,即伪多线程 使用: 可以通过修改tick值来修改GIL锁占用时间,一旦tick=100时,GIL锁释放 IO操作当CPU闲置时释放GIL锁 解决GIL锁影响 1.更换Cpython为Jpytho...
16289d140d45c99d4178d0910df76971c6b7cb71
cleiveliu/code-archive
/code-20191024/python/one-python-craftsman/error.py
1,160
4.21875
4
# 抛出异常,而不是返回结果与错误 # not recomented in python def create_item(name): if len(name) > MAX_LENGTH_OF_NAME: return None, 'name of item is too long' if len(CURRENT_ITEMS) > MAX_ITEMS_QUOTA: return None, 'items is full' return Item(name=name), '' def create_from_input(): name = input() ...
2982267cad4892cad3c0f8dc2098cade5869366f
Vivbhav/DS_Assignments
/ass4/prog4.py
879
3.796875
4
def main(): proc = int(input("Enter number of processes:\t")) counter = [0] * proc while(1): option = int(input("Choose your option: 1. Event at process 2. Send Message 3. Exit\n")) if option == 1: procno = int(input("Enter process where event took place: ")) if procno > proc: print("Invalid proces...
71c8673ab3d39ce5b6dbabfbf95e0af0f69a8601
programmer-anvesh/Hacktoberfest2021
/gridTraveler.py
833
4.1875
4
#The problem is to count number of possible possible paths from top left to bottom right in m x n grid where you can either move right or move down. #The problem falls under category of Dynamic Programming #Time Complexity: O(n^2) # using the two loops #Space Complexity: O(n^2) # utilizing the table ''' Solution submi...
97490aed75bfa5d166b8916bdf2c9d51a05f9683
lucasjct/python_curso_em_video
/Mundo_1/ex16.py
134
3.8125
4
from math import trunc num = (float(input('Digite um número real: '))) print(f'A parte inteira do número digitado é {trunc(num)} ')
81de7c93f726df7aecfdda9416d591d1d40b028d
linusqzdeng/python-snippets
/exercises/list_overlap_comprehensions.py
393
3.734375
4
# A different solution of the exercise list overlap a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] # define am empty list c c = [] # list comprehension result = [x for x in set(a) if x in b] # remove the dulplicates for y in result: if y in result and y n...
316997f09040a1cbebea2fc5a9747808315a0ff0
arpita-ak/APS-2020
/Hackerrank solutions/Easy- HackerRank in a String!.py
701
3.625
4
""" HackerRank in a String!: https://www.hackerrank.com/challenges/hackerrank-in-a-string/problem """ import math import os import random import re import sys # Complete the hackerrankInString function below. def hackerrankInString(s): t="hackerrank" le=len(t) j=0 l=len(s) for i ...
870f181abe8673e92f50ae7ac20c47fc35eee521
DPNT-Sourcecode/FIZ-toun01
/lib/temp2.py
378
3.859375
4
# -*- coding: utf-8 -*- """ Created on Tue Aug 27 16:54:51 2019 @author: admin """ def fizz_buzz(number): if number%3 == 0 and number%5 == 0: return 'fizz buzz' elif number%3 == 0: return 'fizz' elif number%5 == 0: return 'buzz' else: return n...
9348c4ad4874a889eff2814447c15fb4ffd581ee
lenhatquang1998/lenhatquang-fundamental-c4e21
/session3/homeword3.py/btvn2(6).py
844
3.578125
4
size = [5, 7, 300, 90, 24, 50, 75] print("hello, my name is Nhat Quang and these are my ship sizes",size) n = int(input("ban muon thay dan cuu cua ban sau may thang?:")) for i in range(1, n): print("THANG", i) for i in range(len(size)): size[i] = size[i] + 50 ...
9aadd34375efcad8021851fc43b1873f651f8858
aitorlb/Udacity-Free-Courses
/Introduction to Python Programming/Lesson_3_Control_Flow/For Loops.py
2,505
4.40625
4
# Write a for loop that iterates over the names list to create a usernames list. # To create a username for each name, make everything lowercase and replace spaces # with underscores. Running your for loop over the list: # names = ["Joey Tribbiani", "Monica Geller", "Chandler Bing", "Phoebe Buffay"] # should create t...
d94dfbdd17e636a25d4e80df6792b70cbe38da0c
SaumyaGupta907/practice-python
/classpy/list.py
453
4.09375
4
#lists are similar to arrays in c #however;the list can contain data of different types #the items stored in the list are separated with a comma(,) and enclosed within square brackets [] #we can use slice operator[:] to access the data of the list #the concatenation operator(+) and repetition operator(*) works with...
92bd569401288ae282552ded478d982db2006575
rajadg/pytraining
/basic/session01/compound.py
922
3.515625
4
''' Created on 17-May-2018 @author: dgraja ''' # declare a list ls = [0, 1.0, 2, 3, 4, 5, '6', None, -1, 2, 3, 5] s1 = 's1' s13 = '''s1 3''' s2 = "s2" s23 = """s2 3""" ls.append(s1) ls.append(s2) list2 = [s13, s23] final = ls + list2 # print a list print (final, final.__class__.__name__) # find length of the l...
e295f39032376c105dab0b2fd8830e2a60ba16a1
satojkovic/algorithms
/problems/min_cost_climb_stairs.py
409
3.640625
4
def min_cost_climb_stairs(cost): dp = (len(cost) + 1) * [0] for i in range(2, len(cost) + 1): dp[i] = min(dp[i-2] + cost[i-2], dp[i-1] + cost[i-1]) return dp[len(cost)] def test_min_cost_climb_stairs(): assert min_cost_climb_stairs([10, 15, 20]) == 15 assert min_cost_climb_stairs([1, 1, 1,...
290246cfda02d8f74489f01a3255601408026281
Uthaeus/w3_python_exercises
/vowel.py
387
4.25
4
# Write a Python program to test whether a passed letter is a vowel or not. def vowel(l): vowels = ['a', 'e', 'i', 'o', 'u'] if l == 'y': result = "Your letter is sometimes a vowel ;)" elif l in vowels: result = "Your letter is a vowel." else: result = "Your letter is a consonant." return resul...
16cf9480a842994c7146d9cd8f2a7a5901786e57
JiaPeng1234/leetcode2020
/Dynamic Programming/241. Different Ways to Add Parentheses/Solution.py
1,769
3.890625
4
# https://leetcode.com/problems/different-ways-to-add-parentheses/ # By Jiapeng # 记忆化递归求解分段问题 partition problem # Runtime: 32 ms, faster than 85.56% of Python3 online submissions for Different Ways to Add Parentheses. # Memory Usage: 14.2 MB, less than 5.35% of Python3 online submissions for Different Ways to Add Pare...
08fbb64db910859a29b659236b404fd6858e4b50
gil9red/SimplePyScripts
/concurrency_in_python__threading_processing/multiprocessing__examples/synchronization_between_processes.py
445
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = "ipetrash" # SOURCE: https://docs.python.org/3.6/library/multiprocessing.html#synchronization-between-processes from multiprocessing import Process, Lock import time def f(lock, i): with lock: print("hello world", i) time.sleep(1) ...
2486a321317c1c20af9f3f63aa5ed15bc9302756
saurabhK99/substitution-cipher
/attackMain.py
1,874
3.53125
4
from tkinter import * from attack import * #calls letter frequency attack def attack(on, cipherTxt): plainTxt = str() attack = LetterFrequencyAttack(cipherTxt, on) for i in range(10): plainTxt = plainTxt + attack.attack() + '\n\n' answer.config(text = plainTxt) #defining main wi...
4d09eb5d19050f363798d0c6b3b2b6a5a8351e31
nrakshi3060/ShowmeDataStructures
/Concepts/GraphDFSTraversal.py
1,943
3.6875
4
class GraphNode: def __init__(self, value): self.value = value self.children = [] def add_child(self, node): if node not in self.children: self.children.append(node) def remove_child(self, node): if node in self.children: self.children.remove(node) ...
00daf1c7c446fc84ee287c59e2b979f4d43ace0b
ivanleoncz/PythonEggs
/exercises/ex7_generate_2d_array.py
848
4.40625
4
""" Write a program which takes 2 digits, X,Y as input and generates a 2-dimensional array. The element value in the i-th row and j-th column of the array should be i*j. Note: i=0,1.., X-1; j=0,1,¡­Y-1. Suppose the following inputs are given to the program: 3,5 Then, the output of the program should be: [[0, 0, 0, ...
185d4cade378aa0991e9274203c5b0a2cc09c852
alonsovidales/interview_questions
/citations_h_index.py
408
3.515625
4
class Solution(object): def hIndex(self, citations): """ :type citations: List[int] :rtype: int """ citations = sorted(citations, reverse=True) score = 0 print citations for i in xrange(len(citations)): print "i:", i, citations[i], score if citations[i] > i: score = i+1 return score ...
c275d791db72b7da8215db015370643934e66fdf
SrikanthAmudala/COMP551-MiniProject1
/utils.py
2,089
3.640625
4
import numpy as np """ This package regroups methods to apply on the dataset before learning """ def preprocessing(df, prop=0.8): # Convert the dataframe to numpy array X_train = df.to_numpy() # Divide data set and normalize data separately (no information leakage) np.random.shuffle(X_train) ...
2ef2872581748a96a148337974350ba7daecbfec
frvasquezjaquez/code4ladies-calc
/calc.py
376
3.6875
4
""" Clase para Calcular numeros """ class Calc: """ Definicion de Clase de Calculadora """ def sumar(self, num1, num2): """ Funcion para sumar dos numeros inputs: num1: Primer valor para sumar num2: Segundo valor para sumar """ if num1 < 0 or num2 < 0: ...
5cafc88a2088bed5fde022e538632c232b995bf2
LucasGuiraldelli/txtFileManipulation_Python
/Aula08-For/Aula08.py
1,296
4.125
4
# for letra in 'aeiou': # print(letra) # exemplo 01 for index in range(1,101): # for(int i = 0; i <= 101; i++) // o uso em outras linguagens seria assim para incremento print(type(index)) # mostra o tipo da variável print(index) # exemplo 02 for index in range(100,2,-1): ...
f62bc468ae4c1959d37c948ef6aa528dfe64cbc7
DRCCODES/holbertonschool-higher_level_programming
/0x0B-python-input_output/3-write_file.py
196
3.859375
4
#!/usr/bin/python3 """ write to file """ def write_file(filename="", text=""): """ writes to file """ with open(filename, mode="w") as f: right = f.write(text) return right
17f259401d03d59c22774fe146ff0a56143dd02b
vikashbasant/2048game
/LogicsFinal.py
5,384
3.875
4
import random # Start Game def start_game(): mat= [] for i in range(4): # 0 represent the empty matrix mat.append([0]*4) return mat # Adding new 2 in the matrix def add_new_2(mat): # We need to append 2 where matrix is empty..at random position row = random.randint(0,3) col ...
494bb5b539d580b72817ea70e446c844109ad125
uthmaanb/intro-to-python-main2
/histogram.py
390
3.859375
4
import numpy as np import matplotlib.pyplot as plt # to generate a graphical graph nums = [0.5, 0.7, 1.0, 1.2, 1.3, 2.1, 3.1, 3.2, 3.3, 3.4, 3.5] bins = [0, 1, 2, 3, 4] plt.hist(nums, bins) plt.xlabel("nums") plt.ylabel("bins") plt.title("Histogram of nums against bins") plt.show() list1 = np.arange(1, 21) print(l...
6fe7536a74be6431a606939a61b73c83b65fb37e
eamongoonan/CA117
/Lab12.2/doubles_123.py
372
3.640625
4
from sys import stdin def doubles(word): count = 0 for i, c in enumerate(word[1:-1]): if c in "aeiou" and word[i] == c and word[i + 2] != c: count += 1 count += 1 if word[-1] in "aeiou" and word[-1] == word[-2] else 0 return count if (__name__ == "__main__"): print(m...
a253a5f06e1238869bb66bd561d1b3ad75038042
deniseicorrea/Aulas-de-Python
/python/ex045.py
1,058
3.703125
4
from time import sleep from random import randint itens = ('Pedra', 'Papel', 'Tesoura') computador = randint(0,2) print('''Suas opções [0] PEDRA [1] PAPEL [2] TESOURA''') jogador = int(input('Qual sua jogada? ')) print('JO') sleep(1) print('KEN') sleep(1) print('PO!!!') print('-=' *11) print(f'Computador jogou a opçao ...
6d78bdec5f66291c2d43c55836d98b6c7f853c82
bry77/alsalami_story
/other/addSix.py
181
4.15625
4
""" this program will take the input of the user and return that number plus 6 in a print statement """ print('I can add six to any number') age=int(input('Give me a Number '))
12b5ea3871f70a8b7e274b181ca81ca493f3cfad
EdisonZhu33/Algorithm
/备战2020/070-拼写单词.py
1,574
3.84375
4
""" @file : 070-拼写单词.py @author : xiaolu @time : 2020-03-17 """ ''' 给你一份『词汇表』(字符串数组) words 和一张『字母表』(字符串) chars。 假如你可以用 chars 中的『字母』(字符)拼写出 words 中的某个『单词』(字符串),那么我们就认为你掌握了这个单词。 注意:每次拼写时,chars 中的每个字母都只能用一次。 返回词汇表 words 中你掌握的所有单词的 长度之和。 示例 1: 输入:words = ["cat","bt","hat","tree"], chars = "atach" 输出:6 解释: 可以形成字符串...
b0a994c44bd7c15af9e1faf8951ee70d9e7a3613
barcern/python-crash-course
/chapter4/4-6_odd_numbers.py
283
4.46875
4
# -*- coding: utf-8 -*- """ Created on Tue May 5 09:29:02 2020 @author: barbora """ # Use the third argument of the range() function to make a list of the odd # numbers from 1 to 20. Use a for loop to print each number. odds = list(range(1,20,2)) for odd in odds: print(odd)
1a20a1c3b7b8e7235ff4e4e2277e0595eb5d0c30
LucianaMurimi/python-for-IoT
/lesson4_numpy.py
1,190
4.3125
4
import numpy as np import matplotlib.pyplot as plt # The two useful functions in numpy: # 1. arange() -> np.arange(initial, final, increment) # arange() function excludes the final number # 2. linspace() -> np.linspace(initial, final, num_of_points ) # num_of_points are the number...
4ed30e036634b48aaecf7511a00a1aacb7603cb8
MacccLiu/Python_Learning-PythonInterviewBible
/py_code/count_num.py
540
3.75
4
from collections import Counter def count_letters_1(items): result = {} for item in items: if isinstance(item, (int, float)): result[item] = result.get(item, 0) + 1 return result def count_letters_2(items): result = {} items.sort() for item in items: if item in resu...
584a3be30b5eb3d6697891a96fa51d9f9292f15a
opula1234/PythonRepo
/introduction.py
160
3.59375
4
print("Hello world") print("Hello to github") name = input("Please enter your name") print("Hello Mr. " + name + " Please to inform") print("Good Morning")
388cfdbabc36fb5a1ab4ac5eca99bfac77c62278
pppineapple/LeetCode
/Algorithms/untitled0.py
1,719
3.671875
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Fri Sep 7 17:33:44 2018 @author: pineapple """ ''' 你需要找到由两个 n 位数的乘积组成的最大回文数。 由于结果会很大,你只需返回最大回文数 mod 1337得到的结果。 示例: 输入: 2 输出: 987 解释: 99 x 91 = 9009, 9009 % 1337 = 987 说明: n 的取值范围为 [1,8]。 ''' class Solution(object): def largestPalindrome(self, n...
d1933677b5104518aada928afabb199710401861
rajeevbkn/fsdHub-mathDefs
/addSumNum.py
256
4.15625
4
#This is a programme to add digits of a number and return its sum. n = int(input('Enter the number: ')) sum = 0 while n > 0: remainder = n % 10 sum = sum + remainder n = n // 10 print('The sum of digits of the number entered by you is:', sum)
8bb6a2d3ede70cb8e0a7403c69a9383b97d57412
andersonribeir/ufcfup
/desafio.py
540
3.734375
4
from random import randint numero = [] maior = 0 k = 1 j = 0 saltos = 0 tamanho = int(input("Entre com o tamanho da lista: ")) while len(numero)!= tamanho: r = randint(0,100) if r not in numero: numero.append(r) print("\nLista original: ",numero) while k <= len(numero): for i in range(0,len(numero)-1): ...
84b792b5fe907fa841e481e91c40b40571e4e275
claireyegian/unit4
/countdown.py
178
3.6875
4
#Claire Yegian #10/18/17 #countdownn.py - counts down to zero from n def countdownn(num1): i = num1 while i>=1: print(i) i -= 1 print('BOOM') countdownn(9)
c1300fb12b17e52ad29df944ed82e69792dae0c5
prikshat/CAP906
/mylist.py
70
3.65625
4
list=[10,20,30,40] for x in range(1,20): list.append(x) print(list)
35f80ed2c0013519f5276116b5c058be52206e3a
Hiromitsu4676/algorithm
/prime_number.py
326
3.75
4
def main(n): prime_number=[] for x in range(1,n+1): count=0 for i in range(1,x+1): if x%i==0: count+=1 if count==2: prime_number.append(x) return prime_number if __name__=='__main__': N=10000 rslt=main(N) print(rslt) print(len(...
86ab7cb6ccd33adba249c2f45bbe47119360d3ba
PauloVictorGomes/Codigos-Estudos-Python
/Mini-games/Jogo-Advinhacao.py
1,019
3.921875
4
from random import randint from time import sleep resp = randint(0, 10) #número que devemos adivinhar, de 0 a 10 tent = 1 #variavel para contar as tentaivas, já começa em um pois só é contado novamente depois de o usuário errar print('\n----- JOGO DE ADIVINHAÇÃO v2.0 -----') print('\nPensei em um número inteiro, tente...
d4650bc2503a2543d4587ec2f9cd12756e9b1142
imre-antalfy/HardBoiledEggs
/P2_michele.py
7,729
3.640625
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 1 12:45:41 2019 @author: Michele""" def P2 (file): """P2: This function takes a text file conatining DNA Sequences, parses the file and returns a dictionary containg the key which shows which sequence has been compared to which, as well as the aligned ...
6ab14f9c50294284c003a4509fa80b756765e6b9
Catherine025329/trabajo
/ejercicio2.py
2,718
4.0625
4
# Librerías usadas en el programa import random # Leer N, generar aleatorios y calcular suma y promedio # Area de definición de variables cantidadNumeros=0 contadorRepeticionesWhile=0 numero=0 acumuladorSuma=0 promedioNumerosAleatorios=0.0 # Variables segunda parte del ejercicio acumuladorPositivos=0...
8ddbf123027f0fc81028f356cd687c9162f86ec6
Bren585/V6R
/dbdriver.py
4,353
4
4
from database import Database, Character db = Database() def printAll(characters): print() print("| Name | Gender |Mood|Love|") print("}------------+------------+----+----{") for character in characters: print(character) print() choice = None while choice != 0: print() p...
d1b9d35c7bb4b7d5a218a6e182f2573b500e7910
natraj20/python101code
/chapter37_sqlite/create_database.py
317
3.859375
4
# create_database.py import sqlite3 # use :memory: to put it in RAM conn = sqlite3.connect("books.db") cursor = conn.cursor() # create a table cursor.execute("""CREATE TABLE books (title text, author text, release_date text, publisher text, book_type text) """)
1fdd8d475d45e99fe15d619028d27c099512f0b5
felipegust/canal
/exerciciosLogica/logica1.py
369
3.6875
4
# teste 1: imprimir somente elementos pares dentro de um array listaDeFrutas = ['Abacate','Abacaxi','Abiu','Abricó','Abrunho','Açaí','Acerola','Akee','Alfarroba','Ameixa','Amêndoa','Amora','Ananás','Anona','Araçá','Arando','Araticum','Ata','Atemoia','Avelã'] i=0 while (i < len(listaDeFrutas)): if i % 2 == 0: ...
52eb5b7c924dae7bdbcc673bc938935a4c744387
maryella/python_exercises
/while_loops/print_a_square.py
70
3.90625
4
# 5. Print a square i = 1 while i <= 5: print(5 * "*") i += 1
728072568d87f70086ae01b3546d4be2ea422c12
KingMrLee/MyFirstGitCode
/python_多线程/17_协程状态.py
622
3.84375
4
''' 协程状态 ''' def simple_coroutine(a): print("coroutine starting") # b接受send传回来的值 b = yield a print("-------->recived",a,b ) c = yield a+b print("-------->recived",a,b,c) d = yield a+b+c g = simple_coroutine(5) # 预激 aa = next(g) # 先遇到yield,返回a赋值给aa,打印 print(aa) # 然后send发送了6 赋值给b,然后执行了pri...
931606b1adc50dea44da4dcfb54a6cee20fdba5a
lukaswillsie/cryptanalysis
/chi_squared.py
2,023
4.3125
4
from random import randint from utility import sort, caesar_shift, letters, shift_to_letter, count_occurrences, get_num_letters # Takes in a ciphertext, calculates the chi-squared number of each possible # Caesar shift of the text, and returns a list of tuples # (Shifted Ciphertext, Chi-Squared Number, Shift) # in inc...
8ebabbbfec9902d4229b4881fb43f34a31c34dc2
DrChrisLevy/python_intro_udemy
/book/_build/jupyter_execute/content/chapter1/variables_and_types.py
4,932
4.90625
5
#!/usr/bin/env python # coding: utf-8 # # Variables and Types # # Python variables make it possible to keep track of objects that are stored in memory # throughout your Python program. # You may be wondering what an "object" is. It turns out you have # worked with **objects** already in this book and in your Jupyter...
6df4ab33192e14bf12bda479ecad7dce07a65a3b
Teaspot/test
/a/liner_non_liner.py
2,367
3.828125
4
import time import math import random def Get_Radom_list(count): ''' TODO 随机生成 n 个数 :param n: :return:返回随机数组 ''' radom_list = [] for i in range(1, count): radom_list.append(random.randint(1, 20)) print("The random list is: ", end="") print(radom_list) return radom...
f4465a19ea8adc809c1b370f58712ff871a96f11
pythonfrankcc/python_fundamentals
/deckOfCards_oop.py
2,050
4
4
#oop and debugging import pdb import random #inheriting from object #establishing the starting point of the debugger but cannot be used in situations with classe only runs after #classes are called #pdb.set_trace() class Card(object): def __init__(self,suit,val): #creating methods of the Card class self.suit=suit ...
0ff781496f69b85204c414ff04086be89e0d8fb2
vyshakrameshk/EDUYEAR-PYTHON---20
/p_library_management_system.py
3,280
3.5625
4
''' Library Management system using OOPS ''' class Library: books = [] def __init__(self, name, role): self.name = name self.role = role if role == 'student': self.book_bank = [] def show_user(self): print('\nName: {}\nRole: {}\n'.format(self.name, se...
f8481041085ea1a3a61d1ad3e69e9c2997343cde
raymondw99/DD1331
/Lab 4/Extrauppgift.py
1,251
3.890625
4
#!/usr/bin/python # -*- coding: utf-8 -*- List = [] #Skapar kortlek def create_card(var): card = [] for i in range(var): card.append(i); return card #Körning def main(): try: var = int(input("Kortstorlek: ")) if len(create_card(var)) % 2 != 0: print("Felaktig inma...
fcecc678eb4e0be12183f3f042383eea13b95e92
moontree/leetcode
/version1/410_Split_Array_Largest_Sum.py
2,210
3.984375
4
# --*-- encoding: utf-8 --*-- """ Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m subarrays. Note: If n is the length of array, assume the following constraints are satis...
3f36c17b480c0d4ad3d742c18a78c4933a1a9f03
mertinal/String-Permutation-Checker
/main.py
600
3.8125
4
def checkStrings(str1 , str2): status = False str1 = ''.join(sorted("".join(str1))) str2 = ''.join(sorted("".join(str2))) if(str1 == str2): status = True else: status = True if(len(str1) > len(str2)): for i in str2: if(i not in str1): ...
6520b3ffe713f1947cfd7e1f6886fc5ab120b622
izi-manny/Module-4-Data-and-Databases
/process.py
1,066
3.953125
4
log_file = open("um-server-01.txt") # open the text file and save it to a log_file variable def sales_reports(log_file): # define a function that uses the log data as a parameter for line in log_file: # for loop to iterate over the log lines line = line.rstrip() # remove trailing spaces from each line a...
1d9f25a8ed12ce1cd3415a393de33f347c6088f1
JamesRoth/unit6
/longestDictionaryWord.py
224
3.796875
4
#James Roth #5/10/18 #longestDictionaryWord - longest word in dictionary file = open("engmix.txt") length = 0 item1 = "" for item in file: if len(item)>length: item1 = item length = len(item) print(item1)
0644a377d406840ba56f864d11c33e9242066af2
habibor144369/python-all-data-structure
/list.py
343
3.765625
4
# list in list, dictionary, tuple---- item = [12, 45, 67, 89, (23, 56, 78,), ['hello', 'programmer', 'developer'], {'name': 'Habibor Rahaman', 'id': 144369, 'phone': '01768280237'}] print(item[1], type(item[1])) print(item[4], type(item[4])) print(item[5], type(item[5])) print(item[6], type(item[6])) for items in item...
ce6dab420031ce2a9f2c1f9057889507040e4b60
pedrohcf3141/CursoEmVideoPython
/CursoEmVideoAulas/Aula009.py
712
4.125
4
frase = 'Curso em Video Python' print(frase.capitalize()) len(frase) frase.count('o') frase.count('o',3,13) 'Curso' in frase # retorna um boolean frase.find('o') frase.replace('Python','Android') frase.upper() frase.lower() frase.capitalize() # primeira maiuscula o resto miniscula frase.title() # primeiras letra de c...
17b3371145778e8f5b9f2e04d5692f921c02ce27
mdleveille/project_euler
/p05.py
676
4.0625
4
""" 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? """ # LOOKED UP def gcd(a,b): """Compute the greatest common divisor of a and b""" while b > 0: ...
d835431939586548ff34eab92ca8100120b938e5
bhatiakomal/pythonpractice
/Pythontutes/MapFunction.py
348
3.828125
4
'''a=[10,20,30,40,50] def inc(n): return n+2 result=map(inc,a) print(result) for i in result: print(i) #with Lambda Function a=[10,20,30,40,50] result=list(map(lambda n:n+2,a)) print(result) for i in result: print(i)''' a=[10,20,30,40,50] b=[1,2,3,4,5] result=list(map(lambda m,n:m+n,a,b)) print(result) f...
9fe11072b1b64ce31693ba199e9985588aed81d5
Chaguin/PruebasPython
/proyecto2/principal.py
197
3.734375
4
# -*- coding: utf-8 -*- from mayor_menor import mayor num1=int(input("Ingrese el primer valor: ")) num2=int(input("Ingrese el segundo valor: ")) print ("El mayor de ellos es: ",mayor(num1, num2))
9d91fd8d5958a0fd578a62b9a93b725008c1adaa
katamit/dataStructure_practices
/MergeSort.py
2,581
4.375
4
# This program is to demonstrate the principle of Merge Sort in python # Merge sort is not an inplace algorithm, whihc means it requires extra space for sorting. #TIME COMPLEXITY IS 0(nlog(n)) def merge_sort(unsorted_list): if len(unsorted_list) == 1: return unsorted_list mid_point = len(unsorted_list)//2 left...
8827baa16eb594b28ff39dd1a8a86e98208b5de6
hippietilley/COMP-1800
/Scripts/Class examples/(10-18) Robo-Bouncer example.py
658
4.15625
4
# get user input for age age = int(input("How old are you? Answer truthfully, please... ")) if age >= 18 and age <= 30: # user is in range print("Come on in!") elif age < 18: # user is NOT old enough diff = 18 - age # how long does the user need to wait before being able to enter? ...
a2203bb2ac31241832a41c03e5da5369e148bc43
plumchloride/class_DSp2_fractal-tree-curve
/function-hoge.py
329
3.828125
4
from turtle import * def rect(num): for i in range(4): forward(num) left(90) def five_ster(num): for i in range(5): forward(num) right(144) def circle(num): for i in range(360): forward(num) left(1) rect(100) forward(150) five_ster(100) circle(3) mainloop...
0a9df0bfaa5a4489aecd297c50e6a4001eae859f
szkennminn/Script
/Python/Rename.py
840
3.859375
4
#!/usr/bin/env python # coding:utf-8 import os def rename(): path = r"E:\kennminn\Desktop\aaaaa" filelists = os.listdir(path) # 该文件夹下所有的文件(包括文件夹) i = 1 # i的初始赋值不能在for循环里头,不然每次执行for循环都会把i重置为1,不会产生累加效果 for file in filelists:#遍历所有文件 old_dir=os.path.join(path,file) # 原来的文件路径 if os.path.i...
128841e442c2fa2a02fd2c59a344ddf519fee4d2
MaesterPycoder/Python_Programming_Language
/oops/Bank.py
917
3.953125
4
import sys class Bank(object): def __init__(self,name,balance=0.0): self.name=name self.balance=balance def deposit(self,amount): self.balance+=amount return self.balance def withdraw(self,amount): if amount<self.balance: self.balance-=amount ...
b5a3143ee06d86d6b0ea2919beb5d18373a512b2
SharimBabar/Mini-projects
/Class.py
751
3.671875
4
import random class card: def __init__(self, value, suit): self.value=value self.suit=suit def ShowCard(self): if self.value==1: rank="Ace" elif self.value==11: rank="Jack" elif self.value==12: rank="Queen" elif se...
c2eec9eb88f1f14711beacda52d6fd9f4b139741
josejnra/python
/estruturas_de_dados_basicas/listas.py
3,571
4.40625
4
# Alguns exemplos de listas em Python # coding: utf-8 """ Listas são similares a strings, que são uma sequência de caracteres, no entanto, diferentemente de strings, os itens de uma lista podem ser de tipos diferentes (heterogêneas). Listas são mutáveis, enquanto Strings não são. Para indicar que um objeto é uma lista...
2eae89607ed14bd98be0257dd236bcc20e536b63
puturatpande/bootcampXIII_fundamental
/fundamental_02.py
1,093
3.578125
4
alas = 2 tinggi = 5 luas_segitiga = alas * tinggi / 2 print (luas_segitiga) #segitiga 2 alas = 7 tinggi = 2 luas_segitiga = alas * tinggi / 2 print (luas_segitiga) #sederhanakan dengan membuat fungsi def hitung_luas_segitiga(alas, tinggi): return alas * tinggi / 2 segitiga1 = hitung_luas_segitiga(10,2) print (s...
e05097791de25e6e066e2d5690ec5a3376e6ab91
Henry440/Python-TicTacToe
/TicTacToe.py
4,734
3.75
4
import os import time import random board = [0, 1, 2, 3, 4, 5, 6, 7, 8] player = str(input("Playerfigur : ")) computer = str(input("Computerfigur : ")) figur = "" if player == computer: computer = "x" if player == computer: computer = "y" def cls(): os.system('cls' if os.name==...
6184d1edad395ab189b894535d4449867c4263c3
yasharne/Sierpinski-python
/draw_sierpinski.py
1,039
3.84375
4
__author__ = 'yashar' import turtle def sierpineski(points, n, t): color = ['blue', 'red', 'green', 'white', 'GreenYellow', 'violet', 'orange', 'Maroon'] draw_triangle(points, color[n], t) if n > 0: sierpineski([points[0], midpoint(points[0], points[1]), midpoint(points[0], points[2])], n - 1, t) ...
8ae1ccc0ab890222d7558f241836a72a91d38fef
cangyunye/OriOfEvery
/PythonBasicLearning/function/whatismapreduce.py
770
3.875
4
""" map(func, *iterables) 映射 reduce(func, [x1, x2, x3, x4]) = func(func(func(x1, x2), x3), x4) 归约 """ from functools import reduce def add(x, y): return x + y def f(x): return x*x def str2int(s): # def fn(x, y): # return x * 10 + y def char2num(s): digits = {'0': 0, '1': 1, '2'...
95f2f637e132531dabc5beb06556614712dc39f1
vaibhavk20/PythonProjects
/VoiceAssistant.py
1,702
3.625
4
import speech_recognition as sr import pyttsx3 import pywhatkit import datetime import wikipedia import pyjokes listener = sr.Recognizer() # this help to recognize your voice engine = pyttsx3.init() # make obj of pyttsx3 voices = engine.getProperty('voices') # adding all voices in voices variable engine.setProperty...
5f845c0211ee634a9f45eea9fcc7c6ac6369ed13
igortereshchenko/amis_python
/km72/Podolsky_David/5/task4.py
420
3.84375
4
print('Задание 5.4') print('Программа выводит первые два элемента, которые одного знака') while True: list1=str(input('Введите список: ')) list1=list1.split() for i in range(0, len(list1)): if (int(list1[i])<=0 and int(list1[i+1])<=0) or (int(list1[i])>=0 and int(list1[i+1])>=0): print (list1[i], list1[i+1]) ...
c517926d8e81c8206697d3e2a7dabff24203ebcc
wanxue59/Python_Tutorials
/Python/08.02文件操作配合异常处理.py
1,264
4.09375
4
""" 8.3 实例21:带有异常处理的文件操作 实例描述: 对文件分别进行写入和读取操作,并且都使用try/except进行异常处理,最终在finally中进行关闭。 (1)在第一个try里面,以二进制形式打开一个文件,以文本的方式向里面写入一个字符串。使用except 对try里面的异常进行捕获。最终在finally中对文件进行关闭。 (2)在第二个try里面,以文本的方式打开一个文件,并读取里面的内容。使用except对里面的异常进行 捕获。最终在finally中对文件进行关闭。 """ try: # 第一个try语句 f = open(r"D:\PyCharm_Code\Data\te...
fec528bdaa6240bbf6c1004e868fd33ae3727e6f
olcplif/python-hw
/hw#11_Testing/calc_unitests/mul_test.py
644
3.71875
4
import unittest from unittest import TestCase from calc import Calc class TestMul(TestCase): """ testing func mul in the calc """ def test_001(self): self.assertEqual(Calc.mul(0, 0), 0) self.assertEqual(Calc.mul(-1, -1), 1) self.assertEqual(Calc.mul(4, 2.0), 8.0) def tes...
496d29f84a031e35a793d4788b2fa1ed661b31bc
AdityaChirravuri/CompetitiveProgramming
/HackerRank/Python/Strings/TheMinionGame.py
408
3.625
4
#enter the string s = input() vowel = ["A", "E", "I", "O", "U"] stuart = int(0) kevin = int(0) for i in range(len(s)): if s[i] in vowel: kevin += len(s)-i #print(s[i], "stuart: ", kevin) else: stuart += len(s)-i #print(s[i], "kevin: ", stuart) if stuart > kevin : print("...
bf4f855d9743d486747395ecdfbcc3eab7269ba0
Valery780/lesson_3
/factorial.py
119
4
4
n = int(input("Enter a number: ")) factorial = 1 while n > 1: factorial *= n n -= 1 print(factorial)
ef5cae715a0c27b1110876603e89f36edbb1da17
ahemahem-pythoner/Text-Based-Rock-Paper-Scissors
/VS-Rockpapscissors w input.py
1,550
4.15625
4
#Text based Rock Paper Scissors import random def lineBreaks(): print("---") print("Welcome to Text Based Rock Paper Scissors") lineBreaks() print("To start off , enter your name below") lineBreaks() #Input Player Name player1 = input("Please Enter your name ---Player 1 is : ") lineBreaks() player2...
5e108e2ac9332711b318b2e57a1ab78464236647
katie1205/Properties_of_Numbers
/evens_odds.py
1,580
4.6875
5
#This function takes an argument and returns 'even', 'odd', or 'neither' using the following: #if the number is divisible by 2, it is even #all other numbers are either non-integers or odd def even_or_odd(x): return 'even' if x % 2 == 0 else 'odd' if type(x) == int else 'neither' #This function takes two num...
cd834cba0d8c0f18b3d2fb36252cea454c4b8463
kalra19/csv_files
/merge_csv.py
1,517
3.796875
4
import csv import glob import os # get the current file location current_project_directory = os.getcwd() def merge_csv(): """ This Function is used to get all the csv files in input_file_location and then generate a unified csv file """ # location of the input csv files input_file_location = current_proje...
3de38aa921d8f6a36689e3d4a2f44b10bbb872b4
amshrestha2020/IWAssignment-Python-
/DataTypes/UnpackTuple.py
218
3.921875
4
'Program to unpack a tuple in several variables' def main(): unpack_tuple() def unpack_tuple(): x, *y, z = (5, "Python", "Django" ) print(x) print(y) print(z) if __name__=="__main__": main()
b19a4b5380d285a6605ef311cdbfd90f49e35872
kabu1zhan/testBiometcir
/person/service/ageCalculate.py
822
3.75
4
import datetime class Age(object): '''Класс для счета возраста''' def __init__(self, iin: str): self.year = iin[0:2] self.month = iin[2:4] self.day = iin[4:6] self.century = iin[6] def getYear(self): full_year = '' if int(self.century) in range(0, 1): ...
e59774e0cf577d9ee10ad5b591ec384f7dfb7051
tonytan4ever/python-practical-datastructures
/substring/kmp.py
1,328
3.578125
4
''' KMP substring strStr, O(m + n) time complexity ''' def get_prefix_table(target, n): # get the prefix table prefix_table = [0] * (n + 1) prefix_table[0] = -1 # matching target or target i, j = 0, -1 while i < len(target): if j == -1 or target[i] == target[j]: i += 1 ...