blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
8b1cfa1de0e55ed2c8ce01a2ab8e7ec56188daa5
spomenka/ZSV-2018-02
/CodeWars-zadaci/int-cw6-while-znamenke.py
389
3.5625
4
''' napisi program koji za ucitani broj n mnozi njegove znamenke sve dok ne dodje do jednoznamenkastog broja. Program treba ispisati koliko puta se mnozenje moze ponoviti. Npr. n=39 ---> 3 (3*9=27, 2*7=14, 1*4=4) n=999 ---> 4 n=4 ----> 0 ''' n=int(input()) m = 1 z=0 if n < 10: print (0) else: while n > 0: ...
5f8d77b048534a6a06477fc923e33abff0cef22b
jiahuihan98/small-python-projects
/translate Morse Code/morse.py
1,540
3.875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Dec 14 16:42:07 2016 name: Jiahui Han net ID: jh5226 Practice 1 """ def create_dictionary(filename): in_file = open(filename , 'r') dict_morse = {} for line in in_file: line = line.strip() line_list = line.split('\t') ...
e4383b4fac41d8601c9a1ccc2b295d07d8842edf
SophieN12/kyh-practice
/uppg14.py
899
3.75
4
FRUITS = ['banana', 'apple', 'orange'] CARS = ['volvo', 'ford', 'tesla'] COLORS = ['blue', 'yellow', 'pink'] def run(): basket = input("Skriv olikla färger med komma imellan:").split(", ") # basket = ['volvo', 'is', 'an', 'orange', 'apple', 'yellow'] cars = [] fruits = [] colors = [] rest = []...
19411038853a02db5b0272d4fbd4cf5275933689
tkshim/leetcode
/leetcode_0922_SortArrayByParity.py
796
3.5625
4
#!/usr/sortArrayByParityIIbiSolutionn/env python #!coding: utf-8 class Solution(object): def sortArrayByParityII(self, A): """ :type A: List[int] :rtype: List[int] """ #愚数、奇数、返り値のリストを用意する O=[] E=[] X=[] # %は任意の数で割った余りを示す # 偶数と...
97bd3c3e1bef9767a2872d73d7a5e4aa92d02deb
jmcmartin/iteration
/swap.py
1,965
3.875
4
#Number 1 def replace_letter(phrase, swapped_letter, final_letter): new_phrase = '' for i in phrase: if swapped_letter == i: new_phrase += final_letter else: new_phrase += i return new_phrase print replace_letter("banana", "a", "!") #Number 2 def switch_letters(phrase, swapped_letter_1, swapped...
42d1956cc6a74439dad7269527f5ab81064641ab
PurpleBubble123/pp
/object_oriented/inherit/polymorphic.py
1,303
3.90625
4
# It is a nice day. Let's get start # @Author : Boya # @Time : 27/04/2020 15.00 """ 多态:一类事物有多种形态 多态性: """ from abc import ABCMeta, abstractmethod class Animal: def run(self): raise AttributeError("子类必须实现这个方法") class Person(Animal): #pass def run(self): print("人走") class Pig(Animal): ...
26d781961bd31a69ebadb0a8f1c6485cca073421
jfmam/algorithm
/taeho/baekjoon/python/easy.py
146
3.515625
4
arr = [] for _ in range(10): n = int(input()) if n % 42 not in arr: arr.append(n % 42) print(len(arr)) arr [[1,2,3,4,5]]
f3f2e56a9579fcee20fee1a86d714a91527bcf44
jamtot/BitAndBobs
/alculator/alculator.py
4,073
3.765625
4
# -*- coding: utf-8 -*- def formatted(f): return format(f, '.2f').rstrip('0').rstrip('.') class Drink(object): def __init__(self,percentage,mil_amount,cost=0.0,name="Your drink"): self.percentage = percentage self.mil_amount = mil_amount self.cost = cost self.name = name se...
e40183bb571631006bac66d7539085f3a76a0040
BiljanaPavlovic/pajton-kurs
/begginer/2. cas/zadatak2.py
248
3.78125
4
ime=input('Unesite ime:') prezime=input('Unesite prezime:') ime_i_prezime=ime+' '+prezime print(ime_i_prezime) print('Duzina imena je',len(ime)) print('Duzina prezimena je', len(prezime)) print("Duzina imena i prezimena je", len(ime_i_prezime)-1)
83c9aa119280c5221381c2efacbdc1a5699b93cd
lyqtiffany/learngit
/caiNiao/sanShiSiShi/sanShiLiuSuShu.py
399
3.578125
4
#题目:求100之内的素数。 for num in range(1,100): if num > 1: for i in range(2, num): if num % i == 0: break #break之后测试下一个num else: print(num) num = [] for i in range(2, 101): flag = 0 for j in range(1, i+1): if i % j == 0: flag += 1 i...
f8ef122d7f306fee11fd7eaf9a3e6057d7c634e0
dr-dos-ok/Code_Jam_Webscraper
/solutions_python/Problem_74/1204.py
2,667
3.828125
4
#!/usr/bin/env python import sys class b: IN = sys.stdin number = 0 @classmethod def case(cls): cls.number += 1 return 'Case #%d:' % cls.number @classmethod def line(cls, type=str): line = cls.IN.readline() return type(line.strip('\n')) @classmethod d...
fece94f1b1013b09fbd440c8fb40ab64f99d3cc1
skostic14/PA_vezbe
/vezba08/Zadatak/Zadatak/Zadatak.py
5,850
3.546875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Copyright ? 2019 pavle <pavle.portic@tilda.center> # # Distributed under terms of the BSD-3-Clause license. import base64 import random def generate_primes(start, n): ''' Generate a list of prime numbers between ``start`` and ``n`` ''' correctio...
206b65219604f085e5d7efcd9373ec28d2bb8b96
Farazulhaque/UnitConverterApp_Python
/UnitConverterApp.py
2,934
3.9375
4
while True: print() fromValue = int(input("Enter From Value : ")) fromUnit = input("Enter From Unit(in,ft,yd,mi) : ") toUnit = input("Enter To Unit(in,ft,yd,mi) : ") floatfromValue = float(fromValue) if fromUnit == toUnit: print(str(floatfromValue) + " " + fromUnit + " => " + str(fl...
1a3e87eb054b78ded2372d4e2e022c2492437c90
NaNdalal-dev/hacker-rank-problems
/easy/count_valley.py
225
3.5625
4
''' Counting Valleys: https://www.hackerrank.com/challenges/counting-valleys/problem ''' def countingValleys(n, s): v=0 valley=0 for i in s: if(i=='U'): v+=1 if(v==0): valley+=1 else: v-=1 return valley
d31ef6945e559c19a0ce08f292c9ba63d23447d8
Alin666/LeetCode-Primary
/排序-合并两个有序数组.py
1,131
3.859375
4
# 给你两个有序整数数组nums1 和 nums2,请你将 nums2 合并到nums1中,使 nums1 成为一个有序数组。 # 说明: # # 初始化nums1 和 nums2 的元素数量分别为m 和 n 。 # 你可以假设nums1有足够的空间(空间大小大于或等于m + n)来保存 nums2 中的元素。 # # 示例: # 输入: # nums1 = [1,2,3,0,0,0], m = 3 # nums2 = [2,5,6], n = 3 # # 输出:[1,2,2,3,5,6] class Solution(object): def merge_sort(self, nums1, nums...
e14baadac9235d0724be6c8e9ead8bd9e6876018
Aaron136/SPL2
/grundlagen-python.py
1,215
3.953125
4
# grundlagen-python.py # Kommentare erfolgen mit hashtag # Ausgabe von Daten print("Hello World") # Variable definieren (kann ohne Typ erfolgen) heimat = "Erde" print(heimat, "an World: ", "Hallo") # Eingabe wer = input("Und wer bist du? ") # und gibt den Text wieder aus print("Hallo", wer) if(wer == "ich"): ...
a4eb60de7aea4fc2c19c7cdfd32333ec5195053c
CaiqueSobral/PyLearning
/Code Day 1 - 10/Code Day 5 Loops/2_Avarage Height.py
344
3.75
4
student_heights = input("Input a list of student heights. ").split() sum_of_heights = 0 number_of_heights = 0 for n in range(0, len(student_heights)): student_heights[n] = int(student_heights[n]) sum_of_heights += student_heights[n] number_of_heights += 1 print("The avarage height is: " + str(round(sum_of_height...
20411fb420f8ea6086e1fd75ff76989b1e02b0a2
Philex5/Python-Learn
/Python-learn/3.Advanced_Features/列表生成式.py
681
3.640625
4
# List Comprehensions import os print(list(range(1,11))) print([x*x for x in range(1, 11)]) print([x*x for x in range(1, 20) if x % 2 == 0]) print([m+n for m in 'ABC' for n in 'XYZ']) print([d for d in os.listdir('/home/philex/SegNet')]) d = {'x':'A', 'y':'B', 'z':'C'} for k, v in d.items(): print(k+'='+v) pri...
919a267388222ccff998378d9ca7a6915cc5d403
sudarshansanjeev/Python
/xyz.py
284
3.96875
4
#i=1; #while i<=10: # print("Just for Demo: ", i); # i+=1; list1 = [11,22,33,44,55]; for item in list1 : print(item) print("--------------------"); for i in range(0,100,5): print(i); print("---------------------"); for i in range(200,0,-50): print(i);
04e6ad4e73ea9ca3a45d513284b4f855fb30e6d5
AbdeAMNR/python-training
/Lecture 05 OOP/class vs Instence Variable.py
1,364
4.15625
4
class Person(object): """ this is a static var it can be changed depends on how you access it p1.gender='Male' ==> static variable accessed via instance, change will affect to instance Object Person.gender='Male' ==> change will affect all the Instance Objects """ gender = 'female' def ...
7fedafc182fdef23eefd1d9931095ffebd1a6894
leohck/python_exercises
/EX_EstruturaDeDecisao/ex6.py
425
4
4
__author__ = 'leohck' print('>.....----- EX 6 ----.....< ') """ Faça um Programa que leia três números e mostre o maior deles. """ n=[0,0,0] for i in range(3): n[i] = int(input('digite um numero: ')) if n[0] == n[1] and n[1] == n[2]: print('os tres numeros sao iguais') elif n[0] > n[1]: if n[0]>n[2]: ...
c9dbd64d339cfb6bbb0d456a8d9e51aa4dac9391
zzh1026/MyPythonTest
/venv/src/python6mianxiangduixiang/__init__.py
1,184
4.0625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- ' 注释 ' __author__ = 'zzh' # 面向对象编程 # # 面向对象编程——Object Oriented Programming,简称OOP,是一种程序设计思想。OOP把对象作为程序的基本单元,一个对象包含了数据和操作数据的函数。 class Student(object): def __init__(self, name, score): self.name = name self.score = score def print_score(self): ...
06e4b2731ffd9eaedb56f6ff16c6bd8902e330de
menghsuann/Leetcode-Prep
/permutation.py
663
3.96875
4
#function def toString(List): return ''.join(List) def permute(a, l, r): if l == r: print toString(a) else: for i in xrange(l, r + 1): a[l], a[i] = a[i], a[l] permute(a, l + 1, r) a[l], a[i] = a[i], a[l] # backtrack string = "ABC" n = len(string) a = li...
9f5fb1f9d27b0448fbe93dbf994cd565ebed4ca6
alessandraburckhalter/Bootcamp-Exercises
/python101/06-celsius-to-fahrenheit.py
373
4.4375
4
#Task: Prompt the user for a number in degrees Celsius, and convert the value to degrees in Fahrenheit and display it to the user. print("Enter a number in degrees Celsius and you'll get the value in degrees Fahrenheit.") print("\nReady? Let's go!") celsius = float(input("\nTemperature in C? ")) #formula F = (celsi...
ccff11cbba17779a1c7874a24449a90fb5eefe2c
liamw309/PyEncrypt
/keycreater.py
1,099
4.28125
4
import random class keycreater(object): ''' This class is used to create a key for the encryption ''' def __init__(self): ''' This method helps to create the key. It creates a whole new key by appending a new list (key) and removing it from the old list (alphabet). It does this in a rand...
3dfccd60728d7b52daac886c530df3367b1b9a24
jjlis/kurs_katowice
/dzień 2/kolekcje_Zadanie4.py
249
3.546875
4
liczby = [] for i in range(101): if i % 3 == 0 or i % 5 == 0: liczby.append(i) print("liczby podzielne przez 3 lub 5") print("\n".join(map(str,liczby))) print(f"W przedziale 0-100 jest {len(liczby)}liczb podzielnych przez 3 lub 5.")
239b64ef0681a93dae9dfe164100e7815e0ffe34
samh99474/Python-Class
/pythone_classPractice/week3/Week3_Quiz_106360101謝尚泓/quiz3.py
932
3.828125
4
def main(): print("Quiz 3") lines = int(input("輸入要打的行數(奇數):")) if lines % 2 == 0: print('您輸入的不是奇數') return False """Exit import sys sys.exit(0) """ half_lines = lines // 2 + 1 # 打印上半 for i in range(half_lines): print(" " * (half_lines - i...
e47d8f47e7f01481694c995e63214c23392197f1
MatthewMoor/different
/Algorithms/quiksort.py
703
3.78125
4
import random def quicksort(arr): if len(arr) < 2: return arr else: piv = arr[0] smaller = [i for i in arr[1:] if i <= piv] greater = [i for i in arr[1:] if i > piv] return quicksort(smaller) + [piv] + quicksort(greater) array = [321, 45, 1, 52, -2, 4] print(quicksort(array)) #________________...
47a017754bd8deadfca583e7d75c8ed575bea1cd
andreiG97/100daysOfCodeDay1
/day2/ex1.py
194
4.03125
4
# adding digits two_digit_number = input("Type a two digit number: ") def adding_digits(num): a = int(num[0]) b = int(num[1]) return a + b print(adding_digits(two_digit_number))
2ab394b82db6c559ca440e9bb744e755bff59bef
reingart/python
/exercises/book-store/example.py
706
3.515625
4
BOOK_PRICE = 8 def _group_price(size): discounts = [0, .05, .1, .2, .25] if not (0 < size <= 5): raise ValueError('size must be in 1..' + len(discounts)) return BOOK_PRICE * size * (1 - discounts[size - 1]) def calculate_total(books, price_so_far=0.): if not books: return price_so_fa...
abc44dd9ade84bde56a6bed9c0314954f15029ef
juishah14/Accessing-Web-Data
/using_GeoJSON_api.py
2,988
4.03125
4
# Assignment from University of Michigan's Coursera Course Using Python to Access Web Data # For this assignment, we will use the GeoLocation Lookup API, which is modelled after the Google API, to look up universities and parse the # returned data. # The program will prompt for a location, contact a web service, a...
b91a0546c6f8a830651ceba0698663c63a4f445a
zjuzpz/Algorithms
/StrobogrammaticNumberII.py
1,644
4.15625
4
""" 247. Strobogrammatic Number II 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"]. """ # O(n^2 * 5^(n/2)) # O(n) class Solution(object): def f...
cda3d58fb901496b889fe79594a6bee56358b675
BeastTechnique/MailMaster
/pycamera.py
428
3.515625
4
import picamera from time import sleep def take_pic(): print("About to take a picture") with picamera.PiCamera() as camera: i = 0 sleep(.2) while i < 10: sleep(.1) camera.resolution = (1280, 720) camera.capture("/home/pi/Documents/cse408/images/{x}....
7f086657352cc3be9cc2be2f4e9370bfaa6167b3
imagine5am/project-euler
/p007.py
264
3.921875
4
import math def isPrime(n): for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True count = 6 number = 13 while count != 10001: number += 1 if isPrime(number): count += 1 print(str(number))
ddbbdde4555e2167c78ac8d6ca924ca92b9b6111
Ausiden/class
/line_model.py
1,167
3.765625
4
import numpy as np import matplotlib.pyplot as plt def pointplot(x,y): #画点 plt.plot(x,y,'rx',ms=5) plt.xticks(np.arange(4,9,1)) plt.yticks(np.arange(-5,15,5)) def sumcost(x,theta,y,m): #计算损失函数 c=np.dot(x,theta)-y ct=c.T return np.dot(ct,c)/(2*m) def fitpoint(x,y,m,diedai): #迭代返回最优的thet...
e4dc8b5fd2938a697029f0ca38cbf393493b908f
A432-git/Leetcode_in_python3
/946_验证栈序列.py
475
3.609375
4
# -*- coding: utf-8 -*- """ Created on Thu Sep 17 09:48:56 2020 @author: leiya """ class Solution: def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool: stack = [] start = 0 for num in pushed: stack.append(num) while stack and stack[-1] ==...
530927d35f65aa1bc8035ef577d9d4a514682ac0
picktsh/python
/code/day08/99乘法表.py
652
3.5
4
n = 9 for i in range(1, n + 1): str = '' for j in range(1, i + 1): str += '{0}×{1}={2}; '.format(j, i, i * j) print(str) # for 最简化版本 for i in range(1, 10): for j in range(1, i + 1): print('{0}×{1}={2}'.format(j, i, i * j), end=' ') print('') # for 条件退出版本 for i in range(1, 10): f...
7702aa8e8522fcb1047436023b34848137919b71
titanspeed/PDX-Code-Guild-Labs
/Python/b_jack.py
3,718
3.5
4
import random class Card: def __init__(self, suit, rank, value): self.rank = rank self.suit = suit self.value = value self.card = {} self.hidden = None def __str__(self): if self.hidden is True: return '?' else: return '{} of {}'...
a60d761eb0d9bda51048597719c81148d48e38ba
lilianeascosta/CodigosPython
/TheHuxley/Atividade07(matriz)/fabrica_de_motores.py
966
3.625
4
motores = [] aux = 0 vetor_aux = [0] * 2 custo = [] motor_resultado = [] #pega os dados da maquina for mes in range(12): aux = input().split() for i in range(2): vetor_aux[i] = int(aux[i]) motores.append(vetor_aux[:]) #pega os valores do custo e lucro for i in range(2): aux = input().split() ...
0d0fa5df6ce86574aa746ecc6fc5ed7fb64a7cfd
facingwaller/deeplearning
/rnn_lstm/lstm2.py
6,814
4.0625
4
""" Recurrent Neural Network. A Recurrent Neural Network (LSTM) implementation example using TensorFlow library. This example is using the MNIST database of handwritten digits (http://yann.lecun.com/exdb/mnist/) Links: [Long Short Term Memory](http://deeplearning.cs.cmu.edu/pdfs/Hochreiter97_lstm.pdf) [MNIST ...
2116098d9f09c344aee2638682b66d18d42c5aa0
256018/256018-MiniProject
/src/MenuAfterLogin.py
963
3.765625
4
import os import withdraw import deposit import PasswordChange def clear_screen(): # Clear Screen os.system('cls') print() # print blank line after clearing the screen def menu2(account): # account is a list of account info # account[0] id # account[1] name # account[2] password # a...
9ddc238007c87f19a2b02d7cf8cd594cb75d01c0
Nikhil14091997/Code-File
/Cracking the Coding Interview/Linked List/returnKthToLast.py
1,270
3.921875
4
# removing the duplicates from the linked list - unsorted ''' kth to last element in a linkedlist ''' class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def printList(self): temp = self....
ae6cf668cce3faf20a13ff58a233ce4690b3cf54
MrHamdulay/csc3-capstone
/examples/data/Assignment_3/kvrsha004/question3.py
651
4.03125
4
#Q1 of Assignment 3 #KVRSHA004 #Framed message message = input("Enter the message: \n") count = eval(input("Enter the message repeat count: \n")) frame = eval(input("Enter the frame thickness: \n")) endline = 0 hyphens = 2*frame for i in range(frame): print("|"*endline, "+", "-"*(len(message)+hyphens...
bcd1204ff0bab42df4fb9f172c08f060626d6272
PJHalvors/Learning_Python
/ZedEx17.py
958
3.8125
4
#!/bin/env/python """This is Zed's Learn Python the Hard Way: Exercise 17.""" #Import the class(or function, I dunno which yet) argv from module named sys from sys import argv #Import the function exists from class path within module os from os.path import exists print argv #Set variables for argv function script,...
7ce71bad195ae0d1e6d980859b258e23ea6bc56f
lucadiliello/sweep-line-algorithm-python
/examples.py
1,210
3.5625
4
import networkx as nx from matplotlib import * from pylab import * import random import itertools from SweepLineAlgorithm.geometry import Graph def generate_circuit(n_nodes, n_edges, ranges=(0,50)): if n_edges > n_nodes * (n_nodes-1)/2: # this graph cannot exists return None nodes = [(random....
d8fb46159dbb77441ca7ef91aac239f69ab1095f
Eqliphex/python-crash-course
/chapter06 - Dictionaries/exercise6.7_people.py
687
4.125
4
# Initiate 3 persons which are 3 dictionaries: person1 = { 'first_name': 'patrick', 'last_name': 'meyer', 'age': 26, 'city': 'aarhus' } person2 = { 'first_name': 'morten', 'last_name': 'struckmann', 'age': 25, 'city': 'esbjerg' } person3 = { 'first_name': 'david', 'las...
a337546bf2f37d7dd30939f986f202c28797e1c5
Infinidat/infi.clickhouse_orm
/scripts/generate_ref.py
5,151
4.28125
4
import inspect from collections import namedtuple DefaultArgSpec = namedtuple('DefaultArgSpec', 'has_default default_value') def _get_default_arg(args, defaults, arg_index): """ Method that determines if an argument has default value or not, and if yes what is the default value for the argument :param a...
cebfd2fd7cbcd53792e1326a532ae1377ce10196
s-tefan/python-exercises
/quaternions.py
1,967
3.671875
4
class Quaternion: def __init__(self, re=0, im=(0, 0, 0)): self.real = re self.imag = im def conj(self): return Quaternion(self.real, tuple(-k for k in self.imag)) def __add__(self, a): if isinstance(a, Quaternion): return Quaternion( self.real + ...
ea08392eaae3e17cf77736e78f80819005901b5c
Ekaterina-sol/Python_Basics
/hw1/hw1_1.py
662
3.875
4
first_variable = 25; second_variable = 45; sum = first_variable + second_variable print("Первое число: ",first_variable) print("Второе число: ",second_variable) print("Сумма чисел: ", sum) user_name = input("Введите ваше имя: ") user_city = input("Введите ваше место рождения: ") user_age = input("Ведите ваш возраст: ")...
1e68f91b72c2c99c735e7cfc2cd6a32e9c6bc725
sergeyuspenskyi/hillel_homeworks
/HW-13.py
300
3.921875
4
set_1 = set() for number in range(5): set_1.add(input('Put int or float number: ')) set_1 = list(set_1) min_num = set_1[0] max_num = set_1[0] for i in set_1: if min_num > i: min_num = i if max_num < i: max_num = i print('Min num = ', min_num) print('Max num = ', max_num)
8e0b0d332777037b0e55c85871c80a2b5c166727
aroraravi87/Python_ZerotoMastery
/pythonmodules/utilityhelper/utility.py
161
3.578125
4
print(__name__) def addition(num1,num2): return num1 + num2 def multiply(num1,num2): return num1 * num2 def divide(num1,num2): return num1/num2
9867203ce48e26234c889dc62ce4eade653bc0f0
hopo/cio
/01_Elementary/fizz-buzz/py-01/main.py
534
3.890625
4
def checkio(number): if number % 15 == 0: return "Fizz Buzz" elif number % 3 == 0: return "Fizz" elif number % 5 == 0: return "Buzz" return str(number) # int -> str casting if __name__ == '__main__': ex1 = checkio(15) # "Fizz Buzz", "15 is divisible by 3 and 5" print(e...
8a68f668d68eb9d479e6756a45ae4f4797c4db46
hiromzn/study-python
/sample/array_basic.py
1,343
4
4
#! /usr/bin/env python ## ## list (1D) ## l = ['apple', 100, 0.123] print( l ) ## ## list (2D) ## l_2d = [[0, 1, 2], [3, 4, 5], [6, 7, 8]] print( l_2d ) # [[0, 1, 2], [3, 4, 5], [6, 7, 8]] ## ## index ## print(l[1]) # 100 print(l_2d[1]) # [3, 4, 5] print(l_2d[1][1]) # 4 print(l[:2]) # ['apple', 100] print( "l_num =...
cfec126f664a66cf63efe47971bb11ba7eadb19b
luizdefranca/Curso-Python-IgnoranciaZero
/Aulas Python/Conteúdo das Aulas/018/Gabarito/Exercício 2 - Gabarito 2.py
435
4.28125
4
m = int(input("Digite m: ")) n = 1 for n in range(m+1): soma, cont, x, aux = 0, 1, 1, n for cont in range(n): soma = soma + 2*cont while x <= aux**3: if aux**3 == x*aux + soma: print ("O número", aux, "elevado ao cubo tem como soma: ") while aux - 1 >= 0: ...
f9f926c60bc905662c1d7d2a7abed9cf3cc35daa
NotARectangle/Honours2021
/Datatest/extractingLines.py
1,757
3.515625
4
import json import numpy as np import pandas as pd import matplotlib.pyplot as plt #To make plots for who has the most lines in the series. Coded by following # https://www.kaggle.com/zoiaran/who-has-the-most-words-and-lines-in-ds9 data = json.load(open('../Dataset/all_series_lines.json', 'r')) tng_episodes = data['...
7a1c57fe3b2148ce9f263bf6299c45482949a4e6
SmasterZheng/leetcode
/力扣刷题/1281整数的各位积和之差.py
891
3.890625
4
""" 给你一个整数 n,请你帮忙计算并返回该整数「各位数字之积」与「各位数字之和」的差。 示例 1: 输入:n = 234 输出:15 解释: 各位数之积 = 2 * 3 * 4 = 24 各位数之和 = 2 + 3 + 4 = 9 结果 = 24 - 9 = 15 示例 2: 输入:n = 4421 输出:21 解释: 各位数之积 = 4 * 4 * 2 * 1 = 32 各位数之和 = 4 + 4 + 2 + 1 = 11 结果 = 32 - 11 = 21 提示: 1 <= n <= 10^5 """ class Solution: def subtractProductAndSum(self, n): ...
091b088dbb420ac20bd9eb0bfb0336b99fb4919a
suspendisse02/Scientific_Computing_with_Python
/057_built-in_func_list.py
138
3.53125
4
num = [5, 25, 18, 4, 26, 36, 45, 85, 99, 64, 15] print(len(num)) print(max(num)) print(min(num)) print(sum(num)) print(sum(num)/len(num))
f949747256449538fe1ecdc4cd0bb87c1f28db3b
nielsdimmers/training
/HelloWorld.py
1,659
4.46875
4
# HelloWorld.py # Niels Dimmers 2021 # Shows custom message based on commandline name given or asks for name. # Requires at least python version 3 (python3) # Import system library to get version info. import sys # sys.argv contains commandline arguments, the first is the script name, the second the argument, if ther...
8410e2e0bbb28af4f0300fd9a2af9824aba55584
PriyankaKhire/ProgrammingPracticePython
/CircularQ.py
1,134
3.515625
4
#Circular Q class CircularQ(object): def __init__(self, size): self.size = size self.array = [None for i in range(size)] self.numElements = 0 # delete from head self.head = 0 # add from tail self.tail = 0 def push(self, element): if(se...
9bfdce25d300e78f8737c5bca111600bdd566bee
Dhanya1234/python-assignment-5
/assignment 4_ ro check whether given number is present in given range or not.py
136
4
4
def input(n): if n in range(3,9): print("number is in given range ",n) else: print("number is not in given range") input(6)
6b179a5428394cc5757bb0f5de114151ce8f5848
leonberlang/datasciencefundamentals
/week1-exercises/lists-snack-exercise.py
693
4.03125
4
friends = ["Henk", "Jaap", "Kees"] #, "Herman", "Jasper", "Luuk", "Steyn", "Nick" snacklist = [] for name in friends: print(name) name_length = len(name) print(str(name_length) + " characters long") snack = input(name + ", What is your fav snack?") snacklist.append(snack) index = 0 for name in friends...
c8dce913694c4449787e0626696c4941376c531c
saleed/LeetCode
/31.py
743
3.6875
4
def nextPermutation(nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ if len(nums) == 0 or len(nums) == 1: return for i in list(reversed(range(len(nums) - 1))): if nums[i] < nums[i + 1]: break if i == 0 and nu...
79a0ce0b52eb080732c4917aa1af733edb983102
kasrasadeghi/cs373
/notes/06-14.py
772
3.6875
4
# ----------- # Wed, 14 Jun # ----------- """ semantics of the operator and types in Python start exploring in detail iteration and iterables in Python """ def f (n: int) -> int : if (n <= 1) return 1 return n * f(n - 1) def f (n: int) -> int : m = 1 while (n > 0) : m *= n n -...
86482a0a66af515230d5549076c27f6fc2a3340f
sulegebedek/PG1926-Python-Problem-Sets
/TekSayiGuncelleme.py
322
3.59375
4
list=[] index = int(input("Kaç sayı gireceksiniz: ")) for i in range(index): number = list.append(int(input("sayı giriniz:"))) print("\n") print(list) print("\n") enBuyuk = list[0] for j in list: if j % 2 != 0 : if j > enBuyuk: enBuyuk = j print("En buyuk tek sayı: {}".format(enBuyuk))
71d40c8a6eb84689d230f55f2a8a1eb36e826820
liuhuipy/Algorithm-python
/tree/build-binary-tree.py
945
3.578125
4
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def buildTree(self, preorder: list, inorder: list) -> TreeNode: if not preorder: return if len(preorder) == 1: return TreeNode(preorder[0]) ...
a62937d4d557ce87c7126d17e93c6b17d38cdf50
maykooljb/pythonLearning
/areaOfASquare.py
153
4.15625
4
side = input("Enter the measure of the side of the square: "); side = int(side); area = side * side; print("the area of the square is: "); print(area);
a731106799b3a4b0e4fa9106a9c6443798cda0a9
lndaquino/data-structures-and-algorithms-using-python
/Algorithms/patternMatching.py
770
4.03125
4
''' text processing using brute force for patter matching ideia é encontrar padrão (palavra, substring etc) dentro de um texto task - buscar métodos mais otimizados, que retornem multiplas posições do padrão encontrado e pode ser escolhido em ignorar maiuscula/minuscula (por enquanto só retorna o primeiro encontrado) '...
5debfc4c3bf04df02591d6a17649ff1ff7f7f265
elYaro/Codewars-Katas-Python
/8 kyu/Abbreviate_a _Two_Word_Name.py
506
3.609375
4
''' Write a function to convert a name into initials. This kata strictly takes two words with one space in between them. The output should be two capital letters with a dot seperating them. It should look like this: Sam Harris => S.H Patrick Feeney => P.F ''' # 2nd try - after refactor def abbrevName(name): a = ...
609268778d52a688f614910101686b9b59ad53e1
dmytrov/stochasticcontrol
/code/linalg/routines.py
1,327
3.625
4
import numpy as np def lines_closest_pts(a, b, c, d): """ Returns two closest pints on the lines AB and CD, which detetermines the distance between the lines. a, b, c, d: [3] numpy vectors return: n, m: [3] numpy vectors of the closest points """ A = np.array([[(b-a).dot(b-a), -(b-a).do...
24601bd3e990284a5da3ac21758c8dc4703e8e64
hudsone8024/CTI-110
/P3LAB_Debugging_EricHudson.py
460
3.875
4
# CTI-110 # P3LAB- Debugging # Eric Hudson # 30 June 2020 # print() if score >= A_score: print("Your grade is A.") else: if score >= B_score: print("Your grade is B.") else: if score >= C_score: printL"Your grade is C.") else: if score >= D_score: print("Your grade is D.") else: print("Your grade...
570880d9ec264094d14662276b7d66847231bda8
angela-mccleery-miller/journal_list
/PYTHON/pythonAlgorithms/lists.py
424
3.90625
4
#Lists: my_list = [10,20,30, 40, 50] for i in mylist: print i #Tuples: my_tup = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) for i in my_tup: print i #Dict (is a hash-table): my_dict = {'name': 'Bronx', 'age': '2', 'occupation': "Corey's Dog"} for key, val in my_dict.iteritems(): print("My {} is {}". f...
d6ffcf69483c1b4ee356b7609360b1cee2343609
amberbeymer/Beymer_story
/acute.py
175
3.765625
4
pyth_diff = a[2]**2 - (b[0]**2 + c[1]**2) if (pyth_diff > 0): print("Triangle is obtuse") elif (pyth_diff == 0): print("Triangle is right") else: print("Triangle is acute")
032b70ce15e6fd882f76e5417b3f86c6fab16d39
whchoi78/python
/wiget.py
752
3.984375
4
from tkinter import* window = Tk() window.title("hello") """ bt1 = Button(window, text="버튼1") bt2 = Button(window, text="버튼2") bt3 = Button(window, text="버튼3") bt1.pack(side=LEFT) #LEFT, TOP, BOTTON bt2.pack(side=LEFT) bt3.pack(side=LEFT) """ bt = [0,0,0] for i in range(3): bt[i] = Button(window, text="버튼"+str(i...
1a87fe4f117a6cd3900332cda0d1d6248ce73969
Ubivius/art-assets
/pixel_art_generator/utils.py
1,202
3.78125
4
import math import numpy as np from logger import logger def euclidean_distance(row1, row2): """ Method that process the Euclidean distance between two vectors :param row1: First vector :param row2: Second vector :return: Euclidean distance """ #distance = 0.0 #for i in range(len(row1)-1)...
6420c7ed1cb229e10351662a234f8bd17b82ffda
EugeneStill/PythonCodeChallenges
/archive/findTheDuplicate.py
284
3.78125
4
def find_the_duplicate(l1): l1.sort() for i in range(1, len(l1)): if l1[i] == l1[i-1]: return l1[i] return None print(find_the_duplicate([1,2,1,4,3,12])) # 1 print(find_the_duplicate([6,1,9,5,3,4,9])) # 9 print(find_the_duplicate([2,1,3,4])) # None
4cb72c150ceb29c83616792951b5835837908b9c
ritallopes/Cifras
/Vigenere/vigenere.py
861
3.671875
4
alphabet = "abcdefghijklmnopqrstuvwxyz" chave = "ipanema" def searchPosition(ch): ''' Funcao para buscar posicao do caracter no alfabeto definido O(n), onde n e a posicao de ch no alfabeto :param char ch - caracter a ser procurado no alfabeto ''' for i in range(0,len(alphabet)): if alphabet[i] == ch: return...
e8ebec7a4cb5fa70a98fa797f1ee9e5e966fa1cb
lalitzz/DS
/Sequence5/CTCI/1-Array_String/9string_rotation.py
828
3.640625
4
def is_rotation(s1, s2): if len(s1) == 0 or len(s1) != len(s2): return False s1 = s1 + s1 return _is_substring(s1, s2) def _is_substring(s1, s2): return kmp_pattern(s2, s1) def kmp_pattern(pattern, text): print(pattern, text) S = pattern + '$' + text s = compute_prefix(S) result = [] for i in ra...
f40179770b686b5551b49121c51dfe5a4886133f
ashwin-suresh-kumar/Python-Programs
/TikTacToe.py
5,786
3.75
4
''' Created on Dec 22, 2015 @author: Ashwin Suresh Kumar ''' from random import randint first_row = ['NA']*3 second_row = ['NA']*3 third_row = ['NA']*3 flag_p1 = 0 #flag_p2 = 0 def print_board(): global first_row global second_row global third_row print "\n" print "%s | %s | %s" %(first_row[0],...
dcd5a152a34ec17fd522f354d87a8c188c265df8
luitzenhietkamp/cs50
/pset6/caesar/caesar.py
564
4.09375
4
import sys from cs50 import get_string # ensure proper usage if not len(sys.argv) == 2: print("Usage: python caesar.py k") sys.exit(1) key = int(sys.argv[1]) # prompt user for input message = get_string("plaintext: ") # encrypt the message ciphertext = "" for c in message: if c.isupper(): cipher...
a18b3d4c900b760226169f4a0a70f020c9e3854b
doyoonkim3312/PythonPractice
/Exercise/Math Quiz/math_quiz.py
1,132
4.34375
4
############################################################################### # Author: Doyoon Kim (kim3312@purdue.edu) # Date: Mar 19, 2021 # Description This program generate simple math question about adding two digit # number and three digit number. ################################################################...
7fa07c1f85ae18d21c70726cf2cdf2544bf6d883
Sana-mohd/log_in-and-sign_up
/sign_up_if-else.py
1,612
4.03125
4
user_ans=input("enter either log in or sign up: ") if user_ans=="sign up": user_name=input("enter your user name: ") i=1 list=["0","1","2","3","4","5","6","7","8","9"] while i<2: password=input("enter your password: ") a=0 b=0 c=0 for x in password: if...
275a4a57f4fa9151c3288e15cee4b89a325648e4
PavleMatijasevic/PPJ
/vezbanje/vezbanje/automat1.py
573
3.5625
4
import sys stanje = 'A' zavrsno = 'D' prelaz = {('A', 'b'):'B', ('A', 'c'):'CE', ('B', 'b'):'D', ('CE','a'):'CE', ('CE', 'b'):'D'} while True: try: print("Unesi a ili b ili c\n") c = input() if(c != 'a' and c != 'b' and c != 'c'): sys.exit("Pogresan unos!\n") ...
14b3292f4ae4d1b246a6f10be0e5d3dfcfa64d51
karthikkosireddi-g/P-Class
/Week1/16-NestedDictionaries.py
609
3.5625
4
d1 = { "name" : "mac", "ip" : "10.20.30.40", "status" : 1 } d2 = { "name" : "linux", "ip" : "10.20.30.41", "status" : 3 } d = { "d1": { "name": "mac", "ip": "10.20.30.40", "status": 1 }, "d2" : { "name": "linux", "ip": "10.20.30.41", ...
82cd462f5d8b5b34947b7f3818045420b5ac8826
darraes/coding_questions
/v2/_leet_code_/0142_detect_cycle.py
1,123
3.578125
4
class Node: def __init__(self, value, next=None): self.next = next self.value = value class Solution(object): def detectCycle(self, head): """ :type head: ListNode :rtype: bool """ node = runner = head while runner and runner.next: nod...
4189f3cb04fe930b68d6ca56412c3bfac7eedbad
aquibali01/100DaysOfCode-
/Day10/day-10-start/main.py
452
4.28125
4
# function with outputs def format_name(f_name,l_name): """Take first and last name and format it to title format""" #docstring if f_name == "" or l_name == "": return "You didn't provide valid inputs" title_name = f_name.title() + " "+l_name.title() return title_name #return tells the computer the functio...
67a80cf89f7624c14ba84a6d41a9624e19911aa2
tylerem21/isat340_miniproject
/Retrieve member data.py
287
4.03125
4
#Retrieve Data import sqlite3 conn=sqlite3.connect("celebrities.db") cursor=conn.cursor() #SQL SELECT statement sql2="select * from members" cursor.execute(sql2) #get the rows rows=cursor.fetchall() #iterate over the results and print them for row in rows: print(row) conn.close()
2939271b1447cc74e6020193f567c591b4d0a17f
ranasalman3838/pythonpractice
/Day7.py
1,793
4.25
4
# class Dog: # def __init__(self, name, age): # self.name = name # self.age = age # # def bark(self): # print(f"{self.name} is barking") # # def age(self): # print(f"{self.name} age is {self.age}") # # # dog1 = Dog('German Shepherd', 4) # print(f'{dog1.age}') # dog1.bark() #...
48cfb8843839d33e4ee9a02936abc856c8843909
haseeb33/Book-Store
/intermediate.py
2,106
3.96875
4
""" A program that store this book information: Backend functionaltiy Creating the db file attaching the functions with buttons """ from back_end import Database import front_end as fe from tkinter import * db = Database("books.db") #When the app starts creating the book table in books.db def view_command(): f...
5bf9ad5a9c79697216da9ab6aaf4b1f2ae14dc54
tl1759/FinalProject_PDS
/map/userinput.py
1,031
3.515625
4
#################################################################################################### # # # Author : Liwen Tian(tl1759) # DS GA 1007 # Final Project # # This is the users input module. # #################################################################################################### import csv import...
cef919c306f8f9d250e0df226da3b3f2e479edeb
Jace-Yang/ml-algorithms-built-from-scratch
/model_Neural Network/models/NeuralNetwork.py
4,710
3.53125
4
# !!! 请先阅读 代码文档.pdf 中模型的建立、求解和逐步讲解。 # 作者:吴宇翀 经济统计学 2017310836 https://wuyuchong.com # 代码开源托管在 https://github.com/wuyuchong/DataMining/tree/master/HomeWork # ----------------- 导入基本模块 ----------------- import numpy as np import math from matplotlib import pyplot as plt # ------------ 导入source中定义的函数 ------------ fr...
9bda55e43a80dfe4630693922c7ab7b99c567d82
himanshu2922t/FSDP_2019
/DAY-02/operation.py
1,027
3.9375
4
# -*- coding: utf-8 -*- """ Created on Tue Jun 4 15:05:54 2019 @author: Himanshu Rathore """ number_list = input("Enter a space separated list of numbers: ").split() def Add(): sum = 0 for number in number_list: sum += int(number) return sum def Multiply(): product = 0 for number in num...
209dac495d5033c27d1e80b8d413321ea9cd435e
UCGD/PFB2019-Walkthrough
/ProblemSet4/problem4.8-9.py
126
3.71875
4
#!/usr/bin/env python3 for x in range(1,101): print(x) ## same using list comprehension [print(x) for x in range(1,101)]
8e54e5b63fdac43fa0e0d386ce2d93926d821ae9
nabilatajrin/MITx-6.00.1x-IntroductionToComputerScienceAndProgrammingUsingPython
/wk03-structured-types/tuples-and-lists/exercise/exercise-04**.py
601
3.90625
4
aList = [0, 1, 2, 3, 4, 5] bList = aList aList[2] = 'hello' print(aList) print(bList) print(aList == bList) print(aList is bList) cList = [6, 5, 4, 3, 2] dList = [] for num in cList: dList.append(num) print(cList) print(dList) print(cList == dList) print(cList is dList) """Python has the two comparison operat...
70ca306e2928e770b11ee5f2e7a3e05cc86218dd
shiv125/Competetive_Programming
/codechef/JUNE17/correct.py
1,764
3.6875
4
def sieve(MAX,all_primes): prime=[True for i in range(MAX+1)] p=2 while p*p<=MAX: if prime[p]==True: for i in range(p*2,MAX+1,p): prime[i]=False p+=1 for p in range(2,MAX): if prime[p]==True: all_primes.append(p) def binarysearchfloor(arr,low,high,x): mid=0 while low<=high: if low>high: retu...
0db71e1e42f548c5155829ebc14b1dcf419565c4
BigThingisComing/baekjoon
/17413.py
489
3.625
4
import sys input = sys.stdin.readline string = input().rstrip() tmp = '' result = '' tag_tf = False for chari in string: if tag_tf == False: if chari == '<': tag_tf = True tmp = tmp + chari elif chari == ' ': tmp = tmp + chari result = result + tmp tmp = '' else: tm...
17c4c7d94200a1afcd9715bedf7ae9e139031568
Protogenoi/CoreySchafer
/For Beginners/Dictionaries.py
1,057
4.21875
4
student = {'name': 'John', 'age': 25, 'courses': ['Math', 'Gym']} print(student) print(student['name']) print(student['courses']) # Get will return None instead of a error in the key pair value is not found print(student.get('name')) print(student.get('phone')) print(student.get('phone', 'Not Found')) print('-----U...
59f5763b49045c4d5ab2333f281bc5f92f5ee5a7
rishikakrishna/CIS210
/ii_3.py
421
3.71875
4
# Place fingers on first and last letter s = (input) left = 0 right = len(s) - 1; while left < right: if s[left] != s[right]: return False #SyntaxError: 'return' outside fxn #Move fingers towards the center left = left +1 right - right -1 return True #At each step, s is the portion between fingers while len(...
8323dae7fe35af2530c7c9d805f2344b36c74ee0
mpayalal/Talleres
/TalleresDatos/Taller1/punto6Taller.py
315
4.125
4
def invertirNumero(num, indice = 0): if(indice == len(num)-1): return(num[indice]) else: return(invertirNumero(num, indice+1) + num[indice]) numero = input("Ingrese el número que desea invertir: ") numInv = invertirNumero(numero) print("El número invertido es:", numInv)
93f9ab58a463765405b3891375d502892329ba8c
SebastianTuesta/6.0001
/EDX VERSION/Middle Term Exam/p6.py
317
4
4
# -*- coding: utf-8 -*- """ Created on Mon Dec 18 16:58:20 2017 @author: Sebastian """ # Paste your code here def gcd(a, b): """ a, b: two positive integers Returns the greatest common divisor of a and b """ #YOUR CODE HERE if b==0: return a else: return gcd(b,a%b)
4427866df74bd2ce04ed61177b7e724cda05aa2c
daniel-reich/ubiquitous-fiesta
/EjjBGn7hkmhgxqJej_18.py
102
3.671875
4
def word_nest(word, nest): c=0 while nest: nest=nest.replace(word,'') c+=1 return c-1