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 |
|---|---|---|---|---|---|---|
a8e2af8a7e4217863a2f86d58de2a7f99399f6b9 | JayWelborn/HackerRank-problems | /python/30_days_code/day26.py | 445 | 3.703125 | 4 | actual = [int(x) for x in input().split(' ')]
expected = [int(x) for x in input().split(' ')]
if actual[2] > expected[2]:
print(10000)
elif actual[2] < expected[2]:
print(0)
else:
if actual[1] > expected[1]:
print(500*(actual[1] - expected[1]))
elif actual[1] < expected[1]:
print(0)
... |
a088a1698f7d1ddb9ab5f039c94a562d2caeedb4 | bridgerrholt/pygame-tic-tac-toe | /event_handler.py | 2,878 | 3.8125 | 4 | import pygame
from pygame.locals import *
# Handles lists describing every key, primarily including whether they were
# pressed/released this frame and whether they are currently down or not.
class KeyLists:
def __init__(self, length):
# All 3 lists of bools are the same length.
self.length = length
# If the ke... |
47c539d8baea7f89570407f87175cdc8b5529ed7 | vosslab/ctfeval | /appionlib/apCtf/leastsq.py | 7,781 | 3.71875 | 4 | #!/usr/bin/env python
import sys
import math
import time
import numpy
from appionlib import apDisplay
"""
File of functions that solve least square problems in matrix notation:
X * beta = Y
which is equivalent to:
beta[1] * X[1,1] + beta[2] * X[1,2] + ... = y[1]
beta[1] * X[2,1] + beta[2] * X[2,2] + ... = y[... |
66d36714a711258a3e974f1a0ae6ae313d0f4cca | alfredkondoro/NLP_Sentiment-Analysis-py | /main.py | 1,140 | 4.09375 | 4 | import string
#to read the input from the selected text file
input_text = open('input.txt', encoding='utf-8').read()
#to change the selected text into lowercase and remove the punctuation
lowercase_text = input_text.lower()
punctless_text = lowercase_text.translate(str.maketrans('','',string.punctuation))
#to split ... |
7cc2e8e8313d6f8593d120124a35ae6dd35f857c | Aniter-amine/timer | /timer.py | 1,309 | 3.59375 | 4 | import time
import os
from playsound import playsound
# Print user menu
def menu():
print(5*'-' + " Choose " + 5*'-')
print("1 : Study Time (25 minutes)")
print("2 : Short Break (5 minutes)")
print("3 : Long Break (15 minutes)")
print("4 : Enter Your Custom Time")
userChoice = input("Your choi... |
8fe50cff7ae9615ada8b250a2a9df731e3094e8f | shehzad84/Assignments | /Assignment-5/Task_6.py | 989 | 3.671875 | 4 | #task6
###################################################################################
#1.
strIn = (input("Enter a string: "))
Out = [i for i in strIn if i.isupper()]
print(Out)
###################################################################################
#2.
names = ['Khuram', 'Shehzad', 'Dave']
courses = [... |
dd08af0e87a405ae696c6383187b80f5c6557e0b | shehzad84/Assignments | /Assignment-1and2/A2Task1/Code4.py | 99 | 3.546875 | 4 | x = input("Enter first value:")
y = input("Enter second value:")
print x
print y
print(x)
print(y)
|
0a5df7506f8b2bcae4b3dc516c6dcb1dc04d0e0b | yulrizka/adventofcode | /2019/python/day1/day1.py | 741 | 3.828125 | 4 | import unittest
from functools import reduce
import math
with open("../../input/day1") as file:
data = [int(line) for line in file]
def calc(n):
return math.floor(n/3) - 2
def calc2(n):
sum = 0
while True:
n = math.floor(n/3) - 2
if n < 0:
break
sum += n
retu... |
f7fb8211a96f7f80829fa0018f3a52fbe03c68e9 | bleissem/stephanie-wang-hanabi | /gym_hanabi/scripts/print_video.py | 1,369 | 3.5 | 4 | import argparse
import json
def main(video_file):
"""
When you evaluate a policy on a gym environment (see run_ai.py and
run_self.py), gym produces a directory with a bunch of video files showing
some sample executions. The video files are named something like
openaigym.video.0.17502.video010000.js... |
a5663143244114e0f86ebd76c956e4b96490a3ff | math-learning/math-solver | /test/model/theorems/test_theorem_integral_multiply_constant.py | 918 | 3.53125 | 4 | import unittest
from mathlearning.model.expression import Expression
from mathlearning.model.integrate_theorems import IntegrateTheorems
theorem = IntegrateTheorems.integrate_multiply_for_constant()
class TestTheoremIntegralMultiplyForConstant(unittest.TestCase):
def test_simple_multiplication_should_apply(self... |
d7cd9bfba31295af08de7b174ce53f91b3fcd67d | DorotaPotulska/BasicsOfPythonCertificate | /zad7.py | 188 | 3.8125 | 4 | # Zadanie7. Odczytaj wyraz i wypisz pierwszą literę wyrazu.
word= input('Give me a word\n')
print('The first letter is',word[0])
#element ostatni
print('The last letter is',word[-1]) |
24794c1b98f30ffd55eadd2e9fe16b3c452426a2 | JoaoHenriqueOliveira/graph | /bellman_ford.py | 1,750 | 3.734375 | 4 |
# Is a SSSP algorithm - can fin the shortest path from one node to others
# Can be used to detect negative cycles
# Time complexity: O(E*V)
from Graph import *
def bellman_ford(graph, start = None):
if start == None:
start = graph.get_random_node()
print(f"Starting node: {start}")
n = graph.c... |
0d0b2fc96f612c5cd6b380566305e0a38fd2719b | JoaoHenriqueOliveira/graph | /top_sort.py | 1,294 | 3.9375 | 4 | # The topological ordering is an ordering of the nodes in a DAG
# where for each edge from A-> B, node A appears before node B.
# The topological sort algorithm can find a topological ordering in O(V + E)
from Graph import *
def topSort(graph):
n = graph.count_nodes()
list_nodes = graph.get_list_node()
vis... |
e2da42075dfb8658d8707ad3d66d79558758fcf3 | marcinpgit/Python_days | /day3/zadanie1.py | 469 | 3.71875 | 4 | # przyjąć input od użytkownika
dane = input("Podaj grę: ")
# sprawdzić czy string ma 9 znaków
if len(dane) == 9:
# jeśli tak
# sprawdzę x poziomo
if dane.index("XXX") == 0:
# wygrana x
print("Wygrał X")
# sprawdzę x pionowo
# wygrana x
# sprawdz... |
b5016cd50e47756c6de93928222df9408e2bb0ca | marcinpgit/Python_days | /day4/haslo.py | 477 | 3.90625 | 4 | # hasło musi mieć min 6 znaków, litery i cyfry muszą się w nim znajdować
# login = input("Podaj login: ")
haslo = input("Podaj hasło: ")
while len(haslo) < 6:
print ("Hasło jest za krótkie!", end = " ")
print("Podaj prawidłowe hasło")
haslo = input("Podaj prawidlowe haslo: ")
while not haslo.... |
7ac8469e1cda2d743e6222bce4609aee696658bf | marcinpgit/Python_days | /day12/pracownik.py | 1,361 | 3.515625 | 4 | class Pracownik(object):
liczba_pracownikow = 0
roczna_podwyzka = 5
def __init__(self, imie, nazwisko):
self.__imie = imie
self.__nazwisko = nazwisko
self.__stanowisko = None
self.__wynagrodzenie = None
Pracownik.liczba_pracownikow += 1
def wypisz_i... |
f2681cff089ab4902e2baf1ba5aa561180b785e0 | marcinpgit/Python_days | /day4/FizzBuzz.py | 413 | 3.796875 | 4 | # drukuj liczby od 1 do 100
# jeśli podzielna przez 3 drukuj Fizz
# jeśli podzielna przez 5 drukuj Buzz
# jeśli podzielna przez 3 i 5 drukuj FizzBuzz
for i in range(1, 101):
if i % 3 == 0 and i % 5 == 0:
print("FizzBuzz")
continue
if i % 3 == 0:
print("Fizz")
... |
3c01f44d5f1cf305d76ca9ac0111dfd471cb37bb | marcinpgit/Python_days | /day5/listy2.py | 394 | 4.03125 | 4 | lista = [1, "dwa", "trzy", 4]
for element in lista:
print(element)
print()
lista_z = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
for element in lista_z:
print(element, type(element))
for subelement in element:
print(subelement, type(subelement))
print(subelement)
print()
print(lista... |
4085967a1cd1464c7668038866f3724745ddebfd | electrovirus8/FSDP2019 | /Day_03/Day_3_code_challange_solution/duplicate.py | 545 | 3.828125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu May 9 21:32:58 2019
@author: Mayank Jain
"""
"""
Code Challenge
Name:
Duplicate
Filename:
duplicate.py
Problem Statement:
With a given list [12,24,35,24,88,120,155,88,120,155]
Write a program to print this list after removing all duplicate values
... |
2890a81288d66717fcb2c60a64bf2790c5423fa4 | electrovirus8/FSDP2019 | /Day_01/Day_1_code_challange_solution/mileage_cal.py | 547 | 3.90625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed May 8 06:59:24 2019
@author: Mayank Jain
"""
"""
Code Challenge
Name:
Gas Mileage Calculator
Filename:
mileage_cal.py
Problem Statement:
Assume my car travels 100 Kilometres after putting 5 litres of fuel.
Calculate the average of my car.
Hint:
... |
918ceff6d50a96017acda05208ddbf3f05fdeb3a | mohammad-nassar/MSThesisDoc | /ngram-char.py | 1,684 | 3.703125 | 4 | """
Execution sequence: 3
Word character n-gram generation is runnning here.
all character n-grams of each single word is stored in a list in a file named "ngram1.txt"
"""
import pathlib
"""
Pesedocode
readCorpusData(filePath)
for line in filePath
ngramToken(line)
closeFile
ngramToken(word)
T... |
92a1c821be77c19218e7bbbe9425e1a51d8acf4a | jheym/mjc_projects | /mjc_code/MIT_OCW (Summer 2021 Refresher)/exceptFloatSum.py | 1,293 | 3.921875 | 4 | # -*- coding: utf-8 -*-
"""
float + string is a TypeError
0 + 1.423.42 is a SyntaxError
castFloat = float('a') is a ValueError
"""
"""def sumDigits(s):
Assumes s is a string
Returns the sum of the decimal digits in s
For example, if s is 'a2b3c' it returns 5"""
s = 'a2.1b.3cd.e0f1.0' # ... |
fd338cd04dd38eeaa717705959291d3ff6f03844 | jheym/mjc_projects | /mjc_code/MIT_OCW (Summer 2021 Refresher)/greatest_odd.py | 702 | 3.90625 | 4 | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
def greatest_odd(x,y,z):
while x+y+z != 0:
if x >= y and x >= z:
if x%2 != 0:
print(x)
break
else:
x=0
elif y >= x and y >= z:
if y%2 ... |
2516a933b33775fdc298d7ff208bd549331d650b | ChineseKawhi/Data-Structures-and-Algorithms | /LinkList/SkipList.py | 4,563 | 4.09375 | 4 | """
A skip list implementation.
Skip list allows search, add, erase operation in O(log(n)) time with high probability (w.h.p.).
"""
import random
class Node:
"""
Attributes:
key: the node's key
next: the next node
prev: the previous node
bottom: the bottom node in skip l... |
3084602d54300a73df921622088067741fcc90dc | jeetkhetan24/rep | /Assignment/q14.py | 1,233 | 4.03125 | 4 | """
Write a Python program to get next day of a given date.
Expected Output:
Input a year: 2016
Input a month [1-12]: 08
Input a day [1-31]: 23
The next date is [yyyy... |
27a8884bada5af0cb7fea5b1fcc5d6e255188150 | jeetkhetan24/rep | /Assessment/q11.py | 755 | 4.28125 | 4 | """
Write a Python program to find whether it contains an additive sequence or not.
The additive sequence is a sequence of numbers where the sum of the first two numbers is equal to the third one.
Sample additive sequence: 6, 6, 12, 18, 30
In the above sequence 6 + 6 =12, 6 + 12 = 18, 12 + 18 = 30....
Also, you can spl... |
60b2694d2f568c58fdf549a1f2b2f32fa67e2d7a | jeetkhetan24/rep | /Assignment/q17.py | 248 | 3.984375 | 4 | """
Please write a program which accepts a string from console and print the characters that have even indexes
H1e2l3l4o5w6o7r8l9d-
"""
a=raw_input()
b=list(a)
i=0
while(i<len(b)):
print b[i],
i=i+2 # PRINTS ALTERNATE CHARACTERS OF THE LIST
|
64b2f1231620e866a44354f8a72f737e5a6d714b | jeetkhetan24/rep | /Assessment/q25.py | 101 | 3.734375 | 4 | print("Enter the value:")
a=int(raw_input())
disp={}
for x in range(1,a+1):
disp[x]=x*x
print(disp) |
aa9f1ec44ef2cfd37e8abb924e2a695b0c0857a1 | philorfa/ProgLang | /Java-Python-Prolog/ex2-Python.py | 1,966 | 3.53125 | 4 | import queue
import sys
def process(f):
first_line = f.readline()
for line in f:
data = line.split()
start1=(int(data[0]))
end1=(int(data[1]))
start2=(int(data[2]))
end2=(int(data[3]))
solve(start1,start2,end1,end2)
def solve(lin,lout,rin,rout):
visited=set()... |
1286c74bc67406a679900fbe635fabe3c755e759 | chc1129/python_jisen | /04/none.py | 293 | 3.890625 | 4 | None # 何も表示されない
print( str(None) ) # 文字列に変換すると'None'
print('book')
print( str(print('book')) ) # print() の戻り値はNone
d = {'a': 1, 'b': 2} # 辞書を定義
print (d.get('c') ) # 結果がNoneなので何も表示されない
print( d.get('a') )
|
83eccc9a9cef2b97902e49140275c8217dda2e2c | chc1129/python_jisen | /04/boolOr.py | 370 | 3.6875 | 4 | # どちらか一方でも真であれば真
print( True or True )
print( True or False )
print( False or True )
print( False or False )
x = ['book']
y = []
print( x or y ) # xが真なのでxが返る
print( y or y ) # 入れ替えてもyが偽なのでxが帰る
z = 0
print( y or z) # 両方偽なのでzが返る
print( z or y) # 入れ替えるとyが返る
|
48a884fa3e2fa3bc4a3827ba481dcde2a076ae60 | chc1129/python_jisen | /06/isClassInst.py | 1,501 | 3.703125 | 4 | # クラス - インスタンスのひな型となるオブジェクト
# クラス変数- クラスオブジェクトが保持する変数
# クラス変数を持つクラスを定義
class Page:
book_title = 'Python Practice Book'
Page.book_title # インスタンスがなくても参照できる
print( Page.book_title )
Page.book_title = 'No title' # クラス変数の更新
Page.book_title
print( Page.book_title )
# クラス変数にはインスタンスからもアクセス可能
first_page = Page()
second_... |
4f73f3d4dee08f41dbcf97fba090d1a2cf605c01 | chc1129/python_jisen | /04/strFstring.py | 703 | 4.53125 | 5 | # 文字列の変数置換
# f-string -- 式を埋め込める
title = 'book'
f'python practive {title}' # 変数の値で置換
print( f'python practive {title}' )
f'python practice {"note" + title}' # 式を利用
print( f'python practice {"note" + title}' )
def print_title():
print(f'python practice {title}')
print_title()
title = 'sketchbook'
print_title() ... |
ed7416dd06ebe6264a51e1c949098e70100b6953 | chc1129/python_jisen | /03/whilebreak.py | 193 | 3.625 | 4 | def has_book(items):
for item in items:
if 'book' in item:
print('Found')
break # ループを抜ける
else:
print('Not found')
has_book(['note'])
has_book(['note', 'notebook'])
|
2e4167f3f744d7b81c63863a2b8209cb6b7c751b | omondijeff/Pythondaily | /happy_no.py | 537 | 3.515625 | 4 | class Solution:
def isHappy(self, n: int) -> bool:
def square_sum(num):
result = 0
while num > 0:
rem = num % 10
result = result + rem * rem
num = num // 10
return result
seen = set()
while square_su... |
99eceffadbd5609cc37a6318261107504a5bcd00 | SimLongXiang/FYP-SCE17-0282-Learners-Analytic-System | /Client_Reference/Simon Says and Logging Files/Simon_Says(logic).py | 1,838 | 3.703125 | 4 | from sense_hat import SenseHat
import time
import random
sense = SenseHat()
R = [255, 0, 0]
B = [0, 0, 255]
G = [0, 255, 0]
color_char = [R,B,G]
PC_choice = []
human_choice = []
level = 1
speed = 0.5
class main_logic():
def level_message(level):
print("Level: " + str(level) + " Speed: " + str(speed))
... |
467f62c1621f3bd1542c01228ec24d3c3fec740d | Robynleigharris/demerit | /conditional.py | 684 | 3.890625 | 4 | #80-100 A
#70-79 B
#69-50 C
#40-49 D
#0-39 E
"""mark=int(input("please enter mark of student"))
if mark>=80 and mark<=100:
print("grade A")
elif mark>=70 and mark<=79:
print("grade b")
elif mark>=50 and mark<=69:
print("grade c")
elif mark>=40 and mark<=49:
print("grade D")
else:
print("grade E")
if not isinstanc... |
6febde39059c62422f858e99718fa7471c7aa50b | Aternands/dev-challenge | /chapter2_exercises.py | 1,538 | 4.25 | 4 | # Exercises for chapter 2:
# Name: Steve Gallagher
# EXERCISE 2.1
# Python reads numbers whose first digit is 0 as base 8 numbers (with integers 0-7 allowed),
# and then displays their base 10 equivalents.
# EXERCISE 2.2
# 5---------------> displays the number 5
# x = 5-----------> assigns the value "5" t... |
c93155b85d2a71925901d53c6e79eadbbfe7fb9d | baesomi/DLfromScratch | /basic_NN/relu_func.py | 392 | 3.84375 | 4 | import numpy as np
import matplotlib.pylab as plt
def relu(x):
return np.maximum(0,x)
## 다차원 배열
A= np.array([1,2,3,4])
print(A)
np.ndim(A) # 1
A.shape # (4,)
A.shape[0] # 4
B = np.array([[1,2],[3,4],[5,6]])
print(B)
np.ndim(B) # 2 (차원 수)
B.shape
## X * W = Y
X = np.array([1,2])
X.shape
W = np.array([[1,3... |
7543ed0ab2d29d51ab8356e3088ee4ffe057bb58 | PonteIneptique/Siena-2015 | /src/exporters/helpers.py | 317 | 3.578125 | 4 | from collections import namedtuple
Node = namedtuple("Node", ["id", "text", "type"])
Edge = namedtuple("Edge", ["source", "target", "weight"])
def row(length):
""" Create a namedtuple of length column + label """
rows = ["label"] + ["topic"+str(i) for i in range(length)]
return namedtuple("Row", rows)
|
496e5114f9bb729ce0b0132add7b0e0a2eba8e2d | Capstone-Galen/AutoLoanApp | /main.py | 1,874 | 3.796875 | 4 | import decimal as dc
# Auto Loan Calculator console representation
# Created by Galen Schatzman 12/26/2019
#Now added to repository at https://github.com/SchatzmanGPS/ConsoleLoanApp.git
print("")
print("*************************************************************************")
print("**********************************... |
b41277edaf22984242896af5ab0da6482f5f1436 | assasin0308/flask | /run.py | 2,002 | 3.796875 | 4 | from flask import Flask, url_for
# 将当前运行得到主程序构建成为Flask的应用,以便接受用户的请求(request)并给出相应(response)
app = Flask(__name__)
# flask中路由定义,定义用户的访问路径
@app.route('/index')
def index():
return "<h1> this is my first app </h1>"
# 带一个参数的路由
@app.route('/login/<name>') # 参数名称用 <>包裹
def login(name): # 形参与路由参数名称保持一致
return 'this... |
dfc73a74d080f40d40b1b864f6c346ffc1df7f1d | MahimaMehandiratta/MSCW_2020_Python | /Deadline_Of_Project.py | 578 | 4.0625 | 4 | import sys
import datetime
CurrentDate = datetime.date.today()
try:
deadline = input("What is the deadline for the project? (dd/mm/yyyy) ")
deadline = datetime.datetime.strptime(deadline, "%d/%m/%Y").date()
except:
print("Enter the date in the format mentioned!!!!")
sys.exit()
diff = deadli... |
ab6e09772e706a26355f76f076e19e3de47166bd | MahimaMehandiratta/MSCW_2020_Python | /Turtle_challange.py | 165 | 3.9375 | 4 | import turtle
nbrSides = int(input("Enter number of sides of the object: "))
for steps in range(nbrSides):
turtle.forward(100)
turtle.right(360/nbrSides) |
163d1bb0daee1e706d9424a8f8f5210d96d53f7b | Ada-C15A/crypto | /caesar.py | 390 | 3.875 | 4 | def rot13(letter):
if 'A' <= letter <= 'Z':
offset = ord('A')
elif 'a' <= letter <= 'z':
offset = ord('a')
else:
return letter
offset_letter = ord(letter) - offset + 13
wrapped_letter = offset_letter % 26
new_letter = chr(wrapped_letter + offset)
return new_letter
... |
f4674bf85f52e6ca4d538fb5a390ccfd893848af | Kimonokimo/NLP-comment-project | /dataclean.py | 2,480 | 3.78125 | 4 | import re
class DataClean():
'''
Data Preprocessing
As we can see the raw data contains a lot useless information
includes: special punctuations, numbers and abbreviations
The DataClean class uses re to clean punctuations and numbers,
and replace abbreviations in english by their normal... |
3e6450db605a1a2d736a8c862c6f27d105531aa1 | j-bennet/cracking | /2.4_add_lists.py | 988 | 3.78125 | 4 | from linked_list import Node, LinkedList
def add_lists(l1, l2):
if (l1 is None) or (l2 is None) or ((l1.head is None) and (l2.head is None)):
return None
ll = LinkedList([])
h = 0
n1 = l1.head
n2 = l2.head
if n1 is not None: h += n1.data
if n2 is not None: h += n2.data
digit = h % 10
remember = (h - ... |
9c5fff12ae370eaf99fa80fa4d34c566d8e1e00e | j-bennet/cracking | /4.3_build_minimal_tree.py | 323 | 3.625 | 4 | from binary_tree import *
def create_minimal_tree(a):
return add_to_tree(a, 0, len(a) - 1)
def add_to_tree(a, l, r):
if l > r: return None
m = l + (r - l) / 2
n = Node(a[m])
n.left = add_to_tree(a, l, m - 1)
n.right = add_to_tree(a, m + 1, r)
return n
t = create_minimal_tree(range(0, 11))
print t.to_strin... |
7ff30b497d5d002b789b8420a8f239605b3da75b | j-bennet/cracking | /linked_list.py | 1,106 | 3.84375 | 4 | class Node:
data = 0
next = None
def __init__(self, data):
self.data = data
def append(self, data):
tailnode = Node(data)
n = self
while n.next is not None:
n = n.next
n.next = tailnode
class LinkedList:
head = None
def __init__(self):
self.head = None
def __init__(self, from_list)... |
226f3e379753a10f663aecf1b044582cef2008dc | j-bennet/cracking | /2.0_linked_list_basics.py | 208 | 3.59375 | 4 | from linked_list import Node, LinkedList
ll = LinkedList(range(1, 11))
to_remove = [2, 1, 8]
print 'Original:'
ll.output()
for i in to_remove:
print 'Removed ' + str(i) + ':'
ll.remove(i)
ll.output()
|
5aa370683df3346084e92481d9a8b24cd6805548 | Steph99rod/Metrics-Dashboard | /Issues/Code/Issues.py | 6,455 | 3.71875 | 4 | from datetime import datetime
from githubAPI import GitHubAPI
from sqlite3 import Cursor, Connection
class Logic:
'''
This is logic to analyze the data from the githubAPI Issues Request API and store the data in a database.
'''
def __init__(self, gha: GitHubAPI= None, data: dict = None, responseH... |
576efdf068952dbcbb7d04fb3011816042cfad9c | ovainola/python_kurssi | /esimerkit/Basics/3_system_arguments.py | 922 | 3.84375 | 4 | # -*- coding: utf-8 -*-
# Ajokomento esim. python system_arguments 6112 maukka
import sys
if __name__ == '__main__':
sys_args = sys.argv
print(sys_args)
if len(sys_args) < 3 or len(sys_args) > 3:
raise Exception("tarkista argumenttien maara")
python_file = sys_args[0]
other_args = sys_... |
a7359ed98aec386591dae00fcdc78d2b85bfa8ed | ranahere007/Python_Basic | /Python_4.py | 106 | 3.8125 | 4 | #Simple if function
x=10
y=17
if x>y:
print("X is bigger.")
else:
print("Y is bigger.")
|
e4373dd448a448ce804d620dd82b37e511ac7d16 | ranahere007/Python_Basic | /while_1.py | 226 | 3.828125 | 4 | # Eating cookies
cookies = 20
cookie_number = 0
while cookies >= 0:
cookies = cookies - 1
cookie_number = cookie_number + 1
print("Eating a cookie ", cookie_number)
print("I ate all the cookies")
|
a6c9ba207d69c8f3fe33b846bac29f2d7fd30b6b | russellcrowley/CS50x2020 | /pset7/houses/roster.py | 585 | 3.59375 | 4 | import sys
import csv
import cs50
# check command line arguments
if len(sys.argv) != 2:
print("Error, provide one house")
sys.exit(1)
query = sys.argv[1]
# open database for writing
db = cs50.SQL("sqlite:///students.db")
# get list of stdents in house from database
houses = db.execute('SELECT * FROM students W... |
587e5798635e25edab1dd543ffc7f35d35052b45 | Charlzzz/mainhub | /Pystudy/lesson1step13.py | 422 | 4 | 4 | a = float(input())
b = float(input())
x = str(input())
if x == ("*") :
print(a*b)
if x == ("-") :
print(a-b)
if x == ("+") :
print(a+b)
if x == ("pow") :
print(a**b)
if x == ("div") and b != 0.0:
print(a // b)
if x == ("/") and b != 0.0:
print(a / b)
if x == ("mod") and b!= 0.0:
print(a % b)... |
6362fb8b4b02d0ad66a13f68f59b233cdde2038b | jgarcia524/is210_lesson_06 | /task_01.py | 847 | 4.5625 | 5 | #!usr/bin/env python
# -*- coding: utf-8 -*-
"""Listing even and odd numbers"""
import data
from data import TASK_O1
def evens_and_odds(numbers, show_even=True):
"""Creates a list of even numbers and a list of odd numbers.
Args:
numbers (list): list of numbers
show_even (bool): de... |
44c0024661cab7ef3bd9f1f2ce72241a845fd12b | ShiversVert/Snake_Project | /servo_controlling/libs/pydynamixel/Examples/grip.py | 2,375 | 3.5 | 4 |
from pydynamixel import dynamixel, chain
def grip(ser, joint, incr, limit, velocity, verbose, num_error_attempts):
"""
This function will modify the angular position of the servo with the specified ID until
its measured torque exceeds a specified value. This is especailly useful for gripping objects,
... |
ad0cb3caa584db75d7377df2b9e5161976b64176 | pfreisleben/Blue | /Modulo1/Aula 12 - CodeLab Dicionário/Exercicio 4.py | 875 | 3.5625 | 4 | """ Crie um programa em que 4 jogadores, joguem um dado e tenham resultados
aleatórios. Guarde esses resultados em um dicionário. No final coloque esse dicionário
em ordem, sabendo que o vencedor tirou o maior número no dado. Dicas: procure
sobre a função randint(), sleep() e itemgetter da bliblioteca operator. """
imp... |
e35d9de64d658fff3adf421be31b0caf23f3e2b1 | pfreisleben/Blue | /Modulo1/Aula 14 - Exercicios Obrigatórios/Exercicio 2.py | 493 | 4.125 | 4 | # 02 - Utilizando estruturas de repetição com variável de controle, faça um programa que receba
# uma string com uma frase informada pelo usuário e conte quantas vezes aparece as vogais
# a,e,i,o,u e mostre na tela, depois mostre na tela essa mesma frase sem nenhuma vogal.
frase = input("Digite a frase: ").lower()
voga... |
c77b54073b94153f22acc361fe864339194caf9f | pfreisleben/Blue | /Modulo1/Aula 10 - While/Exercicio 1.py | 353 | 4.25 | 4 | """
Exercício 1 - Escreva um programa que pede a senha ao usuário, e só sai do
looping quando digitarem corretamente a senha. """
senha = "9856321"
digitada = input("Digite sua senha: ")
while digitada != senha:
print("Senha incorreta, digite novamente!")
digitada = input("Digite sua senha: ")
print(f'Você d... |
d13d79377331dcc266b89a86e9bef35ce258d449 | pfreisleben/Blue | /Modulo1/Aula 09 - Loops com For/Exercicio1.py | 293 | 3.96875 | 4 | """ Crie um código em Python que pede qual tabuada o usuário quer ver, em
seguida imprima essa tabuada. """
def tabuada():
numero = int(input("Digite o número cuja tabuada deseja ver: "))
for num in list(range(1, 11)):
print(f'{numero}x{num} = {numero*num}')
tabuada()
|
315cdba74cd51658d39a788a872a3e33c62eac6f | pfreisleben/Blue | /Modulo1/Aula 14 - Exercicios Obrigatórios/Exercicio 7.py | 573 | 4.1875 | 4 | # 07 - Crie um programa onde o usuário possa digitar sete valores numéricos e cadastre-os em uma
# lista única que mantenha separados os valores pares e ímpares. No final, mostre os valores pares
# e ímpares em ordem crescente.
lista = [[], []]
continua = 0
while continua < 7:
numero = int(input("Digite um número... |
6c3ba39b9318806444770ba500bc33a0b0000ff0 | pfreisleben/Blue | /Modulo1/Aula 10 - While/Desafio.py | 1,577 | 4.09375 | 4 | """ Desenvolver um programa para verificar a nota do aluno em uma prova com 10
questões, o programa deve perguntar ao aluno a resposta de cada questão e ao
final comparar com o gabarito da prova assim calcular o total de acertos e a
nota (atribuir 1 ponto por resposta certa). Após cada aluno utilizar o sistema
dev... |
6b17a68c013f999b3547abbedd93f12166061c72 | pfreisleben/Blue | /Modulo1/Aula 12 - CodeLab Dicionário/Desafio.py | 1,865 | 4.1875 | 4 | """ DESAFIO: Crie um programa que leia nome, sexo e idade de várias pessoas,
guardando os dados de cada pessoa em um dicionário e todos os dicionários em uma
lista. No final, mostre:
A) Quantas pessoas estão cadastradas.
B) A média da idade.
C) Uma lista com as mulheres.
D) Uma lista com as idades que estão acima da mé... |
d2e2b75a85e09aab40dca105c1cf1cabe404ea07 | ScottPartacz/Python-projects | /Pick_3_Lotto.py | 2,334 | 4.1875 | 4 | # Scott Partacz 1/25/2018 ITMD 413 Lab 3
import time
import random
def check (picked,wining_numbers) :
if(wining_numbers == picked) :
win_or_lose = True
elif(wining_numbers != picked) :
win_or_lose = False
return win_or_lose;
def fireball_check(fireball,picked,wining_numbers) :
count =... |
f8d782f3cf30117662736d2c39716d9ef2dce61e | JaurronWC/web-caesar | /caesar.py | 1,182 | 3.921875 | 4 | lowerAlpha = "abcdefghijklmnopqrstuvwxyz"
upperAlpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def alphabet_position(letter):
#recieve a letter and returns the 0-based number value for that letter
dex = lowerAlpha.find(letter)
if dex < 0:
dex = upperAlpha.find(letter)
return dex
def rotate_character(ch... |
2200d47b6f0a022ca55580b875627bf90d1ef78b | aanchal-ag/pattern | /name.py | 81 | 3.65625 | 4 | n=input("enter the first name")
m=input("enter the last name")
print(m," ",n)
|
d49b6e079c947d19826a612ec80bf0b9eddcb50f | evenhuis/bee_quant | /analysis/pymc3_utils.py | 6,259 | 3.546875 | 4 | import numpy as np
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Functions
# Definitions of functions used in the fitting
def logit(p):
return np.log(p/(1-p))
def invlogit(a):
return 1./(1.+np.exp(-a))
def multilabel_encoder(df,labels,delim='_##_'):
'''Creates a unique inde... |
1a765b54c13784f3f657caa7e9a986edd38f632b | LEEYEONSU/acmicpc_algorithm | /Code/python/algorithm/data_structure/string/2743.py | 64 | 3.609375 | 4 |
word = input()
ans = 0
for i in word :
ans += 1
print(ans) |
29de251cab19ab78cec76bd6c3eccdf0cb47dbb5 | kos0ng/code-challenge | /30DaysofCodehackerrank/queuesandstack.py | 1,082 | 3.84375 | 4 | import sys
class Solution:
def __init__(self):
self.stack = []
self.queue = []
def pushCharacter(self, ch):
self.stack.append(ch)
def enqueueCharacter(self, ch):
self.queue.append(ch)
def popCharacter(self):
return self.stack.pop()
def dequeueCharacter(self):
queue=self.queue[::-1]
print queue
... |
61d770e5c27ad8aaf64f64a3e3f6679d4a9d0dd0 | kos0ng/code-challenge | /ProblemSolvinghackerrank/finddigits.py | 476 | 3.59375 | 4 | #!/bin/python
import math
import os
import random
import re
import sys
# Complete the findDigits function below.
def findDigits(n):
count=0
for i in str(n).replace('0',''):
if(n%int(i)==0):
count+=1
print count
if __name__ == '__main__':
# fptr = open(os.environ['OUTPUT_PATH'], 'w')
t = int(raw_input... |
c69d0af3e94c4cef6a325202cbba6f705475f0a3 | kos0ng/code-challenge | /ProblemSolvinghackerrank/sherloc_array.py | 793 | 3.625 | 4 | #!/bin/python
import math
import os
import random
import re
import sys
# Complete the balancedSums function below.
def balancedSums(arr):
left_count=0
right_count=len(arr)-1
sum_left=arr[left_count]
sum_right=arr[right_count]
while(left_count!=right_count):
if(sum_left>sum_right):
right_count-=1
sum_righ... |
1a880a14da68eece8be9bd5241c8029f3d073492 | kos0ng/code-challenge | /ProblemSolvinghackerrank/modfact.py | 250 | 3.5 | 4 |
def modFact(n, p):
if n >= p:
return 0
result = 1
for i in range(1, n + 1):
result = (result * i) % p
print(str(result)+'\n')
return result
# Driver Code
n = 3; p = 5
print (modFact(n, p))
|
d5bfe4f84d81ae92a0a1bff1b96129ff16caa325 | prateek0635/SnakeWaterGun.py | /SnakeWaterGun.py | 1,501 | 3.859375 | 4 | import random #Imported the random so that Bot can choose the Random S W G
import time # To pause the game between some commands so that it will feel smooth
def check(n,k):
global u,c #Global
if n=='S':
if k=='G':
c=c+1
print("Bot Won This chance")
elif k=='W':
... |
d88ba88d94637bcb1a0662fcb2faf04a458bf3bc | Samvel11/newrepos | /15.py | 4,692 | 4.03125 | 4 |
class Hotel:
def __init__(self,hotel_name,place,mid_room,mid_room_price, lux_room, lux_room_price):
self.hotel_name = hotel_name
self.place = place
self.mid_room = mid_room
self.mid_room_price = mid_room_price
self.lux_room = lux_room
self.lux_room_price = lux_room_price
def HotelPresentation(self):
... |
67a16c9e33281298d56fd7dfecca98228e2d0e29 | Mart-eng/Linked-List | /LList.py | 11,598 | 3.84375 | 4 | from ListNode import ListNode
class LList:
#------------------------------------------------------------
def __init__(self, seq=()):
"""create an LList
pre: seq is a list
post: creates a list containing items in seq"""
if seq == ():
# No items to put in, cre... |
020c158005c42966401616c9645295b9117e844e | lxu213/Birthday-Problems | /triangle.py | 794 | 3.8125 | 4 | # Triangle Exercise from Cyrus
# 2.5 hours
# January 30, 2016
import numpy as np # Numpy: processes large multi-D arrays
import matplotlib.pyplot as plt # Pyplot: provides MATLAB-like plotting framework
import random
# Constant (tuples)
INIT = (5,5)
A = (0,0)
B = (5,10)
C = (10,0)
... |
6759584efb962d126814e8c52cda23f0c6b276c3 | luminita/data-science | /assignments/1/frequency.py | 1,462 | 3.546875 | 4 | import sys
import json
def build_sentiment_dict(filename):
afinnfile = open(filename)
scores = {} # initialize an empty dictionary
for line in afinnfile:
term, score = line.split("\t") # The file is tab-delimited. "\t" means "tab character"
scores[term] = int(score) # Convert the score ... |
9eb93d7ff7eeda82233aad141dae86eac89f7ab2 | Eduardo271087/python-udemy-activities | /section-5/if.py | 475 | 4 | 4 | # Importante recordar los dos puntos (:)
if True:
print('Imprimo esto porque la evaluación fue veradera')
if False:
print('Imprimo esto porque la evaluación fue veradera')
alvaro = 10
if alvaro == 67:
print('Alvaro vale 67')
if alvaro == 10:
print('Alvaro vale 10')
if alvaro == 11:
print('Alvaro vale 67')... |
8c13e0f0fe77d59c514d3b071f1488169a461755 | Eduardo271087/python-udemy-activities | /section-9/multiple-exceptions.py | 1,285 | 4.28125 | 4 | variable = float(input("Introduce algo: "))
# Si se introduce una letra
# File "/home/eduardo-fernandez/source/python-udemy-activities/section-9/multiple-exceptions.py", line 1, in <module>
# variable = float(input("Introduce algo: "))
# ValueError: could not convert string to float: 'l'
a = 2
print("Resultado... |
9af00e0bc6974ceafb86f1987ccabf887a2d10ad | Eduardo271087/python-udemy-activities | /section-8/function-arguments-3.py | 849 | 3.671875 | 4 | def argu(*tu):
for tus in tu:
print(tus)
argu('alvaro', 'chirou', 'estudiantes', 10, [1, 2, 3])
def nombre_diccionario(**lo):
print(lo)
nombre_diccionario(alvaro = 'chirou', Estudiantes = 'Genios', calificaciones = [7, 8, 9])
def nombre_diccionario1(**lo):
for x in lo:
print(x)
nombre_diccionario1(al... |
a05e1db27abeec668ea4e437d73303e1cd7c68b9 | Eduardo271087/python-udemy-activities | /section-8/function-arguments-1.py | 332 | 3.640625 | 4 | def funciones(a, b):
return a - b
print(funciones(2, 2))
# Envío de argumentos por nombre
print(funciones(b = 2, a = 1))
print(funciones(a = 2, b = 1))
def nulos(x = None, i = None):
if x == None or i == None:
print('Amigo, debes ingresar los dos números')
return
return x / i
print(nulos())
print(nu... |
053459a5ca43e4b8e2e59b40086de8822ac81efb | Eduardo271087/python-udemy-activities | /section-3/lists.py | 1,133 | 4.09375 | 4 | listas = [5, 9, "Alvaro", -8, "estudiantes"]
print("listas[0]: '" + str(listas[0]) + "'")
print("listas[-1]: '" + str(listas[-1]) + "'")
print("listas[2]: '" + str(listas[2]) + "'")
print("listas[2:]: '" + str(listas[2:]) + "'")
primera_parte = [1, 2, 3, 4]
segunda_parte = [5, 6, 7]
print("primera_parte + segunda_... |
4d1072ab70a95d63a7ecd80867a1261258aee314 | eunice12jk/samasource-andela | /testdivision.py | 692 | 3.875 | 4 | import unittest
from division import divide
class test_division(unittest.TestCase):
def test_division(self):
self.assertEquals(divide(4,2),2)
def test_negative_division(self):
self.assertEquals(divide(-9,-3),3)
def test_float_division(self):
self.assertEquals(... |
57118368dea3908854535bb30dd9772dd49a0720 | C-H-coder-team/Narcissism_number | /Narcissism number.py | 134 | 3.5 | 4 | n=input()
x=[]
for i in n:
x.append(int(i))
s=0
for j in x:
s+=j**len(x)
if s==int(n):
print("Yes")
else:
print("No")
|
00b1648b8da3188fc8402e79ad8cd5016cb097ea | Juniorexz/python-code | /geradordesenhas/gs.py | 388 | 3.859375 | 4 | import random
import string
tamanho = int(input('Digite o tamanho de senha que deseja:')) #tamanho de quantidade de caracteres
chars = string.ascii_letters + string.digits + 'ç!@#$%&*()-=+,.;/?' #envolve letras maiusculas e minusculas
rnd = random.SystemRandom() #os.urandom(biblioteca que usa nummeros aleat... |
f9efc72645e958603a53114d190ec18ed7412aec | hongfeng2013/algorithm009-class01 | /Week_07/solution130_solve.py | 1,439 | 3.734375 | 4 |
# 130. 被围绕的区域
# 给定一个二维的矩阵,包含 'X' 和 'O'(字母 O)。
# 找到所有被 'X' 围绕的区域,并将这些区域里所有的 'O' 用 'X' 填充。
#
# 示例:
# X X X X
# X O O X
# X X O X
# X O X X
# 运行你的函数后,矩阵变为:
# X X X X
# X X X X
# X X X X
# X O X X
class Solution(object):
def solve(self, board):
"""
:type board: List[List[str]]
:rtype: None Do... |
f0f27957b5459991d70f0ebd7bf3c757e1b52cd0 | hongfeng2013/algorithm009-class01 | /Week_03/solution78_subsets.py | 733 | 3.71875 | 4 |
#输入: nums = [1,2,3]
class Solution(object):
def subsets(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
if nums is None:
return []
res = []
track = []
def backtrack(nums, start, track):
size = len(nums)
... |
0914598b3eab1cc51c7f5557d2dabaa2b8c84019 | hongfeng2013/algorithm009-class01 | /Week_06/soution621_leastInterval.py | 1,364 | 3.515625 | 4 |
# 621.
# 任务调度器
# 给定一个用字符数组表示的CPU需要执行的任务列表。其中包含使用大写的A - Z字母表示的26种不同种类的任务。任务可以以任意顺序执行,
# 并且每个任务都可以在1个单位时间内执行完。CPU在任何一个单位时间内都可以执行一个任务,或者在待命状态。
# 然而,两个相同种类的任务之间必须有长度为n的冷却时间,因此至少有连续n个单位时间内CPU在执行不同的任务,或者在待命状态。
# 你需要计算完成所有任务所需要的最短时间。
# 示例 :
# 输入:tasks = ["A", "A", "A", "B", "B", "B"], n = 2
# 输出:8
# 解释:A -> B -> (待命) -> A ->... |
f7e3084f3626a028122db7097e0e2204e001f693 | hongfeng2013/algorithm009-class01 | /Week_06/solution1143_longestCommonSubsequence.py | 1,312 | 3.578125 | 4 |
# 给定两个字符串 text1 和 text2,返回这两个字符串的最长公共子序列的长度。
#
# 一个字符串的 子序列 是指这样一个新的字符串:它是由原字符串在不改变字符的相对顺序的情况下删除某些字符(也可以不删除任何字符)后组成的新字符串。
# 例如,"ace" 是 "abcde" 的子序列,但 "aec" 不是 "abcde" 的子序列。两个字符串的「公共子序列」是这两个字符串所共同拥有的子序列。
#
# 若这两个字符串没有公共子序列,则返回 0。
#
#
#
# 示例 1:
#
# 输入:text1 = "abcde", text2 = "ace"
# 输出:3
# 解释:最长公共子序列是 "ace",它的长度为 3。
... |
13a7e932a82c47912601fa2852d71f5683694224 | hongfeng2013/algorithm009-class01 | /Week_04/solution153_findMin.py | 562 | 3.671875 | 4 |
# 输入: [3,4,5,1,2]
# 输出: 1
class Solution:
def findMin(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
left = 0
right = len(nums) - 1
while left <= right:
mid = (left + right) // 2
if left == right:
return nums[... |
12e2ae29b2da69b04fadb150c0db9a17c0d5483a | kernelios/dummy_ransomware | /dummy_ransomware/generate_key.py | 1,138 | 3.984375 | 4 | import random
import hashlib
class GenerateKey:
"""
generate new random key using a math trick:
http://mathforum.org/library/drmath/view/67061.html
http://www.math-only-math.com/divisible-by-9.html
"""
def __sum_digits(self, x):
"""summarize the digits of given num... |
98a814f849724278e01c83a84a9455fee73333a3 | AdamBorg/AdamBorgA1 | /AdamBorgA1.py | 7,397 | 4.21875 | 4 | """ IT@JCU CP1404 Assignment 1
Shopping List 1.0
Name: Adam Borg
date: 09/09/2016
GitHub Link: https://github.com/AdamBorg/AdamBorgA1.git
Pseudocode:
function load_items()
create a list to save items to
open items.csv to read contents
for every line in items.csv
save line to the cr... |
63844cddb2026821ec52cb17e0bec3b542abee01 | SoulVictus/MetodyNumeryczne | /Lista 2/zad4.py | 331 | 3.953125 | 4 | import math
for i in range(2, 26, 2):
x = 2**(-i)
result = math.sqrt(x**4 + 4) - 2
print("{0}. {1}".format(i, result))
print("\n")
for i in range(2, 26, 2):
x = 2**(-i)
result = x**4/(math.sqrt(x**4 + 4) + 2)
print("{0}. {1}".format(i, result))
# Widać, że drugi sposób jest dużo bardziej do... |
92cd0001b602a0cdea7e03d6170ba6bd500aca0f | bauglir-dev/dojo-cpp | /behrouz/ch01/pr_13.py | 227 | 4.46875 | 4 | # Algorithm that converts a temperature value in Farenheit to a value in Celsius
farenheit = float(input("Enter a temperature value in Farenheit: "))
celsius = (farenheit - 32) * (100/180)
print(str(celsius) + ' Celsius.'))
|
2e268f3e6fdcc4e9bedf2c540f8fe990bc4a6a10 | mehulpatel21/Python-For-Everyone-University-of-Michigan | /Basics/Chapter_8.py | 2,150 | 3.828125 | 4 | def average_of_list():
numlist = list()
while True:
inp = input("Enter a number: ")
if inp == 'done':
break
value = float(inp)
numlist.append(value)
average = sum(numlist)/len(numlist)
print ("Average: ", average)
def extract_day_of_the_week():
fhand = ... |
18794f89fd73e11dbcd2cb0f2fc79f08e8302b15 | sftoolhk/coursera_python | /fizz.py | 100 | 4.0625 | 4 | f = int(input("Escreva um número: "))
if f % 3 == 0 :
print("Fizz")
else:
print(f)
|
d9b1e59e476964d8fbc31e7c6af38115913b1281 | timqhartnett/Bootstrapped_ML | /BootstrapML.py | 11,004 | 3.5625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 12 09:53:07 2021
First attempt at objected oriented ML bootstrapping
@author: timothy
"""
import pandas as pd
import numpy as np
class data_analysis:
'''
class to handle data analysis and visualization prior to model creation
in gener... |
b387aa4e2cee7cbbfa8c252e87a61759883bfa7d | ismayil028/PythonPractice | /randTest.py | 157 | 3.5 | 4 | import random
a='yes'
while a=='yes':
print('Random Number Generated ')
print(random.randint(1,5))
a =raw_input("Do you want to retry")
print "Thank You" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.