blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a9f4c5a776e6442e5b1e240630fb275f6c8b1334
VinhMaiVy/learning-python
/src/Algorithms/00 Implementation/py_life_the_universe.py
205
3.71875
4
#!/bin/python3 """ Python Input: Output: """ if __name__ == '__main__': while True: n = int(input()) if n == 42: break else: print(n)
6e4e764da06516d76a4a4596995109c8c222da54
GabrielReira/Python-Exercises
/05 - Reajuste salarial.py
207
3.5
4
s = float(input('Digite o salário atual: R$')) r = float(input('Digite a porcentagem de reajuste: ')) novo = s + s * (r / 100) print(f'Com o reajuste de {r}%, o funcionário passa a receber R${novo:.2f}.')
73fca4bc332ba4b3ef040785a934cfcf5e0e01d0
zaifrun/ml
/firstflow.py
2,551
3.515625
4
import tensorflow as tf import matplotlib.pyplot as plt from datetime import datetime def log_scalar(writer, tag, value, step): """Log a scalar variable. Parameter ---------- tag : basestring Name of the scalar value step : int training iteration """ summary = tf.Summar...
a2964f768434fc37556885e266a15fbd0d63933b
FatemaFawzy/Text-Segmentation
/Preprocessing.py
1,221
3.609375
4
import pandas as pd import re #Reading dataset from file. Covert all to lowercase df= pd.read_csv("sets\RandomSentencesDS.csv", error_bad_lines=False)['text'].dropna().str.lower() #remove special characters by replacing them with an empty string. Keep letters, hyphens, and white space only filtered_data= df.apply(lam...
aac6eef18a908e4c625d00ebbfe8b097cbdbd4f0
YerraboluHimajaReddy/LalithaClass
/LalithaPythonClass/AdvancedDatatypes/Set Difference.py
226
3.578125
4
# Difference of two sets # initialize A and B A = {1, 2, 3, 4, 5} B = {4, 5, 6, 7, 8} # use - operator on A print(A - B) #{1, 2, 3} print(B - A) #{8, 6, 7} print(A.difference(B)) #{1, 2, 3} print(B.difference(A)) #{8, 6, 7}
c6f1407abc3c12e2455b1cc75e3cc0c1b11513f5
ATOME1/arithmetic_exercise
/python-test/test_tmp.py
904
3.875
4
from day02.MergeSort import * from day02.QuickSort import * # 生成一组随机数组 def generateRandomArray(maxSize, maxValue): return [random.randint(0, maxValue) for i in range(maxSize)] # 默认排序方式 def comparator(arr): arr.sort() # 使用对数器的方式检测排序是否ok if __name__ == '__main__': testTimes = 10000 maxSize = 100 ...
aa664c3e1d41d17349386d3a84a99deda7ea0450
soo-youngJun/pyworks
/exercise/test04.py
1,146
4.15625
4
# 1번 ''' def is_odd(number): if number % 2 == 1: return True else: return False print(is_odd(8)) # 2번 def avr_number(*args): result = 0 for i in args: result += i print(i, result) return result / len(args) print(avr_number(1, 2)) print(avr_number(3,2,5,4,1)) # 3번...
fb2f26df768c504916e619ef9c97bae006d65594
oota030114/kadai
/study-01-search-main/03_search.py
1,498
3.6875
4
import csv import os # 検索ソース source=["ねずこ","たんじろう","きょうじゅろう","ぎゆう","げんや","かなお","ぜんいつ"] source_b=["ねずこ","たんじろう","きょうじゅろう","ぎゆう","げんや","かなお","ぜんいつ"] ### csv読込み def readCSV(csvFile): if os.path.exists(csvFile): with open(csvFile) as f: listCSV = f.read() f.close() ...
38bd73a417ec268a652588f27f40be4f20b0fd73
willamesalmeida/Maratona-Datascience
/Semana 1 - O poderoso Python/fase 2 - Exercicios/Estruruda de Decisão/Exercicio 1.py
290
4.03125
4
# 1 - Faça um Programa que peça dois números e imprima o maior deles. a, b = map(float, input("Forneça dois valores e direi qual o maior deles: ").split()) if a > b: print("O maior número fornecido é: {} ".format(a)) else: print("O maior número fornecido é: {} ".format(b))
8fcbf0368bfb57f4f5d6c14ed67466b0e54b7213
bansal19/SfM_implementation
/DLT/direct_linear_transform.py
3,137
3.765625
4
import numpy as np import funcs def normalize_and_make_homogeneous(x_unnormalized): """Modify x_unnormalized to normalize the vector according to standard DLT methods and make homogeneous. Normalization is used to stabilize calculation of DLT x_unnormalized: 3 or 2 dimensional input data to be normalized ...
e4b68f6d90fd950a6342c20605ec1a8fc6e0afa4
Podakov4/pyCharm
/module_3/lesson_6.py
448
3.6875
4
# Задача 6. Игра в кубики cube_of_Kostia = int(input('Кубик Кости: ')) cube_of_owner = int(input('Кубик Владельца: ')) if cube_of_Kostia >= cube_of_owner: kostia_pay = cube_of_Kostia - cube_of_owner print('Сумма:', kostia_pay) print('Костя платит') else: owner_pay = cube_of_Kostia + cube_of_owner ...
2027b70382c76671c01d729ba75024a015f3d7fc
MinWooPark-dotcom/learn-pandas
/Part2/2.10_excewriter.py
1,456
3.734375
4
# -*- coding: utf-8 -*- import pandas as pd # 판다스 DataFrame() 함수로 데이터프레임 변환. 변수 df1, df2에 저장 data1 = {'name': ['Jerry', 'Riah', 'Paul'], 'algol': ["A", "A+", "B"], 'basic': ["C", "B", "B+"], 'c++': ["B+", "C", "C+"]} data2 = {'c0': [1, 2, 3], 'c1': [4, 5, 6], ...
71614977e3e2bc4c1f5bf9f493e170b2bda2d9df
pawel123789/practice
/31.py
132
3.59375
4
a = 120 b = 150 for n in range(1, 121): if a / n is int and b / n is int: print(n) else: print('co jest?')
24d60afed921cc62828d98b87050fbd956f69b39
hudhaifahz/LING447
/ClassWork/newfriend.py
158
3.890625
4
name = 'Emma' number = 3 #print ('My new friend is ',name,' who speaks ',number,' languages.') print 'My new friend is',name,'who speaks',number,'languages.'
af03a1f0bc4dbe3c6c50828c3176ddc1903f614f
ZuuVOKUN/Python_learning
/PycharmProjects/hillel_python/src/sample_lists.py
423
3.921875
4
import random a = ['a', 'b', 'c'] b = ['a', 2, 'c', [0, 10, [4, 'z']]] # # print(type(a)) # print(type(b)) # print(b[0]) # print(b[0:2]) # print(len(b)) # # for i in range(len(b)): # print(b[i]) # # print(b[3][2][1]) n = 3 random_list = [] for i in range(n+1): random_list.append(random.random()) print(ran...
aae067d02ddea0f028d42ad2689e2de69d2a254c
yyyuaaaan/pythonfirst
/crk/1.5h.py
1,559
3.796875
4
""" __author__ = 'anyu' Implement a method to perform basic string compression using the counts of repeated characters aabcccccaa would become a2blc5a3. do nothing if this would not make the string smaller. """ def str_compress(strinput): """ very tricky question, border conditions, be careful 0(N) time ...
ba0fe41d8ca02223d6d09ce232bc16449a0616d9
stahl/adventofcode
/2017/day10/b.py
746
3.53125
4
from functools import reduce from operator import xor def rotate(lst, i): """Rotates the list lst i steps to the left.""" lst[:] = lst[i:] + lst[:i] s = '106,16,254,226,55,2,1,166,177,247,93,0,255,228,60,36' lengths = [ord(x) for x in s] + [17, 31, 73, 47, 23] xs = list(range(256)) pos = 0 skip = 0 for r i...
e905060f51c26c112e52bb6dd8d25dd17af56b34
ellyzyaory/Exercise-1-Part-2
/studentgroups.py
921
4
4
class1 = 32 class2 = 45 class3 = 51 print("Number of students in each group: ") class1_group = int(input("Class 1: ")) while class1_group <= 0: class1_group = int(input("Class 1: ")) class2_group = int(input("Class 2: ")) while class2_group <= 0: class2_group = int(input("Class 2: ")) class3_group = int(input...
7d8811709dbee2e2e71ae3b88a06a53be2c461b5
JavierFSS/MySchoolProject
/URI_Online/1019.py
195
3.5625
4
totalWaktu = int(input()) Jumlah = [3600, 60, 1] hasil = [] for item in Jumlah : jumlah2 = (totalWaktu / item) hasil.append(str(jumlah2)) totalWaktu -= item * jumlah2 print(":".join(hasil))
20ac203a74026648339d8417538c6abb15a53979
AlexKohanim/ICPC
/ostgotska.py
212
3.53125
4
s = input() #print((len([x for x in s.split() if "ae" in x]),len(s.split()))) print("dae ae ju traeligt va" if (len([x for x in s.split() if "ae" in x]) / len(s.split())) >= 0.4 else "haer talar vi rikssvenska")
c40df77c0c92769521cee63e11f92e29ea41f7f8
SarveshSiddha/Demo-repo
/assignment1/palindrome.py
195
4.03125
4
a=int(input("enter the number")) demo=a rev=0 while(a>0): dig=a%10 rev=rev*10+dig a=a//10 if(demo==rev): print("number is palindrome") else: print("number is not palindrome")
111f515714aa14ba964fee38c3c488ced6952a2c
mrblack10/tamrin
/jadi/azmon3_3.py
210
3.78125
4
n = input() n = int(n) x = 1 a = 1 while (x>0): ###### for i in range(1,x+1): print("*",end ='') x = x + a print("") ###### or -> print("*" * x) if x == n: a = -1
0a9ef68cd9050e3e72c4d48779c1272934e8bf2b
Ishita-Tiwari/Dynamic-Programming
/14. Shortest Common SuperSequence.py
605
3.609375
4
def shortestCommonSupersequence(s1, s2, n1, n2): dp = [[0 for i in range(n2 + 1)] for j in range(n1 + 1)] ''' Length of shortest common supersequence: max possible length - length of max common subsequence ''' for i in range(1, n1 + 1): for j in range(1, n2 + 1): if s1[i - 1...
29e34f165d7df8b23589360b0c0ecf8cde7ab38e
junhao69535/pycookbook
/chapter3/round_of_digits.py
554
3.765625
4
#!coding=utf-8 """ 数字的四舍五入 """ # 想对浮点数执行指定精度的舍入运算 # 对于简单的舍入运算,使用内置的round(value, ndigits)即可 print round(1.23, 1) # 保留一位 print round(1.27, 1) # 会进行四舍五入 print round(-1.27, 1) print round(1.25361, 3) # 保留三位 # 传给ndigits参数可以是负数,这时,舍入运算会作用在十位、百位、千位等上面 a = 1627731 print round(a, -1) print round(a, -2) print round(a, ...
40a6074b2cef8de13b43327a90c9e28ac3d61cc9
alvaronaschez/amazon
/basics/knapsack_01.py
1,530
4.1875
4
""" https://rosettacode.org/wiki/Knapsack_problem/0-1 https://rosettacode.org/wiki/Knapsack_problem """ import unittest from math import inf def knapsack_01(weights, values, max_weight): """ dynamic programming algorithm based on the following recursive definition: knapsack(i, w) = -inf if w<0 kn...
eb0b73df3629688a2cfeb7c274987a1d5c2a765f
yipcrystalp/Tech-Basics-1
/greet.py
537
3.828125
4
#define 'greet()' def greet(): print ("Hey there!") name = raw_input("Please type your name: ") print ("Nice to meet you " + name) country = raw_input("So where are you from? ") print ("Interesting, so you're from " + country) print ("I'd love to visit there someday! :)") choice = raw_i...
c6bc53ecd6e7f994b9ad5a87e37fc8a467e4ccc5
LStokes96/Python
/Code/ISBN.py
273
3.6875
4
def isbn(digits): digit_list = list(map(int, str(digits))) print(digit_list) isbn = [9,7,8,0,3,0,6,4,0,6,1,5] even = sum(isbn[::2]) * 3 odd = sum(isbn[1::2]) total = even + odd last_digit = 10-(total/10) print(int(last_digit)) print(even) print(odd) isbn(12345)
782288b5640350abc23e5442fcf3544537835c54
sp0002/cp2019
/p03/q6_display_matrix.py
202
3.921875
4
from random import randint def print_matrix(n): for i in range(1,n+1): for p in range(1, n+1): print("{} ".format(randint(0, 1)), end="") print(" ") print_matrix(int(input("Input number: ")))
844c00ef3d28df6d115cbc095c5781cc2ae6e708
packerbacker8/PythonNeuralNetwork
/SimplePerceptron/training.py
761
3.515625
4
from random import uniform def line_func(x): # y = mx + b return 0.3 * x + 0.2 class Point: def __init__(self, x = None, y=None, size = 8): if x is None: self.x = uniform(-1,1) else: self.x = x if y is None: self.y = uniform(-1,1) else: ...
38dd117c3e56885018d2cab408aa2a49d3731e42
sensve/ClientServer
/Server/Server.py
882
3.53125
4
import socket # Set the server address SERVER_ADDRESS = ('127.0.0.1', 5000) # Configure the socket server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.bind(SERVER_ADDRESS) server_socket.listen(10) print('[server]: server is running, please, press ctrl+c to stop') # Listen to requests whi...
4f2f828c09c55be980b888f05a0d951aa06e67da
JiahangGu/leetcode
/All Problems/1584-min-cost-to-connect-all-points.py
2,285
3.546875
4
#!/usr/bin/env python # encoding: utf-8 # @Time:2020/9/15 9:57 # @Author:JiahangGu from typing import List class Solution: def minCostConnectPoints(self, points: List[List[int]]) -> int: """ 大体思路是,首先构造出一个全联通图,然后得到最小生成树。 :param points: :return: """ class Node: ...
2cdcba478f1478c548573b047c36c58da40dd20c
tjschweitzer/CSCI136
/Homework3/2-1-2.py
219
3.921875
4
def odd(a,b,c): count = 0 if a: count+=1 if b: count+=1 if c: count+=1 if count%2: return True else: return False #test code #print(odd(False,False,True))
4f04948364a224ef475d037bac5948c2675fb327
dedx/3DTracker
/SpacePoint.py
1,180
4.15625
4
########################################### # # Class defining a SpacePoint # # J.L. Klay # 14-May-2012 # ########################################### import math class SpacePoint(object): """represents a point in 3-D space in cartesian coordinates in centimeters""" def __init__(self,x=0.0,y=0.0,z=0....
c5f9e38a9f3ba0081b5e8ae96cdf281044d7630e
songzi00/python
/Pro/基础/02数据类型/列表.py
1,363
3.953125
4
""" #获取列表的平均值 list = [12,34,56,87,23] n1 = 0 n2 = 0 while n1 < 3: n2 += list[n1] n1 += 1 print("平均值 = %d" % (n2 / 5)) list3 = [1,2,3,4] print(3 in list3) list5 = [1,2,3,4,5,6,7,8,9] print(list5[2:5]) list6 = [1,2,3,4,5,6] list6.insert(3,280) print(list6) list7 = [1,2,3,4,5,6,7] print(list7.pop(2)) list...
c894dd00e23346434c848955febabe70ff5c731b
Nickruti/Automation
/Input_data_from_file.py
231
3.71875
4
import itertools with open("input.txt") as textfile1, open("input.txt") as textfile2: for x, y in itertools.zip_longest(textfile1, textfile2): x = x.strip() y = y.strip() print("{0}\t{1}".format(x, y))
54b352c358a6384bbb9cec5dffea7bfb378a2439
MDomanski-dev/MDomanski_projects
/Python_Crash_Course_Eric_Matthes/keys.py
541
3.5625
4
favourite_lang = { 'janek': 'python', 'sara': 'c', 'edward': 'ruby', 'paweł': 'python', } friends = ['edward','sara'] for imie in favourite_lang.keys(): print(imie.title()) if imie in friends: print("Witaj, " + imie.title() + "! Widzę, że twoim ulubiony" " językiem programowania jest " + favourite_lang[imie]...
dc40642e002eea4b1dd358080949bca6667575d7
zzhyzzh/Leetcode
/leetcode-algorithms/101. Symmetric Tree/isSymmetric.py
1,249
3.890625
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isSymmetric(self, root): """ :type root: TreeNode :rtype: bool """ if not root: r...
81eb4f2dcbbd12985f98475ac0ba537463083e03
Weeeendi/Python
/类(Dog,Car,Restaurant).py
5,297
4.09375
4
#!/usr/bin/env python # coding: utf-8 # # 类 # ## 创建和使用类 # 与C++的类雷同,都是面向对象编程 # ### 创建Dog类 # In[8]: #dog.py class Dog(): """The attempt to simulate a puppy""" def __init__(self,name,age): """Initialization function""" self.name = name self.age =age def sit(self):...
53f2f7b11acad8a6713ea2daec946b551aeb3c96
abdullahmehboob20s/Python-learning
/chapter-12-advanced-python/9-enumerate.py
179
3.8125
4
import os os.system("cls") # if you want to access the "index" in for loop list1 = [3,12,32,True,"abdullah mehboob"] for index,item in enumerate(list1) : print(f"{index+1}) {item}")
a34841d403c7efcf789f73e5f0e1c9ab0295271d
RaviPrakashMP/Python-programming-practise
/S01Q01.py
65
3.703125
4
name = input("Enter the user name:") print("Hello",name,"!!!")
2c9a7484835e765d1a96d0358e7c5d40dab48512
nikhilsanghi/CNN_Codes
/Keras_Tutorial_v2a.py
15,970
4.03125
4
# coding: utf-8 # # Keras tutorial - Emotion Detection in Images of Faces # # Welcome to the first assignment of week 2. In this assignment, you will: # 1. Learn to use Keras, a high-level neural networks API (programming framework), written in Python and capable of running on top of several lower-level frameworks i...
8dba0d63ed7ab6023c248297d43650eaa758a36f
ShamanKNG/Wizualizacja-Danych
/Lista10/4.py
314
3.640625
4
import matplotlib.pyplot as plt import numpy as np x = np.arange(1, 31, 0.1) plt.plot(x,np.sin(-x),"orange", label='sin(x)') plt.plot(x,np.sin(x)+2,"blue", label='sin(x)') plt.axis([1, 31, -1.5, 3.5]) plt.xlabel('x') plt.ylabel('sin(x)') plt.title("Sinus i Sinus") plt.legend() plt.grid() plt.show()
10b030c17ce0099a259d6f468aefa307d01f15d9
Shilpa-T/Python
/pythonprog/removeduplicate.py
1,136
3.90625
4
""" Given an array of integers, 1 <= a[i] <=n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear twice in this array. """ def removeDuplicates(nums): """ this function returns list of duplicate delement :param nums: :return: list of duplicate el...
583fe103b6fa2e7c76aeec03b2e47460f07a91a8
fawwazbf24/Tutorial-python-mongga
/tutorial2.py
427
3.859375
4
#Fawwaz Byru Fitrianto #program tutorial angka dan boolean #2-11-2020 import math a=24 b=24.5 print(type(a)) a=float(a) print(a) print(type(a)) print() b=int(b) print(b) print() c=a/b print(int(c)) print(a is b) print(a == b) print() counter=0 string = "saya suka kue coklat" print("saya" in string) for f in strin...
8e707074646e76b014a965160726b353ecad0d0f
imalikova/PythonLearn
/MODULE 1/What time is it?.py
412
4.15625
4
input_time = int(input("What time is it? ")) if input_time > 0 and input_time <= 3: print("Good night") elif input_time > 3 and input_time < 12: print("Good morning") elif input_time >= 12 and input_time <= 16: print("Good afternoon") elif input_time > 16 and input_time <= 24: print("Good evening") ...
dbb58953c8a20c20c2f6ccf796a2cd29595515fe
Leonardo612/Entra21_Leonardo
/Aula04/exercicios/print/exercicio02.py
256
3.5
4
# Exercicio 2 # # Imprima o menu de uma aplicação de cadastro de pessoas # # O menu deve conter as opções de Cadastrar, Alterar, listar pessoas, alem da opção sair print("Cadastrar: ") print("Alterar: ") print("Listar pessoas: ") print("Sair")
c6cfe916d73b73c2f9a82c5b74dd2fd170b1c0c6
FernCarrera/Localization
/test_study.py
511
3.6875
4
import study import unittest import numpy as np class TestStudy(unittest.TestCase): def test_normalize_angle(self): test_num = 3*np.pi value = study.normalize_angle(test_num) # about 370deg #while test_num > np.pi: # test_num -= 2.0*np.pi test_num = test_num ...
023d33682cc14cf1917b0f0c2ab9169b264879df
kartikhans/competitiveProgramming
/Number_compliment.py
207
3.65625
4
def findComplement(num): kaim=bin(num)[2:] sup="" for i in kaim: if(i=='0'): sup+='1' else: sup+='0' return(int(sup,2))
317bef442d3550f09c61d797357378244e1b107b
jawid-mirzad/inlaming
/python/pythonuppgift.py
2,252
3.796875
4
import csv print("Hej och välkommen kontakt information") Val = True Val1 = 0 while Val: Val1 = input(''' Förname [0] Eftername [1] Gmail [2] Mobilnummet [3] Födesldag [4] Välj en av talet !''') if Val1 >= "5": print("Välj ett tal mella...
9beb4384c5145d6225a29ab79ce57c44406051fd
mdmohsinalikhan/others
/ProjectEuler/94.py
652
3.640625
4
import math #340000000 perimeters = set() sums = 0 for i in range(2,340000000): if i % 10000000 == 0: print("Finished" + str(i)) if 3*i + 1 <= 1000000000: x = math.sqrt(i*i - ((i+1)/2)*((i+1)/2)) # if x == round(x): x = round(x) if (x-1)*(x-1) + ((i+1)/2)*((i+1)/2) == i*i: print("i+1: " + str(i+1) + ...
cbe86414dd78bc2223863b104c61979a9137e4d1
AaronWenYang/Principle_pf_Programming
/Assignment/Assignment_1/factorial_base.py
1,329
3.59375
4
from math import factorial as fact import sys try: A = int(input('Input a nonnegative integer :')) if A < 0: raise ValueError except ValueError: print('Incorrect input , giving up . . . ') sys.exit() copyA = A list_n = [] k = 1 n = 0 if A >0: while k in range(1,A): if fact(k) < A <...
647931178701414357995ce455e9c39907ba64c9
NAMARIKO/YasashPython_book
/Lesson5.2_1.2.3.py
301
3.5
4
""" listの基本 """ # %% # Sample_1 print("\n[Sample_1]") list = [80, 60, 22, 50, 75] print(list) # %% # Sample_2 print("\n[Sample_2]") print(list[0]) print(list[1]) print(list[3]) print("listの長さは、", len(list)) # %% # Sample_3 print("\n[Sample_3]") for item in list: print(item)
6685a451f3ee32b9aeb3f507b40b426e9f018ab0
litichevskiydv/PythonStudies
/matrix_v2.py
1,324
3.828125
4
class Matrix: def __init__(self, values): self.values = [[x for x in row] for row in values] self._rows_count = len(self.values) self._columns_count = 0 if self._rows_count == 0 \ else len(self.values[0]) def __str__(self): return '\n'.join('\t'.join(str(x) for x in...
aafa57c9e000f8a4c93b094fbe911c8717cd3cc2
alpsarigul/cardiovascular-disease-predictor
/heart_disease_predictor.py
5,207
3.671875
4
# Importing libraries import streamlit as st import pandas as pd import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import LogisticRegression import os print(os.getcwd()) os.chdir("/Users/mani/Desktop/heart-disease-predictor/app") print(os.getcwd()) # Linking the CSS file def local_css(file...
afcf2857e7c70eae703b3e124ca229a11ef576da
lingzt/PythonPractice
/week3/E5.py
520
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Mar 16 20:35:18 2017 @author: lingtoby """ def applyEachTo(L, x): result = [] for i in range(len(L)): #print(L[i](x)) l 里面是所有公式 result.append(L[i](x)) return result def square(a): return a*a def halve(a): ...
a8d1090a9cf76f9f2fc2dd1a5ccb93049a36c238
Eric-Lingren/sandboxes
/bryan-sandbox/afs-200/setup/week-1/morning/main.py
841
3.609375
4
#! Week 1 #* Overview of Python (10m) #* Walkthrough of installing and using Python with VS Code (10-15m) #* Introduction to Python variables and input/output (20m) #* Introduction to Python basic operators (arithmetic, comparison and logical) (10m) #* Introduction to if then else statements in Python (10m) #* Why ...
ccfe89c011750e1e5511eb1fcca6712fc4fcd4d8
Liam30acre/astr-119-hw-1-Liam-Thirtyacre
/variables_and_loops.py
531
4.1875
4
import numpy as np def main(): i = 0 #integer n = 10 x = 119.0 #floating point num declared w a "." # we use numpy to declare arrays quickly y = np.zeros(n,dtype=float) #declares 10 zeros as floats using np #we can iterate through the elements of y by passing an index for i in range(n): #i in range [0,...
0ef244642d3b906216e1af08b2f007015a79847e
jaquelinepeluzo/Python-Curso-em-Video
/aula06a.py
273
3.765625
4
#n1 = input('digite um valor: ') #print(type(n1)) #n2 = int(input('digite um valor: ')) #print(type(n2)) n3 = int(input('digite um número: ')) n4 = int(input('digite outro numero: ')) soma = int(n3+n4) print('a soma entre {} e {} é: {}'.format(n3, n4, soma))
e77736c228f5be996b31710ec8b3b982d1226e4d
L-omit/Python-basics
/assignment10.py
220
4.09375
4
def reverse(x): x = x[::-1] # alku ja loppuarvoja ei ole maaritelty ja koska luku on negatiivinen niin komento ::-1 tulostaa koko listan mutta menee yksi kerrallaan takaperin return x x = reverse([1,2,3,4,5]) print(x)
090fb9c46d6118bb29b11ca9c0b4d329e00526d6
RainFZY/LeetCode-Practice
/125.验证回文串.py
1,020
3.609375
4
# # @lc app=leetcode.cn id=125 lang=python3 # # [125] 验证回文串 # # @lc code=start class Solution: def isPalindrome(self, s: str) -> bool: res = "" for char in s: # 字母 if char.isalpha(): res += char.lower() # 数字 if char.isdigit(): ...
969f6558289917df5034fb88cf3435c191b72491
connergriffin/personal
/cse1284/printname.py
187
4.0625
4
# asks for name input and then displays name name = input('hello what is your name? ') # requests users input print('hello', name, 'nice to meet you') # prints their name
4fde32b356caa85f0420fbda38b877122c246c0d
Rajmeet/Python-Folder-Hack
/Main Virus.py
413
3.515625
4
import os #Creating Multiple folders def createFolder(directory): try: if not os.path.exists(directory): os.makedirs(directory) except OSError: print("Making Directory..." + directory) #Virus Creation """ i = 1 while True: if(i > 0): print("Hello") ...
45d1df16fc22ae87dd92c8b1f16c1b1b8ba17336
tomlxq/ps_py
/leetcode/test_RecursiveDemo.py
685
3.515625
4
#!/usr/bin/python # -*- coding: utf-8 -*- import unittest from RecursiveDemo import RecursiveDemo class TestRecursiveDemo(unittest.TestCase): def test_predict_the_winner(self): self.assertFalse(RecursiveDemo.PredictTheWinner(self, [1, 5, 2])) self.assertTrue(RecursiveDemo.PredictTheWinner(self, [...
bea5e73cef5008ac0c3ea82b87b0a04872632f15
aquilesC/experimentor
/experimentor/models/properties.py
13,357
3.640625
4
""" Properties ========== Every model in Experimentor has a set of properties that define their state. A camera has, for example, an exposure time, a DAQ card has a delay between data points, and an Experiment holds global parameters, such as the number of repetitions a measurement should take. In many situations, th...
81f906cf5a253e12d47f11d650288e75119fd63e
The-bug-err/ProjectEuler
/LargestPrimeFactor.py
688
4.03125
4
""" Author: Vivek Rana Usage : Just run the script in a Python enabled computer. Date : 12-Aug-2016 """ def findPrime(N): while( N%2 == 0): N = N//2 if N == 1: return 2 i = 3 sqrtN = int(N**0.5) while(i<=sqrtN and i<N): if (N%i == 0): N = N//i i = 3 ...
d143b11586c271b9d2fa10071cfb1d3f63ab380a
sunRainPenguin/Python-samples
/threeBodyGuards.py
426
3.5
4
import urllib2 import re def getHtmlPage(url): return urllib2.urlopen(urllib2.Request(url)).read() def getSmallLetters(src): matchList = re.findall('[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]',src) return ''.join(matchList) url = "http://www.pythonchallenge.com/pc/def/equality.html" page = getHtmlPage(url) rst...
df8dd163768355cf1d1e938d75aea1944d03ca10
domishana/Domi
/humanplayer.py
2,356
3.75
4
import player class HumanPlayer(player.Player): def __init__(self, game): super().__init__(game) self.isHuman = 1 def what_coin_play(self): number = int(input()) if number == -1: return -1 self.playcard(number, 'right') return False def what_act...
50a8db7185b45e85c3800aed3e7329f4abc52aac
BryanLinton/Python_Dojo
/flask/flask_fundamentals/understanding_routing/routing.py
1,247
3.953125
4
from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello World!' @app.route('/dojo') def dojo(): return 'Dojo!' @app.route('/say/<name>') def say_name(name): return 'Hi ' + name + '!' @app.route('/repeat/<i>/<word>') de...
a52075e7505651413559dac6aa1cb2d330ebc77c
archDeaconstructor/cs4660-fall-2017
/cs4660/files.py
1,326
3.640625
4
"""Files tests simple file read related operations""" import os import csv class SimpleFile(object): """SimpleFile tests using file read api to do some simple math""" def __init__(self, file_path): self.numbers = [] selfparse = csv.reader(os.path.abspath(file_path),delimiter='/') for ro...
664dd8d5bf6c1181edca5f1cc2a3a3d748d63bca
DenverRenGuy/python
/avgList.py
90
3.546875
4
a = [1,2,5,10,255,3] b = 0 for element in a: b = b + element else: print b/len(a)
a78fe3252001ad9cd51f6e0ca62c0611ceef9681
nsa5953/PythonScripts
/Building_interfaces/tk_window.py
763
4.34375
4
# Python script to building interfaces # Python script with statement to make the "tkinter" module GUI method # and attributes available from tkinter import * # Statement to call upon a constructor to create window object window = Tk() # Statement to specify a title for this window window.title('Label Example') # St...
2d81a76293ca9231d554a09a1d36b99acbad1dcd
sravyabejugam/PythonPrograms
/school_administration.py
1,347
4.0625
4
import csv def write_into_csvfile(student_info): with open("Student_info.txt",'a',newline='') as student_file: writer=csv.writer(student_file) if student_file.tell()==0: writer.writerow(["Name", "Age", "Contact_info", "E-mail_ID"]) writer.writerow(student_info) if ...
4e1c7341a0cd7a11083919d61855b6a92ee4f16c
siarhiejkresik/Epam-2019-Python-Homework
/final_task/pycalc/matcher/matcher.py
674
3.5
4
""" Matchers class. """ from collections import namedtuple from .creator import MatcherCreator Matcher = namedtuple("Matcher", ("token_type", "matcher")) class Matchers: """ Matchers is an iterable container for matchers with methods for creating matchers from literals list or regex. """ def ...
9a02fc0b5e2394b20799e75191555c5744e6c546
TianyaoHua/LeetCodeSolutions
/Palindrome Pairs.py
902
3.546875
4
class Solution(object): def palindromePairs(self, words): """ :type words: List[str] :rtype: List[List[int]] """ dict = {c:i for i,c in enumerate(words)} answer = [] for word in words: n = len(word) candidate = word[::-1] if...
e13d5076c4e6124cb916f6738ff7140b21e25fdf
L-Q-K/C4TAdHW
/Test/test7.py
158
3.9375
4
print('Hi there, this is our sequence: 1, 5, -9, 3') inte = input('So can them: ') s = 'Hi there, this is our sequence: ' + inte + ', 1, 5, -9, 3, ' print(s)
0320ef14a7d046e5165502803e94fcc796532cd9
zeeshan495/Python_programs
/DataStructures/Banking.py
2,166
3.96875
4
from Queue import * from Utility import * class Banking: global que,utility utility = Utility() que = Queue(10, 100000) print("\t***welcome to our bank***") print("first add in queue...then go for transactions :\n") def counter(): print("Enter the 1 amount to deposit \nEnter the 2 amount to withdr...
17a4945155a5cf0f8ff27d95bf8fefc42493d606
jvanarnhem/PythonBC1
/day2.py
1,987
4.09375
4
# i = 1 # while i <= 5: # what follows while must be boolean expression # print(i) # i = i + 1 # necessary to eventually terminate loop # print("Done") # # adjective = "great" # person = "Jeff" # print(f""" Can I do multiline formatted strings? # That is a {adjective} question. Please ask # {person}""") # name...
7dccfd6dece2c16aa6e456b53030eb0dd55f49ca
shills112000/django_course
/PYTHON/OBJECT_ORIENTATED_PROGRAMING/dunder.py
926
4.03125
4
#!/usr/local/bin/python3.7 # __ = double underscore called special methods or magic or dunder mylist= [1,2,3] print (len(mylist)) class Sample(): pass mysample= Sample() #len(mysample) # get error as sample has no length currently print (mysample) # get the object print (mylist) class Book(): def __in...
2b5faaa1fa8f951c7cb7f19fcbb0bfb2abec76ab
mweser/TraffICK
/MenuNavigation.py
380
3.53125
4
import sys def prompt_menu(menu_list, header=""): user_in = input(populate_menu(menu_list, header)) if user_in == 'q': sys.exit(1) return menu_list[int(user_in) - 1] def populate_menu(menu_list, header=""): output = header + "\n" i = 0 for item in menu_list: i += 1 o...
5239c228d225006722c2f4298a95c6c7e86f0784
TsukasaAoyagi/Atcoder
/beginar/0829/2.py
317
3.65625
4
n = int(input()) def has_duplicates2(seq): seen = [] unique_list = [x for x in seq if x not in seen and not seen.append(x)] return len(seq) != len(unique_list) list = [] for i in range(n): list.append(input().split()) if has_duplicates2(list)==False: print("No") else: print("Yes")
d1fadd4b0ee743bf16437bced1998f39bbff54ba
acebk/friendly-octo-potato
/my_reverse.py
118
3.6875
4
def my_reverse(l): l1=[] x=len(l)-1 while x>=0: l1.append(l[x]) x-=1 return l1
725549cf4400697308f1bc2da1bd50e7c97b3704
volrath/aigames
/graphics/utils.py
2,477
3.59375
4
from functools import wraps from math import sin, cos, pi from OpenGL.GL import * from OpenGL.GLUT import * from OpenGL.GLU import * def draw_circle(position, radius, color): """ Draw a circle in a 3d space """ glPushMatrix() glTranslatef(0.,0.,0.) glColor3f(*color) glBegin(GL_LINES) x...
3cf56fba205ee9ebba5e85944ce062b674d6418e
HersheyChocode/Python---Summer-2018
/npointstar.py
770
4.59375
5
import turtle # Allows us to use turtles wn = turtle.Screen() # Creates a playground for turtles alex = turtle.Turtle() # Create a turtle, assign to alex point = int(input("How many points do you want your star to have? Enter an odd positive integer: ")) # This is taking the input of the user and m...
d6169b8f757143bb26b79c7972e1826d6726e50a
TKSanthosh/tutorial-programme
/Specialized collection data types/defaultdict.py
226
3.96875
4
from collections import defaultdict d= defaultdict(int) d[1]="san" d[2]="tho" d[3] = "sh" print(d) print(d[4]) a={1:"san", 2:"tho", 3:"sh"} print(a[4]) #it will show error - keyError: 4 this is how it differs from defaultdict
52505735f383176e81c9a11e1ad005457d664c44
trieuhl/python-basic
/introductory/lesson2_math_operators.py
1,133
3.578125
4
if __name__ == '__main__': a = 1 b = 2 c = 3 d = 4 e = 5 f = 6 # phep cong t1 = a + b print("phep cong hai so") print(a) print(b) print(t1) print("ket qua = ", t1) # phep tru print() print("phep tru hai so") t2 = c - d print(c, "-", d, "=", t2) ...
ff72f947fa29388537bfd0ccabdc172f28569e83
Aasthaengg/IBMdataset
/Python_codes/p02422/s761969353.py
583
3.78125
4
def print_ab(s, a, b): print(s[a:b+1]) def reverse_ab(s, a, b): s_f = s[:a] s_m = s[a:b+1] s_l = s[b+1:] return s_f+s_m[::-1]+s_l def replace_ab(s, a, b, p): s_f = s[:a] s_l = s[b+1:] return s_f+p+s_l s = input() q = int(input()) for i in range(q): option = input().split() if o...
f16bebc62b17dcdeaeb820c25473d9ab2dec7bd1
Abknave/Algorithms-core
/SelectionSort.py
552
3.828125
4
def SelectionSort(l): array=[0 for i in range(len(l))] maximum=(2**32)-1 aux=0 for i in range(len(l)): pivot=l[0] for j in range(1,len(l)): if (pivot>=l[j]): pivot=l[j] aux=j array[i]=pivot...
15e376cd3adb7ba42f61f9da84dde1a0ea258bc7
eur-nl/bootcamps
/zzzzz_archive/eshcc/scripts/notjustalabel/not_just_a_label.py
3,671
3.5625
4
import sys import csv import os import requests import time from bs4 import BeautifulSoup URL = 'https://www.notjustalabel.com/designers?page=%s' DETAIL_URL = 'https://www.notjustalabel.com/designer/%s' def fetch_listing_page(page_number): url = URL % page_number print('fetching listing page %s' % page_numb...
ab09ddc84dad1409d2c908169f080089fef47c54
nabinn/DS_and_Algorithms
/SearchingAlgorithms/binary_search.py
2,080
4.1875
4
def binary_search(num_list, item): """ :param num_list: sorted list of numbers :param item: item to search :return: boolean found This takes O(log n) """ low = 0 high = len(num_list) - 1 found = False while low <= high and not found: mid = (low + high) // 2 i...
97769ca680c6bd93a831a53cfb63eb6bfc2dbda9
PaxtonCorey/First-Projects
/DiceRollingSimulator.py
951
4.34375
4
#This is my first attempt at writing a dice rolling simulator #using one six sided die import random def OneDie(roll): rollAgain="yes" while rollAgain=="yes": print("Okay, rolling!") print( "The die is " + str(random.randint(1,6))) rollAgai...
1a8a47d39b94671309319be5fe73f36e4c314a36
mu71l473d/PublicPythonScripts
/rotstring.py
1,990
3.71875
4
#!/usr/bin/python3 from itertools import product from string import ascii_lowercase as alphabet uppercase = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] lowercase = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'...
4d33ee6f48638fdd84d49015c3433fc65c625dc1
Justyouso/python_data_structure
/my_sort/shellSort.py
1,096
3.703125
4
# -*- coding: utf-8 -*- # @Author: wangchao # @Time: 19-9-3 上午10:07 def shellSort(alist): """ 功能:希尔排序,希尔排序是插入排序的变种,只需要计算出增量和开索引,再调用插入排序即可 :param alist: :return: """ # 计算增量 sublistcount = len(alist) // 2 while sublistcount > 0: # 调用插入排序 for startposition in range(sublis...
965f102c69e2cef4a7f3daf6428b3b9cf0c25644
jjcrab/code-every-day
/day25_capitalizeFirstLetter.py
650
3.53125
4
# https: // www.lintcode.com/problem/936 /?_from = ladder & fromId = 184 def capitalizesFirst(s): # s_list = list(s) # print(s) # print(s_list) # if s_list[0] and s_list[0].isalpha(): # s_list[0] = s_list[0].capitalize() # for i in range(1, len(s_list)): # if s_list[i-1].isspace(): ...
96fa45618d803bacaf4da1df889d4590556f95ad
lfvelascot/Analysis-and-design-of-algorithms
/PYTHON LOG/PYTHON ADVANGE/ORDENAMIENTO/selectionSort.py
591
3.578125
4
def selectionSort(lista,tam): for i in range(0,tam-1): min=i for j in range(i+1,tam): if lista[min] > lista[j]: min=j aux=lista[min] lista[min]=lista[i] lista[i]=aux return lista def imprimeLista(lista,tam): for i in range(0,tam): ...
e28c20918a1ed7bab51399afe603c482f1ebcdf5
FranckNdame/leetcode
/problems/136. Single Number/solution.py
214
3.5625
4
class Solution: # Time complexity: O(n) || Space Complexity: O(1) def singleNumber(self, nums: List[int]) -> int: result = 0 for num in nums: result ^= num return result
467e9ac64a115cca28d8eb4633c427bdf0e96e60
sparkg/Leetcode
/初级算法/树/验证二叉搜索树.py
1,614
3.859375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isValidBST(self, root): """ :type root: TreeNode :rtype: bool """ bool_, _, __ = self.ValidBS...
5b7fb3dc13d3897a87cd0748e4d8ceba6dd352fd
rafaelperazzo/programacao-web
/moodledata/vpl_data/36/usersdata/96/12786/submittedfiles/questao2.py
470
3.84375
4
# -*- coding: utf-8 -*- from __future__ import division n1 = int(input('Digite o primeiro número:') n2 = int(input('Digite o segundo número:') n3 = int(input('Digite o terceiro número:') n4 = int(input('Digite o quarto número:') b = 0 or 3 or 5 or 7 or 9 v = 1 or 6 p = 4 or 8 if n1n2n3n4==bvbp or n1n2n3n4==vbpb or n...
e89007289920c60d4dd19c7a56cf3fdebcb9183b
ericyeung/PHY407
/Lab1/lab1_q1c.py
1,535
3.90625
4
#!/usr/bin/env python from __future__ import division from math import * '''lab1_q1c.py: Determining and plotting the scattering angle distribution''' __author__ = "Eric Yeung" __email__ = "eric.yeung@mail.utoronto.ca" import matplotlib.pyplot as plt import numpy as np N = 2000 # number of particles z = np.rand...
a97caaec8d269543a589b412eee4e1bc850123d2
bhushan-borole/Sorting-Algorithms
/shell_sort.py
546
4.0625
4
''' The idea of shellSort is to allow exchange of far items. In shellSort, we make the array h-sorted for a large value of h. Time Complexity Best : O(n log(n)) Average : O(n(log(n))^2) Worst : O(n(log(n))^2) ''' def SHELL_SORT(A): length = len(A) #initalize gap to mid of the array gap = length // 2 while gap ...
ebce54f9544768a1cd5b60c96e3ffabb8a3a4c52
sofiazenzola/Python-INFO1-CE9990
/NYC_Water_Consumption.py
1,050
3.90625
4
""" NycWaterConsumption.py Reads csv from NYC Open Data URL Puts fields in a list of strings Outputs the water consumption per capita (gallons per person per day) for a given year """ import sys import csv import urllib.request year=input("Select a year from 1979-2016: ") url = "https://data.cityofnewyork.us/api/...