blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a446ac470532285244dcdd432989b9a45a510eeb
aureentuluvacal/python-bootcamp
/section4_conditional_logic/simple_logic.py
287
3.921875
4
print("What's your favorite pizza chain?") favorite = input() if favorite == "Domino's": print("Excellent, best choice.") elif favorite == "Pizza Hut": print("Solid choice.") elif favorite == "Papa John's": print("What the fuck is wrong with you?") else: print("Ok")
666e6aed04cb7bb95dad1c683aa19f2d5ba68394
David-Archer-us/python
/merge_two_sorted_lists.py
1,698
4.1875
4
# Merge two sorted linked lists and return it # as a new sorted list. # The new list should be made by # splicing together the nodes of the first two lists. # Definition for singly-linked list. class ListNode(object): def __init__(self, val=0, next=None): self.val = val self.next = next class...
d0330b1000eeb697e5f0dc7c131ed9aa5cf434e3
yami0307/python-code
/validating_year.py
221
3.984375
4
year=input("Enter any year") y_l=len(year) if y_l==4: if 1900<int(year)<2019: print("The entered year is valid year") else: print("It is an invalid year") else: print("It is an invalid year")
9c4a3782ab3a1d43b16edf1384f6b9bc8cbfcdb7
TeaaPartyy/Basic_Gui_Tutorials_Python
/3_viewer.py
5,104
4.40625
4
#program done by Hamza Slaoui Habib #Basic program to create a viewer for photos, extending the tutorial about how to include pictures in python #tutorial for beginners (functions not 100% optimized) #this guide and the following others in the same file are inspired by the course offered by freecodechamp.org ...
4a42b2115dca2cd9dc2ce58b91dcb220f9840cd5
ccubc/DS_self_learning
/leetcode_algorithm/leetcode_easy_383.py
949
4.03125
4
""" Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will return false. Each letter in the magazine string can only be used once in your ransom note. Ex...
7004bc9b49acc1a75ac18e448c2256cbec808cf4
CodyPerdew/TireDegredation
/tirescript.py
1,350
4.15625
4
#This is a simple depreciation calculator for use in racing simulations #Users will note their tire % after 1 lap of testing, this lets us anticipate #how much any given tire will degrade in one lap. #From there the depreciation is calculated. sst=100 #Set tire life to 100% st=100 mt=100 ht=100 p...
c9bf4d4db097f3b362dee004581fe404c38dfa55
sycoumba/TPPYTHON
/EXO1.py
175
3.765625
4
a=int(input("a?")) b=int(input("b?")) qe = a//b r = a%b qr = a/b if b!=0: print("le quotient entier?",qe) print("le reste?",r) print("le quotient reel?" ,qr)
66db548229addc5224b51a4081c940d29b71eb4b
kevingilfether/FortuneTellerPy
/FortuneTellerPy/FortuneTellerPy.py
3,042
3.9375
4
def quitter(input): if input.lower() == "quit": exit() #Part one - Copy and prompt print("I'm a fortune teller, of sorts.") first_name = input("What's your first name?\n") quitter(first_name) print() last_name = input("Good! Your last name?\n") quitter(last_name) print() age = input("And your age?\n") quit...
2d8152cf9f18b622ac4eee9a01dea977e7e4c094
chesta123/PYTHON-codes
/converting integer into boolian.py
193
4.21875
4
print(("enter the integer you want ot convert into booliean")) integer = int(input()) converted = bool(integer) print(converted) # here if we will enter 0 it willl show false otherwise true
90c2563ae9dbaa946e3b1f5af79d4001384bbfe6
mpyrek/ASD
/lab 5/the_problem_of_matrix_parentheses.py
2,187
3.6875
4
p=[30,35,15,5,10,20,25] import math #do linijki 21 mnożenie 2 macierzy class Matric: def __init__(self,X,rows,columns): self.X=X self.rows=rows self.columns=columns #A=Matric(tab1[2][3],2,3) #B=Matric(tab2[3][5],3,5) #print(A.columns) def matrix_mulityply(A,B): if A.columns!=B.rows: return False ...
fae0ac4ecc9bbae4c1ec1edab3a31937693dc0f9
lluxury/vamei_code
/base/03/list.py
865
3.78125
4
A = [[None] *2 ] *3 #[[None, None], [None, None], [None, None]] A[0][0]=5 #[[5, None], [5, None], [5, None]] # * 并不是建造拷贝,相与是映射关系,要注意 A = [None] * 3 for i in range(3): A[i] = [None] * 2 w, h = 2, 3 A = [[None] * w for i in range(h)] A[0][0]=5 # [[5, None], [None, None], [None, None]] # 两种解决方案,不...
3f2dd07705a88f5f954115b18eefdf4c1c8c9fb7
JediKnightChan/GenotekAssistant
/alice/actions/search_mode_tools.py
1,467
4.5
4
def get_specifying_options(paths, comparison_depth): """ Gets options to specify user request (What nodes user could desire) :param list paths: paths (lists of string nodes) to get options from :param comparison_depth: the index where we should get options (string nodes) :return list of strings: op...
0f14ed0f0c3fc0ab8df368ee561ed2df3c7475d3
stankiewiczm/contests
/ProjectEuler/Solutions/Problems 1-50/Q009.py
185
3.5
4
from numpy import * for a in range(3,300): for b in range(a,500): c = int(sqrt(a*a+b*b)) if (c*c == a*a+b*b) and (a+b+c == 1000): print (a,b,c), a*b*c;
3e707347335ebe1b1393676327abe317ac28e66a
mhworth/examples
/python-examples/src/examples/basic/SearchLists.py
94
3.65625
4
my_list = ["Hello", "World", "!"] if "!" in my_list: print "! was found in my_list"
0990b1626d5e2a60937ae17ff244f2b9cc28422c
VestigesH/GH
/python/18.输出指定格式的日期.py
240
3.875
4
import datetime#引入函数模块 year,month,day=eval(input("please input the year,month and day:")) x=datetime.date(year,month,day) print(x.isoformat())#输出年-月-日的格式 print(x.weekday())#输出日期所在星期数(周几)
38a7b8b3a99a39bf54b4d27023d8bf9da0374604
JacksonJLam/python
/3.1/HoP5.py
578
4.09375
4
#HoP5.py #BMI Calculator #Jackson Lambert 1-4-19 def main() : print("This script will calculate a person's BMI and determine if it is healthy or not") weight = int(input("Enter your weight in pounds: ")) height = int(input("Enter your height in inches: ")) bmi = round((weight*720) / height**2, 2)...
4eef12d9ead9675e00e4c8a7f85d6fe4c42c83b2
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/word-count/37b95248b2684c9aaf1950cf0adb5bae.py
160
3.703125
4
#word count def word_count(input): wl = {} input = input.split() for x in input: if x not in wl: wl[x] = 1 else: wl[x] += 1 print wl return wl
1b7c69d521ee6624fbe49bd3e662f5fe3f53a4a5
soojeong-DA/pre-education
/quiz/pre_python_11.py
217
3.9375
4
"""11. 최대공약수를 구하는 함수를 구현하시오 예시 <입력> print(gcd(12,6)) <출력> 6 """ "유클리드 호제법 이용" def gcd(a,b): return b if a%b==0 else gcd(b, a%b) print(gcd(12,6))
ab432424bcbf38a6d060431afc30ce7270b73f9e
DavidFontalba/DAW-Python
/secuenciales/3hipotenusa.py
865
4.4375
4
# Programa que calcula la hipotenusa de un triángulo rectángulo dados sus catetos # Autor: David Galván Fontalba # Fecha: 10/10/2019 # # Algoritmo # # Leer los dos catetos # hipotenusa <-- raiz cuadrada del (cateto1 ** 2 + cateto2 ** 2) # Mostrar resultado # # Importamos math import math #Presentación print("Bienvenid...
cb370d032e43888c1a8dfd6bf01c95ad268693c5
CelalCanKaya/CSE-321
/HW4/part1.py
814
4.03125
4
def optimalSeq(A): cost = [] hotels = [] for i in range(0, len(A)): #For every hotel cost.append((200-A[i])**2) #Calculate the cost from beginning to this hotel and add to cost array hotels.append(0) for j in range(0, i): #Loop for calculate the optimal cost if cost[i] ...
5db98bbf77a7acc0c9fb74b9b11e9634a743a775
sallytareq/data-structures-and-algorithms-python
/data_structures_and_algorithms/challenges/stacks_and_queues/stacks_and_queues.py
1,782
4.09375
4
class Node: def __init__(self, value): self.value = value self.next = None class Stack: def __init__(self): self.top = None self.size = 0 def push(self, data): node = Node(data) if self.top == None: self.top = node else: ...
a8a746f7fa36eccc2c03ee126f04f7212d0ca0ea
NeoMindStd/CodingLife
/baekjoon/3004py/a.py
61
3.609375
4
n=int(input()) a=n//2 print((a+1)**2+(a+1 if n%2==1 else 0))
87ff667e987b8800faca381da7285e35fa41e53e
alclass/YtIdsGenPySwDv
/randomytids.py
2,230
3.625
4
##!/usr/bin/env python3 ''' From the page below: http://www.learningaboutelectronics.com/Articles/How-to-generate-a-random-video-id-like-youtube-in-Python.php We learnt two things: 1) a ytid is a 64-base 11-character string 2) this 64-base is composed of 26 Uppercase letters, 26 lowercase ones, 10 digit...
fa83e36f7a4cdb72da5ce1a6f89499090c325e5a
Rago-Mateus/Python
/Exercicios/ex019.py
341
3.6875
4
from random import choice n1 = str(input('Primeiro aluno:')) n2 = str(input(('Segundo aluno:'))) n3 = str(input(('Terceiro aluno:'))) n4 = str(input(('Quarto aluno:'))) n5 = str(input(('Quinto aluno:'))) lista = [n1,n2,n3,n4,n5] sorteado = choice(lista) print('Iremos sortear um dos alunos, sendo a aluno sorteado é {}....
7cafe9d5e6e819050fcc2a73f025c122e661ad0c
nilmeier/Pi_GATE
/exercises/times_table.assignment.py
915
4.0625
4
# second coding challenge! # You will learn about: # - for loops, and ranges # - how to use format statements and append strings import sys n_columns = int(sys.argv[1]) n_rows = int(sys.argv[2]) # open repl and show how range works # explaing ( 1, n+1 usage ) # this loop gets added last printrow=4*' ' for col...
f200334aa4482c15c821a0b2493cd615163c91af
ErickFraga/Cryptxxx
/Cryptxxx/VigenereCypher/Cypher_Vigenere.py
5,837
3.75
4
import Alphabet import os def CypherMenu(): ShowTable = bool() while True: os.system("cls") print('-'*10 + ' ==Vigenere_Cypher== ' + '-'*10, end='\n\n') print('\t- 1 : Encriptar') print('\t- 2 : Desencriptar') if ShowTable: print('\t- 3 : Não Mostr...
3a2b5ce995ad7fa5d6bcfb489c131b0cc3b51b78
haofeng0928/data_structure
/search.py
2,577
3.90625
4
# 顺序表查找 def SequentialSearch(a, key): for i in range(len(a)): if a[i] == key: return i alist = [1, 3, 5, 7, 9, 8, 6, 4, 2] result = SequentialSearch(alist, 9) print(result) # 二分查找 & 插值查找 def BinarySearch(alist, key): # 定义左右下标 left = 0 right = len(alist) - 1 count = 0 wh...
eaab8dd917859bff579e393e406e6ba3835764c6
robjwells/adventofcode-solutions
/2019/python/aoc_2019_08.py
3,903
3.5
4
"""Day 8: Space Image Format""" from typing import Iterator, List, Tuple import aoc DAY = 8 class SpaceImage: width: int height: int layers_count: int _data: List[int] def __init__(self, width: int, height: int, image_data: str) -> None: self.width = width self.height = height ...
9f11ce613fbfc70a0a3f096a872a83b3bfc383c9
musalbas/KeypairAuth
/client/dicttools.py
1,441
4.15625
4
"""Extra functionality for dealing with dictionaries.""" import collections def new_items(old_dict, new_dict, deepness=0, _current_level=0): """Compare two dictionaries and return a dictionary containing only the added or changed items. Set deepness to -1 for infinite recursiveness. """ new_ite...
4ac4ccaa1d59e0ca32fcf3f60cc8c3955f93ba9c
ActiveZ/python
/damier.py
567
3.78125
4
import tkinter as tk cell_size = 20 board_size = 10 # ou 8 pour un échiquier canvas_size = cell_size * board_size colors = ["white", "black"] root = tk.Tk() canvas = tk.Canvas(root, width=canvas_size, height=canvas_size) canvas.pack() for x in range(board_size): for y in range(board_size): color = col...
25020326b048a21c02a608ee13b64f9107243ad2
Kyeongrok/python_algorithm
/etc/lecture/basic/05_두점사이거리.py
281
3.515625
4
import math 채연 = (1, 2) 나영 = (3, 4) print(채연[0]) print(채연[1]) print(나영[0]) print(나영[1]) result = math.sqrt(math.pow(나영[0] - 채연[0], 2) + math.pow(나영[1] - 채연[1], 2)) print(result) print(math.sqrt(8)) print(math.sqrt(4+4))
1708e66482d777158a3d04e2f2bc75a1020d8875
kirankalsi/python-exercises
/programs/conditionals-ex.py
144
3.875
4
mark = int(input("Please enter your mark: ")) if mark > 85: print("Distinction") elif mark >= 65: print("Pass") else: print("Fail")
ac28c0b19d2ee8a7e847d8a196d4dc90877f3018
esther1104/enjoy_python
/day14/14-if4.py
420
3.84375
4
strScore=input("점수를 입력하세요.") score=int(strScore) if score>100: print("잘못된 점수입니다.") elif score>=90: print("A 학점입니다.") elif score>=80: print("B 학점입니다.") elif score>=70: print("C 학점입니다.") elif score>=60: print("D 학점입니다.") elif score<0: print("잘못된 점수입니다.") else: print("F 학점입니다.")...
4f27f0ea6eec4c7417f85cfe2112be2d1c56f3f3
hh1204/haohao
/test_unittest/data/r1.py
6,937
4.0625
4
# 导入Python自带的re模块 import re """re.match() 能够匹配出以xxx开头的字符串 match()方法需要传两个参数,第一个参数是写的正则表达式,第二个参数是要匹配的字符串 """ # result = re.match("haohao","haohao.com") # # 如果能匹配到的话可以使用group方法来提取数据 # print(result.group()) # # # .的使用 # ret1 = re.match(".","hao") # print(ret1.group()) # # .的使用 # ret2 = re.match("h.o","hoo") # print(re...
c0bbb4f05561be0670e16f2210c1b9d633fa90c8
jordanbuckindale/Codes-and-Check-Digits
/code_check.py
1,372
3.703125
4
""" Assignment #2 Course: 1026A Due Date: Oct 20th 2021 Description: This program will contain the functions of the program. Created by: Jordan Buckindale Student #: 251246279 """ def basicCode(numVal): stringNum = str(numVal) lastValue = stringNum[-1] num = stringNum[:-1] sum = 0 for n in num: ...
182c3ffd7317fb806446ac2f00dda199a2254ed6
Cabal-GitHub/platzicbpython
/conversor_funciones.py
604
3.6875
4
menu = """ Bienvenido al conversor de monedas 😁 1 - Pesos Argentinos 2 - Pesos Colombianos 3 - Pesos Mexicanos Elige una opción: """ opcion = int(input(menu)) def conversor(moneda,valor): pesos = input ("¿Cuantos pesos "+ moneda + " tienes?") pesos = float(pesos) dolares = pesos / valor dolares = rou...
610df6f33b8d6209042ac75522893fac63fdec7a
jgrugru/ProgrammingChallenges
/leetcode/container_with_most_water.py
570
3.578125
4
def maxArea(height): max_area = 0 l_index = 0 r_index = len(height) - 1 while l_index < r_index: l, r = height[l_index], height[r_index] length = r_index - l_index width = min(l, r) max_area = max(max_area, length * width) if l > r: r_index -= 1 ...
0f6cb8d8754a5d8f8b3ef4d6300b8efac1aeb483
erikthomasson/Python
/labb2ex/ex14.py
453
3.78125
4
# def sum_numbers(any_list): # summa=0 # for element in any_list: # if type(element) == int or type(element) == float: # summa += element # return summa def sum_numbers(any_list): import numbers def is_number(item): return isinstance(item, numbers.Num...
1a1d6892434aa5d6fa5bdfdc32144bfab84b4782
CS251-Fall-2020/outlab-3-190050013-190070020
/q5.py
499
3.546875
4
def rotate(m): n = len(m) l = [] for i in range(0, n): ll = [] for j in range(n-1, -1, -1): ll.append(m[j][i]) l.append(ll) return l def main(): l = [] s = input() ss = s.split() m = len(ss) l.append(ss) for i in range(1, m): s = input() ss = s.split() l.append(ss) m = rotate(l) for i in ra...
e15b2580a48deb63b4b5f759e1ff5193291ac04a
gurkandyilmaz/courses-and-tutorials
/machine_learning/ApproachingAnyMachineLearningProblem/05_approaching_categorical_variables/src/create_folds.py
944
3.609375
4
"""This file is used to take the input data then assign random folds to them based on the target distribution.""" import pandas as pd from sklearn.model_selection import StratifiedKFold import config def create_folds(input_file, target = "target", num_folds = 5): df = pd.read_csv(config.INPUT_DIR / input_file, i...
b0f47180c171a1883bda5bdb2e12c96ea4e6a64e
mzwandile316/Level_0
/Task 4 (1).py
190
4.03125
4
#!/usr/bin/env python # coding: utf-8 # In[14]: number = int(input("enter number: ")) num = number % 2 if num > 0 : print("ODD number") else: print("EVEN number") # In[ ]:
ae7e2a11f3c644b3f110a6c308cb95a17d46312c
maurovasconcelos/Ola-Mundo
/Python/aula18.py
1,572
3.703125
4
teste = [] teste.append('Mauro') teste.append(22) galera = [] galera.append(teste[:]) # comando copiar teste[0] = 'Ximas' teste[1] = 23 galera.append(teste[:]) # galera vai receber uma copia do teste print(galera) print('-=' * 30) #---------------------------------------------------------------------------------------...
fec34c0664618262dcde40b2ab19ea872d89d9dd
mattcall65/intro-to-python-course-programs
/7_2.py
1,297
3.9375
4
#Matt Callahan 2319373 #start of program #end of program #Matt Callahan 2319373 #start of program #end of program def main(): print('Celebreties known by one name:') #We put 4 celeberity names into the list and set counters to move... #through loops and if/else statements celeb...
957612805d489caff5c638033b6c5f60d3e7b28e
Islanderrobotics/IslanderDataPreprocessing
/IslanderDataPreprocessing/datacorrelation.py
6,950
3.65625
4
from pandas.plotting import scatter_matrix import matplotlib.pyplot as plt from PyQt5 import QtWidgets import sys from .DataVisulization import DataVisulization class DataCorrelation: '''this module allows you to be able to view the correlation values of your dataset allowing you the ability to prevent simple ...
b9ec009d15243e24f3d1337df42f87814062fa78
nightwiz/Learn-Python
/Day9/多线程.py
474
3.796875
4
import threading import time def run(n): print('task',n) time.sleep(2) t1 = threading.Thread(target=run,args=("t1",)) t2 = threading.Thread(target=run,args=("t2",)) t3 = threading.Thread(target=run,args=("t3",)) start_time = time.time() t1.start() t1.join() t2.start() t2.join() t3.start() #等待t1执行完毕。相当多进程变成串...
1b751bf7154672d84246824d088b07e3f05496b2
laughouw10/stanCode
/stanCodoshop.py
5,718
4.0625
4
""" File: stanCodoshop.py ---------------------------------------------- SC101_Assignment3 Adapted from Nick Parlante's Ghost assignment by Peter. ----------------------------------------------- TODO: To make a App which can make perfect photo by several different photo shot at the same location but different time (r...
e01616bab71c6474dbab6e16a8cc10a8e316484c
poponzu/atcoder1
/cracking_interview/p80_81_ans.py
412
3.796875
4
n = 10 map_ = {} for c in range(1, n + 1): for d in range(1, n + 1): result = c ** 3 + d ** 3 map_.setdefault(result, [[c, d]]) for result,list in map_.items(): # listを二次元配列扱いにしたい # 8行目を二次元リストに変えた for pair1 in list: for pair2 in list: print(pair1[0],pair1[1],pair2[...
09da13311b5d3d051eac0199252dbf7f67ff8397
AlexandreSollaci/OGcourse_F16
/Students/HanL/Pset_2_func.py
15,098
3.5
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 10 16:44:12 2016 @author: Luke """ # -*- coding: utf-8 -*- """ Created on Wed Oct 5 18:39:07 2016 @author: Luke """ #import packages import numpy as np import scipy.optimize as opt import math import matplotlib.pyplot as plt #Build up the fuctions for w, r, K and L ...
cb0bb15baf9bbc578ec3879fdd087ae50bf2f7d9
balsa30/domaci06-zbirka02
/str3_zad30.py
789
3.96875
4
""" 30. Dva automobila se kreću po kružnoj staži dužine L u suprotnim smjerovima. Polaze iz iste tačke i kreću se stalnim brzinama v1 i v2. Na kom rastojanju će se naći automobili u trenutku T. Ulaz: U jednom redu zadaju se 4 cijela broja L, v1, v2, T, razdvojeni blankom (1 ≤ L, v1, v2, T ≤ 100). Izlaz: Štampati je...
62409ab4a825e5181bf951c676799a2885470658
vishalisairam/TrustSimulation
/11Nov_ProjectPractive
1,714
3.859375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Nov 11 10:51:33 2020 @author: vishali """ import axelrod as axe import random class Player: def __init__(self,name = False): pass class HumanPlayer: def __init__ (self, otherStrategy, name = False): self.otherStrategy = axe...
725fbc4b63f8f0d6c8705ba1910a550cbc769e43
vshesh/alignment-tree
/aligntree/depth.py
861
3.75
4
#!/usr/bin/env python from __future__ import print_function import sys #Sample Usage: #>>> parse_sexp("(+ 5 (+ 3 5))") #[['+', '5', ['+', '3', '5']]] def parse_sexp(string): sexp = [[]] word = '' in_str = False for c in string: if c == '(' and not in_str: sexp.append([]) el...
fd0dac0c8a9c56ca866f0f224b88ca76b810c6f0
rupikarasaili/Exercise
/LabOne/eight.py
271
4.375
4
''' Write a Python program which accepts the radius of a circle from the user and compute the area. (area of circle = PI * r2) ''' radius = float(input("enter the radius of the circle")) area_of_circle = 22/7 * radius ** 2 print(f"the area of circle is {area_of_circle}")
21f5673f6b0b2806d77e3a1f150ba4021603d1b7
bezgubov/python
/education/PythonIntro2014/02_Conditionals/03_SecondMax.py
463
4.09375
4
#!/usr/bin/env python def main(): my_list = input("List :") if type(my_list) == tuple: my_list = list(my_list) elif type(my_list) == int: my_list = [my_list] elif type(my_list) != list: print 'Wrong format!' first_max = max(my_list) while first_max in my_list: ...
184a6d73cf38120e9f95ba395ff58c86f06b1bd2
suonrex/PyTest
/HCF&LCM.py
1,199
4.3125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019-02-05 14:10:41 # @Author : Lance He (suonrex@gmail.com) # @Link : Null # @Version : $Id$ # Finding HCF(highest common factor) or GCD(greatest common divisor) in a normal way def computerHCF(x,y): if x > y: smaller=y else: smaller=x for i in ra...
b6d1b10b3894bbae2b2d3f35c590892aa56fd0b1
snehask7/DAA-LAB
/A4-Inversion/oor1.py
1,216
3.9375
4
"""1. Design an algorithm using brute-force/exhaustive enumeration of all possible pairs of la- bels. Implement the algorithm in Python.""" #TIME COMPLEXITY IS O(n^2) def oop(a): n=len(a) num=0 for i in range (n-1): for j in range(i+1,n): if a[i]>a[j]: num=num+1 print("("+str(a[i])+","+str(a[j])+")") ...
f7791f7f68ff4c7ec9f711bace7aab1bb42528e5
moret/peuler
/p3sqrtlimited.py
775
3.640625
4
class Problem(object): def sqrt(self, n): return n ** 1 / 2 def run(self): n = 600851475143 l = 1 # ruling out even numbers if n % 2 == 0: l = 2 n = n / 2 while n % 2 == 0: n = n / 2 # going over odd numbers o...
ef1de36890799d8cfba17e0292e63fe9d6545cec
mzb2599/python
/Object.py
332
3.96875
4
class Person: def __init__(self, id, name): self.id = id self.name=name print("Inside constructor\n","id:", id, "name:", name) print("Constructor ends") #Creating object of class Person p=Person(1,"Mohd Zaki") print("Id:", p.id) print("Name:", p.name) print("__sizeof__:",...
93416a31413266f6f7235afced00d3ca7c4cfe9f
neeraj-somani/Python_Algos
/Leetcode-Problems/29-779-K-thSymbol-inGrammar.py
1,185
3.625
4
## Notes --> I tried to solve it but unable to understand it. Need to do it again. # In this we are going to solve leetcode #779 problem # https://leetcode.com/problems/k-th-symbol-in-grammar/ # we are going to follow a specific process (D, D, P, A, B) # Definition, Data, Pseudo code, Actual code, Big-O efficiency #...
5c7c026a088a96a50a8133cbd530fbbf6904048f
SianCulligan/python-data-structures-and-algorithms
/python/Data-Structures/graph/graph/queue.py
1,262
3.96875
4
class Queue_Node: def __init__(self, nodeVal=None, nextVal=None): self.nodeVal = nodeVal self.nextVal = nextVal ############################################################################################ class Queue: def __init__(self, front=None, rear=None): self.front = front ...
2a3df5ffe448af39d912f238ecc99c6dcf91754f
ChocolatePadmanaban/Learning_python
/Day4/part4.py
485
3.640625
4
# Editing Builtin Functions in Iterators class BoundedRepeater: def __init__(self, v, uplim): self.value = v self.limit = uplim self.count = 0 def __iter__(self): return self def __next__(self): if self.count>= self.limit: raise StopIteration self...
92ad458ba03c27e34a991c11248da1d5fa7633c3
Arafat0101/Python
/PycharmProjects/FirstPro/10. calculate sum for loop.py
110
3.578125
4
prices = [10,20,30] total = 0 for price in prices: total +=price print(f"Total Price is {total} taka.")
e6c952e20903a8a1a52ed4d03a4b89d3c6a21579
TomasYin/arithmetic
/single_linked_list/reverse_Linked_List2.py
1,109
3.8125
4
# -*- coding:utf-8 -*- """ file:翻转部分单链表 """ class Node(): def __init__(self,data,nextpostion=None): self.data = data self.nextposition = nextpostion class Solution(): def reverse_Linked_List2(head,m,n): i = 1 res = head #设定头结点 res_end = head #设定翻转前的位置 rev = N...
33a2220a601162956400b1b26b1335d7006d6cc0
gabibguedes/EDA2
/lista07/main.py
4,836
3.609375
4
from tkinter import * import numpy as np ## Global variables current_element = 0 values = [] weights = [] k_weight = 0 num_elem = 0 label_1 = '' def knapsack_solver(max_weight, weight_vector, value_vector): n_elements = len(value_vector) matrix = [[0 for x in range(max_weight+1)] for x in range(n_elemen...
160df950201a34ae9e6c0df1ec49f87c90c331db
cn5036518/xq_py
/python16/day22-40/day22 常用模块01 random collection time/03 collections.py
2,372
3.515625
4
#!/usr/bin/env python #-*- coding:utf-8 -*- #@time: 2020/6/27 11:05 '''''' ''' 计算字符串中字符出现的次数 #yanming 思路-算法: 1、遍历字符串 定义一个空字典 2、如果字符不在空字典中,value置为1 3、如果字符在字典中,value自增1 思路2-内置模块 1、引入模块 from collection import Counter 2、创建一个Counter对象,参数传入字符串 3、返回值就是字符和字符出现次数的键值对 4、将返回值转换成字典类型 ''' s1 = 'ahfafafafd' #方法1 dic1 = {...
653928e0d30022be557840f4cff0f7167eb9c908
j-tyler/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/1-last_digit.py
520
4.09375
4
#!/usr/bin/python3 import random number = random.randint(-10000, 10000) if number % 10 == 0: print("Last digit of {} is 0 and is 0".format(number)) elif number < 0: print("Last digit of {} is {}".format(number, (10 - number % 10) * -1), "and is less than 6 and not 0") elif number % 10 < 6: print("...
bb2c3177ee7f8b77dde208368feb9beb98ef35d7
SA253/python-assignment
/Python/files/first.py
1,890
3.953125
4
#write ,read and append to file fo=open('demo.txt','w') #w=write fo.write("hello sachin \n") fo.write("hello saurav \n") fo.write("hello rahul \n") fo.close() #convert to byte fo=open('demo.txt','w') #w=write fo.write("hello sachin \n".encode()) fo.write("hello saurav \n".encode()) fo.write("hello rahul \...
99e2be07bdd4c240052f348a4cdb90dcd6d45aaa
TheProrok29/design_patterns_in_python
/structural/adapter/socket_adapter/device.py
390
3.609375
4
class Device: max_voltage = 12 def __try_charge(self, input_voltage): if input_voltage > self.max_voltage: print( f'Device burned!. Used to height voltage {input_voltage}!. Max possible voltage is {self.max_voltage}') else: print('Charging...!') def ...
881f476394c363427d80cb31caf234ac5928d903
NandishRPatel/python-challenges
/Take-a-Number-And-Sum-Its-Digits-Raised-To-The-Consecutive-Powers-And-Eureka.py
500
3.671875
4
'''def sum_dig_pow(a, b): final_list = [] for i in range(a,b+1): if len(str(i)) == 1: final_list.append(i) else: string = str(i) num = 0 for j in range(0, len(string)): num += int(string[j]) ** int(j+1) if num == i:final_list.append(i) return final_list ''' def sum_dig_pow(a, b): fina...
ea109ac8f0de88630f73aaf74ee2cc44dc73a1f3
PetrJisa/Python-Academy-Projects
/Bulls and cows.py
5,571
4
4
import random import time # global variables odd = 50 * '-' game_stats = list() def main(): # Sets the basic parameters for the game set, part of them by dialogue with player digits, zero = settings() guesses = 0 games = 0 # Communication with player - "do you want to play (again), or to quit th...
47df4e5a1f71a212eaf64de1c3a5e704e812a9d6
LalityaSawant/Python
/python-masterclass/ProgramFlow/guessingGameModified.py
884
4
4
import random min_num = 1 max_num = 10 answer = random.randint(min_num,max_num) # print('Hint: {}'.format(answer)) # TODO: Remove after testing guess = 0 # initialize to any number != answer i = 0 print("Please guess number between {0} and {1}: ".format(min_num,max_num)) while guess != answer: guess = int(input...
931e6108eb3c2a72ec59bb044b38450f32ef7179
Stalinium1945/dz1
/dz 1.2.py
670
4.53125
5
#Задача 2. Уровень - да ты математик. #Условие: Подсчет площади и периметра прямоугольника. #Входные данные: стороны %a% и %b% прямоугольника. #Выходные данные: площадь и периметр данного прямоугольника. a=int(input("Введите сторону А прямоугольника ")) b=int(input("Введите сторону B прямоугольника ")) pri...
933e492c569ec2488a2f29eb1a0f87be8c0470f2
aeshepelevaa/homework_02
/task1.py
202
3.5
4
list_1 = {'number', 'place', '1', '125'} list_2 = "меня зовут саша" list_3 = [1, 2, 3] print(list_1) print(list_2) print(list_3) print(type(list_2)) print(type(list_1)) print(type(list_3))
e8e623d68657652eca3ee8df777ecb457157fa5e
miniblackcat/sql
/homework7.py
401
3.6875
4
import sqlite3 with sqlite3.connect("cars.db") as connection: c = connection.cursor() # create a dictionary of sql queries sql = {'Taurus count': "SELECT count(make) FROM orders WHERE model = 'Taurus'", 'Escape count': "SELECT count(make) FROM orders WHERE model = 'Escape'"} for keys, values in sql.items(...
2086fa6239108a1a01a33d0de5b3c82467efb74f
eyvonne/U3S1Review
/answers/sales.py
2,946
3.828125
4
from comps import * from random import randint, sample, uniform def generate_computers(): # generate a random number between three and five for computers and laptops comps = randint(3, 5) laps = randint(3, 5) # the list where we're going to store the computers computers = [] # generate the com...
81d06349895e48cb65642ddb058ee5be95acaf08
nbrown-dsl/-1-tkinter_codingbat_exercsies
/4 near hundred.py
608
3.84375
4
#coding bat exercsie # https://codingbat.com/prob/p124676 from tkinter import * root = Tk() e = Entry(root, width=35, borderwidth=15,font=("Courier", 44)) e.grid(row=0,column=0,columnspan=3,padx=10,pady=10) def button_click(): n = e.get() e.delete(0,END) if (abs(100-int(n))<=10) or (abs(200-int(n)...
ec05e0bfee7ac8d0ef49009f1dc84e56b1ee5e52
carlosaffrc/python-scripts
/arquivos/io-csv.py
221
4.125
4
#!/usr/bin/python3.9 # Leitura de um arquivo CSV # Usando a API nativa do python import csv with open("pessoas.csv") as entrada: for pessoa in csv.reader(entrada): print("Nome: {} Idade: {}".format(*pessoa))
838b8cc65cee23003abf3d158c4cc7144262ef07
SHC-Robotics-Team-8255/SHC-PY-Examples
/functions.py
1,191
4.21875
4
# functions are extremely important - this will be a long file :( # we've probably all seen mathematical functions like # f(x) = x + 1 # functions in coding can be a lot like that. # we can tell functions to give us a result # based on the inputs we give it # we declare funtions with "def" for define def function(...
11d8febb291daa400cb45bbe0ee28b9d7ca02cf3
jlaufmann/python-fundamentals
/03_more_datatypes/3_tuples/03_12_list_to_tuple.py
1,785
4.40625
4
''' Write a script that takes a list and turns it into a tuple. ''' starting_list = [[1, 2, 3, 4], 'str_object', [5, 6], [7, 8, 9], 10, [11, [12, 13]]] # starting_list = ['a'] ''' Because of difficulties previously mentioned, the list is not given by user input. Practically, most often a list would be passed to a fun...
f9fc8f508dd0168f2209851a06b2495029e9f69d
hary4065/python
/packingunpacking.py
309
3.8125
4
a = 10 b = 20 c = 30 t = a, b, c # packing of variables in tuple x, y, z = t # unpacking of variables in tuple p = 1, 2, 3 print(t+p) # concatenation of tuple print(t*3) # repeatation of elements of tuple print(t == p) # tuples are equal or not print(t > p) # relational comparision of tuples
72dde48f33436a5eb3e63b805a2c3799e8b08a76
verath/advent-of-code-2017
/day2/day2.py
611
3.734375
4
EXAMPLE_SPREADSHEET = ("5 1 9 5\n" "7 5 3\n" "2 4 6 8\n") def calc_checksum(spreadsheet): checksum = 0 spreadsheet_rows = spreadsheet.strip().split("\n") for row in spreadsheet_rows: int_vals = [int(n) for n in row.split()] checksum += max(int_...
aa144a71169da834c62692cbcf7de0a4d89ca6db
mcflurryXD96/Week-Two-Assignment
/convert.py
560
4.0625
4
# __author__ = 'Daniel McMurray' # CIS 125 # Fahrenheit & Celsius Table # # This program prompts the user for a temperature in Fahrenheit, converts it to Celsius, and prints out the results. # Declare Magic Numbers and Constants # LOOPCOUNTER = 2 # name = "bob" # Write program code here # ask user for a temp in Fa...
64324349a6f891cda49b64c1df0e4e8c342432c8
alu0100531060/prct04
/src/eje20.py
268
3.625
4
#!/usr/bin/python #!encoding: UTF-8 x = -b/a a = float(raw_input('Valor de a: ')) b = float(raw_input('Valor de b: ')) print 'Solucion: ', x # Nos muestra un error puesto que las variables que hemos dicho en el programa (a,b) # han sido declaradas después de la x
143e1476713c159f93dbe787c8b931faea592507
cloveses/myhouse
/edd/3.py
814
3.546875
4
from tkinter import* import math root=Tk() root.geometry('600x600') w=Canvas(root,height=600,width=600) w.pack() w0=300 h0=300 w.create_line(0,300,600,300,fill="red",arrow=LAST) w.create_line(300,600,300,0,fill="red",arrow=LAST) for i in range(-5,5): j=i*40 w.create_line(j+w0,h0,j+w0,h0-5,fill="red") w.cr...
da4e166a1aca737988cbd16a16d8c206bac68cca
amangangwani1101/python_short_programs
/PROGRAM08.py
166
4.21875
4
stri=input("ENTER THE STRING OF ODD LENGTH(MORE THAN 7 CHARACTER):-") ans=(len(stri))//2 print(f"3 middle characters of string '{stri}' is:-{stri[(ans-1):(ans+2)]}")
2d0960614fbb1f3b2ba5a1e3fa1e6a845e403f07
thran/the_code
/Project Euler/020 - factorial.py
154
3.703125
4
def factorial(n): product = 1 for i in range(1, n + 1): product *= i return product print sum([int(d) for d in str(factorial(100))])
e22604e1caea45fd81a57111c5337ae06fdfe738
Kontowicz/Daily-coding-problem
/day_020.py
632
3.8125
4
# Given two singly linked lists that intersect at some point, find the intersecting node. The lists are non-cyclical. # For example, given A = 3 -> 7 -> 8 -> 10 and B = 99 -> 1 -> 8 -> 10, return the node with value 8. # In this example, assume nodes with the same value are the exact same node objects. # Do this in O(M...
f42ed06b98032f6b835c8ca104bd911943d43935
GBLMalachias/EstruturaSequencial
/exercicio_02.py
188
4.03125
4
# Faça um Programa que peça um número e então mostre a mensagem O número informado foi [número]. n = int(input('Digite um numero: ')) print('Você digitou o numero {}'.format(n))
7f881ff37af21569b801c3dc6e034ba44093d45a
jnthnwn/competitive-programming
/kattis/vote.py
1,074
3.734375
4
from sys import stdin tc = int(stdin.readline()) for t in range(tc): n = int(stdin.readline()) # track the total number of votes vote_sum = 0 votes = [0 for i in range(n)] for i in range(n): votes[i] = int(stdin.readline()) vote_sum += votes[i] # keep track of which candidate h...
c6e1bb1c576686bce88a86ff0948d1f554390b75
Thanmayee0513/Day4
/lab4tak12.py
169
3.78125
4
my_file=open("words.txt") dict1={} def read_word(my_file): for word in my_file: x=word.strip() dict1[x]=0 print(dict1) read_word(my_file)
800becfccbe28202464b4139b811c6eff05d2bbe
daniel-reich/ubiquitous-fiesta
/WY7r2XtarpupNDWE8_6.py
473
3.78125
4
def tower_of_hanoi(disks, move): towers = (list(range(disks,0,-1)),[],[]) if disks % 2 == 0: coords = {0: (1,2),1:(1,3)} else: coords = {0: (1,3),1:(1,2)} coords[2] = (2,3) for k in range(0,move): i,j = coords[k%3][0]-1, coords[k%3][1]-1 try: if towers[i][-1] > towers[j][-1]: j,...
8974480685710feaf8c230a9ebbdc0ec9f6b465c
xiaoyongaa/ALL
/python基础2周/17猜年龄游戏.py
1,545
3.6875
4
''' 笔记 for i in range(10): #3次机会问一次 ''' age=22 c=0 while True: if c<3: cai=input("请输入要猜的年龄:") if cai.isdigit(): #判断是否为整数 print("格式正确") cai1=int(cai) #判断为整数把输入的变量变成int型 if cai1==age and c<3: print("猜对了") break eli...
bb05f9f906d5aa2d6add974bbf6f446d26e1d52d
renormalizing/Data-Structure
/StackAndQueue/leetcode/合并K个排序链表.py
1,031
3.75
4
class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def mergeKLists(self, lists): """ :type lists: List[ListNode] :rtype: ListNode """ header = ListNode(-1) prev = header lists = [ln for ln...
8942b715a1596275b2292b6ed3204de8ecf36e67
Prabhat1811/Bank-Management-System
/my_input.py
2,958
4.0625
4
''' checks the input ''' import check def username(): while True: username = input('NAME : ') if check.username(username): return username else: print('\n**INVALID CUSTOMER NAME**\n') def email(): while True: email = input('EMAIL ID :...
20a1c5a2d4325504d269519ad38422a3894c2f02
GuilhermoCampos/Curso-Python3-curso-em-video
/PythonExercicios/Mundo 1/3_operadores_aritimeticos/ex008.py
460
4.15625
4
val = float(input('Digite o valor em metros: ')) #cm = val * float(10**2) #mm = val * float(10**3) #print('O valor em metros é {}, em centímetros é {} e em milímetros é {}.'.format(val, cm, mm)) print('{} kilometros \n{}hectometros \n{} decametros \n{} metros \n{} decimetros \n{} centimetros \n{} milimetros \n{} microm...
be39c9f7d20b11b382feeacc8703574ee9ced302
Sameer2898/Data-Structure-And-Algorithims
/Placement Prepration/Hashing/non_repetead_element.py
557
3.6875
4
def printNonRepeated(arr,n): dict = {} for i in arr: dict[i] = 0 for i in arr: dict[i] += 1 l = [] for i in arr: if dict[i] == 1: l.append(i) return l def main(): T = int(input('Enter the number of test cases:- ')) while(T>0): n = in...
1948c12c92edcf84573b9ff070b08fd2f3b58527
sahilsamgi/SECU2002_SBABA09
/lab03/swap.py
166
3.984375
4
x=23 y=45 # python can not swap values of variable. in order to do so, we create another storage for the variable (z). if x<y: z=y y=x x=z print x,y
8ee6b72278143764ebb7c41936fa4794ff3ffacd
srinvsn/Python_vigenere_cipher
/vigenere_encrypt_decrypt_cipher.py
1,388
4.21875
4
""" Encrypts and decrypts a message using using an alpha, numeric or alphanumeric key """ """ Encrypts a string message (m) using an alpha, numeric or alphanumeric key (k) """ def vigenere_encrypt(m, k): list_m = list(m) list_k = list(k) encrypt = '' for (char_m, char_k) in zip(list_m, lis...
6bb46c83898cc3e1a3667878e238d645bef307af
Dorkond/stepik-python-course
/Module 1/1.8.3.py
357
3.8125
4
# Задание 1 # Напишите программу: # Тимофей обычно спит ночью X часов и устраивает себе днем тихий час на Y минут. # Определите, сколько всего минут Тимофей спит в сутки. x = int(input()) y = int(input()) print(x*60 + y)
6b789bea1ef41c26d6bb67062b8c69cf0c09a44d
baraileesuraj/python-concepts
/Functions and Special Parameters/complex.py
816
3.921875
4
def combined(pos, pos1, /, standard,standard1, *, kwd_only, kwd_only1): ''' Use Parameters types in combined Format ''' print(pos, standard, kwd_only, kwd_only1) combined(1, 2, 2, standard1=123, kwd_only=3, kwd_only1=300) def arg_function(arg,*args ,**kwargs): ''' Print 1st , add normal ...
8cca164c1f1fe544d2086530c4f60e4c5c0d4069
virendramali/Assignments
/Swapnil.py
107
3.75
4
num=int(input("Enter row size")) for i in range(1,num+1): for j in range(i): print("*",end="") print()