blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
0411b1c8bd842906c9c3d4cf6ab76b8d8109d2d2
git-cmd/requests02
/05_requests_url.py
453
3.546875
4
# 导包 import requests # 发送待请求参数的URL # 通过URL中的请求参数来发送请求(如:http://www.baidu.com/s?wd=xxx) # response = requests.get("http://www.baidu.com/s?wd=哪吒") # response_z = requests.get("http://www.baidu.com/s", params="wd=小猪佩奇") response_x = requests.get("http://www.baidu.com/s", params={"wd": "海绵宝宝"}) # 查看响应结果 # print(response.t...
3ea1429558c0da9beac485c6bde11c10794adf7b
Velasko/Hackaton-da-Nasa
/09 - funcoes.py
782
4.03125
4
def primeira_funcao(): print('Ola, sou a primeira funcao!') def segunda_funcao(x): return( x * 2 ) def terceira_funcao(x='Mundo'): print("Ola,", x, ', eu sou a terceira_funcao!') def is_prime(x): '''Uma funcao que recebe um entrada x retorna um boleano dizendo se x eh primo ou nao.''' for n in range(2, x): ...
5edc88f84c54801d48369540ae75a9512f517bd0
alinagries/CoolesSpiel
/Spiel/label.py
1,412
3.96875
4
# -*- coding: cp1252 -*- import textwidget import pygame class Label(textwidget.TextWidget): """ Label for displaying text """ def __init__(self, x, y, width, height, text = "", font = textwidget.defaultFont): """ Initialisation of a Label parameters: int x-coordinate o...
ae9b8771cf978cb8b2c8fce91dbb22ce25aa2b9e
Prabukumaradoss/Python
/Dictionary/Dictionary 2.py
157
4
4
x={"a":1,"b":2,"c":3,"d":4} A=input("Enter the Key") if A in x: print(x) elif A not in x: x.update({A:input("Enter the value")}) print(x)
7746cd844cc047e6aafecabced5462f0ff6bc23b
Prabukumaradoss/Python
/Tasks/Fibonacci.py
184
3.921875
4
n=int(input("Enter the end of series:")) a=0 b=1 for i in range(n//2): print(a,end=" ") b=a+b print(b,end=" ") a=a+b if n%2!=0: print(a,end=" ")
0f77114564ebf4976aa0270b8b529e6afa670749
Prabukumaradoss/Python
/Day 8-String/Palindrome.py
227
3.78125
4
a=input("ENTER THE STRING") b=len(a) count=0 for i in range(b): if a[i]==a[-i-1]: count+=1 if count==b: print("Palindrome") else: print("Not a palindrome") break
69475e089f8da68880ddbce382b007a5743ef694
Prabukumaradoss/Python
/Day 2 - Operators/area of triangle.py
137
3.890625
4
print("AREA OF THE TRIANGLE") b=int(input("enter base")) h=int(input("enter hight")) A=(b*h)/2 print(f"AREA OF THE TRIANGLE = {A}")
c0a77a02c5e222558ba5e3fe9b0dbeb605f392c0
Prabukumaradoss/Python
/Modules/OTP.py
285
3.515625
4
import random OTP="" for i in range(4): b=int(random.random()*10) OTP+=str(b) print(OTP) def verify(): a=input("Enter otp") if OTP==a: print("Otp is verified") else: print("Enter crt OTP") verify() verify()
4d796801beefbe9f918ddaa481c89d94969430b8
neelesh98965/code-freak
/python/Red Devil/Number_guesser.py
416
4
4
def number_guesser(): n = 100 c = 0 while (c < 5): i = int(input("Enter Your Guess\n")) if (i < n): print("Your guess is smaller") elif (i > n): print("Your guess is larger") else: print("Right answer") break c = c + 1 ...
170f02f6857b192722fb5a7aa1682ca982ff0444
neelesh98965/code-freak
/python/Red Devil/FizzBuzz.py
538
4.3125
4
""" Write a function called fizz_buzz that takes a number. 1. If the number is divisible by 3, it should return “Fizz”. 2. If it is divisible by 5, it should return “Buzz”. 3. If it is divisible by both 3 and 5, it should return “FizzBuzz”. 4. Otherwise, it should return the same number. """ def fizz_buzz(n):...
5db6ae04fb70742b33fd8cedb5fd70761fac7128
0xall/FindingMin
/find_min.py
2,790
3.625
4
import argparse from matplotlib import pyplot as plt from decimal import Decimal from polynomial import Polynomial from root import get_newton_raphson from root.approximation import get_min_approximation, get_min_approximation_with_momentum from visualization import visualize_newton_iteration args = argparse.Argumen...
16b266cd90d62520583d377a85c3828c4858dda7
0xall/FindingMin
/visualization.py
1,104
3.8125
4
from decimal import Decimal from typing import Tuple from polynomial import Polynomial import numpy as np from matplotlib import pyplot as plt def visualize_polynomial(p: Polynomial, interval: Tuple[str, str]): x = np.linspace(float(interval[0]), float(interval[1]), 100) y = np.zeros(len(x)) for level,...
c22cf05885219a64aaceb5481309b0de9a949b55
CodexJeff/for-and-while
/comp1405_f17_generator_suite_for_assignment_5/comp1405_f17_assistant_a5.py
1,848
3.671875
4
import pygame pygame.init() original_maze_image = pygame.image.load("your-assigned-maze.png") window = pygame.display.set_mode(original_maze_image.get_rect().size) window.blit(original_maze_image, (0, 0)) pygame.display.update() my_color_grey = (64, 64, 64) my_color_black = (20, 12, 28) my_color_white = (22...
88da31e0d43dd3c06b2221419f432c5eeded6a7b
lavanyaSR/python_0730
/oops/inherit.py
684
4.03125
4
class A(): def feature1(self): print("inside feature1") def feature2(self): print("inside feature 2") #class B inherits class A and all methods comes under B - here B is single level inheritence class B(A): def feature3(self): print("inside feature1") def feature4(self): ...
017c55a4721ba1594176ded31ad21aefca594c20
srisaivalli/Python
/Basics.py
720
4
4
#Programs #1) Sum x=10 y=20 print "Sum is = ",(x+y); #1.1) Dynamic i/p x=input("enter x value"); y=input("enter y value"); print "sum is =", (x+y); #2) Total & Average sno=input("Enter sno :"); sname=raw_input("Enter sname:"); s1=input("Enter the value of s1 :"); s2=input("Enter the value of s2...
bd05e90e8feee4b2c00ffff03f18f72ae596e540
ivoloshi/python
/wordsearch.py
13,199
3.625
4
########################################## # NAME: Maya Voloshin # ID: 322853680 # login: mayavolo # DESCRIPTION: ex5 ########################################## import sys import traceback import os def check_input_args(args): """ checks if the given arguments exist and are legal :param args: the files ...
8499b00f2dfeb4ac111a61ccce2b8728f8392170
derly88/clase-1
/listas.py
370
3.515625
4
valores=range (50,101,2) print valores n=0 n2=0 for i in valores: if i%2==0: n=n+i else: n2=n2+i print "suma pares "+"="+str(n) print "suma impares "+"="+str(n2) #nuevo_valor= input ("ingrese nuevo valor: ") #valores += [nuevo_valor] #valores.append (input("ingrese nuevo_valor: ")) ...
fb9ab37b0f6ec5106ee39f3e873e18f88e51ab36
edchtzwe/pylab
/regexFileInFolderSearch.py
1,025
3.65625
4
# regex file in folder search # 09 Dec 2016 # Edmund Chong / 7440820@gmail.com import os; import re; from lib import folderPath; progName = os.path.basename(__file__); print "progName = " + progName; folderPath = folderPath.getFolderPath(); print "Quit at first match in file? (0 or 1):" try: flag1 = int(raw_inpu...
5e4c9d86a59a49fdea7cdab50ed24d399d689b5f
sirwin4/checkers
/checkers.py
14,079
3.84375
4
board = [["0", "o", "0", "o", "0", "o", "0", "o"], ["o", "0", "o", "0", "o", "0", "o", "0"], ["0", "0", "0", "0", "0", "0", "0", "0"], ["0", "0", "0", "0", "0", "0", "0", "0"], ["0", "0", "0", "0", "0", "0", "0", "0"], ["0", "0", "0", "0", "0", "0", "0", "0"], ["0", "x", "0", "x", "0", "x", "0", "x"], ["x", "0", "x", "...
d9981172590c4569d6b4df0536d7f7681a5fdbca
jmh0036/ProjectEuler
/CubicPermutations2.py
831
3.5625
4
from itertools import permutations def IsCubic(number): return int(round(number ** (1. / 3))) ** 3 == number def PermuteNumber(number,permutation): NumberList = [i for i in str(number)] PermutedList = [NumberList[i] for i in permutation] return int(''.join(PermutedList)) DesiredLength = 5 PermCubics...
c3bc9d5e690c209f552a8d8151581934bff125d0
marvinsenjaliya/Basic-Python-And-Data-Structures
/Dictionary/8_create_dic_from_string.py
370
3.9375
4
""" Created on 1/14/2020 @author:Marvin Senjaliya """ """ problem statement: Write a Python program to create a dictionary from a string. Note: Track the count of the letters from the string. Sample string : 'w3resource' Expected output: {'3': 1, 's': 1, 'r': 2, 'u': 1, 'w': 1, 'c': 1, 'e': 2, 'o': 1} """ str='w3res...
67cac9de2390ef1362edc4399f290ebe0cda30be
marvinsenjaliya/Basic-Python-And-Data-Structures
/Array/1_create_array.py
347
3.921875
4
""" Created on 1/13/2020 @author :Marvin Senjaliya """ """ problem statement : 1. Write a Python program to create an array of 5 integers and display the array items. Access individual element through indexes. """ import array as arr a=arr.array('i',[1,2,3,4,5]) for j in a: print (j) print(a[0]) print(a[1]) pri...
0cf48072cfacfec37017e7ecf663594ac8f21d5e
marvinsenjaliya/Basic-Python-And-Data-Structures
/String/3_change_char.py
432
3.734375
4
""" Created on 1/15/2020 @author:Marvin Senjaliya """ """ problem statement: . Write a Python program to get a string from a given string where all occurrences of its first char have been changed to '$', except the first char itself. Sample String : 'restart' Expected Result : 'resta$t' """ sample_string='rest...
3c07df79e6a6b62d1b9caa62740752b209e9916b
marvinsenjaliya/Basic-Python-And-Data-Structures
/Basic/26_num_of_char.py
232
3.734375
4
""" Created on 1/13/2020 @author :Marvin Senjaliya """ """ problem statement: Write a Python program to count the number occurrence of a specific character in a string """ s = "hi, my name is marvin" print() print(s.count('i')) print()
a2a96dfab8e8c275b9e901dd3734f048b4ab7c2f
marvinsenjaliya/Basic-Python-And-Data-Structures
/Basic/41_convert_into_binary.py
257
3.984375
4
""" Created on 1/13/2020 @author :Marvin Senjaliya """ """ problem statement: . Write a Python program to convert an integer to binary keep leading zeros. Sample data : 50 Expected output : 00001100, 0000001100 """ x=12 print(format(x,'08b') print(format(x,'10b')
286ac990210f8912724c5f37485daf9d4b31557f
marvinsenjaliya/Basic-Python-And-Data-Structures
/String/10_occurrence_of_string.py
257
3.75
4
""" Created on :1/15/2020 @author:Marvin Senjaliya """ """ problem statement: Write a Python program to count occurrences of a substring in a string. """ str='hi i am working on "data engineering",and you' str_count=str.count("data engineering") print(str_count)
e4f2e3e27e9a5856db5ecdc2d6dff3713de670b6
marvinsenjaliya/Basic-Python-And-Data-Structures
/String/7_sort_alphanumerically.py
468
4.03125
4
""" Created on :1/15/2020 @author :Marvin Senjaliya """ """ problem statement: Write a Python program that accepts a comma separated sequence of words as input and prints the unique words in sorted form (alphanumerically). Sample Words : red, white, black, red, green, black Expected Result : black, green, red, whi...
20dfa5a5e12930d1d3f1b17e1c14e28f70259e15
marvinsenjaliya/Basic-Python-And-Data-Structures
/Array/2_reverse_elements_in_array.py
219
4.0625
4
""" Created on 1/13/2020 @author :Marvin Senjaliya """ """ problem statement: Write a Python program to reverse the order of the items in the array. """ import array as arr a=arr.array('i',[1,2,3,45,43]) a.reverse() print(a)
89377179d47380c9dc33f334f78d8eb8dddbc609
marvinsenjaliya/Basic-Python-And-Data-Structures
/Dictionary/7_unique_value_in_dic.py
533
3.9375
4
""" Created on 1/14/2020 @author :Marvin Senjaliya """ """ problem statement: Write a Python program to print all unique values in a dictionary. Sample Data : [{"V":"S001"}, {"V": "S002"}, {"VI": "S001"}, {"VI": "S005"}, {"VII":"S005"}, {"V":"S009"},{"VIII":"S007"}] Expected Output : Unique Values: {'S005', 'S002...
d15376734208c35ed9ce3847c484bf72b4ca8502
YChaeeun/WTM_learningPython
/4_int_float.py
403
3.875
4
def int_div(a, b) : root = a // b remainder = a % b print("Root: ", root) print("Remainder", remainder) n1 = int(input("A number: ")) n2 = int(input("Divided by: ")) print(int_div(n1, n2)) def bet_sum(c, d) : c = int(c) d = int(d) sum = 0 for i in range(c+1, d): sum += i ...
a3aac3528312d90213978df624bd7bb84f088e43
YChaeeun/WTM_learningPython
/1_input/0509_input.py
1,619
4.125
4
# 0509 # 자료형 이해하기 & 파이썬 입출력 연습하기 # 자료형 # 문제 1 : 3.14를 문자열, 정수, 실수로 출력하기 num = 3.14 numTostring = str(num) floatToint = int(num) intTofloat = float(floatToint) print(numTostring, type(numTostring)) print(floatToint, type(floatToint)) print(intTofloat, type(intTofloat)) print() # 줄 한 칸 띄기 # 입출력 # 문제 1 : 실수를 입력받아 ...
9705a09929ca2aeb3b1547f5560b7f8bb8e3aa13
NeilNjae/szyfrow
/szyfrow/support/text_prettify.py
2,075
4.3125
4
"""Various functions for prettifying text, useful when cipher routines generate strings of letters without spaces. """ import string from szyfrow.support.segment import segment from szyfrow.support.utilities import cat, lcat, sanitise def prettify(text, width=100): """Segment a text into words, then pack into li...
6ba10ae67a54e46c284a23f8bf11211ccac3c579
NeilNjae/szyfrow
/szyfrow/support/segment.py
718
3.546875
4
"""Setments a string of characters into words, following a language model. Implementation taken from [Peter Norvig](https://norvig.com/ngrams/ch14.pdf) """ import sys from functools import lru_cache from szyfrow.support.language_models import Pwords sys.setrecursionlimit(1000000) @lru_cache() def segment(text): ...
293e47330f3a1092379e848bc639512f0e5476b2
NeilNjae/szyfrow
/szyfrow/cadenus.py
8,990
3.9375
4
"""Enciphering and deciphering using the [Cadenus cipher](https://www.thonky.com/kryptos/cadenus-cipher). Also attempts to break messages that use a Cadenus cipher. The plaintext is written out in a grid, with one column per letter of the keyword. The plaintext is written out left to right in rows. The plaintext ne...
573eb97df3861bd9c5bb04c8cf4eb964291b1bd3
treboryx/AoC
/2019/day01/part2.py
298
3.78125
4
import math def fuel(mass): f = math.floor(mass / 3) - 2 return f + fuel(f) if f > 0 else 0 # return f > 0 ? f + fuel(f): 0 with open('input.txt') as fp: line = fp.readline() sum = 0 while line: sum += fuel(int(line)) line = fp.readline() print(sum)
c9c0ab5c833cb6a7e718e577c180f1dd96b7c72a
Elijah-M/Module14
/class_definitions/hangman_game.py
37,648
4.03125
4
""" Author: Elijah Morishita elmorishita@dmacc.edu 11/23/2020 This is a Two Player Hangman game, the GUI is completed via tkinter. Player 1 presses the START NEW GAME button, types in a word or phrase, and clicks on ENTER to register it. Player 2 then attempts to figure out the word by clicking on the Letter buttons di...
3736c52a42c9772954ae82852d53b7a699f91009
lawrencedovin/ml-data-science-bootcamp
/python-pt-2/zip.py
79
3.53125
4
list1 = [1,2,3] list2 = [4,5,6] result = list(zip(list1, list2)) print(result)
ff0d733641c09be374e8050aecf834b08a0684bd
UniBus/Server
/data_management/modules/gtfs/server/stop_times.py
4,399
3.546875
4
#! /usr/bin/python ## This module import stop_times.txt to table 'stop_times' in a mySQL database # # It take two parameters, as # import_stop_times $dbName $cvsFilePath # # Thus, it imports $cvsFilePath/stop_times.txt to $dbName.stop_times. # if $dbName.stop_times exists, it deletes the table first. # #...
811776321f1229342f8b4c9d9f052e1d9e31fd6b
stalinkush/MIT-Introduction-to-Computer-Science-and-Programming-Using-Python
/Week 2 Simple Programs/Test/gcditer.py
313
3.5
4
# -*- coding: utf-8 -*- """ Created on Sat Feb 16 22:38:36 2019 @author: stali """ def gcditer(a,b): """ This fuction takes in two intergers and returns gcd of the numbers """ x = min(a, b) while x != 0: if a%x == 0 and b%x == 0: return x x -= 1 return 1
450a21de05719a0b9d18674612a7dd9a1490d2da
feitosajoas/exercicios-python3
/exercicios02-coursera.py
4,006
3.65625
4
# coding: utf-8 # In[1]: def insertionSort(A): for i in range(1,len(A)): x = A[i] j = i-1 while j>=0 and x<A[j]: A[j+1] = A[j] j=j-1 A[j+1] = x return A # In[2]: def dimensoes(array): tamanho = (len(array), len(array[0])) print(f'{tamanho[0...
445f5891da472b6ab63f678fcf5bbadf55de26af
feitosajoas/exercicios-python3
/exercicios01-coursera.py
12,501
3.78125
4
# coding: utf-8 # In[1]: ladoquadrado = input("Digite o valor correspondente ao lado de um quadrado:") perimetro = 4 * int(ladoquadrado) area = int(ladoquadrado) ** 2 print("perímetro: {0} - área: {1}".format(perimetro, area)) # In[2]: n1 = int(input("Digite a primeira nota:")) n2 = int(input("Digite a segund...
5a947a544cea1bb10b4f6f46503c1e1f5b8c647d
heloowird/speech_and_language_processing
/code/max_match.py
888
3.53125
4
#!/usr/bin/env python #coding:utf-8 #author:heloowird from __future__ import print_function import sys def forward_max_match(sentence, word_dict, token_list): if not sentence: return for i in range(len(sentence)): prefix = sentence[0:len(sentence)-i] suffix = sentence[len(senten...
d9ef06541e511a83aefdc6cb947720a5414079d1
keitho18/tkinter_freecodecamp_course
/tkinter_tutorials/grid.py
437
4.125
4
from tkinter import * root = Tk() #Creating a label widget myLabel1 = Label(root, text="Hello World") myLabel2 = Label(root, text="My name is Keith") #Putting the widgets into the GUI using the grid coordinates #If there are empty grid cells, then the GUI will skip them when the GUI is displayed myLabel1.g...
0da86eeca4594ccce734b37617488759fd82696a
sebasc167/Ant-Colony-Optimization
/ant_colony_optimization.py
11,620
4.09375
4
''' Ant colony optimization algorithm for: Shortest Route between Carnival Attractions Problem Visit each city once and find the shortest route between all attractions Author: Sebastian Castro Date: 8/20/2021 ''' import random ''' Below you will find the Dictionary containing the dist...
26c50c6c71919cae84125863fffc03a0fc4e5940
Kellysmith7/Module-4
/topic4/validation_with_try.py
639
3.9375
4
""" Program: validation_with_try.py Author: Kelly Smith Last date updated: 09/17/2019 Program to find the average of three numbers and returns a value error if a negative number is entered """ def average(x, y, z): if x < 0: raise ValueError elif y < 0: raise ValueError elif z < 0: ...
454b50d9a8b007d16f4f52d8f7d446e450a71275
hubbm-bbm101/lab5-exercise-solution-b2210356106
/Exercise3.py
440
4.21875
4
import random number = random.randint(0, 20) guess = 0 print("A random number is generated between 0 and 20. Please type your guess.") while guess != number: guess = int(input("Your guess = ")) if guess < number: print("Please increase your guess and try again.") elif guess > number: ...
d7c75e5eaea33866c3524bfa246c65988d89b400
C-CCM-TC1028-102-2113/programs-that-require-calculations-AndresEmiliano
/assignments/03Promedio/src/exercise.py
433
3.796875
4
def main(): #escribe tu código abajo de esta línea a = float(input("ingresa tu calificacion de la materia 1:")) b = float(input("ingresa tu calificacion de la materia 2:")) c = float(input("ingresa tu calificacion de la materia 3:")) d = float(input("ingresa tu calificacion de la materia 4:")) cal = (a+b+c+d) / 4 p...
fb942ed5676439480ec068c3436f4c1147ae4681
Rahul4269/Python-star
/multiple inherance.py
648
3.53125
4
class Person: def __init__(self,personname,personage): self.name=personname self.age=personage def showName (self): print(self.name) def showage(self): print(self.age) class student: def __init__(self,studentid): self.studentid=studentid def...
f56d6be39aed9bb7a19f8db157094a103f26cdae
Rahul4269/Python-star
/break continou pass.py
326
4
4
for val in "Impetas": if val=="e": break print(val,end="") print() for val in "Impetas": if val=="e": continue print(val) else: print(val,end="") print() for val in"Impetas": if val=="e": pass print(val) else: print(val,end...
58c427ba615795e8a5ad3e6d31b623d6285d52f9
Rahul4269/Python-star
/button1.py
373
3.71875
4
from tkinter import * r=Tk() r.configure(background="orange") fname=Button(r,text="first name",fg="yellow",bg="green") lname=Button(r,text="last name",fg="blue",bg="green") address=Button(r,text="Address",bd=10) id=Button(r,text="ID",padx=70) dob=Button(r,text="Date of Birth",padx=50) fname.pack() lname.pack()...
94a6ccf7eb7481a7be3e90a5a8aaa26d8f95d204
Rahul4269/Python-star
/entry5.py
440
3.703125
4
from tkinter import * window=Tk() window.title("Welcome to Impetus Consultrainer") def clicked(): res="Welcome "+txt.get()+" to mumbai" lbl.configure(text=res) Label(window,text="Welcome to Dadar").grid(row=3,column=0) lbl=Label(window,text="Hello") txt=Entry(window) btn=Button(window,text="Click M...
6d28641f740d08f2a4f327a37e1742053e8446d3
Azumait/grammar1-1
/back_python_3_dataprocess1/1_python_matplotlib1_better_min/1.py
3,234
3.65625
4
# 파이썬 데이터분석 커리큘럼 : 맷플롯립 - 판다스 - 하둡 - 텐서플로우 # 통계 num_friends = [100, 40, 30, 30, 30, 40, 100, 100, 30, 30, 54, 54, 3, 3, 3, 25, 25, 30, 30, 54, 29, 29, 29, 77, 77, 99] print('원본데이터:', num_friends) # 동일한 친구수를 가진 사람을 모아서 보여주자 import collections friends_count = collections.Counter(num_friends) print('카운터:', friends_count...
76d73bb9e96d2016bf525ffecaa9650e333f1e4f
Azumait/grammar1-1
/back_python_3_dataprocess1/1_python_matplotlib1_better_min/4.py
2,206
3.515625
4
# 파이썬 배열과 집합 다루는 법 복습 # # 집합(셋)을 이용해서 중복제거하기 # arr1 = ['LTE', 'LTE', '5G', '5G', '5G', 'WCDMA', 'WCDMA', 'LTE'] # arr2 = [4, 4, 5, 5, 5, 3, 3, 4] # set1 = set(arr1) # set2 = set(arr2) # arr1 = list(set1) # arr2 = list(set2) # print(arr1) # print(arr2) # # 리스트와 셋에 요소(element) 추가 arr1 = [1, 2, 3] arr1.append(4) # print...
d98c9210a56e6fc745389095ee82a7c95089eda3
Azumait/grammar1-1
/back_python_1_basic1/1_python_grammar1/1.py
1,847
4.0625
4
# [변수와 데이터타입] # 주석(comment) : # 입력 또는 ctrl + / 로 표현한다. 메모같은 것 # 변수(variable) : 변하는 수 id = "pencil" print(id) print("뭐로 쓸까요? - ",id,"으로 쓰죠.") # 숫자 변수 : ""를 입력하지 않으며, 숫자. 연산가능. 데이터타입이 숫자인 변수. num = 10 plus = 1 minus = 2 multiply = 3 divide = 5 print(num + plus) print(num - minus) print(num * multiply) # 30 print(num ...
1ce97a7b2be9a31028359bb93d3a12b1084f76a8
Azumait/grammar1-1
/back_python_1_basic1/1_python_grammar1/9.py
1,524
4.125
4
# [정식 클래스 만들기] class Human(): # 모델링(초기화) def __init__(self, name, weight, language): self.name = name self.weight = weight self.language = language # print시의 처리 def __str__(self): # print했을 때 클래스는 위치만 나오는데, 이걸 지정하면 이대로 나온다. return "{}은 {}키로이며, {}언어를 구사해요.".format(se...
ebd7137cbefdb7de793fdeff72e7d2bca42dda82
Azumait/grammar1-1
/back_python_3_dataprocess1/2_python_pandas_x_matplotlib1_min/1.py
939
3.890625
4
# 판다스 : DataFrame 다루는 라이브러리 (엑셀, csv file등과 비슷한 형태의 데이터) # pip install pandas : DataFrame 자체 import pandas as pd from pandas import DataFrame as df # DataFrame을 df로 정의하기 df1=df( data={'Num':[1,2,3], 'Name':['Kim','Park','Lee'], 'Color':['red', 'blue', 'black']}, columns=['Name', 'Num', 'Color'], ...
4c5654b4cd2ba4ef00f930a9f94276750bf644c6
Azumait/grammar1-1
/back_python_1_basic1/1_python_grammar1_min/4.py
1,193
4.4375
4
# Method(parameter) 만들기 # 블럭 지정 후 ctrl + / = 주석처리 # definition 정의 # def add(a, b): # result = a + b # print(result) # # 호출 # add(1, 3) # def printHello(): # print('Hello') # printHello() # def add10(a): # result = a + 10 # print(result) # add10(1) # add10(10) # def addmulti(a): # result ...
5380f0cbaeddd4b3e88654b829628255db3c1109
Cayce2514/Python
/collatz.py
812
4.21875
4
def getNumber(): global number while number == 0: try: number = int(input("Please enter a number: ")) except ValueError: print("That doesn't seem to be a number, please enter a number") return number def collatz(number): if (number % 2 == 1): print('You picked an ...
d6d68b7a346833fc9eaf0db16334692c617aa8fa
GuySrinivasan/oeis
/oeis/utility.py
1,215
3.53125
4
def choose(a, b): if a < b: return 0 r = 1 for i in range(0, b): r *= a - i r /= i + 1 return r def factorial(a): r = 1 for i in range(0, a): r *= i + 1 return r def fibonacci(): a, b = 0, 1 while 1: yield a a, b = b, a+...
0cc37b9a80c09f30919a44ba743c13049138a31c
jhirniak/ads
/string/balanced paranthesis/python/balanced.py
551
3.78125
4
""" by Konrad Stojanowki 12 November 2014 """ matching = {} matching['{'] = '}' matching['('] = ')' matching['['] = ']' def balanced(braces): stack = [] for b in braces: if b in matching.keys(): stack.append(b) else: if len(stack) > 0: last = sta...
26cbae4d0e5458df3ee82f30b396ab2af9c03c6a
kenchose/car
/car.py
933
3.78125
4
class Car(object): def __init__(self, price, speed, fuel, milage): self.price = price self.speed = speed self.fuel = fuel self.milage = milage if self.price > 10000: self.tax = .15 * 100 else: self.tax = .12 * 100 def display_all(self): ...
289ffe9c113242e580140b6aeda7cc5fa9101c6e
Sohyun617/keras
/keras18_new_scaler2.py
837
3.6875
4
import numpy as np x= np.array(range(1,21)) y= np.array(range(1,21)) x= x.reshape(20,1) print(x.shape) print(y.shape) from sklearn.model_selection import train_test_split x_train, x_test, y_train, y_test = train_test_split( x,y, test_size=0.5 , shuffle = False ) print("=======================")...
e2516f0128165e1854423e2f1ec1b0794ecbcbcd
OpenTaal/alphabetical-sort
/python/sort-human.py
494
3.828125
4
#!/usr/bin/env python3 from natsort import humansorted from locale import LC_ALL, setlocale from sys import argv if __name__ == '__main__': if len(argv) != 2: exit(0) words = [] with open(argv[1]) as input_file: for line in input_file: word = line[:-1] words.append...
5dcbd95ee93ae4e54543c36b4b2bdaba680f64ef
wogud220/pdfchall
/1A Bucket Challenge.py
1,292
3.71875
4
def possible(input,target): """ dp definition: dp[i] means whether number i can be formed from adding the buckets (takes boolean value). dp[0] = True, base case 0 is always True since we just do not need to add any numbers. dp[i] = dp[i-j] for j in numbers in the input list. If dp[i-j] is True, then we can s...
a91e4f95f2995a4f1e4aa5adbfd3637b01f452f7
victoriaWindle/Windle_V_RPS_Fall2020
/GameComponents/winLose.py
698
3.515625
4
from GameComponents import gameVars def winorlose(status): #print("called winorlose", status) if status == "won": pre_message = " You are the winner!" else: pre_message = "You lost!" print(pre_message + "would you like to play again?") print("You ", status, "! Loser. Would you like to play again?") choic...
3ebad468dbe84137b3d2bf30e713637701b9c88a
XiaoshengLiang/Connectionist-Computing
/Neural Network/Question3.py
4,586
3.765625
4
# coding: utf-8 import numpy as np import matplotlib.pyplot as plt import math from scipy import optimize # Create the train data and test data def createData(dim,size): X = np.random.uniform(-1,1,size = (dim,size)) y=[] sum = 0 for line in X: y_item = [] for num in line: ...
d6f28e0639a0ad779b8c883b4305d80fd997f504
eubr-bigsea/Compss-Python
/ddf_library/functions/etl/replace_values.py
1,428
3.75
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = "Lucas Miguel S Ponce" __email__ = "lucasmsp@gmail.com" from ddf_library.utils import generate_info def replace_value(data, settings): """ Replace one or more values to new ones in a pandas's DataFrame. :param data: A list of pandas's DataFram...
7653dbcc1feaaad9202b2925329f345342871e9b
ladinu/cs350
/hw3/johnsonTrotter.py
4,528
3.9375
4
#!/usr/bin/env python LEFT = 'left' RIGHT = 'right' class Element: def __init__(self, value, direction): self.value = value; self.direction = direction def __repr__(self): direction = '' if self.direction == LEFT: direction = "<-" else: direction = "->" ret...
5fbe766b1c34a55a863543799e648dcfeec931a7
mjk7817/PythonPractice
/Rock.py
1,144
4.0625
4
import random choice = ["Rock", "Paper", 'Scissors'] computer = random.choices(choice) player = False cpuScore=0 playerScore = 0 while True: player = input("Rock, Paper, or Scissors? ").capitalize() if player == computer: print("Tie!") elif player == "Rock": if computer == "Paper": ...
eb454bca8d2dc28741794a78c60218b2cf8d2557
suleymanekmekci/wordGame
/main.py
4,812
3.78125
4
import random import sys import time if len(sys.argv) < 3: print("You must write two arguments for this program") else: wordFileName, letterFileName = sys.argv[1],sys.argv[2] with open(wordFileName,"r",encoding="utf-8") as wordsFile: myWordDict = {} for line in wordsFi...
1911b1ef55adff6741cc60974c43e3e7754af2d1
LCAV/pyroomacoustics
/pyroomacoustics/doa/detect_peaks.py
6,980
3.671875
4
""" Detect peaks in data based on their amplitude and other features. Author: Marcos Duarte, https://github.com/demotu/BMC Version: 1.0.4 License: MIT """ from __future__ import division, print_function import numpy as np __author__ = "Marcos Duarte, https://github.com/demotu/BMC" __version__ = "1.0.4" __license__ ...
0bf4efdecc8974f83ef5a53c952d56aed493f69b
DimartX/oop_exercise_01
/tests/tester.py
805
3.671875
4
#!/usr/bin/env python3 x, y = map(float, input().split()) a = complex(x, y) x, y = map(float, input().split()) b = complex(x, y) def cmp(a, b): return 1 if (abs(a) > abs(b)) else 0 if (abs(a) == abs(b)) else -1; print("Addition:", "%.3f" % (a + b).real, "%.3f" % (a + b).imag, sep = ' ') print("Subtraction:", "%....
ad90281db4c93c8721887316e1e14e1e7fa126d5
ShrohanMohapatra/ThreadGo
/example.py
854
3.78125
4
from project.threadGo import threadMatrixProduct # enter the size of the matrices n = int(input("Enter the size of the matrix ")) # take input from user A = [] B = [] print("Enter the elements of matrix A") for i in range(n): a =[] for j in range(n): a.append(int(input())) print() A.append(a) p...
3c39870c4d3ffb2924ba21a3e8232f38f8558bfd
PaoloReyes254/OOP-python
/Classes.py
666
3.703125
4
#First Class class dog(): def __init__(self, name, age): self.name = name self.age = age def speak(self): print("Hi there, I am a dog and I can talk, my name is " + self.name + " and I am " + str(self.age) + " years old") def change_age(self, age): self.age = age d...
3dce4ecd3c32c6844b9835d11f845fc2b810f5d3
apeuta/Ujian_Himpunan
/himpunan.py
689
3.6875
4
#DISCLAIMER : Antara 1 dan 20, berarti 1 dan 20 tidak disertakan batas = range(2,20) A = set (range(2,20,2)) B = set (range(1,20,2)) C = set (range(-9,0,1)) D = set (filter (lambda x : (x == 5) or (x % 3 or x==3) and (x % 2 or x == 2) and (x > 1) , batas)) E = set(filter (lambda x : x not in D, batas)) print (f"Hasil...
1e9e0239d7250d476a53b689cd61abec05f860c1
Greenphire/python-xlsx
/xlsx/xlcols.py
1,015
4.03125
4
''' Convert excel column names to integers and vice-versa ''' from string import ascii_uppercase def xlcol2num(x): ''' >>> xlcol2num('A') 1 >>> xlcol2num('AA') 27 >>> xlcol2num('KN') 300 >>> xlcol2num('DKJ') 3000 >>> xlcol2num('GJH') 5000 ''' if list(x) != [c for c ...
c9f92fd2b4e8bbfb8e3eb3f05f15ffa60e93c396
yolothedino/PYTHON_PROJECT
/1902157.py
6,276
3.59375
4
import csv import sys def copyall(filename, datasetnumber): if datasetnumber == 1: ifile = open('co-curricular-activities-ccas.csv', "rb") reader = csv.DictReader(ifile) ofile = open(filename, "wb") writer = csv.DictWriter(ofile, fieldnames=reader.fieldnames) writer.writeh...
c0fa40faf02434da48d2906e2ab13039aa791d82
A-blackfish/research-tools
/finding_variable.py
232
3.796875
4
s1 = 8 s2 = 10 s3 = 12 value = ['s1', 's2', 's3'] i=1 name='{}{}'.format('s', i) x=eval(name) print(x) # output is 8 # this script can help you finding variable according to its name # a = 's'+1 # print 's1:', s1 # print 'a:', a
9d983bb134e2a18304131785685717b45a5a2799
EuihoonSeol/Python-Command-Line
/movie_ticketing_system.py
8,270
3.796875
4
import json def get_movies(file_name): with open(file_name) as f: data = json.load(f) return data def get_movies_genres(movies): genre_list = [] for genre in movies: genre_list.append(genre) return genre_list def get_movies_titles(movies): title_list = [] for genre ...
2e4bd16b53a39bd7f09cfd77b3910fe699889d21
xjq1006/chatroom
/Tom.py
124
3.546875
4
# a=[1,2,3,4,3,6,3] # n=3 # for i in a: # x=a.count(3) # for j in range(1,x+1): # a.remove(n) # print(a)
943ce83e94875c7949464f81ec82e557a1b6a52c
bfontaine/previewer
/previewer/text.py
1,962
3.515625
4
# -*- coding: UTF-8 -*- import textwrap def fit_width(text, font, width, max_lines=None): if not text: return text w, _ = font.getsize(text) # easy case if w <= width: return text pt_w, _ = font.getsize(".") width_pt = int(width / float(pt_w)) wrapped = None wrap_wi...
2b7ad53f606eb5ac7f257ed41a73b06050d61f2c
jramshur/Code-Snippets
/python/dataframe_duplicates.py
432
3.546875
4
import pandas as pd myfile="C:\\myfilepath\\myexcelfile.xlsx" df = pd.read_excel(open(myfile,'rb'), sheet_name="mysheetname") # return series containing all duplicates df[df.duplicated(['MyColumnName'], keep=False)] # alternative mask = df.MyColumnName.duplicated(keep=False) df_duplicates=df[mask] df_notduplicates=...
a4b937ded3a4c26937bf3ff2c0e5b463ea9ea8f4
lwillmeth/AnalysisofAlgorithms
/Implementation1/DivideConquer.py
2,304
3.609375
4
#!/usr/bin/python ''' CS 325 - Implementation 1 Divide and Conquer Kyle Prouty, Levi Willmeth, Andrew Morrill Winter 2017 ''' import math, sys, time if(len(sys.argv)>1): inputfile = sys.argv[1] else: inputfile = 'example.input' delta = float("inf") min_pts = [] def readFile(): with open(inputfile) as file: ...
483644bbfcf63efb3494e7009a2e3b13fd197044
lwillmeth/AnalysisofAlgorithms
/Knapsack/Knapsack.py
892
3.828125
4
#try to make as much money for max weight for knapsack #do i take item (x)? #weight left in sack = total weight of already taken items #edge: # adding item # neg value of item #keep track of # (item looking at, weight of taken items) def knapsack(weight, items): maxweight = weight+1 maxitems = len(items)+1 ...
8271197763e942373597f67a4cf3ab3131e01085
boini-ramesh408/week1_fellowship_peograms
/algoriths/BubbleSort.py
402
4.1875
4
from com.bridgelabz.python.utility.pythonUtil import bubble_sort list=[]#to take run time values in sorting first take one emply list and add the elements to the empty list try: num=int(input("enter the number")) for i in range(0,num): element = int(input()) list.append(element) bubbl...
7b76ec530d187cf7bad8bb8b30cf3915245e722b
boini-ramesh408/week1_fellowship_peograms
/logicalPrograms/TemparatureConversion.py
318
4.0625
4
from com.bridgelabz.python.utility.pythonUtil import temparatue_conversion try: celsius = float(input("enter Celsius to convert Fahrenheit:")) fahrenheit = float(input("enter Fahrenheit to convert celsius:")) temparatue_conversion(celsius, fahrenheit) except: print("enter only float values")
2b8718be4aab23ee6fceeddc4418dfaa78b7da1c
vutran1710/Algorithm-with-unusual-languages
/python/strong_password.py
737
3.515625
4
numbers = "0123456789" lower_case = "abcdefghijklmnopqrstuvwxyz" upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" special_characters = "!@#$%^&*()-+" def minimumNumber(n, password): low = False upp = False num = False spe = False count = 4 for c in password: if c in lower_case and not low: ...
d20f621210982f584ba77e26104452582cd5de63
lucyexley/my-first-blog
/python_intro.py
747
4.03125
4
def hi(): print("Hello") print("How are you?") def hiv2(name): print("Hello " + name) def area(side): return side * side print("Hello World") if 1 > 2: print("Yes") hi() else: print("Wrong") hiv2("Becky") small_square = area(2) big_square = area(small_square) print(big_sq...
4d7a37c3c1fa3ab8e02e8c046af3c2b006b66a9f
diparai/IS211_Assignment4
/sort_compare.py
2,389
4.1875
4
import argparse # other imports go here import time import random def get_me_random_list(n): """Generate list of n elements in random order :params: n: Number of elements in the list :returns: A list with n elements in random order """ a_list = list(range(n)) random.shuffle(a_list) ret...
27b994c3924007d90e49e4fc1c92fc4eef573a45
CodeyBank/simple-database-using-postgres
/postGRE_script.py
2,132
3.671875
4
import psycopg2 def create_table(): connection = psycopg2.connect("dbname='shop' user='postgres' password='Thebossm@#995' host='localhost' port='5432'") cur = connection.cursor() cur.execute("CREATE TABLE IF NOT EXISTS store (item TEXT, quantity INTEGER, price REAL)") connection.commit() c...
98d271d6aebde98570afec7675016381b49c3d2f
shanthivimalanataraajan01/code
/46player.py
127
3.625
4
#ms import math n=int(input()) r=n*(math.pi)/180 if r<1 and r>0: print(round(math.sin(r),2)) else: print(round(math.sin(r)))
da4171e80748dc6cb078dad37b1d4a25c310a1f5
shanthivimalanataraajan01/code
/isogram.py
166
3.515625
4
# your code goes herems s=input() s1=s.lower() l1=[] c=0 for i in s1: if i.isalpha(): if i in l1: c=c+1 l1.append(i) if c>1: print('No') else: print('Yes')
3baa3eee1491aa9b70e7e3c7da852466fd30840d
shanthivimalanataraajan01/code
/playerholiday.py
168
3.625
4
#ms a=["Monday","Tuesday","Wednesday","Thursday","Friday"] b=["Saturday","Sunday"] c=input() if c in a: print("no") elif c in b: print("yes") else: print("invalid")
41f803886799e9665f96f2b4d4068b24b1e9d087
shanthivimalanataraajan01/code
/186pl.py
81
3.515625
4
#m,s a=input() if "Vishal" and "Sundar" in a: print("yes") else: print("no")
0165f32ada56de17f796ac49060e7b081a891f98
shanthivimalanataraajan01/code
/huntduplicate.py
112
3.53125
4
# your code goes here from collections import OrderedDict a=input() b="".join(OrderedDict.fromkeys(a)) print(b)
eabb73a4092281f19c17ab551327848bcf523dc5
kahei-li/python_revision
/days-calculator/time-till-deadline.py
514
4.15625
4
from datetime import datetime user_input = input("enter your goal with a deadline separated by colon. e.g. goal:dd/mm/yyyy\n") input_list = user_input.split(":") goal = input_list[0] deadline = input_list[1] print(input_list) deadline_date = datetime.datetime.strptime(deadline, "%d/%m/%Y") # converting input date in...
afc51782bff39b1481e95e13b6bcfd4807f1c839
mboudiaf/cs229-supply-chain
/code/RL_code/src/experiment/experiment.py
3,095
3.5
4
author = 'Malik Boudiaf, mboudiaf@stanford.edu' import matplotlib.pyplot as plt class Experiment(object): """ An experiment matches up a task with an agent and handles their interactions. """ def __init__(self, task, agent): self.task = task self.agent = agent self.stepid = 0 ...
9c186957aa455567eaab702b1423e2a3a064f4ea
fcunhaneto-test/pyalgorithms
/graphs/dfs.py
5,363
3.9375
4
#!/home/francisco/.pyvenv/mypython3/bin/python3 # -*- coding: utf-8 -*- """ This module implement a DFS(Depth First Search) function for a graph. It also implements a topological ordering function and another to find a strongly connected connection. """ from graphs.graph_implement import * class DFSVertex(): """...
63dbcdb8d119977dd0dcb80819b15c4cbb6a9194
PierreGe/bayes-classification
/src/utilitaires.py
587
3.765625
4
# -*- coding: utf-8 -*- # Mathieu Bouchard && Pierre Gerard import numpy def minkowski(x, y, p=2.): """ Calcule la distance Minkowski entre un vecteur x et une vecteur Y """ if type(x) == float or type(x) == int: x = numpy.array([x]) if type(y) == float or type(y) == int: y = nump...
6b1d4fb1f4a5272b0963df5ddd5840be347d291b
zahranorozzadeh/tamarin6
/main.py
3,930
3.609375
4
def read_from_database(): try : products = [] f = open("e:/kelass mohandes aemi/6/zahra_store/database.csv","r") big_text = f.read() products_list = big_text.split('\n') for i in range(len(products_list)): info = products_list[i].split(',') ...