blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
146a1363c28f972231c7885636b83a3c00651c94
gad26032/python_study
/basics/string_tasks.py
720
4
4
s = "abcdef" # 0. вывести на экран каждый символ for i in s: print(i) # 1. вывести на экран каждый второй символ print(s[1::2]) # 2. Вывести на экран индекс буквы "e" print(len(s[3::-1])) # 3. Вывести на экран буквы в обратном порядке print(s[::-1]) # 4. Ввести "a_b_c_d_e_f" s2 = "_" print(s2.join(s)) # 5. Вывести ...
5880536ee3e5982049b16eb9804183304d679a9c
shadowstep666/phamminhhoang-fundamental-c4e25
/section3/homework_day3/2.6sheep.py
1,022
3.5625
4
size = [ 5 ,7,300 , 90 ,24,50,75] print("Hello , my name is hiep and these are my sheep size :") print(size) print(" now my biggest sheep has size",max(size), " let's shear it") x = size.index(max(size)) size[x]=8 print("after shearing , here is my flock") print(size) month = int(input(" nhap vao so th...
543feb476cd90a33cf73360eec32aaa5472c50be
Harryhar1412/assignement4
/eight.py
322
4.40625
4
# 8. Write a Python program to remove the nthindex character from a nonempty # string def truncate_char(str, n): starttext = str[:n] endtext = str[n + 1:] return starttext + endtext input_string = input("Enter String value: ") pos = int(input("Enter the Position: ")) print(truncate_char(input_string, pos)...
2ae2e976399151cfce8d34159e252a10b171dc3f
ABHINAVPRIYADARSHI/Computer-Networks
/crc.py
2,452
3.765625
4
def divide(divisor,codeword,new_codeword): rem=[] for i in codeword: if(len(rem)==len(divisor)): break else: rem.append(i) cont=0 cont1=len(divisor)-1 new_divisor=divisor[:] while(cont!=len(new_codeword)): for i in range(len(divisor)): ...
0f735c43bda9c3dbe67cd93f3024050e2c442eb2
liujinshun/Python
/class.py
546
4
4
#!/usr/bin/python #coding=utf-8 # 类名首字母大写 class Person(object): def __init__(self,name): self.name = name age = 10 #第一位self不传参 def color(self,c): print "%s is %s,he is %d"%(self.name,c,self.age) boy1 = Person("Jame") boy1.age = 12 print boy1.age print boy1.name boy1.face = "帅" boy1.co...
3df918b51af606232e5fff239bf71bf1b580eaeb
girlingf/CSE331
/CircularQueue.py
5,044
4.125
4
class CircularQueue(object): def __init__(self, capacity=2): """ Initialize the queue to be empty with a fixed capacity :param capacity: Initial size of the queue @pre: a capacity of the circular queue, if no input is provided it will default to 2 @post: initializes...
c8484de60223b833238af12ebaaa55c74675bc9b
Arix2019/myPythonRepo
/testExp.py
238
3.75
4
#parte do arquivo funcExp.py from funcExp import exp string = input('>>>Digite a expressão: ') print('-+'*20) if exp(string) == 0: print('>>>Parâmetros aceitos.') else: print('>>>A sintaxe da sua expressão possui erros.')
bafafed53affad542425dc7680b57f95c2f80c50
sophcarr/comp110-21f-workspace
/projects/cyoa.py
3,353
4.09375
4
"""Which Disney Princess Are You?""" __author__ = "730320301" player: str = "" points: int = 0 HAT: str = '\U0001F920' def main() -> None: """Main program.""" global player global points player = input("Hello, player! What is your name? ") greet() print(player + ", do you want to keep playin...
c334472a739655927757a93c79396669e3989524
ellismckenzielee/codewars-python
/decode_the_QR_code.py
1,060
3.515625
4
#decode the QR code kata #https://www.codewars.com/kata/5ef9c85dc41b4e000f9a645f import numpy as np def scanner(qrcode): qr_code_indeces = [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] for i in range(21)] for i, row in enumerate(qrcode): for j, val in enumerate(row): if (i+j)% 2 == 0: ...
4571b5ca7d229fdc1f49e05d246d142ae246f27e
devin-kennedy/collatz
/collatz.py
1,662
3.671875
4
import math solved = {} def collatzAlgorithm(n): if n % 2 == 1: return 3 * n + 1 else: return n // 2 def append_value(dict_obj, key, value): if key in dict_obj: dict_obj[key].append(value) else: dict_obj[key] = [value] def collatz(n): chain = n nextValue = n ...
ec542707625c4fb6c967ffd4da9b1544da67ec6c
brandonIT/grading
/grading.py
2,477
4.09375
4
def printDirections(): print("Welcome to the Grading Machine!\nThis program is designed to convert your grades (in numbers)\nto their letter version counter parts.\nThe program will continue to read in grades until you enter -1.") def getInt(): num=0 print("Please enter the numerical value of the grad...
5eea149d88d72b84cc7d6e4c1b9236e9a81d741d
atanas-bg/SoftUni
/Python3/Lecture_03_Functions/demo_package/demo_functions.py
2,021
4.03125
4
def div_mod(number, divider): num = number // divider modulus = number % divider return num, modulus # return(num, modulus) print(div_mod(5, 2)) # по-удобно r, m = div_mod(13, 3) print(r) # отпечатва 4 print(m) # отпечатва 1 def print_greeting(name="everybody"): print("Hello, ", name) print_gr...
a08eefc483eaa317ec83c5aca0050679833a3b4d
Alcamech/CSCE355-2017
/src/searcher_DFA.py
2,502
3.9375
4
# -*- coding: utf-8 -*- import sys ''' Text Search - read a string w from a text file - output a DFA that accepts a string x if and only if w is a substring of x @Author: Lawton C. Mizell DFA (Q, Σ, δ, q', F) Q - states Σ - alphabet δ - transitions q' - start_state F - accepting_states ''' def main(): #read ...
dd01623027938f1566acbcb48c138bf1f3d9f844
cinxdy/Python_practice
/Tutor/yesul_find.py
492
3.78125
4
# find_transfer.py #다음과 같이 영어 문장과 찾을 단어를 입력 받아서, #그 단어가 입력된 문장에 몇 번 나타나는지 출력한다. #또 찾은 단어는 모두 대문자로 바꾼 후 문장을 출력한다 #19/4/1-10 #조예슬 input_str=input("Input a sentence :") input_find=input("Input a word for search :") count = input_str.count( input_find ) input_str = input_str.replace( input_find, input_find.upper() ) pr...
a7a50be19c818ea1b8f2ed52221f22fbc849a169
mitoop/py
/knapsack.py
790
3.953125
4
#!/usr/bin/env python # 类似 Knapsack problem 源代码来自于知乎 import random random.seed() # 组数 自定义 groups = 5 # 一百组0-1000内的随机数 values = [random.randint(0, 1000) for i in range(100)] # 从大到小 减小之后的误差 values.sort(reverse=True) # 生成对应数目的空列表数 target_groups = [[] for grp in range(groups)] for v in values: # 计算列表值得和 并从小到大排序 ...
e2ab037688e6be8a6c13d94e4381a725853d11cb
alvas-education-foundation/Krishna_Katira
/coding_solutions/26-06-20.py
168
3.578125
4
a=[] l=int(input("Enter lower limit: ")) u=int(input("Enter upper limit: ")) a=[x for x in range(l,u+1) if x%2!=0 and str(x)==str(x)[::-1]] print("The numbers are: ",a)
79759ba0edc4aa9cd5841aad1f08a5bdd0f1c7a1
lxh935467355/hello-world
/weather.py
958
3.75
4
# 已知实时天气预报API接口为: # http://www.weather.com.cn/data/sk/101110101.html # 返回的是JSON格式的数据,请爬取天气预报信息,并将爬取到的信息保存到文件中。 import json from urllib import request url = "http://www.weather.com.cn/data/sk/101110101.html" if __name__ == '__main__': resp = request.urlopen(url) # 发送GET请求,返回响应对象 if resp.stat...
4cf1d3eb5f26d69b8ce077d60630cb4b9ef31873
Suspious/alweer
/while 5.py
91
3.6875
4
while True: x = input("hoe heet je? ").lower() if x =="anthony": break
01224569b9761c6fa6ad2004d8d0856e498203c6
jackx99/Python-Tutorial
/Sorting.py
1,524
4.4375
4
# Hello Guys # Today lesson is Sorting a list. We are going to learn Selection Sort. # How selection sort work? a list is sorted by selecting elements in the list, one at a time, and moving # them to their proper positions. This algorithm finds the location of the smallest element in the unsorted portion # of the list ...
3992d1fd064ce6ddd78e3ac1637129757203aaff
Aleksandrov-vs/dz_ege
/task_26.py
926
3.640625
4
DATA = [] def load_data(): with open('./26.txt') as f: size, count = f.readline().split(' ') size = int(size) count = int(count) for line in f: DATA.append(int(line)) return size, count def main(): size, count = load_data() DATA.sort() sum = 0 cou...
6cb95a512c5584e0c6f4ad796ccecb7d9c2f1ea1
florianjanke/Pythondateien
/Name+ frohe Weihnachten passt sich dynamisch an den Namen an.py
366
3.5
4
texteins=input("Wie heißt du?: ") laengeeins=len(texteins) textzwei=" Frohe Weihnachten " laengezwei=len(textzwei) sternchen="*" laengedrei=int((laengezwei-laengeeins)/2) print(sternchen*laengezwei+(2*sternchen)) print(sternchen+textzwei+sternchen) print(sternchen+" "*laengedrei+texteins+" "*laengedrei+sternche...
a85a1eaab4e5f670bc8989362cd759abee68c2e1
HariData20/Rock-Paper-Scissors
/Rock-Paper-Scissors/task/rps/game.py
2,606
3.96875
4
# Write your code here import random import sys name = input('Enter your name:') print('Hello, {}'.format(name)) score = 0 selection = input() if selection == '': options = ['rock', 'paper', 'scissors'] else: options = selection.split(',') print("Okay, let's start") # rock,gun,lightning,devil,dragon,water,air,...
367d7a5def6e2c307b27fbae5f043cd5bfab071d
316112840/Programacion
/ActividadesEnClase/Class/Registro.py
1,268
3.578125
4
import random as r class Registro: numeroRegistros = 0 def __ini__ (self, nombre, apellidos, edad): Registro.numeroRegistros += 1 # Para que cada vez que se cree un objeto, aumente una unidad self.nombre = nombre self.apellidos = apellidos self.numero = Registro.numeroRegi...
36969e16e9c5e5982123b07b6e4070fd4a55e3f5
emmapatton/Programming-Module
/Practice and Revision/format.py
264
4.03125
4
# Emma Patton, 2018-03-02 # Formatting output for i in range(1, 11): print('{:2d} {:3d} {:4d} {:5d}'.format(i, i**2, i**3, i**4)) a = 5 print(f'The value of a is {a} and a+1 is {a+1}.') for i in range(1, 11): print(f'{i:2d} {i**2:3d} {i**3:4d} {i**4:5d}')
28a61445b2709c73184490340e621510d8d1600e
hobler/chanmap
/wedge.py
5,576
4.1875
4
""" Geometry operations with a wedge. A wedge is defined by the triangle bounded by the lines y=0 and y=x, and by a circle with its center on the negative x axis or at the origin. """ import numpy as np from geom import Line, Circle, intersect from stereographic import stereographic_projection, cartesian class Wedg...
0fe29c6e68cd83b86d240dcec155f0319b3c40d1
priyankabb153/260150_daily_commits
/list/position.py
411
3.921875
4
# Write a Python program to change the position of every n-th value with the (n+1)th in a list list1 = [1, 0, 3, 2, 5, 4] """ i=0 while i <= (len(list1)-1): temp = list1[i] list1[i] = list1[i + 1] list1[i + 1] = temp i = i + 2 """ def position(list1): for i in range(0, len(list1), 2): ...
060f59b1bfb2b219b102b38ac88d8d7685c4661d
LuongMonica/passwd-validator
/passwd-validator.py
3,055
4.40625
4
# password validator """ must follow: - Minimum length is 5; - Maximum length is 10; - Should contain at least one number; - Should contain at least one special character (such as &, +, @, $, #, %, etc.); - Should not contain spaces """ prompt = str(input("Enter a valid password. Password must be 5-10 character...
0514f4538df9863ee99d0c3211e8c2745f98ac0b
kashyapa/interview-prep
/revise-daily/epi/revise-daily/stacks/max_api.py
1,445
3.671875
4
#!/usr/bin/env python class max_stack: max_cache = [] max_count = {} def __init__(self): self.st = [] def max_val(self): return max_stack.max_cache[-1] if len(max_stack.max_cache) > 0 else -float('inf') def pop(self): val = self.st.pop() if val in max_stack.max_co...
5ee368d55297cc6773de66f69aba1a849a09733e
cameronhawtin/Recursion-and-Homoglyph-Translation-in-Python
/Homoglpyh Translation.py
2,558
4.1875
4
# # Cameron Hawtin # 101047338 # # Gaddis, T. (2015). "Starting Out With Python" # # This program loads a string from an external file and uses # it's contents to form a homoglyph translation dictionary. # # The external file contains: ";R:12;I:1;E:3;D:cl;I:!;B:!3;G:(_+;J :(/;:" # # Function to insert a ...
1e0fa72d2b53299daad354fcd0cc42386802e3ef
corridda/Studies
/CS/Programming_Languages/Python/Python_Documentation/The_Python_Standard_Library/Built-in Functions/s-z/vars_test.py
997
4
4
"""vars([object])""" # https://www.programiz.com/python-programming/methods/built-in/vars from pprint import pprint """Return the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute. Objects such as modules and instances have an updateable __dict__ attribute; however, othe...
d49e1bc7740518c58ad4c76d8ff01ce225230e16
edumeirelles/Blue_modulo1
/Aula_11/aula11.py
968
3.53125
4
# lista_contatos =[('Eduardo','16 99260-1155'),('Fulano','11 99999-0000'),('Beltrano','21 88888-5555'),('Sicrano','31 66666-7777'),('Zé','41 56565-7979')] # # print(lista_contatos) # dic_contatos = dict(lista_contatos) # # print(dic_contatos) # # print(len(dic_contatos)) # # dic1 = {'valor1':'valor2',} # # print(len(d...
7a7a3c22c68db0ab6853978635105f56eabf237a
hellokejian/PythonBasic
/advanced/04tuple2.py
2,079
4.0625
4
"""一 元组和列表""" # 可将字符串和列表拉到一起 str = 'kejian' num = [1, 2, 3, 4, 5, 6] # iterator = zip(str, num).__iter__() # while iterator.__next__: # print(iterator) """可以使用for循环来访问元组的列表""" tuplelist = [('kejian', 0), ('chenqi', 1), ('kechen', 3)] for name, num in tuplelist: print(name, num) print("======================...
39429b96083ac31aa5ccb870ecd1ab61397c5e0c
uniyalnitin/competetive_coding
/Codeforces/469_D2B(DreamoonAndWiFi).py
591
3.546875
4
''' Problem Url: https://codeforces.com/contest/476/problem/B Idea: Permutation and Combination ''' import math s1 = input() s2 = input() plus, minus = s1.count('+'), s1.count('-') pre_plus = s2.count('+'); pre_minus = s2.count('-') req_plus, req_minus = plus- pre_plus, minus - pre_minus if req_minus < 0 or req_p...
23b0d366b3dbaa5706af3cd3305a36715017f8fb
JitendraAlim/Data-Science-Toolkit
/Python/Python Programs/14. Sum Of Numbers From 1 to 100.py
295
4.0625
4
# Write A Progam To Obtain The Sum Of Numbers From 1 To 100 # Method 1 x = 1 y = 0 while x<101: y = y + x x = x + 1 print("The Sum Of Numbers From 1 To 100 is ",y) # Method 2 y = 0 for x in range(1,101): y = y + x print("The Sum Of Numbers From 1 To 100 is ",y)
005a95217cf8643ee927dd587084e7fc7fa70941
lewis-munyi/MSOMA-Boot-camp
/high-level-functions.py
243
3.75
4
from math import sqrt, pi, pow def identity(k): return k def cube(k): return pow(k,3) def summation(n,term): total, k = 0, 1 k = 1 while k <= n: total = k total += term(k) k += 1 return total
f862925ff235296d410fb72d5332b6000b2202a9
foureyes/csci-ua.0479-spring2021-001
/_includes/classes/27/timer.py
285
3.59375
4
import turtle t, wn = turtle.Turtle(), turtle.Screen() # turn animation of turtles off t.hideturtle() wn.tracer(0) def draw(): t.up() t.forward(5) t.down() t.circle(20) # update screen wn.update() # call again in 50 milliseconds wn.ontimer(draw, 50) draw() wn.mainloop()
84e4e8331f89d1d0fd87d576ce75cb6ba3c4f139
Bikram-Gyawali/pythonnosstop
/003/list2.py
648
4.375
4
items=[0,1,2,3,4,5,6,7,8,9,10] print(items[-2]) #gives second last value print(len(items)) print(items[:3]) #gives the first 3 value [0,1,2] //this is basically the slicing in python print(items[:]) # gives all values print(items[0:-1]) print(items[5:]) print(items[0:10:2]) print("============") print(items[0::2]) ...
8d5d1088f2ae9b1d7956b7ca9b5ee784d3f85b8a
laobadao/Python_Learn
/PythonNote/hello.py
712
4.0625
4
print("Hello,Python! and Hello Python") if True: print("oo true") else: print("oo false") print("111", "number", "string") print("100*2+33-90*2/2==", 100 * 2 + 33 - 90 * 2 / 2) # print("请输入你的名字:") # name = input() # # print("hello", name, "nice to meet you") # # name = input("please calculat...
68196a7aa6b9c031d13755882cf10fe4ae52516d
marlonsp/EP2
/paciencia_acordeao.py
4,476
3.828125
4
#funções para o funcionamento do jogo from f_cria_baralho import cria_baralho from f_extrai_valor import extrai_valor from f_extrai_naipe import extrai_naipe from movimentos_possiveis import lista_movimentos_possiveis from possibilidade_de_movimento import possui_movimentos_possiveis from empilha_carta import empilha #...
7a1bb5983db731a81c471168c5b89e909f73bc5d
Maerig/advent_of_code_2017
/day11/main.py
1,285
3.875
4
ORIGIN = 0, 0 def read_input(): return open('input.txt').read().rstrip().split(',') def move(x, y, direction): if direction == 'n': return x, y - 1 if direction == 's': return x, y + 1 north_offset = (-1 if (x % 2 == 0) else 0) south_offset = (1 if (x % 2 == 1) else 0) if d...
d3a3bd9cfcf6ac493f50d678412c86d44d0f1f42
muhammedessa/python_database
/pythonDatabase/2/create_database.py
732
3.515625
4
#create a database named "mydatastore" import mysql.connector mydb = mysql.connector.connect( host="localhost", user="muhammed", password="muhammed" ) mycursor = mydb.cursor() mycursor.execute("CREATE DATABASE mydatastores") mydb.close() #Check if Database Exists # import mysql.connector # # mydb = mysq...
3be72e509c43b421faf00327874041930830d29c
CPurely/basic_practice
/practice_code/chapter2tab.py
5,843
3.6875
4
import tkinter as tk # imports from tkinter import ttk from tkinter import scrolledtext from tkinter import Menu from tkinter import messagebox as mBox from tkinter import * win = tk.Tk() # Create instance win.title("Python GUI") # Add a title # win.resizable(0,0) # Change the main windows icon win.iconbitmap(r'C:\...
10960d1308483d9ed4889e7e7fe08f3b6cbed48b
daniel-reich/turbo-robot
/e5XZ82bAk2rBo9EfS_20.py
1,338
3.890625
4
""" Given a series of lists, with each individual list containing the **time of the alarm set** and the **sleep duration** , return **what time to sleep**. ### Examples bed_time(["07:50", "07:50"]) ➞ ["00:00"] # The second argument means 7 hours, 50 minutes sleep duration. bed_time(["06:15", "10:0...
f495b14cd4061bb6a223dea6c9cdbcecebde9722
geshem14/my_study
/Coursera_2019/Python/week2/week2task37.py
1,019
4.25
4
# week 2 task 37 """ текст задания Определите количество четных элементов в последовательности, завершающейся числом 0. Формат ввода Вводится последовательность целых чисел, оканчивающаяся числом 0 (само число 0 в последовательность не входит, а служит как признак ее окончания). """ bool_step = True # вспом. логическа...
6c962fcb2dfc25ae2365627f9f0623c6693487b6
MrColinHan/Twitter-US-Airline-Sentiment
/GeoSpatial Analysis/tweet_location_count.py
1,321
3.578125
4
import csv def read_csv(filedir, listname): file = open(filedir) reader = csv.reader(file) for row in reader: listname.append(row) def write_csv(x, y): # write list x into file y with open(y,'w+') as file: wr = csv.writer(file, dialect='excel') wr.writerows(x) file.close...
9cfc89aeb1354133c45aef0f7bc28b5555d66d0a
jduan/cosmos
/python_sandbox/python_sandbox/tests/effective_python/test_item10.py
1,136
3.890625
4
import unittest class TestItem10(unittest.TestCase): """ enumerate provides concise syntax for looping over an iterator and getting the index of each item from the iterator as you go. """ def test1(self): flavor_list = ['vanilla', 'chocolate', 'pecan', 'strawberry'] mapping = {} ...
22033d72ae8125b073f53299c82fc06085a920ec
unsortedhashsets/VUT-ISJ
/MINITASKS on lecctures/isj_task41_xabram00.py
1,400
3.609375
4
# minitask 4.1 default_qentry = ('How do you feel today?', ['sad','happy','angry']) funcqpool = [('If return statement is not used inside the function, the function will return:', ['0', 'None object', 'an arbitrary integer', 'Error! Functions in Python must have a return stat...
5cf16491a4644b2b59cef1e5b87806aa202142d3
diable201/Grokking_Algorithms
/lec_04/recursive_max.py
365
4.03125
4
def recursive_max(list): if len(list) == 0: return None elif len(list) == 1: return list[0] else: max_element = recursive_max(list[1:]) if list[0] > max_element: return list[0] else: return max_element list = [0, 4, 1023, 511, -11, 9] print("...
15546cc3ec9be09fef629ad95af6afc77602b6e4
itandjaya/Iris-Classification
/NN_IRIS_main.py
5,457
3.5625
4
## NN_digits_main.py ## Main function to test the Neural Network - digits. ##################################################### ## 4-Layers NN: [28*28, 60, 15, 10]. ## Image size is 28 x 28 pixels. ## from import_data import load_data; from NN_Model import NN_Model, one_hot; from random import randint;...
99b83234b8abc52a45191c4f66d76546e96d4cf7
sam-kumar-sah/Leetcode-100-
/53a. Maximum Subarray.py
703
3.984375
4
//53. Maximum Subarray ''' Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. ''' //code: //method-1: def ms(nums): em=nums[0] im=nums[0] for i in nums[1:]: if(i < em+i): em+=i else: em=i if(im < em): ...
8c3963443701156f5abd53f03aa01c2d475d9a78
aakib97/Python_Learning
/Code for thought 7/sorting.py
1,308
3.984375
4
## Code for thought 07 ## Change the following sorting algorithms so that each algorithm returns ## the number of swaps between the list items, ## the number of comparisons between list items, ## and the sum of these two operations in the sorting algorithm def bubblesort(L): count_s = count_c = 0 keepgoing = T...
230573190255493b53a56615c3c25fd87d7cb531
mhussain790/SatData
/SatData.py
1,630
3.625
4
""" Author: Masud Hussain Course: CS162 Assignment: 5C """ import json class SatData: def __init__(self): """ Opens the sat.json file when a SatData object is created and reads info from file. JSON data is stored in sat_dictionary and then file is closed. """ with open(...
8e23a64a9caeef0a7eba6989a1a3fcfe9350cfd8
nivedipagar12/PythonSamples
/Tic_Tac_Toe_Game/main.py
5,994
4.3125
4
'''Title : Tic Tac Toe Author : Nivedita Pagar Date : 10/04/2018 Details : 1) The code plays the Tic Tac Toe Game with Two players sitting on the same computer and declares whether a player won the game or it was a tie. 2) It keeps playing until the players want to stop ''' import...
ba6b615a3efb7b68509ce9156b582fd678081cc2
aindrila2412/Algorithms
/Online_Challenges/Vaccine.py
2,116
3.953125
4
# Finally, a COVID vaccine is out on the market # and the Chefland government has asked you to form a plan to distribute it to the public as soon as possible. # There are a total of N people with ages a1,a2,…,aN # There is only one hospital where vaccination is done and it is only possible to vaccinate up to D people...
eee1ca44c09c1d54d5ab985f3f415a9e6f8a2aa8
soroushh/PythonLearningUdemy
/loop.py
229
4.03125
4
my_variable = "hello" for letter in my_variable: print(letter) user_wants_true = True counter = 0 while counter <= 5 : if user_wants_true == True: print("still true") counter += 1 print("it is over")
ee6ab97f8af871d7dedbe2807945d357d920d22e
shollercoaster/madlib
/madlib.py
770
3.6875
4
import re def madlib(): fresh=open("fresh.txt", 'w+') #fresh.txt is just an empty text file where the changed paragraph is written. story=open("story.txt", 'r') with open("write.txt", 'r+') as output: read=story.readlines() write=output.readlines() # print(read) # print(write) ...
4e6b237741d61ebddb8a27203968807b7f4c08b5
harshil1903/leetcode
/Math/1281_product_and_sum_of_digit_of_number.py
820
3.71875
4
# 1281. Subtract the Product and Sum of Digits of an Integer # # Source : https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/ # # Given an integer number n, return the difference between the product of its digits and the sum of its digits. class Solution: def subtractProductAndSu...
d76dbaeee5891faa8dee8623777bef6d0451956d
Ghanshyam1296/Python-Basics
/oop.py
875
4.03125
4
#Python Object Oriented Programming class Employee: pass #Instance of class emp_1=Employee() emp_2=Employee() print(emp_1) print(emp_2) emp_1.first='Ghanshyam' emp_1.last='Rathore' emp_1.pay=50000 emp_2.first='Narseh' emp_2.last='Rathore' emp_2.pay=6000 print(emp_1.first) print(emp_2.pay) #_...
b78b459957df836523cb5f3b446cb75257a0291f
CHIRRANJIT/Python-language
/modules.py
1,271
3.859375
4
# importing built-in module math import math # using square root(sqrt) function contained # in math module print math.sqrt(25) # using pi function contained in math module print math.pi # 2 radians = 114.59 degreees print math.degrees(2) # 60 degrees = 1.04 radians print math.radians(60) ...
6252e1df6973ee6db76fa2031936467cb26eb64b
wmm0165/crazy_python
/07/7.2/gobang.py
1,223
3.890625
4
# -*- coding: utf-8 -*- # @Time : 2019/6/23 18:43 # @Author : wangmengmeng # 定义棋盘的大小 BOARD_SIZE = 15 # 定义一个二维列表来充当棋盘 board = [] def initBoard() : # 把每个元素赋为"╋",用于在控制台画出棋盘 for i in range(BOARD_SIZE) : row = ["╋"] * BOARD_SIZE board.append(row) # 在控制台输出棋盘的方法 def printBoard() : # 打印每个列表元素 fo...
06312b8f1b2c0d2c5b29bb010b832a98105d5c5c
NicoleRL25/cincy_employee_analysis
/code/data_cleaning.py
12,807
3.5
4
# -*- coding: utf-8 -*- """ Created on Sun Jan 10 09:12:02 2021 @author: letti """ import pandas as pd from pandas.api.types import CategoricalDtype import numpy as np from datetime import datetime def clean_emp_list(file_name=None): """ Reads the cincinnati employee csv file and outputs a clean file ...
6477c414cce91b179ca8677cdfc3eacbbbd94086
ho-kyle/python_portfolio
/023.py
224
3.875
4
from math import pi, tan s = eval(input('Please enter the value of s: ')) n = eval(input('Please enter the value of n: ')) area = n * s**2 / 4 * tan(pi / n) print(f'The area of the regular polygon constructed is {area}')
2b30b4688fe1df288682af5aabb5f521b8fb33ae
amoljagadambe/python_studycases
/apptware/apptware/elasticsearch/itertool_test.py
436
3.5625
4
import itertools input_list = [ {'a':'tata', 'b': 'bar'}, {'a':'tata', 'b': 'foo'}, {'a':'pipo', 'b': 'titi'}, {'a':'pipo', 'b': 'toto'}, ] # data = {k:[v for v in input_list if v['a'] == k] for k, val in itertools.groupby(input_list,lambda x: x['a'])} # print(data) for k, val in i...
ec27b5fb1eabd7e5b7d56c96392ced2356f07f9d
rajeshsvv/Lenovo_Back
/1 PYTHON/9 PYTHON PROGRAMS/PYTHON PROGRAMS NOUS/Techbeamers/ds list techbeam1.py
3,126
3.953125
4
# https://www.techbeamers.com/python-programming-questions-list-tuple-dictionary/''' # Tuples have structure, lists have an order # Tuples are immutable, lists are mutable. # ''' """ a=[1,2,3,4,5,6,7,8,9] print(a[::2]) answer [1, 3, 5, 7, 9] """ ''' a=[1,2,3,4,5,6,7,...
a9d6dd10d09c4c1f8e787bd8d188c53c72582c82
QuanAVuong/dsa-py
/03.1-Stacks.py
1,260
4.0625
4
class Stack: def __init__(self): self.stack = [] def isEmpty(self): return self.stack == [] def showStack(self, operation=""): for i, v in enumerate(self.stack): if i == 0 and operation == "push": print("|___|" if self.sizeStack() == 1 else "| |", f"<-- {self.stack[-i-1]}") el...
0e90edfbcd7dce7f95b41148df73482c4da77b5b
aliakseik1993/skillbox_python_basic
/module1_13/module4_hw/task_4.py
1,559
3.984375
4
print('Задача 4. Калькулятор скидки') # Андрей переехал на новую квартиру, и ему нужно купить три стула в разные комнаты. # Естественно, цена на стулья в разных магазинах различается, # а где-то ещё и скидка есть. # Вот для одного из таких магазинов он и написал калькулятор скидки, # чтобы проще ориентироваться в це...
a896d68de280b2ad9bc3788ad1ccad29f15c6a0b
Nicendredi/exercices-python
/fibonacci/fibonacci.py
7,067
3.765625
4
from liste import * # Cette ligne permet à {fibonacci.py} d'accéder aux fonctions de liste.py # Une suite de Fibonacci est une suite où chaque élément est la somme des deux # éléments précédents : # f(0) = 1 # f(1) = 1 # f(2) = 2 = 1 + 1 # f(3) = 3 = 1 + 2 # f(4) = 5 = 2 + 3 # f(5) = 8 = 3 + 5 def combiner(objet1, ...
2f1024bf5398050f4b09e277a312a660dc11e6ca
JaceHo/AlgorithmsByPython
/QuickSort.py
1,740
3.921875
4
def quickSort(alist): quickSortHelper(alist, 0, len(alist) - 1) def quickSortHelper(alist, first, last): if first < last: splitPoint = partition(alist, first, last) quickSortHelper(alist, first, splitPoint - 1) quickSortHelper(alist, splitPoint + 1, last) def partition(alist, first,...
8321f5e0132f856215d328d4df68c23eb26ac99c
thomasyu929/Leetcode
/Tree/recoverBST.py
1,518
3.828125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: # 1 # def recoverTree(self, root: TreeNode) -> None: # """ # Do not return anything, modify root in-place i...
1291ac60ec8af117e7a7f6712aa4243b7848a688
ArsRoz/Homework3-Arseni-Rozum
/task1.py
284
4.1875
4
# 1. Создайте словарь с помощью генератора словарей, # так чтобы его ключами были числа от 1 до 20, # а значениями кубы этих чисел. dict_1 = {x: x**3 for x in range(1, 20)} print(dict_1)
27a033ae52d97efb68adfdb9ddf7f18f3b608c5a
anthonychl/Head-First-Python-2ndEd
/chapter4/vsearch_old.py
344
4.125
4
#defining a function that utilizes the code in vowels7.py def search4vowels(): """ display any vowels found in an asked-for word """ vowels = {'a','e','i','o','u'} #or vowels = set('aeiou') word = input("Provide a word to search for vowels: ") found = vowels.intersection(set(word)) for vowel in fou...
289f3db4eac1853c86a88288ffa9387cf4675c0a
possientis/Prog
/python/decorator.py
149
3.53125
4
def double(f): def newFunc(x): return 2*f(x) return newFunc @double def h(x): return x + 3 print("Hello world!") print(h(7))
989ef438482139675f44fe1817dce039d4499002
AusCommsteam/Algorithm-and-Data-Structures-and-Coding-Challenges
/Challenges/sentenceSimilarityII.py
2,879
3.84375
4
""" Sentence Similarity II Given two sentences words1, words2 (each represented as an array of strings), and a list of similar word pairs pairs, determine if two sentences are similar. For example, words1 = ["great", "acting", "skills"] and words2 = ["fine", "drama", "talent"] are similar, if the similar word pairs a...
b774c8ded079fe43192fae1a057c45c17f3eef35
jabberwocky0139/recursion-drill
/rec06.py
1,037
3.875
4
# -*- coding: utf-8 -*- from functools import reduce # (0, 0)から(x, y)までの経路の総数を出力する def maze(x, y): if x == 0 and y == 0: return 1 elif x > 0 and y > 0: return maze(x-1, y) + maze(x, y-1) elif x > 0 and y == 0: return maze(x-1, y) elif y > 0 and x == 0: return maze(x, y-1...
1811f4aaf710e74a23b2f8098ba521d2b875a9b8
Lupin0/Capston
/demo11.py
1,176
3.5625
4
import sqlite3 conn = sqlite3.connect('abc.db') # 라이브러리와 연결 cur = conn.cursor() # cursor는 핸들러와 같은 역할 # cursor를 통 SQL 명령을 보내고 cursor를 통해 답을 받는다 cur.execute('DROP TABLE IF EXISTS Counts') # 이미 테이블이 존재하면 제거 cur.execute('''CREATE TABLE Counts (name TEXT)''') fname = 'output.txt' fh = open(fname) for lin...
db3157ee3b4794209cbd4d84b8cf4d6a92e15f53
Deiwin-Ignacio-Monsalve-Altamar/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/0-square_matrix_simple.py
176
3.703125
4
#!/usr/bin/python3 def square_matrix_simple(matrix=[]): new_matrix = [] for x in matrix: new_matrix.append(list(map(lambda x: x * x, x))) return new_matrix
ae0cca5203ef28ec7a350b5e701b0822467192ad
zhanhuijing/JianzhiGallery_Python
/Strings/no50_OccurOnlyOnceInString.py
663
3.75
4
import pdb def OccurOnlyOnceInString(str): if str==None: return False charhashtable = [None]*256 for i in range(256): charhashtable[i]=-1 strlength = len(str) for j in range(strlength): if charhashtable[ord(str[j])-ord('a')]==-1: charhashtable[ord(str[j])-ord('a')] = j elif charhashtable[ord(str[j])-ord...
00f203d143663cf60727cff4584e1d89d28b529b
fengshuai1/1807-2
/14day/学生类.py
265
3.5
4
class student(): count = 0 def __init__(self,name): self.name = name student.count+=1 def ji(self): print('学生') @classmethod def getcount(cls): return cls.count a = student('赵') a = student('孙') a = student('老') a.ji() print(a.getcount())
454b641b451099893036fc5966f414c83f1d4910
kousei03/coffee-projects
/python/jtclub/okapi.py
415
3.640625
4
def okapi(): rolls = str(raw_input("Enter dice rolls: ")) x, y, z = int(rolls[0]), int(rolls[1]), int(rolls[2]) if x == y and y == z: print("The payout is $", x+y+z, ".") elif x == y: print("The payout is $", x+y, ".") elif y == z: print("The payout is $", y+z, ".") elif ...
209767c710919961ecde0c5542f6b6d1a1a887b2
joincode/pythontraining
/FizzBuzz.py
474
3.765625
4
import os os.system('cls') # O %s é utilizado como marcador de posicao #https://docs.python.org/3.4/library/string.html print ("Criar um Programa Teste FizzBuzz!!!") line = 0 while (line < 100): line += 1 if (line % 3 == 0 ) and (line % 5 == 0): print ("%s - FizzBuzz!!!" % line ) elif (lin...
3a3b854841896bae886acc935fba4bdfb7ad2d85
kis619/SoftUni_Python_Basics
/6.Nested_loops/Exercise/02. Equal Sums Even Odd Position.py
1,670
3.671875
4
# first_number = input() # second_number = input() # # first_digit = first_number[0] # third_digit = first_number[2] # fifth_digit = first_number[4] # second_digit = first_number[1] # fourth_digit = first_number[3] # sixth_digit = first_number[5] # odd_sum_first_number = int(first_digit) + int(third_digit) + int(fifth_...
f16a84e1df6888696f91533699957a1c9b9e5045
sturnerin/Katerina
/HW-5/HW-5.py
412
3.65625
4
with open("latinwords.txt", "a", encoding="utf-8") as f: print("пожалуйста, вводите латинские слова, пока вам не надоест ") a=input() if a=="": print("вы ничего не ввели :(") else: while a!="": if a.endswith("tur"): f.write(a) f.write(...
b2caa3e2ed79f075f8362bfb4aea09cc58cd36cd
JulieRoder/Practicals
/Activities/prac_02/randoms.py
777
4.1875
4
""" Random Numbers """ import random print(random.randint(5, 20)) # line 1 print(random.randrange(3, 10, 2)) # line 2 print(random.uniform(2.5, 5.5)) # line 3 # What did you see on line 1? # smallest: 10, largest: 20, smallest possible is 5. # What did you see on line 2? # smallest: 3, largest: 9, got a lot of 5's...
482436c614aae6bcd015f2664e2ba99d6e21b51d
dimaswahabp/Kumpulan-Catatan-Fundamental
/Kumpulan Tugas/ganjil genap.py
165
3.671875
4
x = int(input('masukkan angka anda :')) if x % 2 == 0: print(f'angka ini {x} adalah angka genap') else: print(f'angka ini {x} adalah angka ganjil')
518f7d94d1f230478bc8cca59388dce959bbbd3e
MartinThoma/algorithms
/Python/dataclasses/impl_class.py
1,472
3.953125
4
from typing import Optional class Position: MIN_LATITUDE = -90 MAX_LATITUDE = 90 MIN_LONGITUDE = -180 MAX_LONGITUDE = 180 def __init__( self, longitude: float, latitude: float, address: Optional[str] = None ): self.longitude = longitude self.latitude = latitude ...
d5c69935b79382015b832815efc76de876ca9420
econmang/Student-Files
/cs356/hw/chap_3/hw3_2.py
1,145
4.28125
4
print("Problem 3-2") print("Complementary Colors\n") quit = False while not quit: color = input("Enter a color:\n") color = color.strip().lower() if color == "red": print("The complementary color to red is: Green!") elif color == "green": print("The complementary color to green is: Red...
ff50e9adeddb7e9c0882722cbaafc8e8524bdbaf
ExileSaber/2019-year
/python操作数据库/python操作Mongodb数据库/插入.py
722
3.546875
4
import pymongo #创建数据库连接 client = pymongo.MongoClient(host='localhost', port=27017) #另一种连接方式 #client = pymongo.MongoClient('mongodb://localhost:27017/') #指定数据库 db = client.test # 或者 #db = client['test'] #指定集合 collection = db.students #collection = db['students'] #插入数据 student1 = { 'id': '201701...
0e4b714761e6e3380cd5312ae1bffac6783f6e0e
karist7/Python-study
/함수의 활용 1번.py
401
3.90625
4
counter = 0 def flatten(data): out = [] for i in data: if type(i) == list: out += flatten(i) else: out.append(i) return out example = [[1,2,3],[4,[5,6],7, [8, 9]]] print("원본:", example) print("변환:", flatten(example)) #append활용 빈리스트 생성은 맞췄지만 리스트...
d130e56b25bb59801e350794da3756addb8e9a13
Bhaktidave/my_first_blog
/elseif.py
166
3.90625
4
a="bhakti" b="bansi" c="harshita" n=input("enter name") if n==a: print("hi"+a) elif n==b: print("hie"+b) elif n==c: print("hi"+c) else : print("hie")
0cab2835d9d753b1a7a1e8f38724146c956a1d48
jaegyeongkim/Today-I-Learn
/알고리즘 문제풀이/프로그래머스/Level 1/정수 제곱근 판별.py
158
3.6875
4
import math def solution(n): if (math.sqrt(n)+1)**2 == int((math.sqrt(n)+1)**2): return (math.sqrt(n)+1)**2 else: return -1 print(1)
7eec5687d5353f37dac3b3093a5f3f7f691ee0a9
bssrdf/pyleet
/B/BitwiseANDofNumbersRange.py
669
3.90625
4
''' -Medium- *Bit Manipulation* Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive. Example 1: Input: left = 5, right = 7 Output: 4 Example 2: Input: left = 0, right = 0 Output: 0 Example 3: Input: left = 1, right = 21474836...
284a5de4db1d1448056e9fc744a98f62f05396b7
qinzhouhit/leetcode
/777canTransform.py
1,042
3.5
4
''' keys: two pointers Solutions: Similar: T: S: ''' from typing import List # https://leetcode.com/problems/swap-adjacent-in-lr-string/discuss/217070/Python-using-corresponding-position- class Solution: # T: O(N) # S: O(1) def canTransform(self, start: str, end: str) -> bool: if len(start) != len...
2f99d5f30b846c92f0941d11d84191ab7fb3d8fe
Taranoberoi/PYTHON
/13_Reading_Writing_file.py
1,654
4.0625
4
# for Writing in file # f= open("C:\\Taran,Courses & others\\Machine Leanring Codebasics\Python\\funny.txt","w") # f.write("I love Java") # f.close() # for appending in the file # f = open("C:\\Taran,Courses & others\\Machine Leanring Codebasics\\Python\\funny.txt","a") # f.write("\nOne more time I am appending...
5ab97cf74d57899236308ffb9fcc9d817fddd411
ali-mohammed200/HangmanPython
/v1-5a.py
2,177
4.21875
4
##################### ##################### ## Version 1-5a Below ## ##################### ##################### ### Fixed some loop holes in guessing # and added the letter banks ## Adding loop functionality to show letters guessed ## without using regex print("Welcome to Hangman!") word = "anonymous" original = ...
7219e9e118e3f3a8fc5964c97da08b51b6653a51
hardikpatel21/python_udemy
/tkinter/weight_convert.py
1,010
4.0625
4
from tkinter import * # Create window window=Tk() def from_kg(): # get the vallue of e1_value # print(e1_value.get()) grams=float(e2_value.get())*1000 pounds=float(e2_value.get())*2.20462 ounces=float(e2_value.get())*35.274 # adding value of e1_value to text widget at the end of the text t...
6a8e1a20eebf10456e1020491806920c3cee8a6a
0911707/-INFDEV02-1_0911707
/ListPractice/ListPractice/ListPractice.py
551
4.0625
4
class Empty: def __init__(self): self.IsEmpty = True Empty = Empty() class Node: def __init__(self, value, tail): self.IsEmpty = False self.Value = value self.Tail = tail y = 0 l = Empty m = Empty cnt = int(input("how big of a list? ")) for i in range(0, cnt): a =...
757b25ae87cda15b8ace96f11198f1d544c11884
Xiaoyin96/Algorithms_Python
/interview_practice/Other/QuickSort.py
424
3.984375
4
#!/usr/bin/env python # encoding: utf-8 ''' @author: Xiaoyin ''' def quick_sort(array): if len(array) < 2: return array pivot = array[0] less = [i for i in array[1:] if i <= pivot] # exclude pivot great = [i for i in array[1:] if i > pivot] return quick_sort(less) + [pivot] + quick_sort(g...
6a4671ca3728cbca2f708f9bc87a9f16a2113341
boomNDS/prepro_play
/w3/what_math.py
187
3.875
4
"""What a Math""" import math def main(): """What a Math""" numx = float(input()) numa = float(input()) radians = numa*(math.pi/180) numy = print(radians) main()
28493f7c832a426a9548310928d457e8d1595637
guanxv/Codecademy_note
/Python_sys/Python_sys.py
577
3.5625
4
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# #-#-#-#-#-#-#- python Sys. #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#- #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-...
22b28809790d9f3a07e316e262386918860fa0c9
1BM16CS007/PythonLab-1BM16CS007-aatithya
/DivBy5.py
179
3.65625
4
str1=input("Enter the binary sequence: ") lis = str1.split(",") str2="" for i in range(len(lis)): if int(lis[i],2)%5==0: str2+=lis[i]+"," print ("Output is: ",str2[:len(str2)-1])