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 |
|---|---|---|---|---|---|---|
d8726cf4939f0fe2742dfb08fac1d68e9e3912db | Vitality999/HSE_1 | /Task_2.py | 545 | 3.984375 | 4 | # 2. (2 балла)
# Для двух строк l1 и l2, а так же числа n вывести строчку l3, состоящую из конкатенации l1 и l2, повторенной n раз.
# Например, для l1='hello', l2='world', n=2, l3 будет равно 'helloworldhelloworld'
l1 = str(input('Введите первое слово.\n'))
l2 = str(input('Введите второе слово.\n'))
n = int(input('Вве... |
9b7c6e30ca621c5796db893acbb3eab3a7b7d1f5 | paskwal/python-hackerrank | /Basic_Data_Types/04_finding_the_percentage.py | 1,169 | 4.21875 | 4 | # -*- coding: utf-8 -*-
#
# (c) @paskwal, 2019
# Problem
# You have a record of N students. Each record contains the student's name, and their percent marks in Maths, Physics and Chemistry.
# The marks can be floating values. The user enters some integer N followed by the names and marks for N students.
# You are re... |
0ba2effff17991b3413621e0d570fa752959728a | paskwal/python-hackerrank | /Collections/02_named_tuples.py | 1,713 | 4.03125 | 4 | # -*- coding: utf-8 -*-
#
# (c) @paskwal, 2019
# https://www.hackerrank.com/challenges/py-collections-namedtuple/problem
# Problem
# Dr. John Wesley has a spreadsheet containing a list of student's IDs, marks, class and name.
# Your task is to help Dr. Wesley calculate the average marks of the students.
# Average = ... |
ef98e118a0f7bb14bcc79693c41ed870c638bdec | paskwal/python-hackerrank | /Basic_Data_Types/01_list_comprehensions.py | 1,177 | 3.875 | 4 | # -*- coding: utf-8 -*-
#
# https://www.hackerrank.com/challenges/list-comprehensions/problem
# Task
# Let's learn about list comprehensions! You are given three integers X, Y and Z representing the dimensions of
# a cuboid along with an integer N. You have to print a list of all possible coordinates given by (i,j,k)... |
3c530015d9a9088feb6ce024b49fc3cd51717ba9 | shobha-bhagwat/Python | /games/RockPaperScissors.py | 1,554 | 4.15625 | 4 | import random
rock = 1
paper = 2
scissors = 3
names = {rock: "Rock", paper: "Paper", scissors: "Scissors"}
rules = {rock: scissors, paper: rock, scissors: paper}
player_score = 0
computer_score = 0
def start():
print("Lets play Rock, Paper, Scissors!!")
while game():
pass
scores()
def game()... |
3eed1469ae90561bb9a21487579d822b21d09f8b | shobha-bhagwat/Python | /algorithms/binarySearch.py | 440 | 4.125 | 4 | def binarySearch(arr, start, end, x):
while start <= end:
mid = (start + end)//2
if arr[mid] == x:
return mid
elif arr[mid] < x:
start = mid + 1
else:
end = mid -1
return -1
arr = [-5, 3.0, 10, 20, 50, 80]
x = 3
result = binarySearch(arr... |
a0a4f14b03427a5da19197e5c9faa283886cc456 | shobha-bhagwat/Python | /algorithms/BFS_for_graph.py | 1,288 | 4.0625 | 4 | from collections import defaultdict, deque
class Graph:
def __init__(self):
self.graph = defaultdict(list)
def addEdge(self, u, v):
return self.graph[u].append(v)
def BFS(self, graph, vertex): # Breadth-first traversal
queue = deque([vertex])
level = {vertex: 0}
... |
7acfe13d5488a91a59f78cbd030e353d508c6b5d | Baha2490/cryptopals | /Set1/language.py | 1,182 | 3.71875 | 4 | #!/usr/bin/python3
english_letters_freq = [0.08167, 0.01492, 0.02782, 0.04253, 0.12702, 0.02228, 0.02015, # A-G
0.06094, 0.06966, 0.00153, 0.00772, 0.04025, 0.02406, 0.06749, # H-N
0.07507, 0.01929, 0.00095, 0.05987, 0.06327, 0.09056, 0.02758, # O-U
... |
5d321e674e79ec3037a4831fa1be766fe26a8aab | celusta/Python | /mookwl_P2Q4.py | 312 | 4.125 | 4 | # Filename: mookwl_P2Q4.py
# Name: Marcus Mook Wei Lun
# Description: Determine whether the input year is a leap year
# Prompt user for year
year = int(input("Enter year:"))
# Display result
if year%4 == 0 and year%100 != 0 or year%400 == 0 :
print(year, "is a leap year.")
else :
print(year, "is not a leap yea... |
315914119f6db5d17b9630a093a5faebced64c3c | nbowd/numsum | /numsum_gui.py | 9,516 | 3.828125 | 4 | from tkinter import *
import tkinter.font as font
from tkmacosx import Button
from math import floor
from numsum_game_logic import Numsum
import sys
import os
class GuiNumsum:
"""Contains GUI setup for Numsum game."""
def __init__(self):
"""Initialize all the variables of the GUI and of Numsum."""
... |
0de5e2974b94a9670ce888dcf186db5324f0ab3b | Tyrell2000/TwitterCovidMisinformation-Project1 | /IdToTweet.py | 7,383 | 3.640625 | 4 | # in pycharm, go to file, settings, project, project interpreter,
# click on the + and type in tweepy to install the tweepy library
import tweepy
# The consumer_key, consumer_secret, access_token, and access_token_secret are here for testing purposes, we need to replace them later.
# consumer_key and consumer_se... |
29f4f3e375c77c34efdb9601291462a75ff5f533 | IvorryC/Book-Music-app | /Music/Book Library/password_stuff.py | 682 | 4.0625 | 4 | # Should we import the users? or should i just make a better security thing
username = []
password = []
user_name = input("Welcome, what is your name? ")
user_password = input("Please type in your password. ")
print(f"Thank you {user_name}, welcome back!")
if user_name in user_name:
username.append(user_name)
... |
8efcd379a59eeb338bba909ec549b5e121cc06af | IvorryC/Book-Music-app | /Learning python the hard way/ex5.py | 533 | 3.953125 | 4 | name = 'Caleb R. White'
age = 23 # not a lie
height = 70 # inches ;(
weight = 155 # Ibs
eyes = 'Brown'
teeth = 'White'
hair = 'Brown'
print(f"Lets talk about {name}.")
print(f"He's {height} inches tall.")
print(f"He's {weight} pounds heavy")
print("Actually thats not too heavy")
print(f"He's got {eyes} eyes and {hair}... |
1fd72f4ff1c1ca6370f0d6f9726b8fb7e56c25c9 | IvorryC/Book-Music-app | /Music/Book Library/app/create_table.py | 335 | 3.84375 | 4 | import sqlite3
connection = sqlite3.connect('data.db')
cursor = connection.cursor()
table = "CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, username text, password text)"
cursor.execute(table)
table = "CREATE TABLE IF NOT EXISTS books(name text, pages int)"
cursor.execute(table)
connection.commit()
conn... |
1c4fd5fcd62ad0f830c9a338b5ede6ec4a244deb | lakviat/pythonScripts | /Utils/FindDuplicates.py | 3,073 | 3.984375 | 4 | # We have two lists
# list1 = []
# list2 = []
#
# List one and list two has duplicates numbers that iterating multiple times, we need to find
# how many times it iterates in list1 and list2, and whatever is more the count we need to store
# in different list
#
# list1 = 1, 1, 2, 2, 3, 3, 4, 4, 4]
# list2 = 1, 1, 2, 2, ... |
191d07df7149b9518aa354c6dfea28e6f8597e4b | cyberjam/TIL | /Prog_L1_시저암호.py | 879 | 3.515625 | 4 | # 문제 오류 있습니다.
# 여러 공백은 1개의 공백으로 처리된다는 조건은 테스트 케이스에서 고려하지 않았습니다.
# 따라서 여러 공백을 1개의 공백으로 처리하면 오답입니다.
def solution(s, n):
return "".join([" " if char==" " else chr(ord(char)+n-26*int((ord(char)+n)/(90+1))) if char.isupper() else chr(ord(char)+n-26*int((ord(char)+n)/(122+1))) for char in s])
# 다른 사람 풀이
def caesar(s,... |
918cc4c18daefb21cf670e27c49a7094b3bee126 | cyberjam/TIL | /Prog_L1_문자열내p와y개수.py | 627 | 3.609375 | 4 | def solution(s):
return True if len([char for char in s if char == "P" or char == "p" ])==len([char for char in s if char == "Y" or char == "y"]) else False
print(solution("pPPYYY"))
print(solution("aaaa"))
print(solution("a"))
#문제를 Pp와 Yy를 합해 짝수인지 물어보는줄 알았으나 Pp 와 Yy 개수가 같은지 물어보는 문제.
# 다른사람풀이
# 모두 소문자... |
b002e718e79d86ea8595c353c30778882264dc24 | cyberjam/TIL | /Prog_L2_더 맵게_heapq.py | 1,360 | 3.578125 | 4 | # heapq를 사용해보는 문제
# 처음에는 list로 pop insert 하려고 했지만 효율성 0
# heapq는 오름차순으로 정렬된 자료구조기때문에 index 0은 최소라는것을 이용
# list comprehension으로 하나하나 확인하는 것보다 효율성이 높아진다!
##################################heapq#########################################
# import heapq # heapq는 내장함수
# heapq.heapify(list) # 리스트를 heapq로 변환
# heapq.heappop(h... |
700611ea01da77858a95a619545934033ed3e404 | excelsior091224/Hangman_improved_version | /Hangman_A.py | 1,416 | 4.09375 | 4 | import random
word_list = []
def make_word_list():
global word_list
while True:
word_list.append(input("Enter a word or type q to quit."))
if "q" in word_list:
word_list = word_list[0:word_list.index("q")]
break
def hangman():
random_number = random.randint(len(wor... |
f2f26129a8b0fdf8dd7f9dc390778b326fab04ff | paras666/PythonClass | /factorial2.py | 166 | 4.1875 | 4 | x = int(input("enter the number to find factorial: "))
y = 1
for z in range(x,1,-1):
print(z*y,"x",z-1)
y = y*z
print("your factorial is",y)
if(x<=1):
print(1)
|
1c7fc0169cb5a8bf55cbfb44152f13589566aa25 | paras666/PythonClass | /fun4.py | 163 | 3.78125 | 4 | def fun1():
x1 = int(input("Enter the value of x1:"))
x2 = int(input("Enter the value of x2:"))
x3 = x1*x2
return x3
# x4 = fun1()
print("Multiple", fun1()) |
fc930e0c864e1689789d2527f26217d815f9ecf2 | paras666/PythonClass | /cheaking.py | 180 | 4.125 | 4 | def factorial(n):
x = int(input("enter the value:"))
return 1 if (n == 1 or n == 0) else n * factorial(n - 1 or n == 0);
print("Factorial of", x, "is",
factorial(n) |
127a4ee30b74fd55558ef13fc9b4af0f4838c9b1 | Denys8887/WeUpCode | /short_version_password_generator.py | 681 | 3.96875 | 4 | import random
import secrets
import string
print("Welcome to password generator\n")
num = string.digits
upper = string.ascii_uppercase
lower = string.ascii_lowercase
symbols = string.punctuation
def password_generator():
user_input = input("Do you want a strong? Yes/No: ")
if user_input.title() == 'No':
... |
1a257fddb2c63d53423544a9737d3dca62e85968 | xperrylinn/whiteboard | /algo/easy/branch_sums.py | 1,328 | 4.1875 | 4 | # Write a function that takes in a Binary tree and retuns a list of
# its branch sums ordered from leftmost branch to rightmost branch
#
# A branch is the sum of all values in a Binary Tree branch. A
# binary tree branch is a path of nodes in a tree that starts at the
# root and ends at any leaf
# This is the class ... |
8dd36abe2a916a5018b6137701156f7959a9691a | reza-asad/Kosaraju-Algorithm | /kosaraju_algorithm.py | 2,232 | 3.984375 | 4 | # Reza Asad
# Algorithm Class
# Jan 24th, 2016
######################### Algorithms ######################
# Implementation of the strongly conncected components of
# a directed graph using Kosaraju's algorithm
# input:
# G: A dictionary representing a directed graph
# is_reverse: A boolean to indicate weather th... |
b97e7cac68f4468f9ff6560a1b73f7bfb882bf72 | supercp3/code_leetcode | /leetcode/mirror.py | 732 | 3.546875 | 4 | class TreeNode:
def __init__(self,x,left=None,right=None):
self.val=x
self.left=left
self.right=right
class Solution:
def Mirror(self,root):
if root is None:
return
if root.left is None and root.right is None:
return
temp=root.left
root.left=root.right
root.right=temp
if root.left:
self.Mi... |
9ea5501f761e33a2eb2d9a64a5539f65ba046008 | supercp3/code_leetcode | /leetcode/hasPath.py | 1,143 | 3.53125 | 4 | '''
回溯法运用:
矩阵中查找路径
'''
class Solution:
def hasPath(self,matrix,rows,cols,path):
visited=[0 for i in range(rows*cols)]
pathlength=0
for row in range(rows):
for col in range(cols):
if self.hasPathCore(matrix,rows,cols,row,col,path,visited,pathlength):
return True
return False
def hasPathCore(self,... |
9ae2ccf4e88e93d0c47565cd6b0b9d18825faa2f | supercp3/code_leetcode | /basedatestructure/stack_run_class.py | 822 | 4.15625 | 4 | class Node:
def __init__(self,value):
self.value=value
self.next=None
class Stack:
def __init__(self):
self.top=None
def push(self,value):
node=Node(value)
node.next=self.top
self.top=node
def pop(self):
node=self.top
if node is None:
raise Exception("this is an empty stack")
self.top=node.n... |
9c49339b8d7382f05a6a789aa0f23df9887d2acc | supercp3/code_leetcode | /leetcode/rectCover.py | 334 | 3.734375 | 4 | class Solution:
def rectCover(self,number):
if number<=0:
return 0
if number==1:
return 1
if number==2:
return 2
else:
num=[0 for i in range(number+1)]
num[0]=0
num[1]=1
num[2]=2
for i in range(3,number+1):
num[i]=num[i-1]+num[i-2]
return num[number]
s=Solution()
res=s.rectCover... |
2fd91462313a6c2ebe45bfb312fb13d44f51566c | supercp3/code_leetcode | /leetcode3_tree/nextnode.py | 396 | 3.703125 | 4 | class TreeNode:
def __init__(self,x,left=None,right=None,next=None):
self.val=x
self.left=left
self.right=right
self.next=next
class Solution:
def GetNext(self,root):
if not root:
return None
if root.right:
root=root.right
while root.left:
root=root.left
return root
while root.next:
... |
7bc993843006be68d1cbf42f7f4c30c069d797a1 | supercp3/code_leetcode | /leetcode/strmatch.py | 503 | 3.78125 | 4 | '''
字符串匹配算法
'''
def stringMatch(str1,str2):
len1=len(str1)
len2=len(str2)
flag=False
if len1==len2:
for i in range(len2):
st1=""
st2=""
if str2[i]==str1[0]:
st1=str2[i:]+str2[0:i]
st2=str2[i::-1]+str2[-1:i:-1]
print(st1)
print(st2)
if st1==str1 or st2==str1:
flag=True
break
... |
e314110149e5c46bf58474e4ea13dfd1ac771040 | supercp3/code_leetcode | /leetcode/jumpFloor2.py | 411 | 3.5625 | 4 | '''
动态规划,从上往下分析,从下往上计算
'''
class Solution:
def jumpFloor(self,number):
if number<=0:
return False
if number==1:
return 1
if number==2:
return 2
else:
num=[]
num=[0 for i in range(number+1)]
num[0]=0
num[1]=1
num[2]=2
for i in range(3,number+1):
num[i]=num[i-1]+num[i-2]
return ... |
2379f4605ad99bac02f5e57761da876633b86c9d | supercp3/code_leetcode | /leetcode/FindkthToTail.py | 800 | 3.625 | 4 | '''
输入一个链表,输出该链表中倒数第k个结点
考察代码的鲁棒性
'''
class ListNode:
def __init__(self,x=None):
self.val=x
self.next=None
class Solution:
def FindKthToTail(self,head,k):
node1=head
node2=None
count=0
if head==None or k==0:
return None
for i in range(k-1):
if node1.next!=None:
node1=node1.next
count+=1
... |
e4b756404bcabf21dd92f4b0cfeacd346402d6c6 | supercp3/code_leetcode | /newoffer/suning/lab2.py | 279 | 3.5 | 4 | import sys
def solve(numlist,target,num):
global num
if target==0:
num+=1
return num
else:
for i in range(len(numlist)):
solve(numlist,target-numlist[i],num)
if __name__=="__main__":
global num
num=0
num=[2,5]
target=100
res=solve(num,target,num)
print(res) |
877ee9220c82d773f6b8e7e83b281e1be3b455dc | vedashri15/new1 | /Basic1.6.py | 717 | 4.84375 | 5 | #Write a Python program to accept a filename from the user and print the extension of that.
filename = input("Input the Filename: ")
f_extns = filename.split(".")
print ("The extension of the file is : " + f_extns[-1])
#The function returns a list of the words of a given string using a separator as the delimiter ... |
7164300636003c3d4c046be24b01ab9e0abcad7d | kennethriva/Machine-Learning-for-drugs-cytokines | /2-Experimental-centered-dataset-G1.py | 7,725 | 3.59375 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Experimental-centered dataset
#
# One special type of normalization is centering feature values using averages of the feature in different conditions. Some papers are describing this normalization as Moving Average (MA) calculation. Thus, the experimental normalization could ... |
91fcd6e52b811c547c93bb95f3cd97ebe75d8d6d | BlazeKl/T2grafos | /funciones/conexo.py | 889 | 3.53125 | 4 | # x es el arreglo bidimensional (matriz)
# n es el largo del arreglo, matriz n*n cuadrada
#n es la cantidad de vertices o nodos
from numpy.linalg import matrix_power
def is_conexo(x,n):
arrgl = [[0 for x in range(n)] for y in range(n)]
matc=[[0 for x in range(n)] for y in range(n)]
for i in range(0,n):
... |
7d1fa94679eb9af23d4e9869d6a814c83c413465 | BlazeKl/T2grafos | /funciones/euleriano.py | 527 | 3.578125 | 4 | # X es el arreglo bidimensional (matriz)
# n es el largo del arreglo, matriz n*n cuadrada
def is_euleriano(x,n):
arreglo_grados = [0 for x in range(n)]
for i in range(0,n):
acum=0
for j in range(0,n):
acum+=x[i][j]
arreglo_grados[i]=acum
contador=0
for i in ra... |
590dc99fe7143cd705c96e60dffd8843d97be61c | marcello-telles/fund-prog-2018.1 | /AP1-Q2-2017.2.py | 322 | 3.609375 | 4 | def fatorial_duplo(n):
if n > 1:
return n*fatorial_duplo(n-2)
else:
return n
num = int(input())
while num >= 0:
if num % 2 == 0:
print("O número %d é par" % num)
else:
print("O fatorial duplo de %d é %d" % (num, fatorial_duplo(num)))
num = int(input())
|
85c53dbee3db530435a9f69c43fac32606b6b476 | tonylattke/python_helpers | /5_functions_methods.py | 1,154 | 4.34375 | 4 | ######################## Example 1 - Create a function and using ########################
# Even or not
# @number : Number to decide
# @return : True if the number is even, otherwise Flase
def even(number):
return number % 2 == 0
# Testing Function
for aux in xrange(0,10):
if even(aux):
print "%d - Even" % aux
e... |
fe3a824af5ff836ad66dc6c22c19722ec52b2dec | smv1999/pyvect | /pyvect/__init__.py | 4,945 | 3.734375 | 4 | # Module name: Pyvect
# Short description: Pyvect is a open source python module created for the purpose of simplifying the vector calculations such as finding the angle between vectors, projection of one vector over the other and much more...!
# Developers: Vigneshwar Ravichandar(@ToastCoder), Moulishankar M R (@Mouli... |
ef0d7335c1c0f234b167772e833d007a10442e58 | RithickDharmaRaj-darkCoder/Linked_List | /circular_sll.py | 4,766 | 4.0625 | 4 | # Data Structure ...
# User-Defined ...
# Linked List ...
# Circular Linked List ...
# Circular-Singly Linked List ...
class create_node:
def __init__(self,data):
self.data = data
self.next = None
class C_S_linkedlist:
def __init__(self,object_name):
self.name = object_name
sel... |
814b38ea8e60debb171b1a3205f220daf940c125 | MilanaShhanukova/programming-2021-19fpl | /queue_/queue_.py | 1,489 | 4.0625 | 4 | """
Programming for linguists
Implementation of the data structure "Queue"
"""
from typing import Iterable
from math import inf
# pylint: disable=invalid-name
class Queue_:
"""
Queue Data Structure
"""
def __init__(self, data: Iterable = (), max_size=inf):
if data is None:
self.d... |
8f6f34a49a9920138306f43dca03aaf9d4952df3 | MilanaShhanukova/programming-2021-19fpl | /shapes/circle.py | 803 | 4.125 | 4 | """
Programming for linguists
Implementation of the class Circle
"""
from math import pi
from shapes.shape import Shape
class Circle(Shape):
"""
A class for circles
"""
def __init__(self, uid: int, radius: int):
super().__init__(uid)
self.radius = radius
def get_area(self):
... |
9d18b3bf085faca203fb80cc49d289bdda6887a7 | MilanaShhanukova/programming-2021-19fpl | /shapes/rectangle_test.py | 1,224 | 4 | 4 | """
Programming for linguists
Tests for Rectangle class.
"""
import unittest
from shapes.rectangle import Rectangle
class RectangleTestCase(unittest.TestCase):
"""
This Case of tests checks the functionality of the implementation of Rectangle
"""
def test_rectangle_get_uid(self):
"""
... |
bad694009154ef7225a867d6ab80b87d1d2b4f56 | romulorafas/linguagem_de_programacao_ufmg_2017_01 | /TRABALHO PRÁTICO/Python/nimGame.py | 2,270 | 3.9375 | 4 | # LINGUAGEM DE PROGRAMAÇÃO - 2017/1
# PROFESSOR: Carlos Camarão
# ALUNO: Rômulo Rafael da Silva - 2012055308
import random
print("""************ NIM GAME ***********""")
jogador1= str(input("Digite seu nome: "))
jogador2= "Computador"
numPalitosRemover= 0
fimGame= False
numeroPalitos=random.randint(10,20)
if ... |
2a7025b5fa04355b585d72ea30e75aa3e7bc645c | Arulprabha/zoho-recruitment-2020 | /zoho-06.02.20.py | 304 | 3.59375 | 4 | # Used Python 2
inp = int(input())
if inp > 0:
for i in range(inp, 0,-1):
for j in range(inp,0,-1):
if j >= i:
print(j),
else:
print(i),
print
|
15e89ce6763fe48ccb5cdc9565e61488458faec5 | EnriqueSubias/Practica2 | /greedy_iterative.py | 2,509 | 3.828125 | 4 | #! /usr/bin/env python3
"""Greedy Iterative""" # Coste minimo O(n^2)
import sys
from calculate import Calcul
def greedy():
"""Greedy"""
coste_total = greedy_iterative(calcular.get_n_points(),
calcular.get_pos_x(), calcular.get_pos_y())
if coste_total not in (-1, "imp... |
ea3da4943f40818167baae0d6fbb6cd43e524425 | wangdexinpython/test | /nothing/for_i_in_zip.py | 88 | 3.59375 | 4 |
li=[1,2,3,4]
l12=['a','b','c','d']
for i,j in zip(li,l12):
print(i)
print(i,j) |
1c14f80470bc5c858587261c932b8fe958f1b1c3 | yvonneonu/Test8 | /test8.py | 774 | 4.34375 | 4 | # A Simple Python 3 program to compute
# sum of digits in numbers from 1 to n
#Returns sum of all digits in numbers from 1 to n
def countNumberWith3(n) :
result = 0 # initialize result
# One by one compute sum of digits
# in every number from 1 to n
for x in range(1, n + 1):
if(has3(x) == True... |
4ec7b5d79f037cd31ddbc2dce88902f6570c09c5 | Moosedemeanor/learn-python-the-hard-way | /ex21.py | 862 | 4.09375 | 4 | def add(a, b):
print "ADDING %d + %d" % (a, b)
return a + b
def subtract(a, b):
print "SUBTRACTING %d - %d" % (a, b)
return a - b
def multiply(a, b):
print "MULTIPLYING %d * %d" % (a, b)
return a * b
def divide(a, b):
print "DIVIDING %d / %d" % (a, b)
return a / b
print "Let's do som... |
23fc16833b837be218127fa0bbc8fbb0693ccc36 | anastasiacebotari15/Introducere-Afisare-Calcule | /p8.py | 371 | 4.09375 | 4 | """ se introduc de la tastatura trei cifre. Afisati pe aceeasi linie 5 numere formate cu
aceste cifre luate o singura data"""
x=int(input("Introduceti 1 nr:"))
y=int(input("Introduceti 2 nr:"))
z=int(input("Introduceti 3 nr:"))
print(str(x)+str(y)+str(z), str(y)+str(z)+str(x), str(z)+str(y)+str(x), str(y)+str(x)+... |
23b4ca94923b101d5d3bd755d73246820a91c50e | SI507-Waiver-Fall2018/si-507-waiver-assignment-f18-lipar8023 | /part2.py | 1,784 | 3.609375 | 4 | # Name: Linya Li
# Uniq Id:linyal
import sqlite3 as sqlite
import sys
con = sqlite.connect('Northwind_small.sqlite')
cur = con.cursor()
#----- Show all customer names from the Customer table
def print_cust_names():
q1 = '''
SELECT Id, CompanyName FROM Customer
'''
result1 = cur.execute(q1)
print... |
2e18cc1a45117a87365953911afcfcc93b74e697 | ayman-elkassas/Binary-Classification-Sigmoid | /binary-classification.py | 3,439 | 3.609375 | 4 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import scipy.optimize as opt
path='week_3-ex_2.csv'
data=pd.read_csv(path,header=None,names=['Exam 1','Exam 2','Admitted'])
# print('data = ')
# print(data.head(10))
# print()
# print('data.describe = ')
# print(data.describe())
fig... |
efc02751fc37e78ad393d2c238812a3f267aba09 | marciosobral/curso-python-basico | /Exercício 6.py | 343 | 3.875 | 4 | #-*- coding: utf-8 -*-
# EXERCÍCIO 6
from time import sleep
print("\nPrograma que verificar se um número inteiro é par ou ímpar\n")
sleep(1)
num = int(input("Qual o número? "))
sleep(0.5)
print("\nCalculando...")
sleep(0.5)
result = num % 2
if result == 0:
print("\nNúmero par")
else:
print("\n... |
48bb00168f1a890929a634c402688a8e83f035a4 | stidsem4/td-1 | /main.py | 2,250 | 3.5625 | 4 | from collections import namedtuple
# tuples et nameed tuple
point_en_2d = (0, 0)
Point2D = namedtuple('Point2D', ['x', 'y'])
p2d = Point2D(x=0, y=1)
print(p2d)
p2d[0]
print(p2d.x) #y
Point1D = namedtuple("Point1D", ["x"])
print(Point1D)
p_04 = Point1D(0.4)
print(p_04)
p_05 = Point1D(0.5)
# Ce qu'on voudrait
#... |
0efc63ac7d07f35ae5d978169adb8849f175bad4 | eawww/BI_HW | /HW1/seqid.py | 2,201 | 4.125 | 4 | #Bridget Mohn and Eric Wilson
#CS 466R
#Homework 1
#Reads an input filename from command line, opens the file, reads each character
#in the file to see whether the file contains a DNA, RNA, or Protein sequence
import sys
#Input filename is taken from the command line which is the second argument
InputFile... |
aa5deee0e8fafb530e3b76a7a4dcdeef0dfec9eb | bpandola/advent-of-code | /2015/day_05.py | 1,755 | 3.78125 | 4 | def is_nice_v1(word):
# Contains at least three vowels.
num_vowels = 0
for s in word:
if s in 'aeiou':
num_vowels += 1
if num_vowels <= 2:
return False
# Contains at least one letter that appears twice in a row.
num_repeated = 0
for a in 'abcdefghijklmnopqrstuvwxy... |
812395c19164e132575a86fb0189dca4f99608eb | bpandola/advent-of-code | /2015/day_12.py | 1,292 | 3.515625 | 4 | import json
def find_sum(obj, current_sum=0, ignore_obj_value=None):
if isinstance(obj, list):
for item in obj:
current_sum = find_sum(item, current_sum, ignore_obj_value)
elif isinstance(obj, dict):
if ignore_obj_value is None or ignore_obj_value not in obj.values():
f... |
970f834841071cbbb4c0504c9839d2c4d6d22bd3 | bpandola/advent-of-code | /2021/day_02.py | 1,253 | 3.671875 | 4 |
def parse_input(filename):
commands = open(filename).read().split('\n')
commands_parsed = [
(command.split(' ')[0], int(command.split(' ')[1]))
for command in commands
]
return commands_parsed
def calculate_position(commands):
horizontal, depth = 0, 0
for action, value in comm... |
a544e849b7214973407275a44e6c0a5415a18ad1 | bpandola/advent-of-code | /2019/day_01.py | 1,115 | 3.875 | 4 | def calculate_fuel_for_mass(mass):
return mass // 3 - 2
def calculate_fuel_for_fuel(fuel_mass):
fuel_needed = 0
fuel_for_fuel = calculate_fuel_for_mass(fuel_mass)
while fuel_for_fuel > 0:
fuel_needed += fuel_for_fuel
fuel_for_fuel = calculate_fuel_for_mass(fuel_for_fuel)
return fue... |
78adf7ad22335262469fa7304999af9329071b8d | soodoku/python-workshop | /py_scripts/get_html.py | 1,060 | 3.5 | 4 | '''
@author: Gaurav Sood
@title: Get text of html
@date: 4/10/2015
Steps:
1) install BeautifulSoup, urllib (these days urllib2)
2) Run the script
python get_html.py
'''
# import libs
from BeautifulSoup import BeautifulSoup
from urllib import urlopen
import urllib2, urlparse
import re
# open url
url = urlopen... |
9841721651babdf1febe9c82e11d759ed788d4cb | jar948/data-conversions | /printveggies.py | 608 | 3.75 | 4 | vegetables = [
{"name": "eggplant", "color": "purple"},
{"name": "tomato", "color": "red"},
{"name": "corn", "color": "yellow"},
{"name": "cucumber", "color": "green"},
{"name": "potato", "color": "brown"},
]
# write header file to csv
import csv
with open('veggies.csv', 'w') as blabla:
typer = csv.writer(blab... |
90d6187d21b73d23c716e87d1b28c50bb3ab06e6 | thisispk1/Hacker-Rank-Solutions | /Day 6_Let's Review.py | 296 | 3.609375 | 4 | T=int(input())
arr=[]
for i in range(T):
arr.append(input())
# print(arr)
i=0
while i<T:
even=''
odd=''
for n in range(len(arr[i])):
if n%2==0:
even=even+arr[i][n]
else:
odd=odd+arr[i][n]
print(even,odd)
i=i+1
|
2172303caad5a4f80ca579838390776d0589e1da | thisispk1/Hacker-Rank-Solutions | /String Comparison.py | 712 | 3.734375 | 4 | # Input string
a = [1,2,3]
b =[2,3,3]
# Comparison
score= [0,0]
# scrcom1 = [a[0]>b[0], a[1]>b[1], a[2]>b[2]]
# # scrcom2 = [a[0]<b[0], a[1]<b[1], a[2]<b[2]]
# scrcom3 = [a[0]==b[0], a[1]==b[1], a[2]==b[2]]
# # for n in scrcom1 :
# # print('in')
# if n == True:
# score[0] = score[0]+1
# ... |
01bc34026a929f888f926b7027a11a1e70d6ab94 | neelravi/autotests | /example01.py | 377 | 3.53125 | 4 | def add(a, b):
return a + b
def test_add():
assert add(2, 3) == 5
assert add('space', 'ship') == 'spaceship'
assert (add(0.1, 0.2) - 0.3 <= 1.0e-6)
def subtract(a, b):
return a + b # <--- fix this in step 8
## dummy comment added to trigger tests
# uncomment the following test in step 5
#def... |
370b2d981802897f2c822edb8c78343c2a837398 | Radost1987/5_lang_frequency | /lang_frequency.py | 1,409 | 3.5625 | 4 | import os
import re
from collections import Counter
def load_data(filepath):
if not os.path.exists(filepath):
return None
with open (filepath,encoding='utf-8') as file:
input_data=file.read()
return input_data
def get_list_of_words(data):
if not data:
return None
a... |
43af2548dc114926d4484a64679589929aa3f22a | cifpfbmoll/practica-5-python-joseluissaiz | /P5E10.py | 768 | 4.21875 | 4 | #Practica 5
# Ejercicio 10
# Escribe un programa que pida la altura de un triángulo y lo
# dibuje de la siguiente manera:
#
#--------Variables
numeroLinea = 1
#
#---------Imports
import sys
#---------Inputs
altura = input("Introduce la altura del triangulo : ")
try:
altura = int(altura)
... |
504b89011418c1661929552c52e3fe9842f7ad52 | cifpfbmoll/practica-5-python-joseluissaiz | /P5E3.py | 1,277 | 4.34375 | 4 | # Practica 5
# Ejercicio 3
# Escribe un programa que pida dos números y escriba la suma de enteros
# desde el primero hasta el último.
#
#
#------------------------imports
import sys
#
#------------------------variables
numeroCuenta = 0
numeroCuentaMostrar = ""
#
#------------------------inputs
#numUno
... |
32ab9d15ff3e0602a612aef0b7c1122c44b04900 | eaalthoff/CS178HomeWork | /Assignment3.py | 423 | 3.84375 | 4 |
repeat=input('Enter a string')
noCase=''
noCase=repeat.lower()
chara=''
def firstChar():
for char in noCase:
noCase.count(char)
if noCase.count(char) == 1:
chara=noCase.find(char)
return(repeat[chara])
return('')
firstChar()
caseString=input('Enter a... |
92acffa3da3924f85cc4c6eb640f255fd1248d71 | asklasek/Casino | /comebet.py | 3,478 | 3.9375 | 4 | # Come bets portion of Craps game.
import random
import miscfunctions
import images
# Takes the point, chipcount, and initial bet amount and runs the placeComeBet() and rollComeDice(). Returns the winnings or losses.
def comePortion(point, money, initialBet):
money, finalBet=placeComeBet(money)
comer... |
de34527f3e9dd145e06fb3382a9bf68fd5b36078 | lbelmanw/Lectures | /Test.py | 101 | 3.640625 | 4 | def factorial(x):
value = 1
for i in range(x):
value = value * (i+1)
return value |
9c038b139294cb2b9d5462f1983e3d9999584e7a | gao183010049/python | /电话薄.py | 4,235 | 3.875 | 4 | # -*- coding: UTF-8 -*-
class Phone_Book(object):
def __init__(self,name='',path='/home/gao/桌面/phonebook.data'):
self.name = name
self.path = path
def add_or_alter(self):
tel = raw_input('请输入电话号码')
try:
fp = open(self.path,'r+')
except IOError:
... |
6124057f783ef516d6568a6c1d79603a96b7ce20 | Natalieefd/POSTTEST2 | /program_sederhana_tentang_data_mahasiswa.py | 4,939 | 3.96875 | 4 | '''
!!catatan!!
Buatlah Program sederhana tentang data Mahasiswa dengan
minimal 5 variabel inputan. contoh
1. Nama
2. Nim
3. dan seterusnya
Gunakan tipe data STR,INT,dan Float (wajib di pakai semua)
Simpan data mahasiswa di dalam list
!!poin plus!!
Memiliki Menu tampilan dan memakai dictionary
'''
from ... |
13bd3be315ccb5080fe6d42f3a832c537114ccc6 | DarthSidM/repo1 | /lcmseparate.py | 163 | 3.828125 | 4 | n1=int(input("enter number:"))
n2=int(input("enter number:"))
for i in range(1,n1*n2+1):
if i%n1==0 and i%n2==0:
print("lcm is =",i)
break |
c6633d3add2fdfe920af3557d8bd0ede5b426687 | evoloji/Gui-Enflasyon-Hesaplama | /Enflasyon Hesaplama Aracı.py | 3,861 | 3.578125 | 4 | #!/usr/bin/python3
#ìkütüphaneler
import datetime
from tkinter import *
import locale
#from decimal import Decimal
#import re
#alanlar
alanlar = ("Poliçe Başlangıç Tarihi", "Hasar Tarihi", "Enflasyon Oranı", "Sigortalı Bedeli", "Enflasyonlu Sigorta Bedeli","Katsayı")
#Hesaplama ve girdi tanımları
def ... |
f1f57fdd8968e42ab2d569874881710c0f1679ff | HoloTheDrunk/golden-wind-map-editor | /map_editor/ezgraphics.py | 35,272 | 3.9375 | 4 | # -*- coding: utf-8 -*-
# Graphics module
"""
Graphic module
Author : D. Raphaël, EPITA
Version 0.1
SUMMARY :
PART 1 : CONSTANTS AND CLASSES
PART 2 : COLORS
PART 3 : GRAPHIC WINDOW
PART 4 : TEXT DISPLAY
PART 5 : SHAPE DRAWING
PART 6 : IMAGE MANAGEMENT
PART 7 : SOUNDS AND MUSIC MANAGEMENT
PART 8 : MOUSE HANDLING
PART... |
1edc5a9a0e53abcd0474d29f4127b73ede2dc5fe | chanconan/Coursera | /py4everyone/AccessingWebData/Week6/assignment1.py | 287 | 3.5625 | 4 | import urllib.request, urllib.error, urllib.parse
import json
url = input('Enter url: ')
try:
data = urllib.request.urlopen(url).read().decode()
jsonData = json.loads(data)
print('Sum is',sum([int(x['count']) for x in jsonData['comments']]))
except:
print("Need a URL") |
e8c40085105bdab4558fff0ef5964cc48595a346 | admason/PythonProjects | /Stock_control.py | 1,554 | 3.90625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[36]:
a=6
b=8
if a>b:
a = a+2
b = b+2
print('The larger vale is a=', a)
else:
a = a+2
b = b+2
print('The larger value is b=',b)
# In[38]:
if True:
print("It's true")
# In[40]:
x=True
if x:
print('x was true')
else:
## print('x not ... |
c7db128a5c53b7c68494de486953708cdc91f854 | rinald/evaluator | /evaluator/lexer.py | 3,482 | 3.71875 | 4 | '''Defines a lexer for mathematical expressions.'''
from .token import Token
from .errors import ReadError
from .util import *
class Lexer:
'''Lexer for mathematical expressions.'''
EOI = '' # end of input
def __init__(self, expression):
self.expression = expression
self.cursor_at = 0
... |
0c10a8e374c656864a21584901586bf3815d0018 | ss130/python200819 | /scoreslist.py | 508 | 3.71875 | 4 | scores=[]
maxscores=0
minscores=100
maxname = 0
minsame=0
total=0
for i in range(5):
n=int(input("成績:"))
name = input("name:")
scores.append(n)
if n>maxscores:
maxscores=n
maxsname=name
if n<minscores:
minscores=n
minsname=name
total=total+n
s=tot... |
1fb6f0d42bd23a6c0d8062d629983a62e96c2f55 | taspyn/python-class | /rectangle.py | 453 | 3.921875 | 4 | class Rectangle:
length = 0
width = 0
def __init__(self, length,width):
self.length = length
self.width = width
def area(self):
return self.length * self.width
def perimeter(self):
return 2 *(self.length+self.width)
small = Rectangle (2,3)
large = Rectangle (5000,7000)
print ("length an... |
3267bcaa907a1eda60abe8c60ff69b7cc7cff0a9 | Ryan-Lawton-Prog/IST | /IST Assessment Program/I1.py | 2,768 | 4.28125 | 4 | def a():
while = True:
print """
\tGuide Contents:
\t* raw_input() = Gives the user the option to input data to the user,
anything inbetween the '()' will be displayed before
the users input.
"""
raw_input()
break
test = True
while te... |
9bc1edb29c6feb34e3384611c3353014579821d0 | Ryan-Lawton-Prog/IST | /IST Assessment Program/Run.py | 1,632 | 4.15625 | 4 | import Beginner
# Program Varriable is now True
Program = True
# 'while' Program is true run and loop this
while Program:
# select your difficulty text
print "Please select your Stream"
print "Beginner:"
print "Intermediate:"
print "Advanced:"
# difficulty input
Difficulty = raw_inpu... |
365f02e7d2dd7e510c6dd509399380625b27c394 | arshadahmad08/arshad1805 | /python/pyramid_pattern/number_pattern_1.py | 344 | 3.671875 | 4 | '''
Problem statement
1
2 3
4 5 6
7 8 9 10
'''
def pattern_func(args):
if args <= 0 :
print("Please pass integer value")
else :
n = 1
for i in range(0,args):
for j in range(0, i+1):
print(n , end = " " )
n = n + 1
print("\r")
... |
c0641327a5c641cdafefcf9e1e0c2486826aec24 | Munyiwamwangi/politico | /app/tests/test_user_model.py | 1,577 | 3.8125 | 4 | # tests for user model
import unittest
from app.api.model.user import User
class UserModelTestCases(unittest.TestCase):
"""
Class to test if the user required fields are present.
"""
def setUp(self):
"""
Creeate the user instance.
"""
self.new_user = User(
... |
53f33a934c6d59479b6b9035d2453869c3eda6aa | Suhoy95/alabuga-sof | /sof.py | 158 | 3.84375 | 4 | import turtle
t = turtle.Turtle()
t.shape("turtle")
t.speed(10)
n = 50
iterations = 360 // 16
for i in range(iterations):
t.forward(15)
t.left(15)
|
78f0ecb4613a400814b44debb12ad8f2d88b3727 | ankitrev/Bike-Rental-System | /main.py | 1,066 | 3.578125 | 4 | from Models.BikeRent import BikeRental
from Models.Customer import Customer
def main():
shop = BikeRental(100)
customer = Customer()
while True:
choice = input("Enter Choice: ")
try:
choice = int(choice)
except ValueError:
print("That's not a valid choice!")
continue
if choice == 1:
shop.di... |
be9cdacd0ac9b13bb453d72d560e7cb5e8709dcd | FredTheDino/AoC2020 | /py01.py | 419 | 3.6875 | 4 | from itertools import combinations
def f():
numbers = []
while True:
try:
n = int(input())
except:
break
numbers.append(n)
for a, b in combinations(numbers, 2):
if a + b == 2020:
print(a * b)
break
for a, b, c in combinat... |
bfd0335bada1fc5e5bbce0b2b222a843937a0ea4 | elenabasta/pythonProjectSM | /ui.py | 2,546 | 3.921875 | 4 | from item_manager import Start
def show_menu():
while True:
print('Item Manager')
print('--------------')
print('1. Add Item to collection')
print('2. Show Items in collection')
print('3. Delete Items from collection')
print('4. Exit')
response = input('Choi... |
c1384ad2fc5108fe8ef771b239eb2cd6fa1e5570 | StudyGroupPKU/TESTs | /eunjin/h180310_mar2nd.py | 345 | 3.640625 | 4 | #1
a=4
b=8
print("a,b=",a,b)
t=a #a값을 t에 저장
a=b #b값을 a에
b=t #t값을 b에
print("after a,b = ",a,b)
#2
c=6
d=2
if c>d:
k=c
c=d
d=k
print(c,d)
#3 저번숙제할때 썻던방법
x=[251,357,82,136,62]
for i in range(len(x)):
for j in range(1,len(x)):
m = x[i]
x[i]=x[j]
x[j]=m
print(x)
|
b575fd3f21eac492b229e3d0dd161fc646e78113 | sebranly/connect-four | /main.py | 14,315 | 3.953125 | 4 | # RULES TO FOLLOW
"""
(1) Variables should follow this naming convention: variableName
(2) Functions should follow this naming convention: function_name
(3) If possible and if it improves the codebase, refactor a function by adding a parameter
(4) If possible use booleans, instead of variables of type i... |
ac80ad6d6a06648ea55d3103adc474305336c869 | MemoirGardien/Voting-Machine | /checksum.py | 804 | 4.09375 | 4 | #words.txt and words2.txt are the test files for this checksum program
import hashlib
# File to check
fname = input("Enter file name: ")
# this gets the md5 checksum of the original file
md5a = hashlib.md5(open(fname ,'rb').read()).hexdigest()
print (md5a)
#------------------------------------------------------------... |
5349ce1d44721551442854a65c39092268fa9b93 | jjelarmo/data-structure-and-algorithm | /Graph_undirected_adjacency_list.py | 9,638 | 3.765625 | 4 | class Vertex(object):
def __init__(self, node):
self.node = node
self.neighbor = {}
self.status = "unvisited"
self.step = 0
def __str__(self):
return str(self.node) + ":" + self.status
def add_neighbor(self, new_node, weight=0):
if isins... |
4f1e83eba5e1cb27f08fee1c4c45188be055bab9 | kopc718/test | /mediana_before.py | 331 | 3.546875 | 4 | dane = [3, 5, 13, 55, 44, 75, 21, 54, 43, 53, 11, 111, 223, 12312]
def mediana(x):
s = sorted(x)
w = int(len(s))
if w % 2 != 0:
f = int((w - 1)/2)
d = s[f]
print(d)
elif w % 2 == 0:
f = int((w/2-1))
g = int(w/2)
d = (s[f] + s[g])/2
print(d)
med... |
f7a5b6a10212ed28585772e81f20a55eb7d341c2 | utoppia/leetcode | /671.py | 652 | 3.625 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def findSecondMinimumValue(self, root: TreeNode) -> int:
if not root:
return -1
... |
50bb316ea30205e543004fbea287e33c91289d52 | utoppia/leetcode | /Heap/1705_maximum_number_of_eaten_apples.py | 659 | 3.609375 | 4 | from heapq import heappush, heappop
class Solution:
def eatenApples(self, apples: List[int], days: List[int]) -> int:
# every day, we choose the apple with least period date
# heap
heap = []
today, n = 0, len(days)
ans = 0
while heap or today < n:
if today < n:
... |
fd74a415a569ef27a397326b99c5f2b56e3098e4 | utoppia/leetcode | /BinarySearch/BinarySearchTree/98_validate_binary_search_tree.py | 983 | 3.71875 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def dfs(self, root: TreeNode) -> (bool, int, int):
if not root.left and not root.right:
return True,... |
bb5da0b4fbb13adcfd59732a7556cd35ead6ed47 | utoppia/leetcode | /Stack/MonotonicStack/1019_next_greater_node_in_linked_list.py | 671 | 3.75 | 4 | # Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def nextLargerNodes(self, head: ListNode) -> List[int]:
# monotonic stack
pos = 0
st = []
root = head
n = 0
... |
b345090730c694cfdad74b4f47fc9cdec02fc202 | menphim/practice | /dot_install/python_introduction/hello.py | 4,153 | 4.25 | 4 | # coding: UTF-8
# 変数(データにつけるラベル)
# データ型
# 数値
# 真偽値
# None
# 関数・オブジェクト
# 要素が並んだもの
# 文字列
# リスト
# タプル
# セット
# 辞書型
# 整数,小数,複素数
# 演算子 + - * / // % **
print 10*5
print 10 // 3.0
print 10/3
print 10 % 3
print 2**3
msg = "hello world"
print msg#コメント
print 5+2.0
#整数同士の割り算 → 切り捨ての整数
print 10/3.0
# 文字列
# "Hello" 'hello'
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.