blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
58190b8d5ef4b58b61ef87426a6684e20645b578
brian-m-ops/codewars
/6kyu/array_diff.py
359
3.59375
4
def array_diff(a, b): for num in b: if num in a: for i in range(a.count(num)): a.remove(num) return a a = [7, -4, 14, 1, 8, -9, -11, 14, -13, -1, 7, -8, -18, 19] b = [7, 17, 19, -3, -12, 11, 16, 19, -7, 8] print(array_diff(a, b)) # if number is in both a and b. Remove from...
4f91f858b58ca216b1bb71ac5b06984096edda57
Hyun-JaeUng/TIL
/PythonExam/Day7/tupleTest4.py
457
3.515625
4
import time def gettime(): now = time.localtime() print(now, type(now)) return now.tm_hour, now.tm_min # 자동으로 패킹되어 튜플로 리턴됨 result = gettime() print("지금은 %d시 %d분입니다" % (result[0], result[1])) hour, minute = gettime() print("지금은 %d시 %d분입니다" % (hour, minute)) # =============== divmod =============== d, m =...
cb71dbe6414333bd02030527d174472b5cad5baf
kkarakaya/python-ogrenci_not
/Ogrenci.py
2,127
3.546875
4
class Ogrenci: # default constructor # Bir öğrenci ogrenci no, ad, soyad, vize1, vize 2 ve final bilgilerini içeren bir listenin parametre # olarak verilmesi ile oluşturulur def __init__(self, ogrenciNo, ogrenciBilgileri): self.ogrenciNo = ogrenciNo self.ad = ogrenciBilgileri["Ad"] ...
2953ef8f910d9f66f48be8456c5fa44092024298
mryyomutga/PracticePython
/src/Foundation/Library/practice31.py
1,127
3.921875
4
# -*- coding: utf-8 -*- # CSVファイルの操作 from __future__ import print_function import csv with open("data.csv", "r") as f: reader = csv.reader(f) # readerオブジェクトの生成 print(type(reader)) i = 1 for row in reader: print("row {0}".format(i)) print(row) # list型オブジェクトのためアクセス可能 ...
7d890451efc7b5a59dbf4e0a774223033e2f8aec
Rosa-Palaci/computational-thinking-for-engineering
/semana-3/class-11/mayores-prueba1.py
1,103
4.125
4
#INSTRUCCIONES: # Define una función que recibe tres números # enteros y regresa los número ordenados de # menor a mayor. # Haz la prueba con dos tercias de números def orden_asc(a, b, c): if a > b and a > c: mayor = a if b > c: medio = b menor = c else: #Signific...
1c968c88bac194ff93fd65089832938d85f3d5a1
saparia-data/data_structure
/geeksforgeeks/searching/1_search_element_in_array_solved.py
1,847
4.09375
4
''' Given an integer array Arr[] and an element x. The task is to find if the given element is present in array or not. Input: First line contains an integer, the number of test cases 'T'. For each test case, first line contains an integer 'N', size of array. The second line contains the elements of the array separat...
ada312913d3afceb9d1c7afd8cad557309d34488
avielz/self.py_course_files
/self.py-unit4 Conditions/4.2.1.py
495
3.8125
4
rain_mm = int(input("choose rain mm: ")) if rain_mm < 6 and rain_mm > 4: print("illegal") else: print("legal") if not (rain_mm == 5): print("legal") else: print("illegal") if rain_mm > 20 and rain_mm < 40: print("legal") else: print("illegal") if not (rain_mm < 20 and rain_mm > 40): print...
1c6db34c061638b92d8fd58c7fd466c8c3d0f524
garima0562/guessing-game
/main.py
477
4.0625
4
secret_word = 'beautifull' guess ="" guess_count = 0 guess_limit = 3 out_of_guesses = False print('''welcome in this game! here you need to guess the word hint: some albhabet that used in word are "a,u,e,t"''') while guess != secret_word and not(out_of_guesses): if guess_count < guess_limit: guess = input('enter...
5d0a4c18c4da63c878473ab3bbda6ddddb5cb6f5
JorgeGallegosMS/backwards-poetry
/app.py
1,242
4.3125
4
import random def lines_printed_backwards(string_list): '''Takes in a list of strings containing the lines of your poem and prints the lines in reverse''' index = len(string_list) string_list.reverse() for line in string_list: print(f"{index} {line}") index -= 1 def lines_pr...
ec74baef935491951c842b2e07f9829ae98d3128
FelypeNasc/PythonCursoEmVideo
/Exercicios/001-020/desafio012.py
257
3.625
4
#faça um código que leia um preço e mostre-o com 5% de desconto val = float(input('Digite o valor da mercadoria: R$')) desconto = val-(val*0.05) print('Com o desconto de 5%, o valor do produto passou de R${:.2f} para R${:.2f}.' .format(val, desconto))
f8973512582a078cd9c764dd5715067069ad0d24
ekocibelli/Special-Topics-in-SE
/HW04_Test_Ejona_Kocibelli.py
7,247
3.75
4
""" Author: Ejona Kocibelli Project Description: Testing functions count_vowels, last_occurrence, my_enumerate and testing simplify and simplified adding, subtracting, multiplying and dividing in Fraction class. """ import unittest from HW04_Ejona_Kocibelli import Fraction, count_vowels, last_occurrence...
f3d79ee8484811acfab1d69d86e2d7da3677e788
4dw1tz/Python-GUI-Notetaking-App
/Notepad for GitHub.py
20,240
3.71875
4
#Notetaking App from tkinter import * #As tkinter is the only imported framework, I imported all packages without worrying about naming collisions. #This saved me from having to make a reference to the module everytime I used a tkinter function or method. #This try and except sequence is ...
d3d753546b7eedde166ad4fa2df0bbf70376da8d
bom04/Python
/6603.py
1,091
3.65625
4
""" 맞게는 나오나 sort썼는데 문자열로 sort되서 그런지 숫자 크기순이 아니라 문자열 순서대로 나옴. 나머지는 다 맞으나 백준에서 시간초과됨 """ import random l=[] while(1): k=input() if(k=="0"): break l.append(k) for i in l: s1=int(i[0]) s2=i[2:] s2=s2.split() s3=s1 sum=1 p=0 while(1): sum*=s3 s3-=1 p+=1...
43ea1c3d3a94e7e22eac2da2160026ae835684a4
resu15/Python
/python6.py
112
4
4
a=int(input("enter year")) if(a%4==0 and a%100!=0 or a%400==0): print ("leap year") else: print("not leap")
756794e9a53a8f3e573130a5fab91b2415efaace
kaiserbergin/rpbot
/hello.py
443
3.703125
4
import re msg = "Hello World" print(msg) def reMatch(pattern, string): matchObj = re.match(pattern, string, re.IGNORECASE) if matchObj: print("matchObj.group() : ", matchObj.group()) print("matchObj.groups() : ", matchObj.groups()) else: print("No match!!") reMatch(r'\d+:\d+', "...
f130a5f384a110a5c92b175e0aeebaa5b4573934
marinavicenteartiaga/Advent-of-Code-2020
/puzzles/day_1/day_1_variation.py
927
3.75
4
from puzzles.utils import resources def find_matching_values(values): while values: # not empty for i in range(0, len(values)): first_value = int(values[i]) value_2 = 2020 - int(first_value) for x in range(i, len(values)): if int(values[x]) < value_2: ...
804ca5b2bce60e56d1186afeb3a93cc27d805f23
decalopo/MaterialDeEstudioIFTS14Robotica
/AlgOrdenamiento.py
734
3.84375
4
#Creo matriz A=[0,0,0,0,0]; #Declaración de Funciones #Ingresamos los numeros def ingresoNumeros(A): for ii in range(0,len(A)): x=int(input("Ingrese un numero")); A[ii]=x; print (A); z=input("PRESS TO ORDER"); #Aca ordenamos los valores ingresados def algoritmoOrdenamiento(...
fa8c2aa68ec6ef12b0f39b73e958f9b0fe5205f4
Prakort/competitive_programming
/longest-palindromic-substring.py
3,738
4.03125
4
def dp(s): """ pre-computed the palindrome substring and store value in the 2D list the next substring will check both end and inner substring that has been processed already runtime: O(N^2), outter loop iterates over N elements, inner loop iterates up to N elements space: 2D list to store pre-computed value...
5d5d905afd93ea2752f9799c541545708fdc2348
aady28/Python-scripts
/Intro to Python and Numpy_v2.py
5,975
3.640625
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 23 04:58:29 2019 @author: Singhman """ import numpy as np import scipy as sp import pandas as pd import matplotlib as mpl import seaborn as sns k = 100 #An Integer l = 100.0 #A Floating Point q = 3.14j #A complex number print(k) print(l)...
804d5994a5e77864f804433e9b096dfc94cedb5e
xxxhol1c/PTA-python
/programming/4-4.py
312
3.71875
4
from math import sqrt def prime(x): if x == 1: return False for i in range(2, int(sqrt(x) + 1)): if x % i == 0: return False return True n = int(input()) for i in range(2, n // 2 + 1): if prime(i) and prime(n - i): print(f'{n} = {i} + {n - i}') break
17733a5515a2d12d73de236533edbdf082d26432
Rerebla/MegaProjectList-Numbers
/DistanceBetweenTwoCities.py
675
3.796875
4
from geopy.geocoders import Nominatim from geopy.distance import great_circle geolocator = Nominatim(user_agent='my_application') input1 = input("First city: ") input2 = input("Second city: ") unit = input( "Which measurement of lenght would you want? [0]Kilometers, [1]Miles") location1 = geolocator.geocode(input1...
6cceeaa43a1ab844b5513088042991e7406f69a5
Tacysea/LeetCode-python
/Tree/700.py
298
3.5
4
# -*- coding: utf-8 -*- class Solution: def searchBST(self, root: TreeNode, val: int) -> TreeNode: if root and root.val > val: return self.searchBST(root.left, val) elif root and root.val < val: return self.searchBST(root.right, val) return root
dc6c44ef24e102e6eeb4a8c45b03df15f6170003
leguims/Project-Euler
/Problem0067.py
2,864
3.6875
4
Enonce = """ Maximum path sum II Problem 67 By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top to bottom in triangle.txt (right click and 'Save Link...
7e05d337a86221fea329209f3ae6a41e17171e4a
kielejocain/AM_2015_06_15
/Week_3/letter_frequency.py
830
4.09375
4
# Task Description: # Display the number of times each letter occurs. # # What clarifying questions would you want to ask? # # What types of data structures will we need? sentence = "Now is the time for all good people to come to the aid of their planet." output = {} for c in sentence: if c not in output....
1ae8853d8d01277b8224016b63a607fe44bd9574
makrayr/PYL
/Lista Probleme 'Cateva exercitii'/Problema 6.py
164
3.578125
4
n=int(input('n=')) print('Modurile prin care',n,'poate fi scris ca suma de 2 termeni consecutivi este:','\n') for i in range(0, (n//2)+1): print(i,'+',n-i,'\n')
1e0e4623c8ec4694648a9bcf9ce8cf828d4178e1
ReliableDragon/DesertedDesert
/location.py
685
3.703125
4
class Location(object): def __init__(self, key, printable_name, name, description, atmosphere): self.key = key self.printable_name = printable_name # Name with articles, etc. self.name = name # Name players will use to target self.description = description # Description when viewed from elsewhere ...
1069e58c6e29d807ee83a4ed5a6d873cedbc932e
alqamahjsr/InterviewBit-1
/07_DynamicProgramming/maximum_longest_common_subsequence.py
1,844
3.796875
4
# Maximum Longest Common Subsequence # https://www.interviewbit.com/problems/maximum-longest-common-subsequence # # Defining substring # For a string P with characters P1, P2 ,…, Pq, let us denote by P[i, j] the substring Pi, Pi+1 ,…, Pj. # # Defining longest common subsequence(LCS) # A subsequence is a sequence that c...
ab70397abc41007e5e116cac7afbe90e3cc9952d
abhishekkmr031/lazypython
/substring.py
564
3.5625
4
# From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 # str = 'X-DSPAM-Confidence: 0.8475 ' def substring(): text = 'X-DSPAM-Confidence: 0.8475 ' colon_pos = text.find(':') space_pos = text.find(' ', colon_pos+2) #num = text[colon_pos+2:space_pos] num = float(text[colon_pos+2:space_pos]) ...
af24e52705239982eee05e4f70439ed789aebb7a
zchen0211/topcoder
/python/leetcode/combinatorial/247_strobo_num.py
1,124
4.125
4
""" 247. Strobogrammatic Number II (Medium) A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Find all strobogrammatic numbers that are of length = n. For example, Given n = 2, return ["11","69","88","96"]. """ class Solution(object): def findStrobogramm...
38338587cb2a7df24fd63206a567e8efb660b1a5
bizelite/algorithm
/asap/hanoi.py
279
4
4
def hanoi(n, start, waypoint, destination): if n == 0: return hanoi(n-1, start, destination, waypoint) print('{} move {} => {}'.format(n, start, destination)) hanoi(n-1, waypoint, start, destination) if __name__ == '__main__': hanoi(5, "A", "B", "C")
5bb6b36d4973684395e6307a7d67a4632903ecf5
alfaroJose/CI-1323-proyecto
/arquitectura-proyectoprogramado/src/AreaDatos.py
2,566
3.671875
4
#Clase para representar el area de datos de la memoria principal class AreaDatos: def __init__(self): self.datos = [] self.llenar() #Método para guardar un dato en el arreglo de datos #Se recibe el dato nuevo a guardar y la posición donde se desea guardar en el arreglo de datos def gua...
feebe6489eb03f05f5ce95538b60d31fe34ea0c9
alexthemonkey/interviewBit
/Trees/Balanced_Binary_Tree.py
1,606
4.03125
4
""" Balanced Binary Tree https://www.interviewbit.com/problems/balanced-binary-tree/ Given a binary tree, determine if it is height-balanced. Return 0 / 1 ( 0 for false, 1 for true ) for this problem """ # Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # ...
a5072df8c8e4a7a3936f7f173db0efb3b2fa5874
AnneLivia/ICCP-USP
/listaOrdenada.py
322
3.828125
4
def ordenada(lista): orded = True for i in range(1,len(lista)): if(lista[i - 1] > lista[i]): orded = False return orded def main(): lista1 = [1,2,3,4,5,6] lista2 = [9,3,11,35,31,4] print(lista1," is orded: ", ordenada(lista1)) print(lista2," is orded: ", ordenada(lista2)...
d66ee814bba5b7b79a6be36fa6bf1e08e48d6e39
qamine-test/codewars
/kyu_5/fibonacci_streaming/test_all_fibonacci_numbers.py
2,350
3.515625
4
# Created by Egor Kostan. # GitHub: https://github.com/ikostan # LinkedIn: https://www.linkedin.com/in/egor-kostan/ # ALGORITHMS import allure import itertools import unittest from utils.log_func import print_log from kyu_5.fibonacci_streaming.all_fibonacci_numbers import all_fibonacci_numbers @allure.epic('5 ky...
962d3d0da984991cef6d01b90ea8f4614490b9d3
judowal/Secret-Ciphers
/cipher.py
5,128
4.0625
4
# imports random module import random class Cipher: """ creates cipher class that all other classes will be inherit from """ # initializes the class with preset values def __init__(self): """ intializes class's starting values """ # alphabet that all cipher conversions will be based upon ...
e4e90b78e97f54432768181d75f6484db3d92f49
EAeliasalejandro/Curso-MachineLearning
/CodigoDePractica/CodigoPython/programaIntegrador.py
2,003
3.765625
4
#Codigo par ejemplificar una tienda de abarrotes import sys import validadortelefono from validadortelefono import validateTel #//////CLASE CLIENTE////// class Cliente: #Constructor y parametros def __init__(self,nombre,telefono,producto): self.nombre = nombre self.telefono = telefono self.producto =...
6593dcc0bdc89c788ad0a24b5986a4d45efd3fa1
ThanushaJ/coding-bootcamp
/LoopingProblems/reverseNumber.py
244
4.0625
4
"""Write a program to enter a number and print its reverse. """ number2R = int(input()) reverseNum = 0 while(number2R>0): remainder = number2R % 10 reverseNum = (reverseNum*10) + remainder number2R = number2R//10 print(reverseNum)
4831d2388629898f07a03667cfa61d2e9414d4f6
sambapython/python21
/cindition-looping statements-2016-Nov-12.py
9,722
3.6875
4
# coding: utf-8 # In[1]: 10>20 # In[2]: "10"<"20" # In[3]: "10"<"2" # In[4]: "sub" in "substring" # In[5]: a=10 b=10.0 # In[6]: id(a) # In[7]: id(b) # In[8]: a is b # In[9]: a==b # In[10]: bool(a==b) # In[11]: bool(a is b) # In[12]: bool(0) # In[13]: bool(-10) # In[14]: bool(10...
f94d76a7afbe9ec7d2845f202f3378b9b5473d6c
liaoyajun/python_learn
/demo_guess_num.py
546
3.703125
4
# coding: gbk # # ޴汾 from random import randint num = randint(1, 100) # һд # import random # num = random.randint(1, 100) print('һ 1 - 100 ') answer = -1 while answer != num: answer = int(input('µǣ')) if answer > num: print('µִˣ𰸱' + str(answer) + 'С') elif answer < num: print('µСˣ𰸱' + ...
8f24d8dbc3e9fccf838c602a4ce7b4e61faf6ce4
Shubhampy-code/Let_us_C_book_solution_5th-Edition
/Chapter 2-The Decision Control Structure/let_us_c_2_(C_C).py
537
4.25
4
"""Any year is input through the keyboard. Write a program to determine whether the year is a leap year or not. (Hint: Use the % (modulus) operator)""" year = int(input("Enter the year:")) """fir_cond = year%4 sec_cond = year%100 third_cond = year%400""" if (year%4==0) : if year%100!=0: print(" Entred Ye...
ae483977d9868af5f2a61c4a058ba60590a474da
ArunDruk/official_practice
/mysql_practice_1.py
2,475
3.671875
4
import mysql.connector ################################################## Connecting to the Database ################################################## mydb=mysql.connector.connect( host="localhost", user="root", password="Feb@2020", database="test_db1" # This tells python to point to the database tes...
ed1f0d75747a8a7d34637c6ef3038ce13f0ba370
likaon100/bootcamp_alx
/cwiczenie 6_08.10.18.py
251
3.609375
4
liczba = input("podaj liczbę: ") liczba = int(liczba) print(f"większa od 10: {liczba>10}") print(f"mniejsza od 15: {liczba<=15}") print(f"podzielna przez 2: {liczba%2==0}") print(f"większa od 10 lub podzielna przez 5: {liczba>10 or liczba%5==0}")
f7d6ae3220a74d37b90e7aa7edf0570dfcb6879c
greesegrass/drawLove
/love3.py
557
3.953125
4
import matplotlib.pyplot as plt import numpy as np import math def draw_love(): x = np.linspace(0, 1, 1000) y1 = np.sqrt(1 - np.power(x, 2)) + np.power(x, 2/3) y2 = -1 * np.sqrt(1 - np.power(x, 2)) + np.power(x, 2/3) plt.plot(x, y1, color='red', linewidth=2) plt.plot(-x, y1, color='red', linewidt...
7326d6efe485932c6bf746770abb8bc0264841d8
ErickMwazonga/sifu
/arrays/existance/contains_duplicate.py
1,410
3.890625
4
''' 217. Contains Duplicate Link: https://leetcode.com/problems/contains-duplicate/ Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. Examples 1. [1, 2, 3, 1...
935608b9052e3c59fd6d2444e262b37509952bd3
pradeepsinngh/A-Problem-A-Day
/by-data-structure/hash-tables/easy/006-max_no_of_balloons.py
541
3.96875
4
# Prob: Maximum Number of Balloons # Given a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible. # You can use each character in text at most once. Return the maximum number of instances that can be formed. class Solution(object): def maxNumberOfBalloons...
8ab5635437bf7530bef9c2fdc6c99ef36ef5fe99
FT-Labs/BaslangictanIleriSeviyeyePythonUdemy
/Bolum5/MapFonksiyonu.py
258
3.734375
4
""" Author : Arda Date : 4/25/2020 """ sayilar = [1 , 3 , 5 ,7] meyveler = ["portakal" , "elma" , "armut" , "çilek"] sayilar1 = [2 , 1 , 3 , 1] # print(list(map(lambda x : x+x , sayilar))) print(dict(map(lambda x , y : (x , y) , meyveler , sayilar1)))
6ecb0fc5be400e7e846c13b10d994192b71337ba
srihariprasad-r/workable-code
/Practice problems/divide_conquer/sorting_algorithms/mergesort.py
834
3.53125
4
def merge(A,arr, low, mid, high): k = low i = low j = mid + 1 while i <= mid and j <= high: if A[i] <= A[j]: arr[k] = A[i] i += 1 k += 1 else: arr[k] = A[j] j += 1 k += 1 while i <= mid: ...
4f1c663a08ce8d7aca608eb046981b04d62726d7
Cdm2308/textDungeon
/classData/player.py
1,436
3.984375
4
# ************************ # Player class # ************************ class Player: # Constructor def __init__(self): self.inventory = [] self.hp = 125 self.weapon = None # Add an item to the players inventory def add_item(self, item): print() self.inventory.ap...
37983d97ae7ed40a70692de96d37f137d83f7bad
kiribon4ik/Basics_python
/Lesson_1/Task_3.py
226
3.671875
4
number = input('Введите любое число: ') n = int(number) numbers_list = [] for i in range(1, (n + 1)): numbers_list.append(int(number * i)) print(f'Сумма чисел равна: {sum(numbers_list)}')
e9a558717d0240a600605e46541b0207ad58f5b2
othee86/ml
/simulator.py
4,517
3.59375
4
""" This is Santa Uncertain Gifts Simulator """ import os import numpy as np import math import random import click class Horse: def __init__(self, num): self.weight = max(0, np.random.normal(5,2,1)[0]) self.name = 'horse_' + str(num) class Ball: def __init__(self, num): self.weight ...
b1f620e3db6b2e28e6cb8addc9653659c1794ff1
naydichev/advent-of-code-solutions
/2015/18/puzzle_1.py
1,567
3.84375
4
#!/usr/bin/env python3 import itertools def main(lights, steps): print_lights(lights) for i in range(steps): lights = animate(lights) print_lights(lights) lights_on = sum(itertools.chain.from_iterable(lights)) print(f"there are {lights_on} lights on") def print_lights(lights): ...
5b8e225384ead40b9aaf8de0622ac918b50ccb11
ntupenn/exercises
/medium/247.py
726
4.34375
4
""" A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Find all strobogrammatic numbers that are of length = n. For example, Given n = 2, return ["11","69","88","96"]. """ def findStrobogrammatic(n): mapping = {"0": "0", "1": "1", "6" : "9", "8": "8", "9": "...
9a42d0ddf809e03c66b4d9c5698f19e4b884f4a0
shengxio/randSTRING
/src/randSTRING/.ipynb_checkpoints/randSTRING-checkpoint.py
1,762
3.859375
4
from math import ceil import string import random class randSTRgen: ''' This is a generator class which creates a random variable string with preset variables. ''' optionDict = {'lower letters':string.ascii_lowercase, 'upper letters':string.ascii_uppercase, ...
83ed94a4c847c7ea24568cd61968fca392f10a3f
GreenGitHuber/code_something
/http_tool/sample_server.py
1,280
3.84375
4
""" python3 + flask """ from flask import Flask from flask import request, session app = Flask(__name__) @app.route('/login', methods=['POST', 'GET']) def login(): # 如果是一个post请求 if request.method == 'POST': if request.form['username'] == 'admin' or request.form['password'] == '123': ...
9df1ed8e8f6726b725392c84884c472179901530
dmitriyanishchenko/Teach_My_Skills_Python_base
/src/Home-_and_classworks/Work_3[conditional statements]/hw_3_task_3_3.py
506
4.3125
4
# Ввести строку. Если длина строки больше 10 символов, то создать новую строку # с 3 восклицательными знаками в конце ('!!!') и вывести на экран. # Если меньше 10, то вывести на экран второй символ строки some_line = input('Enter some line --->') if len(some_line) > 10: new_line = some_line + '!!!' print(new_...
47f73fbb797193d25da614131f5e9feca28ac2b6
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/264 Ugly Number II.py
1,166
3.515625
4
""" Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers. Note that 1 is typically treated as an ugly number. """ _______ h__ __author__ 'Daniel' c_ Node(o....
bdaa9ec85c6d97e0ef2094d71bde960700e26004
phucle2411/LeetCode
/Python/min-cost-climbing-stairs.py
215
3.515625
4
# https://leetcode.com/problems/min-cost-climbing-stairs/ class Solution: def minCostClimbingStairs(self, cost): a, b = 0, 0 for c in cost: a, b = b, min(a + c, b + c) return min(a, b)
6eac31674626df5054eb299dd6efe0255ab72d9e
atm98/Python
/sdj.py
430
3.65625
4
import random num=random.randint(0,100) def chec(n,h): if(n<h): cho=int(input("enter guess")) return check(n,cho) elif(n>h): cho=int(input("enter guess")) return check(n,cho) else: return 1 i=1 choice=int(input("enter guess")) while(i!=10 or num!=choice):...
c5d96e0a87e96a8e6480d9475ca76075d87c91e2
hovikgas/Python-Coding-Challenges
/lists/sum_odds/sum_odds.py
433
4.15625
4
''' Write a function called oddball_sum() that takes in a list of integers and returns the sum of the odd elements. >>> oddball_sum([1,2,3,4,5]) 9 >>> oddball_sum([0,6,4,4]) 0 >>> oddball_sum([1,2,1]) 2 ''' def oddball_sum(nums): # Replace the line below with all your code. Remember to return the requested d...
17013ddba0db2287a80bb5fe4c11c3f501bf6ef3
mairiigomez/Days-Left-Suscription
/test/creating_class.py
1,172
3.78125
4
"""Create class for students, attributes are what we read from the csv - How do we assing it to an attriute""" import csv class Students: def __init__(self, name, status, days_left, end_date): self.name = name self.status = status self.days_left = days_left self.end_date = end_d...
a0132104a0d55c45b52c62b9dfd1e25f574498bb
JustinKnueppel/ProjectEuler
/problems/0/problem004.py
734
3.71875
4
#https://projecteuler.net/problem=4 # A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. # Find the largest palindrome made from the product of two 3-digit numbers. def isPalindrome(num): stri = str(num) if stri == stri[::-1]: ...
6c3ec4502128b252618b1baf4336548be1f921d1
rockrunner/Learn_Python100Day
/day3/triangle.py
316
3.53125
4
#!/usr/bin/python # -*- coding: utf-8-*- import math a=int(input('a边长:')) b=int(input('b边长:')) c=int(input('c边长:')) if a+b>c and b+c>a and c+a>b: L=a+b+c p=L/2 S=math.sqrt((p-a)*(p-b)*(p-c)) print ('周长:%.0f'%L) print ('面积:%f'%S) else: print('不能构成三角')
9b55d5431456b32d3f0b853c3b29a5fc96d95160
winarcooo/algorithm-playground
/maximum_element/solution.py
279
3.71875
4
# def maximum_element(stack): def main(): n = input() # item = input() items for i in range(n): elem = input() if i == 1: elem = input() items.append([1,]) # maximum_element(); if __name__ == "__main__": main()
e3a8f6002bd0261d70436c0ae906716027ba7eb6
issacianmutiara/Issacian-Mutiara-Paska_I0320053_Tiffany-Bella_Tugas-3
/I0320053_Exercise 3.1.py
173
3.8125
4
#Cara mengakses nilai di dalam list Python list1 = ['fisika', 'biologi', 1991, 2021] list2 = [1,2,3,4,5,6,7] print("list1[0]: ",list1[0]) print("list2[1:5]: ",list2[1:5])
1352b4201653501d9dc88319444708c9bc28cddb
mariettas/SmartNinja_Project_smartninja_python2_homework
/lower_case.py
142
3.96875
4
while True: choice = input("Would you like to continue? (y/n)") if choice.lower() != "y" and choice.lower() !="yes": break
b6226ff6aed113db062128f42b7192cc564a579f
jasonminhvuong/GeeksForGeeks
/Tree/mirror_tree.py
352
3.828125
4
""" Given a Binary Tree, convert it into its mirror. """ class Node: def __init__(self, val): self.right = None self.data = val self.left = None def mirror(root): if not root: return mirror(root.left) mirror(root.right) temp = root.left root.left = ...
ddaa0dbaf9db27a21296a0ae7be659e3ce7f5542
memiles47/UdemyPythonProgrammingMasterClass
/Section3/Strings2.py
568
3.59375
4
__author__ = "Michael E Miles" # # 01234567890123 parrot = "Norwegian Blue" print(parrot) print(parrot[3]) print(parrot[4]) print(parrot[9]) print(parrot[3]) print(parrot[6]) print(parrot[8]) print() print(parrot[0:6]) # Norweg print(parrot[-14:-8]) print(parrot[0:6:2]) # Nre print(parrot[:6:3]) # Nw n...
1b4fd3260bbcdf0d52c50f52848ac9a5dc39733a
Crytec1512/Second
/main.py
2,302
4.09375
4
import math from copy import copy class Point: def __init__(self, x1, y1): self.x1 = x1 self.y1 = y1 def __copy__(self): return def distance(self, other): delta_x = self.x1 - other.x1 delta_y = self.y1 - other.y1 return (delta_x ** 2 + delta_y ** 2) ** 0.5 ...
76fc5cb4156d22b03b5e16a75b2efc728e47bbe0
luyihsien/leetcodepy
/38 Count and Say.py
1,842
3.640625
4
#此題我搞不清楚要如何判斷何時1何時2 猜: ''' class Solution: def countAndSay(self, n: int) -> str: ''' ''' i代表字符下标,从0开始取值,也就是从第一个字符开始 因为要让i取到最后一个字符,并且后面还要进行i+1的操作 所以将原字符串随意加上一个‘*’字符防止溢出 Q1 有做字串內增刪嗎?字串內本就不能刪或自由增(除了str+'a'這種直接尾巴增存到另一數,以及.replace()可以改 class Solution: def countAndSay(self, n): if n==1: return '...
ad2ebf373abe489d8c8beb0cdca908d375a7029d
SpencerXD/assignment-problems
/linear_encoding_cryptography.py
1,446
3.734375
4
alphabet = ' abcdefghijklmnopqrstuvwxyz' def encode(string, a, b): numbers = [] for char in string: if char != " ": numbers.append(a*(ord(char) - 96)+b) if char == " ": numbers.append(a*(0) + b) return numbers print(">>> get_encoding('a cat', 2, 3)") assert encode("...
d070175267cf195626107e6cc72d32d5dd7693ac
epai/hanoi-terminal-game
/__game__.py
5,152
4.125
4
""" The game class encapsulates all internal game logic. """ """ || || || || || || || || || ┌----------┐ || ...
b6ab2a6881260b0e62fe72d1700907ca4e6860fb
babacar93/Massaly
/aleatoire.py
132
3.671875
4
from random import randint x=randint(0 9) a=input("saisir un nombre") if int(a)==int(x): print("bravo") else: print"(perdu")
99166e17a7614ff3b711ede85d724d7ababc3a77
bgoonz/UsefulResourceRepo2.0
/MY_REPOS/DATA_STRUC_PYTHON_NOTES/python-prac/projecteuler/euler019.py
1,025
3.640625
4
#!/usr/bin/env python """ Solution to Project Euler Problem 19 http://projecteuler.net/ by Apalala <apalala@gmail.com> (cc) Attribution-ShareAlike http://creativecommons.org/licenses/by-sa/3.0/ You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. ...
4371f302e0a0f87c26f4ee3071a82c65a5b4e046
leozachl/python-kurs
/plz.py
203
3.546875
4
import re def is_plz(plz): plz = re.sub(r'\s+', ' ', plz.strip()) matches = re.search(r'^[Aa][- ]?[1-9]\d{3}$',plz) if matches: return True else: return False
6351cfad548b908dd2c8a16dfdbe09ae5cbb8fa1
magezil/holbertonschool-machine_learning
/math/0x00-linear_algebra/6-howdy_partner.py
298
3.875
4
#!/usr/bin/env python3 """Implement cat_arrays function""" def cat_arrays(arr1, arr2): """ Concatenate two arrays arr1: list of ints/floats arr2: list of ints/floats Return: new list of ints/floats """ new_list = list(arr1) + arr2 return new_list
9c6d6dd5858499b611e0f6fc5edf167b41303cb0
dlee67/MLPy
/PandaDemo.py
457
3.90625
4
# Got straight from the Introduction to Machine Learning with Python import pandas as pd from IPython.display import display # create a simple dataset of people data = {'Name': ["John", "Anna", "Peter", "Linda"], 'Location' : ["New York", "Paris", "Berlin", "London"], 'Age' : [24, 13, 53, 33] } ...
2be36f991cd5ee288de8cfc1dc9787976bab22f8
CyrilZxy/Python
/2.py
1,706
4.40625
4
#变量 message = "Hello Python world" print(message) message = "hello python" print(message) mesage = "python" print(mesage) #字符串 print("this is a string") print('string') name = "cYril zXy" print(name) print(name.title()) print(name.upper()) print(name.lower()) first_name = ("cyril") last_name = ("zxy") full_name =...
df243ada855a0c0d8296c428d3cd71aa48ccc995
dlsnoopy95052/test1
/test98.py
685
3.734375
4
import sys import xml.etree.ElementTree as etree def get_attr_number(node): # your code goes here a = 0 # if node.attrib: # print(node.tag, node.attrib) # a += len(node.attrib) for child in node.iter(): print(child.tag, child.attrib) a += len(child.attrib) ...
3bc2dd625b935a6b008cc8888d722968109e0216
AdnCodez/Codewars
/Reversed_string.py
478
4.1875
4
# 8 kyu / Reversed Strings # Details # Complete the solution so that it reverses the string value passed into it. # solution('world') # returns 'dlrow' def solution(strng): result = '' if len(strng) == 0: return result else: for i in range(1, len(strng)): result += strng[-i...
786d08c10d985635ecc89e27586c01afe43e002e
gal-forer/jo_snippets
/bubble_sort.py
718
4.21875
4
def bubblesort(array): # we minus 1 because we are always comparing the current value with the next value lengthOfArray = len(array) - 1 # numbe of rounds will be the total length - 1, for array with length 5, we will do 4 rounds: 0 and 1, 1 and 2, 2 and 3, 3 and 4. for i in range(lengthOfArray): ...
cb3e177a9f83ee6e5cb5420a3a4aa93909f2d6d8
BiancaPal/PYTHON
/INTRODUCTION TO PYTHON/confirmed_users.py
704
4.28125
4
# USING A LOOP WITH LISTS AND DICTIONARIES # To modify a list as you work through it, use a while loop. # MOVING ITEMS FROM ONE LIST TO ANOTHER unconfirmed_users = ['alice', 'brian', 'candace'] confirmed_users = [] while unconfirmed_users: current_user = unconfirmed_users.pop() print(f"Verifying user. {current_...
bbe65613e225619aa912b5af92e8df900660f0be
Victor-El/data-structures
/tests/linkedlist_test.py
6,325
3.5625
4
import unittest from structures.linked_list import LinkedList, IndexOutOfBoundException class LinkedListTestCase(unittest.TestCase): # def test_something(self): # self.assertEqual(True, False) @staticmethod def class_started(): print("LinkedListTestCase started") @staticmethod d...
4be6f0c93720385ae4059fb0cae28c745c3abee8
cuong1997565/tutorial_python
/chuong8/bai3.py
855
3.71875
4
# def to_power(num, *args): # if args: # return [i**num for i in args] # else: # return "You didn't pass any args" # nums = [1,2,3] # print to_power(2,*nums) #kwargs as a parameter # def func(**kwargs): # for k,v in kwargs.items(): # print k + " : "+v # func(first_name = 'harshit', ...
dbf9993e55a37202cd55e19d509488e8ead1691d
BardisRenos/Project-Euler
/Problem10.py
1,108
3.890625
4
# Summation of Primes # Problem 10th # The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. # Find the sum of all the primes below two million. class Problem10: @staticmethod def summationOfPrime(num): if(type(num) is str): return False if(num<1): return False ...
221fa9ac3920d81a2460fa1f01e4f70a4015543a
adriamarimon/csv_wordcount_analyzer
/test/title_word_counts.py
1,458
3.53125
4
import sys sys.path.append("../opower/csv_wordcount_analyzer") def assert_equals(expected, actual): '''Asserts equality of two values. TODO: use a proper unit testing library''' if(not expected == actual): raise Exception("Expected: " + str(expected) + ", but got " + str(actual)) print "Running tests" from cs...
57e6bc3d4e9fc8114b591a1e71b4795ba609ba3e
dasafo/Python
/archivos_externos_13_I.py
1,019
3.84375
4
#importamos la biblioteca 'io' de python para trabajar con flujo de datos, y su metodo 'open' from io import open archivo_texto=open("archivo.txt", "w") #'r' modo lectura frase="Estupendo día para morir \n en esta ciudad" archivo_texto.write(frase) archivo_texto.close() #Ahora lo leemos y decimos que nos diga lo ...
f849be0d0c0d2fa89ac2c44a2bf0149d04fa636d
Polin-Tsenova/Python_OOP
/gym/project/customer.py
878
3.5
4
class Customer: autoincremented_id = 1 def __init__(self, name: str, address: str, email: str): self.name = name self.address = address self.email = email self.id = Customer.autoincremented_id Customer.autoincremented_id += 1 @staticmethod def get_next_...
ef293c2db9da4a232e655037b7ea4d9df50d28ed
akashgupta910/python-practice-code
/Exercise_calculator.py
1,325
4.21875
4
# CALCULATOR def calculator_sqr(sqr_num): print(f"Square of {sqr_num} is {sqr_num * sqr_num}") def calculator_cube(cube_num): print(f"Cube of {cube_num} is {cube_num * cube_num * cube_num}") def calculator(num1, num2): operator = input("Enter '+' for Addition, '-' for Subtraction, '*' for Multiplication ...
7cbb4b26f94da90c57b53ffb02062cfa561b19d2
momo-o/LPTHW
/ex18.py
439
3.78125
4
def print_two(*args): #define function name and the name and number of arguments. arg1,arg2 = args print "arg1:%r, arg2=%r" %(arg1,arg2) #operate with arguments and present the outcome. def print_two_again(arg1,arg2): print "arg1:%r, arg2=%r" %(arg1,arg2) def print_one(factor): print "arg1: %r" %factor def print...
4ca4911c787c01d38a4d453d351a9cfe0f46f00b
zhanjw/leetcode
/codes_auto/138.copy-list-with-random-pointer.py
876
3.515625
4
# # @lc app=leetcode.cn id=138 lang=python3 # # [138] copy-list-with-random-pointer # """ # Definition for a Node. class Node: def __init__(self, x: int, next: 'Node' = None, random: 'Node' = None): self.val = int(x) self.next = next self.random = random """ class Solution: def copyRand...
902c3b4bde2a9561434e06c763ee17f2b8574c97
jonaspfab/permit-predictor
/permit_predictor.py
2,375
3.8125
4
""" The permit predictor is an example application using a trained model to predict the confidence that a building permit is issued """ import numpy as np from data_io import restore_object from constants import CATEGORICAL_FEATURES, NUMERIC_FEATURES, PCA_PICKLE_FILE, ENCODER_PICKLE_FILE, MODEL_PICKLE_FILE def main(...
c1c107ee4878d56268424fdc117e275e3d3253bd
rsosseh/fellowship-answers
/answers/sort_by_string.py
469
4.0625
4
def sort_by_string(s, t): # sorts string, s, by order of string, t. # ("hello", "leho") => "lleho" # ("good", "osf") => "oogd" # ("", "hea") => "" # ("heyyy", "") => "heyyy" if len(t) == 0: return s st = list(s) sorted_string = "" # sort letters for i in range(len(t)): for j in range(len(s)): if s[j...
b559e5f274a8140cf72fa80f88bab55bed2b8c9e
evrardco/advent-2019
/day_6/day_6_2.py
1,540
3.53125
4
from sys import argv def add_edge(graph, v, w): if v in graph: graph[v].append(w) else: graph[v] = [w] if w in graph: graph[w].append(v) else: graph[w] = [v] def build_graph(orbit_map): graph = {'COM': []} nodes = [] for edge in orbit_map: edge = edge...
70d4c325583d8951bae542c37740eb2a5b88a7cf
rickruan/my_git
/python/test_classattr.py
372
3.65625
4
# !/usr/bin/env python3 # -*- coding: utf-8 _*_ __author__='Rick Ruan' class Stduent(object): name='Stduent' def __init__(self,name): self.name=name s=Stduent('Bob') s.score=90 print('stduent\'s name is',s.name) print('stduent\'s attr name is',Stduent.name) s.name='Michael' print('stduent\'s name is...
fd197fa1a79bf63ff17420e9c81c18a3a74ac5fe
python20180319howmework/homework
/caoxu/20180401/h4.py
1,377
4.1875
4
''' 每一个要求封装成小函数 ''' import os #创建目录 def my_path(l): if os.path.exists(l) != True: os.mkdir(l) #创建文件 def my_open(l,n): f = open(l+n,"x+") f.close() #写入内容 def my_write(l,n,cont): with open(l+n,"r+")as f: f.writelines(cont) #追加标题 def my_write2(l,n,cont2): with open(l+n,"r+")as f: content = f.read() ...
1c2d9e2c029479eecf8d60e7d54d1c45625f5f42
hamin7/ITE3035_Python
/Python/Lecture8/8-3.py
1,982
4
4
print('''도서관에서 열심히 공부하던 당신은 바람을 쐬기 위해 잠깐 나왔습니다. 마침 자판기가 보이네요''') print(''' ------------------------------------- | | | 밀크티/에너지드링크/콜라 | | | ------------------------------------- ''') money = int(input('자판기에 얼마를 넣을지 입력하세요:')) print('제품 금액보다 넣은 돈...
041c8a0ce5fec55a82d27de1800fe15d782dad7a
GJayme/RaciocionioLogicoPython
/Lista_01_11.py
480
3.890625
4
''' 11 - Elabore um algoritmo que mostre a série na tela e ao final o valor da soma S para cada um dos itens a seguir: a) S = (1/1) + (3/2) + (5/3) + (7/4) + ... + (99/50) ''' num1 = 1 num2 = 1 soma = 0 while num1 <= 99 and num2 <= 50: a = num1 / num2 print(a) soma = soma + a num1 = num1 + 2 ...
fc503623889300932fc358842f7e02239ced2cb7
c4collins/Euler-Project
/euler6.py
294
3.8125
4
#initialize variables square_total = 0 sum_total = 0 for x in range(1,101): # evaluate the range for sum and squares sum_total += x square_total += x**2 print "Sum Total Squared is: ", sum_total**2 print "Square Total is: ", square_total print "Difference is ", sum_total**2 - square_total
3ae659d76968d7a3477f5ed05933c95f403010f9
vparent/ProjetAnonymisation
/month_spliter.py
1,259
3.5625
4
import csv import sys from gauss import write_file def write_file_month(f, j, m): write_file(f[:-4] + "_month_" + str(j), m, ['id_user', 'date', 'hours', 'id_item', 'price', 'qty']) return """ Get the csv file puted in arguments and creates 1 csv file for each months """ if __name__ == "__main__": if not...
b08461085bd0c7552838c347ef740e2f915f356e
neethu567/basicPythonExamples
/classmeth2.py
568
3.84375
4
"""class methos""" class studnet: school="admaren" def __init__(self,name,age,std): self.name=name self.age=age self.std = std @classmethod def student_name(cls,instance): instance.name = "NEw NameA changed with class method" instance.age = "NEw age changed with ...