blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
aaf02763d3b8ef0952f681de941f98a57a8bf35a | jailukanna/100daysofcodechallenge | /day16_Hacker_rank challenge.py | 641 | 4.25 | 4 | # https://www.hackerrank.com/challenges/word-order/problem
# Problem Statement:You are given words. Some words may repeat. For each word, output its number of occurrences.
# The output order should correspond with the input order of appearance of the word.
'''
Sample Input
4
bcdef
abcdefg
bcde
bcdef
Sample Output
... |
ce42c743dd7fb273d979517afba641754ddaf48a | corifeo/challenges | /reverse_vowels.py | 654 | 4.28125 | 4 | """
Write a function that takes a string as input and reverse only the vowels of a string.
"""
VOWELS = set('aeiou')
def reverse_vowels(input_string):
string = list(input_string)
vowels = []
indexes = []
# loop through string to find vowels
for x, y in enumerate(string):
if y in VOWELS:
... |
77bc0334264181a3e05ccefa0b198423d1df9bf5 | kikiyoung/425-Machine-Learning | /HW3/homework3.xinyuan.py | 10,671 | 3.65625 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Homework Assignment 3
# Xinyuan Yang
#
# UID:305255240
# ## Problem I. Logistic Regression
# In[45]:
import numpy as np
import matplotlib.pyplot as plt
from getDataset import getDataSet
from sklearn.linear_model import LogisticRegression
# Starting codes
# Fill in t... |
483e12218f140a769b22b2ac23dbd6240bef948e | alestrzelec/python | /ldld.py | 205 | 3.625 | 4 | a = [1,2,3]
b = [3,4,8]
#while len(a) > 0:
# a.pop()
# print "lala"
c = []
for i in range(len(a)):
c.append(a[i] + b[i])
print c
for i in range(len(a)):
a[i] = a[i] + b[i]
print a |
d7e44a9854e0cc34b7606ac9bc78182537928eca | jake1512/SE04-Nhom29.1 | /rotation.py | 1,539 | 3.5 | 4 | import math
# 3D rotation
# rotate by X axis
def rotateX3D(theta, posxy):
sinTheta = math.sin(math.radians(theta))
cosTheta = math.cos(math.radians(theta))
newPosXY = []
for node in posxy:
tmpz = node[2]
tmpy = node[1]
z = tmpz * cosTheta + tmpy * sinTheta
y = tmpy... |
ee0f6e3f3598f5478d3cac3c224b5576ceae38f2 | daniel-amaral/temp-trabalho-ad | /entidades/evento.py | 868 | 3.5625 | 4 | class Evento():
def __init__(self, tipo_de_evento, func_gera_amostra):
self.__tipo_de_evento = tipo_de_evento
self.__func_gera_amostra = func_gera_amostra
self.__instante = None
@property
def tipo_de_evento(self):
return self.__tipo_de_evento
def instante(self):
... |
2534535d0f1d7f205565c9c152f986274e0f71cc | lukeFalsina/StudyPlanGeneratorPolimi | /GenerateStudyPlan.py | 2,655 | 3.703125 | 4 | # GenerateStudyPlan.py
# This small Python script takes as an input the solution provided
# by AMPL on the study_plan.mod and saves in an outfile file
# the corresponding study plan table using courses information
# stored in the auxiliary file "course_info.txt"
#
# Author: Luca Falsina
#
from tabulate import tabulat... |
313b1311d3ebeaec945301ce2cbbf4f70ec61c46 | jeffseif/projectEuler | /src/p043.py | 656 | 3.625 | 4 | #! /usr/bin/python3
# The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property.
# Let d1 be the 1st digit, d2 be the 2nd digit, and so on. In this way, we note the following:
# d2d3d4=40... |
a8b7588ed349fd0cc87a9653ef7c6c22af7e741f | dhankhar313/Coursera-Courses | /An-Introduction-to-Programming-the-Internet-of-Things-(IOT)-Specialization/4. The Raspberry Pi Platform and Python Programming for the Raspberry Pi/Week 3/assignment.py | 95 | 4 | 4 | temp = []
for i in range(3):
temp.append(int(input('Enter number:')))
print(sorted(temp))
|
a27e67abea3a173a443e8e8a8b06bdf1eb3c6ad0 | Yaswanthbobbu/IQuestions_Python | /Questions/9. swap any element.py | 223 | 3.859375 | 4 | list =[1,2,3,4]
#approach
list[0],list[2]=list[2],list[0]
print(list)
#tuple
get=(list[0],list[2])
list[2],list[0]=get
print(list)
#pop
pos1=list.pop(1)
pos2=list.pop(2)
list.insert(1,pos2)
list.insert(3,pos1)
print(list)
|
b69d85df1e94e594b26c9019b77ea5fb53eb369a | hasanIqbalAnik/math-prog | /find_group_generator.py | 530 | 3.53125 | 4 | from collections import defaultdict
# we find the generators of a cyclic group formed by F*_p where p is any prime number.
def generate_group_elements(prime):
return [x%prime for x in range(1, prime)]
def find_all_group_gen(group_elems, prime):
d = {k: True for k in group_elems}
res = []
for elem in group_elems... |
1d0442cb0b294d47c33f6a9c2c8831338e604ce3 | developeryuldashev/python-core | /python core/Lesson_10/Class_work1/methods.py | 491 | 3.53125 | 4 | # coding=utf-8
def Print(x):
for i in x:
for j in i:
print(j, end=' ')
print()
def Input(m,n):
x = []
for i in range(m):
b = []
for j in range(n):
b.append(int(input('x[{}][{}]='.format(i,j))))
print('--------------')
x.append(b)
r... |
1e2354a47691c33d42ae92a8dfa5c3e9dd1e2def | Life-of-pi/python_bootcamp | /sets.py | 178 | 3.625 | 4 | mylist=[4,6,4,6,4,4,67,6]
print(set(mylist))
my_dict= { 'siva':[45,6,4,6,4,5], 'sanjay':{'c':[45,3,67,34,6],'java':[45,4,3,6,8]}}
print(my_dict)
print(my_dict.keys())
|
a568e24e944303c95fd0528c19a686d5fbfa9c6e | shengqianfeng/deeplearning | /pystudy/io/file_rw.py | 3,602 | 4.34375 | 4 |
"""
读文件:
要以读文件的模式打开一个文件对象,使用Python内置的open()函数,传入文件名和标示符
"""
# f = open('D://text.txt', 'r') # 标示符'r'表示读,这样,我们就成功地打开了一个文件
# 如果文件不存在,open()函数就会抛出一个IOError的错误,并且给出错误码和详细的信息告诉你文件不存在
# FileNotFoundError: [Errno 2] No such file or directory: 'D://test.txt'
# 如果文件打开成功,接下来,调用read()方法可以一次读取文件的全部内容,Python把内容读到内存,用一个str对象表示
#... |
3bcb4c28f6c4c149a686896e8cae08ea8fd61f74 | Mcilie/TaliffExer | /p06 r12 ilie michael CODE 57.py | 150 | 4.1875 | 4 | year = int(input("Enter year: "))
if year %4 ==0 and year %400 ==0 and year %100 != 0:
print("Leap year")
else:
print("year is not Leap")
|
3ffaf93b3a7f8baa7f499784cfee01687c5f04dc | jaysimon/leetcode | /junior/02-linker/03-reverseList.py | 1,187 | 4.0625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*- #
# Copyright (C) 2018 ShenZhen Hian Speech S&T Co.,Ltd. All rights reserved.
# FileName : reverseList.py
# Author : Hou Wei
# Version : V1.0
# Date: 2019-02-21
# Description:
# History:
class ListNode:
def __init__(self, x):
self.val = x
self.next = N... |
7b36083d01865d8bf91f881a9bdce25f897f5885 | sathya-sai/Python | /DataStructure/BalancedParanthisis/paranthisis.py | 546 | 3.71875 | 4 | from DataStructure.utility import Stack
def parChecker(symbolString):
s = Stack()
balanced = True
index = 0
while index < len(symbolString) and balanced:
symbol = symbolString[index]
if symbol == "(": # if ( push the element
s.push(symbol)
elif symbol == ")": # if... |
7e69b56f88d81488abc816174d0bca993ff279f1 | MoisesSantosC/cursoPythonDSA | /Cap02/Projeto/calculadora.py | 952 | 4.34375 | 4 | # Cabeçalho
print(f'{19*"*"} Python Calculator {19*"*"}')
print('\nSelecione o número de opção desejada:\n')
print('1 - Soma\n2 - Subtração\n3 - Multiplicação\n4 - Divisão')
# Variáveis de entradas do usuário
op = input('\nDigite a sua opção (1/2/3/4): ')
num1 = int(input('\nDigite o primeiro número: '))
num2 = int(in... |
fae611e30af9637784648551481042cbae120235 | eduardogomezvidela/Summer-Intro | /4 Turtles/Exercises/13.py | 525 | 4.46875 | 4 | #A sprite is a simple spider shaped thing with n legs coming out from a center point. The angle between each leg is 360 / n degrees.
#Write a program to draw a sprite where the number of legs is provided by the user.
import turtle
screen=turtle.Screen()
screen.bgcolor("black")
alex=turtle.Turtle()
alex.color("white")
... |
acbeb43bb40d31fa2440b0402f3582f9dcd40d15 | captainsafia/advent-of-code-2018 | /day-1/solution.py | 839 | 3.515625 | 4 | # Iteration 1
with open("frequencies.txt") as frequencies:
result = 0
numbers = frequencies.read().splitlines()
for number in numbers:
if number.startswith("-"):
number_as_int = int(number[1:])
result -= number_as_int
elif number.startswith("+"):
number_as... |
2888747acd6b8a883e31b72ad4ce7b0b993f4eb4 | cmcfaul/teaching | /quadratic_cancellation_errors.py | 1,063 | 4.21875 | 4 | #!/usr/bin/python
"""
The Quadratic Equation ax^2 + bx + c = has two solutions.
the solutiosn can be written as either:
x1,2 = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
x'1,2 = \frac{-2c}{-b \pm \sqrt{b^2 - 4ac}}
"""
VERSION = '$Id: $'
from cmath import sqrt
def quadratic_traditional(a,b,c):
"""
Provides the... |
b3144c6e663e4a19bd039206323310edbb7ba216 | mario-sanz/Connect4-AI | /connect4-AI.py | 12,492 | 3.640625 | 4 | import numpy as np
import pygame
import sys
import math
import random
ROW_COUNT = 6
COLUMN_COUNT = 7
BLUE = (0,0,255) # blue color for the screen
BLACK = (0,0,0) # black color for the screen
RED = (255,0,0) # red color for the tiles of player 1
YELLOW = (255,255,0) # yellow color for the tiles of player 2
... |
022f4c829f0cb234d522d70d2ef561f710320d49 | TNY-NeXT/python- | /线程的简单示例2.py | 523 | 3.6875 | 4 | import time
import threading
begin = time.time()
def foo(n):
print('foo %s' % n)
time.sleep(1)
print('end the foo')
return
def bar(n):
print('bar %s' % n)
time.sleep(3)
print('end the bar')
return
#串行执行花费4秒多
# foo(2)
# bar(3)
#并行执行3秒多
t1 = threading.Thread(target=foo, ... |
a592c5b797a7606e9e60a888c7bcaae9a82c8a02 | Aasthaengg/IBMdataset | /Python_codes/p02819/s078970240.py | 328 | 3.71875 | 4 | import math
X = int(input())
def is_prime(x):
a = int(math.sqrt(X)) + 1#ある数が素数かどうかはO(√A)で判定できる
for i in range(2,a):
if x % i == 0:
return False
return True#xは素数
for j in range(X,10**5+4):
if is_prime(j):
ans = j
break
print(ans) |
34091697afe304a8dad01e2899f1ff82d11cb726 | Arjahck/Cipher | /programme_DE.py | 8,266 | 3.5 | 4 | from math import sqrt
'''
linear cryptography
'''
def diviseurs(n):
D,racine=[1],int(sqrt(n))
fin=racine+1
for d in range(2,fin):
if n%d==0 :
D.extend([d,n//d])
D=sorted(set(D))
return D
def phi(n):
D=diviseurs(n)
Phi,somme=[1],"1"
for i,div in e... |
37633f85fe0abbdd5b60b3d9110be497b103b868 | Heisenberg66/ORAL1 | /10 Exemples illustrant l’utilisation de différentes méthodes de résolution de problèmes algorithmiques/euclide.py | 219 | 3.53125 | 4 | def euclide_iter(a,b):
while a%b!=0:
a,b=b,a%b
return b
def euclide_rec(a,b):
if a%b!=0:
return euclide_rec(b,a%b)
return b
print(euclide_iter(96,76))
print(euclide_rec(96,76))
|
7f80f286089a6ee8e03577172a7364b258baf86c | mikephys8/The_Fundamentals_pythonBasic | /ex2-1.py | 857 | 4.03125 | 4 | __author__ = 'Administrator'
def get_capital(country):
countries = {'Canada': 'Ottawa', 'Greece': 'Athens', 'France': 'Paris',
'Germany': 'Berlin', 'Japan': 'Tokyo', 'Spain': 'Madrid',
'Norway': 'Oslo'}
for item in countries:
if country == item:
return coun... |
6de89fef9facbd1163a8bad5b6ac107cd9b8f196 | Yta-ux/python_algorithms | /basic_algorithms/aumento_mútiplos.py | 281 | 3.703125 | 4 | s1=float(input('Digite seu salário:'))
maior= s1 +(s1 * (10/100))
menor= s1+(s1 * (15/100))
if(s1<= 1.250):
print('Seu salário era de R${:.3f}, passou a ser R${:.3}'.format(s1,menor))
else:
print('Seu salário era de R${:.3f}, passou a ser R${:.3f}'.format(s1,maior))
|
2fa39686be88bc5184bcaefc397e6538c4c4059b | Prateek478/ds_algo_problem_solving_python- | /15_smaller_difference_pair.py | 1,639 | 4.09375 | 4 | '''
Smallest Difference pair of values between two unsorted Arrays
Given two arrays of integers, compute the pair of values (one value in each array) with the smallest (non-negative) difference. Return the difference.
Examples :
Input : A[] = {l, 3, 15, 11, 2}
B[] = {23, 127, 235, 19, 8}
Output : 3
That is, the... |
bb8c57cbb13e79dca311f2f43044a5dd0e0cf6c0 | vcaptainv/Painting | /turtle_interpreter.py | 3,211 | 4.125 | 4 | #Yusheng Hu
#turtle interpreter
#VERSION 2
import turtle
import random
class TurtleInterpreter:
def __init__(self, dx = 800, dy = 800):
turtle.setup(width=dx, height=dy)
turtle.tracer(False)
def drawString(self, dstring, distance, angle):
#create two lists which can include information of turtle position and... |
c3faeb46497f6b620c545302a636b958516f3801 | SushantKrMishra/Basic-School-administration-Tool | /FirstProject.py | 1,542 | 3.984375 | 4 | #project1: Basic School administrationTool
import csv
def write_into_csv(info_list):
with open('student_info.csv' , 'a', newline= '') as csv_file:
writer = csv.writer(csv_file)
if csv_file.tell() == 0:
writer.writerow(["Name","Age","Contact Number","Email Id"])
writer.wr... |
37efaebfc1da15f21a019b77254c84169d515470 | jwasher/fakepandas | /fakepandas.py | 6,532 | 3.984375 | 4 | import operator
def num_rows(d):
'''
Get number of data rows.
Raise ValueError if not all columns have the same number of rows.
'''
if len(d) == 0:
return 0
def gen_columns():
for v in d.values():
yield v
columns = gen_columns()
length = len(next(columns))
... |
d17abcd718bf3f8d3bdb48edfaadd38dc3b80cf2 | Joedmo15/Continental | /main.py | 5,778 | 3.546875 | 4 | import random
from random import shuffle
def straight_check(list, run_count=1):
list.sort()
if len(list) == 1:
if run_count == 4:
return True
else:
return False
elif run_count == 4:
return True
elif list[0] + 1 == list[1]:
return st... |
93540707ca6bc8d6e2515228b90513490300b12c | cristobalgh/python | /dellibro/rolldie.py | 713 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Dec 17 15:07:08 2018
@author: cristobal.galleguill
"""
import random
def rolldie():
return random.choice([1,2,3,4,5,6])
def rollcoin():
return random.choice([0,1])
def rollN(n, fun):
result = ''
for i in range(n):
result = result ... |
8aba9c68a5fb936fa275bcba14e16a775ac37cb7 | DurgaMahesh31/Python | /source/datatypebasics.py | 1,512 | 4.03125 | 4 | """ This module is to practise data types"""
# to comment out the code select the line of code and ctrl + /
name = "Python"
print(name)
print(name[0])
print(name[-1])
a = 20
print(a) # 20
print(type(a)) # <class 'int' >
b = a
print(b) # 20
print(type(b)) # < class 'int' >
print(id(a), id(b)) # 111 111
print(a is b) ... |
2d41ffaea069e6de022f6c4cc06b0fd9bb118db8 | karockai/Yongorithm | /자료구조/스택큐/주식가격.py | 561 | 3.578125 | 4 | # https://programmers.co.kr/learn/courses/30/lessons/42584
prices = [1, 2, 3, 2, 3]
def solution(prices):
from collections import deque
answer = deque([0])
time = 0
stack = [[prices[-1], 0]]
for i in range(len(prices)-2, -1, -1):
time += 1
while (stack and prices[i] <= stack[-1... |
2877537b6df22debf3273d02f8534c90019de37e | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_200/1318.py | 586 | 3.5 | 4 | def fix_one_inversion(n):
num_digits = len(n)
for i in range(num_digits - 1):
if (int(n[i]) > int(n[i + 1])):
if (i == 0 and n[i] == '1'):
return ['9'] * (num_digits - 1)
n[i] = str(int(n[i]) - 1)
return n[: i + 1] + ['9'] * (num_digits - i - 1)
return n
t = int(input())
for case... |
866f0e29e617f5ea8cd011fcbd351d96ec507270 | dsiegler2000/Coeus | /src/evaluation.py | 33,207 | 3.734375 | 4 | """
All code related to evaluating a board state
"""
import json
import logging
import os
from typing import Union, List, Optional, Tuple
import chess
import utils
from movegeneration import SearchBoard, PieceList
from utils import count_bin_ones
logger = logging.getLogger(os.path.basename(__file__))
class BoardEv... |
4edd924a4bc2ae69e4aad8b38457d64b3de17079 | spinon187/practice | /treepaths.py | 487 | 3.734375 | 4 | class Solution:
def binaryTreePaths(self, root):
results = []
self.dfs(root, '', results)
return results
def dfs(self, node, string, arr):
if not node:
return
if node.left or node.right:
string += (str(node.val) + '->')
... |
5f631cfcc81db77a83ac3f2cc89b95d657d3a3b6 | Bot-Zavod/botchallenge | /board/_pathfinding.py | 5,422 | 4.03125 | 4 | """ Pathfinding methods of the board """
from typing import Tuple, List, Set
class Node:
"""A node class for A* Pathfinding"""
def __init__(self, parent=None, position=None):
self.parent = parent
self.position = position
self.g = 0
self.h = 0
self.f = 0
def __eq... |
6158b346fb994583de0e54ac4a3f98f47c3bd422 | ToddZenger/PHYS19a | /tutorial/lesson01/numpy_tutorial.py | 2,937 | 4.3125 | 4 | """
Author: Todd Zenger, Brandeis University
The purpose of this program is to tie in between lists and Numpy arrays
and to introduce some concepts of Numpy
"""
import numpy as np
"""
Anytime we want to use Numpy, we must write this on top of our script
"""
# First, let's look at lists once again
x = [4, 9, 12, 13]
y... |
e8d5f3b501d1acebe6f6e2f435a39d40df9f7ed2 | Zahidsqldba07/practice-python-2 | /08_rock_paper_scissors.py | 1,265 | 4.25 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays
(using input), compare them, print out a message of congratulations to the
winner, and ask if the players want to start a new game)
"""
player1 = str(input("Who is player 1?"))
player2 = str(input... |
cabe516536213d890ba5efa4e3f674396b99d36b | xiangge/xiangge_repo | /programing/learn_python/test05.py | 1,331 | 3.578125 | 4 | #encoding:UTF-8
# https://leetcode.com/problems/next-permutation/description/
def nextPermutation(nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
1,2,3 → 1,3,2
3,2,1 → 1,2,3
1,1,5 → 1,5,1
"""
if len(nums) >1:
# get start place
... |
e7856c335ad7acde5c072c0db212eae9a098e870 | amanjaiswalofficial/100-Days-Code-Challenge | /code/python/day-24/Dictionary.py | 309 | 3.71875 | 4 | import math
dictn={}
name=''
n=int(input())
for x in range(n):
name=str(input())
phy=float(input())
chem=float(input())
maths=float(input())
totalavg=float(phy+chem+maths)/3
dictn[name]=totalavg
uinput=str(input())
for x in dictn:
if(x==uinput):
print(float(dictn[x]))
|
a5d1c6f6a3f39e6f76b68dd43f029dac37ee8ea3 | Victorkme/PythonProjects | /pythonscripts/mineSweeper.py | 3,456 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Apr 22 11:22:12 2019
@author: User1
"""
matrix = [[True,False,False],[False,True,False],[False,False,False]]
def minesweeper(matrix):
if not matrix:
return [[0]]
rows = len(matrix)
columns = len(matrix[0])
result = [[0 for col in range(columns)] for ... |
8f542901b827e6a5a6939872b7dfa9bc83625cf8 | Viiic98/holbertonschool-machine_learning | /supervised_learning/0x0D-RNNs/8-bi_rnn.py | 1,390 | 4.375 | 4 | #!/usr/bin/env python3
""" Bidirectional RNN """
import numpy as np
def bi_rnn(bi_cell, X, h_0, h_t):
""" performs forward propagation for a bidirectional RNN
- bi_cell is an instance of BidirectionalCell that will
be used for the forward propagation
- X is the data to be used, given as... |
571790eba0c2bce61b187353f19fc766cd7cbc05 | SidStraw/leet-codes | /2021-08/2021-08-02 (day15)/CXPhoenix/solution1.py | 891 | 3.90625 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode:
if not l1 and not l2:
return None
if not l1:
... |
18fffccc83edc59159b2e08ea72ac91f04fb855b | q1003722295/WeonLeetcode | /_44-WildcardMatching/WildcardMatching1.py | 2,526 | 3.53125 | 4 | '''
给定一个字符串 (s) 和一个字符模式 (p) ,实现一个支持 '?' 和 '*' 的通配符匹配。
'?' 可以匹配任何单个字符。
'*' 可以匹配任意字符串(包括空字符串)。
两个字符串完全匹配才算匹配成功。
说明:
s 可能为空,且只包含从 a-z 的小写字母。
p 可能为空,且只包含从 a-z 的小写字母,以及字符 ? 和 *。
示例 1:
输入:
s = "aa"
p = "a"
输出: false
解释: "a" 无法匹配 "aa" 整个字符串。
示例 2:
输入:
s = "aa"
p = "*"
输出: true
解释: '*' 可以匹配任意字符串。
示例 3:
输入:
s = "cb"
p = "... |
98c36e38b891c3afeef4d5de8729ed32d73e68bf | zhio/python_notebook | /常见编程语言语法比较/example.py | 1,442 | 3.640625 | 4 | # array = []
# array.append(2)
# array.append(3)
# array.append(1)
# array.append(0)
# array.append(2)
# #链表
# class ListNode:
# def __init__(self, x):
# self.val = x # 节点值
# self.next = None # 后继节点引用
# n1 = ListNode(4)
# n2 = ListNode(5)
# n3 = ListNode(1)
# n1.next = n2
# n2.next = n... |
f20f1b21fb8964b8f5b1bd62226ed18e61c12ac8 | hamseul/ch03-2 | /input_multiply.py | 131 | 3.78125 | 4 | num1=int(input("첫 번째 수를 입력하세요. : "))
num2=int(input("두 번째 수를 입력하세요. : "))
print(num1*num2)
|
702f52d934e24fc003f1cee734fcc5498e5897f4 | AlbertoPeon/project-euler | /40/40.py | 564 | 3.578125 | 4 | #! /usr/bin/env python3
# https://projecteuler.net/problem=40
from functools import reduce
from itertools import count
from operator import mul
important_digits = [1, 10, 100, 1000, 10000, 100000, 1000000]
length = 0
result = []
for number in count(start=1):
str_number = str(number)
if length < important_di... |
f29edad0513c504ff865a683746fe446c3558f8b | JaehoonYi/Python-GCSE-2019-2021 | /python/LESSON ACTIVITIES FOR YEAR 1, TERM 1/week 5/activity 5.2.4.py | 141 | 3.765625 | 4 | answer = input("Is it snowing? ")
if answer == ("yes"):
print ("You’d better take a sledge.")
else:
print("Have a good day.")
|
f98890dd1b38df1a49b1bfe0f447719307bdc2fb | dkssyd07/OlympicLOGO | /LOGO.py | 308 | 3.671875 | 4 | #Olympic Logo
import turtle as p
def drawCircle(x,y,c = 'red'):
p.pu()
p.goto(x,y)
p.pd()
p.color(c)
p.circle(30,360)
p.pensize(7)
drawCircle(0,0,'blue')
drawCircle(60,0, 'black')
drawCircle(120,0,'red')
drawCircle(90,-30,'green')
drawCircle(30,-30,'yellow')
p.done() |
4f659fd65b0643f5a4b9d496792e2e683202168e | iamnaf/Meedya | /seriesdownloader.py | 2,858 | 3.515625 | 4 | import os
import bs4
from selenium import webdriver
import urllib2
from bs4 import BeautifulSoup
"""
download bs4 by using pip install bs4 on the command line
download selenium by using pip install selenium on the command line
"""
"""
This is a damn crude code i just wrote, but it sure downloads something... |
c4430f27d22bd62b083c77325b9d408e5af1ce80 | oscar-liu/unittest.io | /fn.py | 177 | 3.5 | 4 | #待测试的方法函数
#加
def add(a, b):
return a+b
#减
def minus(a, b):
return a-b
#乘
def multi(a, b):
return a*b
#除
def divide(a, b):
return a/b
|
efe7c337cce5459b6c1a24b10701af7244db5c06 | kt3a/GWCPython | /ClassDemo.py | 849 | 4.15625 | 4 | import tkinter
from tkinter import Button
#define the quit function
def set_quit():
top.destroy()
#to show text
def show_text():
message.insert(0,e.get())
#Layout
top = tkinter.Tk()
top.geometry("300x300")
#label
label = tkinter.Label(top, text = "Hello World!")
top.title("First GUI")
label.pack()
#En... |
ee12cd1e29a65a784de1e44a9134f19b3ce7877a | MannazX/mannaz | /Learning Python/Fibbonacci sequence.py | 1,646 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 10:39:07 2019
@author: magge
"""
import numpy as np
import matplotlib.pyplot as plt
import math as m
"""
The following script is about the Fibonacci sequence and the
Golden ratio, the first part of the script approximates
the golden ratio to 15 decimal places (40 iter... |
e123157dad83fddac5e778c8485e75d281fea483 | Lindisfarne-RB/GUI-L3-tutorial | /Lesson52OOPS.py | 1,433 | 4.1875 | 4 | '''Docstrings for documenting classes
We already know about writing comments to document our code. With classes, we usually write docstrings to say what the purpose of the class is. You might remember these from looking at functions in level 2.
A docstring is a description written on the first line of a class (or func... |
c73d58c4838b4250069c2f3c242c9bc2feb96014 | MinWooPark-dotcom/learn-pandas | /Part1/1.15_transpose.py | 1,842 | 3.546875 | 4 | import pandas as pd
exam_data = {'이름': ['서준', '우현', '인아'],
'수학': [90, 80, 70],
'영어': [98, 89, 95],
'음악': [85, 95, 100],
'체육': [100, 90, 90]}
df = pd.DataFrame(exam_data)
print(df)
print('\n')
# 이름 수학 영어 음악 체육
# 0 서준 90 98 85 100
# 1 우현 80 89 95 9... |
bd24828a4d9cb8e602cd8e75e5c0221a8dd05837 | 969452199/pythonproject | /day02/day02_class09.py | 1,132 | 3.9375 | 4 |
'''集合'''
l1 = set([1,2])#{1, 2}
print(l1)
l2 = {1,(1,2,3)}
print(l2)#{1, (1, 2, 3)}
l3 = {2,3,4,2,3,5}#集合互异
print(l3)#{2, 3, 4, 5}
print(type(l3))#<class 'set'>
l4 = {3,2,4,5}
print(l3 == l4)#无序性#True
print([1,2,3] == [2,1,3])#False
#列表不能作为集合的元素
#a = {1,2,[3,4]}
#创建可变集合用set(),不可变用frozonset()
a = [1,2,3,4,5,5,6]
prin... |
6c7a51ebed92033b6fac38a4585f51d499cedc53 | yanshuyu/learn-python | /buildinFuction/map.py | 408 | 4.15625 | 4 |
def pow2(x):
return x**2
def add(x,y):
return x+y
if __name__ == "__main__":
numbers = [1, 2.2, 5, 7, 9]
mapnumbers = map(pow2, numbers)
print('numbers before map: ', numbers)
print('map numbers: ', mapnumbers, [e for e in mapnumbers])
print('numbers after map: ', numbers)
arr1 = [... |
bfef1a8c0c8f1e60d07d1c55e73deaf68d4b3878 | nowmaciej/python | /unittests/circle_area.py | 206 | 3.96875 | 4 | from math import pi
def circle_area(r):
if type(r) not in [float,int]:
raise TypeError("value mus be number > 0")
if r < 0:
raise ValueError("value must be > 0")
return pi*(r**2) |
d141a088dc89774f913f10eb08b7cd216bf90081 | gabits/training | /python/project_euler/002-fibonacci_evens_sum_under_4million.py | 942 | 3.828125 | 4 | """Each new term in the Fibonacci sequence is generated by adding the previous
two terms. By starting with 1 and 2, the first 10 terms will be 1, 2, 3, 5, 8,
13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed
four million, find the sum of the even-valued terms.
"""
d... |
bb50aa7e68ecddaeefd7d65e29fbef5d46f3e310 | 0911012580/ccc | /lesson 02.py | 130 | 3.515625 | 4 | var = 2005
print(var)
real = 1
print(real)
name = 'bình minh'
place = 'bắc ninh'
print( name + ' lives in ' + str(place))
|
d64417548e1a5eef149ea81f3efaa0bfd61c3d6b | Dutta-SD/CC_Codes | /Competitions/Atcoder/ABC_200/C.py | 322 | 3.53125 | 4 | from itertools import combinations
n = int(input())
c = combinations (range(n), 3)
candidates = [tuple(map(int, input().split())) for _ in range(n)]
teamPower = -1
for item in c:
power = min([max([i, j, k]) for i, j, k in zip(*[candidates[p] for p in item])])
teamPower = max(power, teamPower)
print(teamPowe... |
198351a7649298d2d75f6e9b7d1e643aeea89d38 | nazaninsbr/Introduction-to-Selection | /Intro-to-Numpy/reshape.py | 132 | 3.796875 | 4 | import numpy as np
a = np.array([[1, 2], [3, 4], [5, 6]])
print(a.shape)
a= a.reshape(2,3)
print(a)
a=a.reshape(6, 1)
print(a) |
970e0dddffd4ecd28345cc1c384412736dc5dbfe | sudhansom/python_sda | /python_fundamentals/00-python-HomePractice/w3resource/conditions-statements-loops/problem2.py | 916 | 4 | 4 | """
Write a Python program to convert temperatures to and from celsius, fahrenheit.
[ Formula : c/5 = f-32/9 [ where c = temperature in celsius and f = temperature in fahrenheit ]
Expected Output :
60°C is 140 in Fahrenheit
45°F is 7 in Celsius
"""
print("choose the option : \na. Celcius to Fahrenheit. \nb. Fahrenheit... |
617eef0a8d130abb7e6c2d0ea01b5a4707d02ac5 | qirh/tic_tac_toe | /main.py | 9,534 | 3.640625 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import sys
import copy
from random import randint, shuffle
class IllegalMove(Exception):
pass
class Player():
def __init__(self, char, name):
self.char = char
self.name = name
def __repr__(self):
return f'({self.char})'
def __eq__(self, othe... |
b849934f1bdcc1e6394affa37c5b98b6dca2ba93 | Tetsuya3850/DSA-Primitives | /ArraysStrings/shortest_sequentially_covering.py | 1,189 | 3.640625 | 4 |
def smallest_sequentially_covering(paragraph, keywords):
# Time O(N), Space O(M), where N is the length of the paragraph and M is the length of keywords
keyword_to_idx = {k: i for i, k in enumerate(keywords)}
latest_occurrence = [-1] * len(keywords)
shortest_subarray_length = [float("inf")] * len(keywo... |
3b49b8fe287935488da4d2f3369f644011b851cc | poulomikhaiitm/Shinichi-Kudo | /minutes & seconds.py | 221 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri May 17 13:54:03 2019
@author: shinichikudo
"""
N = int(input('Enter the value of Minutes = '))
P = int(input('Enter the value of seconds = '))
S = (N*60) + P
print(S) |
edd13442611e8bae82f91cc3805d68a503873f6a | Phys767-Spring17/Azmain_fizzbuzz | /fizzbuzz/fizzbuzz.py | 397 | 4.15625 | 4 | #def fizzbuzz(number):
# <code here operates on number>
# return <something>
def fizzbuzz(number):
if number % 3 == 0 and number % 5 == 0:
return 'fizzbuzz'
elif number % 3 == 0: # % means remainder after dividing by the following number
return 'fizz'
elif number % 5 == 0: # remainder... |
1d25a17421d9fd3092579a5d38ef0376b7195232 | XiangyuDing/Beginning-Python | /Beginning/python3_cookbook/ch02/06-ignorecase.py | 601 | 4.53125 | 5 | # 2.6 字符串忽略大小写的搜索替换
import re
text = 'UPPER PYTHON, lower python, Mixed Python'
print(re.findall('python', text, flags=re.IGNORECASE))
print(re.sub('python','snake',text, flags=re.IGNORECASE))
def matchcase(word):
def replace(m):
text = m.group()
if text.isupper():
return word.upper()
... |
d28a2496e71fe7f63b5ed6e58b28b1b3747cf671 | votus777/AI_study | /ML/m17_pipeline_iris_keras.py | 2,415 | 3.578125 | 4 | # iris를 케라스 파이프라인 구성
# 당연히 RandomizedSearchCV 구성
import numpy as np
from keras.utils import np_utils
from keras.models import Model
from keras.layers import Input, Conv2D, Dropout, Flatten, Dense, MaxPool2D
from sklearn.model_selection import train_test_split
from sklearn.datasets import load_iris
from sklearn.... |
5610a4c02ec95d79e5c7b77ec7aa25e3fb355c5c | preethikarthi99/mysql | /mysql_crud.py | 3,419 | 3.75 | 4 |
'''
Created on Apr 20, 2017
@author: Preethi
source:
https://www.w3schools.com/python/python_mysql_insert.asp
'''
#!/usr/bin/python
import base64
import sys
import codecs
import MySQLdb
def get_db():
db = MySQLdb.connect(host="localhost", # your host, usually localhost
user="root", ... |
3926fe01aed39ab36596362396f2790bea6a1038 | manpreet7688/LearningProjects | /map_filter_lambda.py | 689 | 3.984375 | 4 | def sequare(n):
return n**2
my_list = [1,2,3,4]
print(map(sequare, my_list))
def filter_ex(n):
if n%2==0:
return n
my_list_filter = [1,2,3,4,5,6,7,8,9]
print(filter(filter_ex, my_list_filter))
# Filter another example
def splicer(name):
if len(name)%2==0:
return 'Even'
else:
... |
b5a4e4e2a514e5273bf50aa5d4326555d8764b9f | sunnysong1204/61a-sp14-website | /slides/23.py | 6,720 | 4.25 | 4 | class Tree:
"""A Tree consists of a label and a sequence
of 0 or more Trees, called its children."""
def __init__(self, label, *children):
"""A Tree with given label and children."""
self._label = label
self._children = list(children)
@property
def is_leaf(self):
r... |
fddb068475712fd6d2f1fcfd78f5e2ef3ec365af | shubham-debug/Python-Programs | /WinningStrategy.py | 657 | 3.578125 | 4 | #winning strategy
def solve(arr):
p1=0
p2=0
arr.sort(reverse=True)
p1=arr[0]
if(len(arr)>=3):
p2=arr[1]+arr[2]
elif(len(arr)==2):
p2=arr[1]
count=3
while(count<len(arr)):
p1+=arr[count]
count+=2
count=4
while(count<len(arr)):
... |
dbdeb5ef53af84fd9bc0d8d01765b04d6935a1f8 | richakbee/Back-Order-Prediction | /Data_preprocessing_prediction/preprocessing.py | 14,785 | 3.515625 | 4 | import csv
import pickle
from datetime import datetime
import os
import numpy
import pandas
import sklearn
from sklearn.impute import _knn
class preprocessing:
"""
This class shall be used to clean and transform the data before training.
Written By: richabudhraja8@gmail.c... |
668d2562096b9cefabab411ec5922a4219b2712a | Koozzi/Algorithms | /SAMSUNG/SWEA/PROBLEM/1949_등산로조정_20210419.py | 1,820 | 3.546875 | 4 | from collections import deque
def get_highest():
highest = 0
for i in range(N):
for j in range(N):
highest = max(highest, board[i][j])
return highest
def get_start_index(highest):
start_index = []
for i in range(N):
for j in range(N):
if board[i][j] == hig... |
f6a1a274dfc0fa0f79992316e690d5129351badf | jasonfreak/arena | /1025/250/main.py | 1,381 | 3.640625 | 4 | class PeacefulLine(object):
def __init__(self):
object.__init__(self)
def check(self, y):
last = y[0]
for student in y[1:]:
if student == last:
return 'impossible'
last = student
return 'possible'
def makeLine(self, x):
... |
2d67e53e3d6230ea087082e57cd3babf22c11517 | hwillmott/csfundamentals | /leetcode/257_binarytreepaths.py | 789 | 3.6875 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
# @param {TreeNode} root
# @return {string[]}
def binaryTreePaths(self, root):
def getPath(root, stringsofar, result):
... |
832c5102ccc2b4ea516737d5c0d5d8cceefda0b9 | fjguaita/codesignal | /Arcade/Intro/47_isMAC48Address.py | 646 | 3.703125 | 4 | import re
def isMAC48Address(s):
if len(s)!=17:
return False
for i in s.split('-'):
if "".join(re.findall('[0-9A-F]',i))!=i:
return False
return True if len(s.split('-'))==6 else False
def isMAC48Address(s):
return bool(re.match(('^' + '[\dA-F]{2}-' * 6)[:-1] ... |
87a0492db1130a7e9fe89e5d21f40d7d498ea71a | bramvanulden/programming | /Les6/pe6_4.py | 697 | 3.6875 | 4 | i = False
def new_password(x, y):
if x not in y:
if len(y) >= 6:
for c in y:
if c in "0123456789":
i = True
if i == True:
print("Uw wachtwoord is succesvol veranderd.")
else:
... |
435c7edab2f4dba0e99c01480e6edeb43df906dd | rafaelperazzo/programacao-web | /moodledata/vpl_data/415/usersdata/296/86505/submittedfiles/exe11.py | 222 | 3.65625 | 4 | # -*- coding: utf-8 -*-
n = int(input("Digite um número: "))
soma = 0
while (n > 0):
if 10000000 <= n <= 99999999:
resto = n%10
n = (n-resto)/10
soma = soma + resto
print(soma)
|
87d3d3720a69fab9dea3045810a52cd2ca87e800 | l0uvre/CS50-2017 | /pset6/caesar.py | 640 | 3.78125 | 4 | import sys
def main():
if len(sys.argv) != 2:
print("Usage: ./caesar k\n")
exit(1)
else:
pText = input("plaintext: ")
print("ciphertext: ", end = "")
key = int(sys.argv[1])
for char in pText:
if char.isalpha():
if char.islower():
... |
ac798dc7ff51c3c60079a7674b4d4aff2314a815 | Bill-Portugues/Proyect-Euler---Python | /28 - Number spiral diagonals.py | 309 | 3.546875 | 4 |
def SpiralWaves(number):
layers=int((number+1)/2)
OriginalNum=1
sum=1
step=2
for x in range(1,layers,1):
for y in range(1,5,1):
sum += OriginalNum + step*y
OriginalNum += step*4
step+=2
print (sum)
SpiralWaves(1001) |
44c1c5287f51ce880dcf328e17f2652ecdc6512f | rohit18259/Rummy | /rummy/rummy.py | 16,049 | 3.921875 | 4 | import pygame
import random
import time
import itertools
### This is an indian rummy game.
# we will have 1 pure sequence of 4 cards, 1 sequence of 3 cards, and 2 sets of 3 cards each.
# you have to arrange the cards in the following sequences and sets in the order as given by the marking on the game screen.
... |
02ba7b4bbc251b7fed0e4db91a93484b507f2aa8 | setu-parekh/Object-Oriented-Programming-in-Python | /private_protected_public.py | 1,834 | 4.15625 | 4 | # Public - making members (attributes and methods) of the class accessible to that particular class, derived class and also outside the derived class.
# Protected - making members (attributes and methods) of the class accessible to that particular class and its derived members.
# Private - making members (attributes ... |
73c96652f91062342de74789e7b72f95fb576a5c | coldspeed5566/coldspeed | /2019_python/01.io/loop.py | 1,226 | 3.75 | 4 | def prNum(n):
for i in range(0, n+1):
print(i, end = ' ')
print("")
#prNum(5)
def pr_Range(a, b):
for i in range(a, b):
print(i, end = ' ')
print()
#pr_Range(10, 20)
def pr_odd1(n):
x = 1
for i in range(n):
print(x, end = " ")
x += 2
print()
#pr_odd1(5)
def pr_odd2(n):
for i in r... |
88eff2ee04f6569af42783238339ab1191e6b809 | Amortized/Algorithms-and-Data-Structures | /Binomial_Fibonacci_Heaps/BinomialHeaps.py | 5,474 | 3.734375 | 4 | """ Author : Rahul
Binomial Heaps Implementation
Insert ele, Merge Heaps,Del ele, Find Min ele, Decrease Key ele,Del Min Ele all in O(log n)
"""
def test():
data = [500,20,30,400,580,60,700,80,90]
H = BinomialHeap()
tempNode = None
for d in data:
n = HeapNode(d)
if d == max(data... |
5fc93e11624f1bb89d5935e459be83f0051304aa | seema1711/My100DaysOfCode | /Day 4/removeItemLL.py | 1,440 | 4.03125 | 4 | ''' We can remove an existing node using the key for that node. We will locate
the previous node of the node which is to be deleted. Then point to the next pointer
of this node to the next node to be deleted.
'''
class Node:
def __init__(self,data=None):
self.data = data
self.next = None
class SLi... |
5fc3d93dcdc8b3ded7313b709526b21ae515137b | ClemenceLVR/Terminator | /Terminator/fonctionTerminator.py | 5,907 | 3.578125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 29 14:27:12 2018
@author: skaering
"""
import re
def findRegex(source):
# search numerical values in the text using a regex
pattern=re.compile(r"""
(([[]?[0-9]+([.,]\d+)?-[0-9]+([.,]\d+)?[]]?)# interval
| #or
... |
83a09a56d522ef36d53b55566a287086803c2bcb | gmumar/Optimization_problems | /warehouse/solver_working.py | 5,674 | 3.5625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
def cheapestWarehouse_dist(wlist,n):
# Selects the nth cheapest warehouse by least avg distance cost whose capacity is greater than 0
global avgDistanceToWarehouse
n = n - 1
return avgDistanceToWarehouse[n][1]
def cheapestWarehouse_fixed(wlist... |
c1776cc19ff56b0e98342dbcbeff905d09432b6e | indiee27/IPMI-Portfolio | /Python/Week02/utils2.py | 9,052 | 3.5625 | 4 | """
utility functions for use in the image registration exercises 2 for module MPHY0025 (IPMI)
Jamie McClelland
UCL
"""
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('default')
import scipy.interpolate as scii
def dispImage(img, int_lims = [], ax = None):
"""
function to display a grey-scale ... |
f5a64cd6875ca4a40b22edf4ba6efbbe5e3b1156 | Levi-Huynh/Sprint-Challenge--Graphs | /util.py | 1,070 | 3.71875 | 4 |
# Note: This Queue class is sub-optimal. Why?
# b/c self.que is using array
# time complexity to pop off first index in array is O(n) (shifts all over 1 at time )
# LL or DEQ maybe be tter
class Queue():
def __init__(self):
self.queue = []
def enqueue(self, value):
self.queue.append(value)
... |
953713d0322304704a707a57dfa244cba7d705b4 | nicholaswuu/Year9DesignPythonNW | /Data Analysis/DataAnalysis1.py | 1,159 | 3.859375 | 4 | data = open("dataAnalysis1.txt","r");
dataString = data.read()
dataList = dataString.split("\n")
for i in range(0, len(dataList), 1):
dataList[i] = dataList[i].replace(",","")
dataList[i] = float(dataList[i])
minimum = min(dataList)
print(minimum)
maximum = max(dataList)
print(maximum)
diff = maximum - minimum
... |
3a88cf59365c1bd57650f4ef6c369dc028820587 | AliceSkilsara/python | /tasks/task25.py | 441 | 4.4375 | 4 | month = input("Input your month:").lower()
if month == "january" or month == 'february' or month == 'december':
print("It's winter")
elif month == 'march' or month == 'april' or month == 'may':
print("It's spring")
elif month == 'june' or month == 'july' or month == 'august':
print("It's summer")
elif mont... |
fc48c0acdfeb79d89f3ad19b26adb67cc9e1b943 | Rayanthere/91883-884-Gk-Quiz | /Python assesment/V1(User Details)/user _details_v2.py | 594 | 4.03125 | 4 | #the following code is to ask rhe user their user details
print("*********************Welcome to the General knowledge Quiz**********************")
print("This quiz is been developed by Rayan")
while True:
name = input("What is your name : ")
if name.isalpha():
break
print("Please enter y... |
15b490d28617d1da9ef888402045f84c25015c40 | pravalikavis/Python-Mrnd-Exercises | /unit6_assignment_03.py | 3,723 | 3.984375 | 4 | __author__ = 'Kalyan'
notes = '''
This problem will require you to put together many things you have learnt
in earlier units to solve a problem.
In particular you will use functions, nested functions, file i/o, functions, lists, dicts, iterators, generators,
comprehensions, sorting etc.
Read the const... |
e4602357f874d1f0dabbffdf6d3f8811f25297ce | andrew-rietz/FiftySeven_Coding_Challenges | /challenges/c49_FlickrPhotos/49_FlickrPhotoSearch.py | 2,992 | 3.71875 | 4 | """
Some services provide search features and give you a lot of control
over the results you get back. All you have to do is construct
the right kind of request.
Create a program with a graphical interface that takes in a search
string and displays photographs that match that search string. Use
Flickr's public photo ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.