blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
2565ed582c19e452caa3ba60edfee24ff0831a50 | kerabatsos/PythonVisual | /VSC/TkInter.py | 598 | 3.515625 | 4 | import tkinter
mainWindow = tkinter.Tk()
mainWindow.title("Main Window")
mainWindow.geometry('640x480+8+400')
label = tkinter.Label(mainWindow, text = 'Hello')
label.pack(side="top")
canvas = tkinter.Canvas(mainWindow, relief = 'raised', borderwidth = 1)
canvas.pack(side = 'top')
button1 = tkinter.Button(mainWin... |
f05b2f378aa357770430ab8e36da59c29ef836d6 | damnbhola/Data-Structures-and-Algorithms | /LinkedLists/circular_singly_linked_list.py | 3,026 | 4.03125 | 4 | class Node:
def __init__(self, value):
self.value = value
self.next = self
class CSll:
root = None
def __len__(self):
return self.length()
def clear(self):
self.root = None
def append(self, value):
temp = Node(value)
if self.root is None:
... |
4169d6b6efaa155f403fa0e5b64124bc9ea5eeb6 | Tuabuela987/untitled1 | /pasword.py | 201 | 3.6875 | 4 | cog = input ("Dime tu apellido: ")
num = input ("Dime un numero: ")
c= ""
for i in range(len(cog)):
if i%2 !=0:
c +=cog[i]
else:
c+=(num)
c.replace (" ", "")
print (c)
|
8934ee6ae3e3d0d077d5f980b6e122dc8fd62e57 | guoyu07/CLRS | /Calc.py | 3,824 | 3.578125 | 4 | __author__ = 'Tong'
priority = {"+": 0, "-": 0, "*": 1, "/": 1, "mod": 1, "(": -99, ")": -999}
n_operands = {"+": 2, "-": 2, "*": 2, "/": 2, "mod": 2}
def get_next(infix):
# Avoid accidental space
infix = infix.strip()
# Find the most adjacent operator
index = float("inf")
operator = ""
for o... |
139fd221c83592618faf1ce9934a0f592873ad06 | guoyu07/CLRS | /LeetCode/SameTree.py | 916 | 4.09375 | 4 | __author__ = 'Tong'
# Given two binary trees, write a function to check if they are equal or not.
#
# Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
# Definition for a binary tree node
class TreeNode:
def __init__(self, x):
self.val = x
... |
4c7045be009bd31fe16273a03e25c4962e000a51 | nixis-institute/practice | /python/bhawna/c.py | 54 | 3.703125 | 4 | st="hello"
l=[]
for i in st:
l.append(i)
print(l)
|
78de36c0caa58cda1da792522db0c88a253a50bd | nixis-institute/practice | /python/bhawna/bp2.py | 155 | 4.125 | 4 | def factorial(a):
c=1
for i in range(1,a+1):
c=c*i
return c
a=int(input("enter the value"))
f=factorial(a)
print("factorial is",f) |
895e4b795c074a0374f19847bab6f355a062f918 | nixis-institute/practice | /python/Rupes/week.py | 336 | 4.03125 | 4 | n=(int(input('Enter the value ')))
if (n==1):
print('Today is Monday')
elif (n==2):
print('Today is Tuseday')
elif (n==3):
print('Today is Wednesday')
elif (n==4):
print('Today is Thasday')
elif (n==5):
print('Today is Friday')
elif (n==6):
print('Today is Starday')
elif (n==7):
print('Today... |
8f6fff733e43ef494a2e18267762edd4dcdbf90f | nixis-institute/practice | /python/bhawna/loop.py | 177 | 3.984375 | 4 | n=int(input("enter the range"))
s=''
for i in range(1,n):
s=s+"*"
print(s)
"""for i in range(1,n):
for j in range(i):
print("*",end="")
print("\n")
""" |
fc74a256feab2521a434af367ca61b3fb6734789 | nixis-institute/practice | /python/bhawna/b.py | 175 | 4.1875 | 4 | a=int(input("enter the value"))
for i in range (1,a):
#print("even values",(a%2 is 0))
if i%2 is 0:
print("no is even",i)
else:
print("no is odd") |
aeab15f7f34cbad76d3a883e44b0883a1666e4d7 | nixis-institute/practice | /python/bhawna/week.py | 352 | 4.125 | 4 | number=int(input("enter the number"))
if number==1:
print("monday")
elif number==2:
print("tuesday")
elif number==3:
print("wednesday")
elif number==4:
print("thursday")
elif number==5:
print("friday")
elif number==6:
print("saturday")
elif number==7:
print("sunday")
else:
... |
27fd8430aeadc3d3b9ca14599580ecf14c5ff5fc | nixis-institute/practice | /python/Sunil.py | 591 | 3.890625 | 4 | A=input('Enter the product name ')
B=input('Enter the price of the product ')
C=input('Enter the quantity of the product ')
Total=B*C
if (C>=10):
dis=(Total)*0.05
print('you have got as moch discounte',dis)
elif (C>=15):
dis=(Total)*0.10
print('You have got discounte',dis)
elif (C>=20):
d... |
88b9991c67a8ec4f86d27dfceb26092e68e133eb | nixis-institute/practice | /python/even.py | 126 | 4.1875 | 4 | value = int(input("Enter value "))
if(value%2==0):
print("This is even value ")
else:
print("this is odd value ") |
5b29b6b3fc720588197e6a6221137f43be6b845c | nixis-institute/practice | /python/bhawna/1.py | 180 | 4.0625 | 4 | a=input("enter the first value")
b=input("enter the second value")
if a>b:
print("a is greater")
elif(a==b):
print("both are equal")
else:
print("b is greater") |
6df18d079b147a461bda9aeea39718dbe682f6d4 | nixis-institute/practice | /python/insertdata.py | 472 | 3.625 | 4 | import sqlite3 as sql
import pandas as pd
con=sql.connect("new.db") # to open the database in which we have to insert the data
command="insert into stud values('Dhruv',10,99)" #stud is the name of the table
command1="insert into stud values('Raftaar',11,95)"
command2="insert into stud values('Muhfaad',10,99)"
com... |
f72fcc7790b2a4593cfbf4745994bf59957550b8 | nixis-institute/practice | /python/bhawna/bp.py | 471 | 4.0625 | 4 | def subtraction(a,b):
f=a-b
return f
def addition(a,b):
d=a+b
return d
def multiplication(a,b):
e=a*b
return e
a=int(input("enter the first value"))
b=int(input("enter the second value"))
c=int(input("enter the user choice"))
if c==1:
f=subtraction(a,b)
print("subtraction",f)
elif c==2:... |
4e31abc9850d0272cec22aa50e7f52d0375bb342 | nixis-institute/practice | /python/hello.py | 173 | 3.546875 | 4 | v=['Hello world']
#for k in range(0, len(v)):
print(v.index(v,beg=0 end=len(v)))
print("\n")
#j=len(v)
#print(j)
#str.index(str, beg = 0 end = len(string)) |
df160cf2cc81fd5c83faf73cc8e80db114af75dd | nixis-institute/practice | /python/squre.py | 154 | 3.6875 | 4 | from math import *
value = int(input("Enter a value "))
sq = sqrt(value)
print (sq)
# round is global function
#truck is library function |
0afc6c78a477809a276a8de5d4f7bf26a1e46755 | nixis-institute/practice | /python/bhawna/power.py | 163 | 3.859375 | 4 | def power (a,b):
c=1
for i in range (b):
c=c*a
return c
value=int(input("value"))
p=int(input("power"))
z=power(value,p)
print("no is",z) |
768b7b2bb0dd863b28c6ff657a3819fc4ae6162a | akuks/Python3.6---Novice-to-Ninja | /Ch9/09-FileHandling-01.py | 634 | 4.21875 | 4 | import os
# Prompt User to Enter the FileName
fileName = str(input("Please Enter the file Name: "))
fileName = fileName.strip()
while not fileName:
print("Name of the File Cannot be left blank.")
print("Please Enter the valid Name of the File.")
fileName = str(input("Please Enter the file Name: "))
f... |
848ff8ae6cb99f3f6b768df53ebd4d9fd9486cfe | akuks/Python3.6---Novice-to-Ninja | /Ch8/08-tuple-01.py | 204 | 4.125 | 4 | # Create Tuple
tup = (1, 2, 3, "Hello", "World")
print(tup)
# Looping in Tuple
for item in tup:
print (item)
# in operator
b = 4 in tup
print(b)
# Not in Operator
b = 4 not in tup
print (b)
|
28db87b07427c1847f54e6f159dfc92e4fe0a310 | Bin-ary-Li/MPCS51100AdvProg | /text_compressor/count_vocab.py | 349 | 3.75 | 4 | import sys
assert(len(sys.argv) == 2), "Please pass in the filename to count its unique words."
originalfile = sys.argv[1]
with open(originalfile, 'r') as file:
data = file.read().replace('\n', ' ')
og = data.split(" ")
og = [word.lower() for word in og if word != ""]
og_set = set(og)
print(f"{originalfile} has ... |
14d3f48bd0f5a76dcaba33cb3064fe2ef013a3e5 | pbscrimmage/thinkPy | /ch12/letter_freq.py | 877 | 4 | 4 | """
letter_freq.py
Author: Patrick Rummage
[patrickbrummage@gmail.com]
Objective:
Create a function called most_frequent that takes a string
and returns a list of characters found, sorted by frequency.
"""
import sys
def most_frequent(s):
freqs = {}
t = []
for c in s: # Build di... |
bbed894c316e17e8cdbde0ed2d0db28ddd6d2285 | pbscrimmage/thinkPy | /ch5/is_triangle.py | 1,108 | 4.46875 | 4 | '''
is_triangle.py
Author: Patrick Rummage
[patrickbrummage@gmail.com]
Objective:
1. Write a function is_triangl that takes three integers as
arguments, and prints either "yes" or "no" depending on
whether a triangle may be formed from the given lengths.
2. Write a function that promp... |
342994426eab183a25362208907f318ef11fc5f6 | pbscrimmage/thinkPy | /ch6/is_power.py | 398 | 4.03125 | 4 | '''
is_power.py
Author: Patrick Rummage
[patrickbrummage@gmail.com]
Objective:
Define a function, is_power, that takes parameters a and b
and returns True if a is a power of b. Returns False otherwise.
'''
def is_power(a, b):
if a == b:
return True
elif a < b:
return False
... |
a3338b41d3399b462b32674111f28e465782f6f2 | abbye1093/AFS505 | /AFS505_U1/assignment3/ex16.py | 1,309 | 4.4375 | 4 | #reading and writing files
#close: closes the file, similar to file > save
#read: reads contents of files
#readline: reads just one readline
#truncate: empties the file
#write('stuff') : writes 'stuff' to file
#seek(0): moves the read/write location to the beginning of the files
from sys import argv
script,... |
92557bfd2d9342e17b2155d68e4aacecb2914b43 | KatherineSanchez98/stack | /Python_Stack/stack.py | 3,148 | 4.4375 | 4 | '''
----------------------------------
#Developed by |
@user: Katherine Sánchez |
#id: 201612408 |
#e-mail: sanchezkathy29@gmail.com |
----------------------------------
This example demonstrates how to build a stack,
we only need 2 classes:
1)Node: only has a constructo... |
72d72c40a3279d64be8b7677e71761aed1b7155f | ggggg/PythonAssignment- | /exchange.py | 452 | 4.1875 | 4 | # get currency
print('enter currency, USD or CAD:')
currency = input().upper()
# get the value
print('Enter value:')
value = float(input())
# usd
if (currency == 'USD'):
# make calculation and output result
print('The value in CAD is: $' + str(value * 1.27))
# cad
elif (currency == 'CAD'):
# make calculation an... |
a9c9af8c162419f1bcb1e1aa49ce2fdf43ee5397 | hubugui/ds | /sort/insert/insert.py | 529 | 4.03125 | 4 |
#!/usr/bin/env python
import random
import sys
def insert_sort(array):
for i in range(1, len(array)):
j = i - 1
while j > -1 and array[j] > array[i]:
tmp = array[i]
array[i] = array[j]
array[j] = tmp
i = i - 1
j = j - 1
array = []
if len(sys.argv) > 1:
digits = sys.argv[1].split(",")
for digit... |
efea3fc1186254cd2a2b40171114de6af466a8cd | angelaannjaison/plab | /15.factorial using function.py | 312 | 4.21875 | 4 | def fact(n):
f=1
if n==0:print("The factorial of ",n,"is 1")
elif(n<0):print("factorial does not exit for negative numbers")
else:
for i in range(1,n+1):
f=f*i
print("The factorial of ",n,"is",f)
n=int(input("To find factorial:enter a number = "))
fact(n) |
754c02472453ab001c18bb13f5118aa0851ada80 | angelaannjaison/plab | /17.pyramid of numbers.py | 258 | 4.15625 | 4 | def pyramid(n):
for i in range(1,n+1):#num of rows
for j in range(1,i+1):#num of columns
print(i*j,end=" ")
print("\n")#line space
n=int(input("To construct number pyramid:Enter number of rows and columns: "))
pyramid(n) |
e500b5ef5f72359ba07c06ed10ec2b3e12dabfb6 | angelaannjaison/plab | /to find largest of three numbers.py | 297 | 4.1875 | 4 | print("To find the largest among three numbers")
A = int(input("Enter first number = "))
B = int(input("Enter second number = "))
C = int(input("Enter third number = "))
if A>B and A>C:
print(A," is greatest")
elif B>C:
print(B," is greatest")
else:
print(C,"is greatest")
|
8e3aeedca99b9abff8282876fbf5b655c1f10a76 | mtouhidchowdhury/CS1114-Intro-to-python | /Homework 3/hw3q4.py | 787 | 4.46875 | 4 | #homework 3 question 4
#getting the input of the sides
a = float(input("Length of first side: "))
b = float(input("Length of second side: "))
c = float(input("Length of third side: "))
if a == b and b == c and a ==c :# if all sides equal equalateral triangle
print("This is a equilateral triangle")
elif ... |
e2836dded795cfd45e297f05d467e04c35901858 | mtouhidchowdhury/CS1114-Intro-to-python | /Homework 7/hw7q3.py | 1,710 | 4.1875 | 4 |
#importing module
import random
#generating a random number and assign to a variable
randomNumber = random.randint(1,100)
#set number of guesses to 0 and how many remain to 5
numberGuesses= 0
guessRemain = 5
#first guess
userGuess = int(input("please enter a number between 1 and 100: "))
# minus from guess ... |
3f73f9b5c399f697fca37a7d62f21fcb01aef3d7 | mtouhidchowdhury/CS1114-Intro-to-python | /Homework 11/hw11.py | 6,436 | 3.578125 | 4 | '''
M. Touhid Chowdhury
CS 1114
mtc405
N14108583
Note: Used updated windows file
First function cleans the data and makes new file with just city, date, high temp, low temp, and precipitation
Second Function converts farenheit to celsius
third function converts inch to centimeter
fourth function uses the l... |
3b3f9e1540f090670d043bd72837d3f538ec7fd4 | mtouhidchowdhury/CS1114-Intro-to-python | /Homework 3/hw3q2.py | 1,406 | 4.0625 | 4 | #hw 3 question 2
#getting user input
firstItem = float(input(" Enter price of first item: "))
secondItem = float(input ("Enter price of second item: "))
total = firstItem + secondItem#total before discount
#comparing prices to give 50% discount
if firstItem > secondItem:
secondItem1 = secondItem * 0.5
... |
e3be918087f3b8dc2da3444990a4d8fd17a14790 | tianzhihen/cv-bringupy | /PIL-cases/converts.py | 349 | 3.515625 | 4 | from PIL import Image
def convert_to_gray_image(image):
return image.convert("L")
if __name__ == '__main__':
image_input_path = "/media/cv-bringupy/test.jpg"
image_output_path = "/media/cv-bringupy/test_gray.png"
img = Image.open(image_input_path)
img_gray = convert_to_gray_image(img)
img_... |
aea94ecd2fa9a95ea410453e7c5280b91651864c | mishalzaman/python-tile-engine | /lib/Map.py | 1,891 | 3.5 | 4 | import pygame
import json
import math
class Map:
def __init__(self, filename, display):
self.filename = filename # map filename
self.display = display # pygame.display
self.width = 10 # width of tile
self.height = 10 ... |
1dab6630272ecc34eaa6fd0c6b020f4d386010f8 | cjam3/AutomateTheBoringStuffPractice | /Chapter 20/textFieldToPython.py | 740 | 3.671875 | 4 | #! python3
# textFieldToPython.py - Uses pyautogui to select text in notepad and pyperclip to copy it to a string
import pyautogui, pyperclip
def main():
print(selectAllFromNotepadAndCopy())
def selectAllFromNotepadAndCopy():
# Copies all text in a notepad window to a string and adds that to a list of string... |
dc741bd8af0b3adee9ef05be7cdd494f15db9707 | cjam3/AutomateTheBoringStuffPractice | /Chapter 6/TablePrinter.py | 879 | 3.65625 | 4 | import copy
def main():
tableData = [['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']]
printTable(tableData)
def printTable(table):
colWidths = [0] * len(table)
for i in range(len(table)):
l... |
eabcae3b5fc67a8dda9e3a2dfcf931cf5067ffb4 | cjam3/AutomateTheBoringStuffPractice | /Chapter 4/CommaCode.py | 454 | 3.515625 | 4 | def commaList(spam):
commaListStr = ''
if len(spam) == 0:
return commaListStr
for index, item in enumerate(spam):
if index == len(spam) - 1:
commaListStr = commaListStr + 'and ' + str(item)
else:
commaListStr = commaListStr + str(item) + ', '
return comm... |
c49d289d5294f3eae75646124e40f9ab1b0cd734 | cjam3/AutomateTheBoringStuffPractice | /Chapter 12/ImageSiteDownloader.py | 1,192 | 3.53125 | 4 | #! python3
# ImageSiteDownloader.py - Downloads the preview images from imgur for a user given search term
import os, bs4, requests
def main():
# Get search term
searchTerm = input('Imgur Search: ')
searchTermForURL = '+'.join(searchTerm.split())
URL = 'https://imgur.com/search?q=' + searchTermForURL
... |
9b5a3195476c5d4c1689f52c7ef76a7a25e36072 | AbhishekMallick/Blackjack | /CardDeck.py | 1,435 | 4.09375 | 4 | '''CardDeck class to represent a deck and pull a card out at random'''
import random
class CardDeck:
nameMap = {
1:'Ace',
2:'Two',
3: 'Three',
4: 'Four',
5: 'Five',
6: 'Six',
7: 'Seven',
... |
64f014c7262d7ca044cff2df2292b0b02bb45bd1 | Nishant-15/Python_Projects | /Leap_finder_gui.py | 542 | 3.640625 | 4 | from tkinter import *
from tkinter.messagebox import *
root=Tk()
root.geometry("500x500")
root.title("Leap or Not By Nishant Patil.")
root.iconbitmap("calci.ico")
def Leap():
year=int(ent.get())
if year%4==0:
showinfo("Result","Leap Year.")
else:
showinfo("Result","Not a Leap Year.")
f=("Times ... |
a12107517ff64eb1332b2dcfcbe955419bc5d935 | kelvin5hart/calculator | /main.py | 1,302 | 4.15625 | 4 | import art
print(art.logo)
#Calculator Functions
#Addition
def add (n1, n2):
return n1 + n2
#Subtraction
def substract (n1, n2):
return n1 - n2
#Multiplication
def multiply (n1, n2):
return n1 * n2
#Division
def divide(n1, n2):
return n1 / n2
opperators = {
"+": add,
"-":substract,
"*": multiply,... |
07a8230657be774930ebc70f39508a9d6e38ebc9 | DaniloDalessandro/PROGRAMAS-EM-PYHTON | /PYTHON BRASIL/LISTA 02/022.py | 202 | 4 | 4 | # POR: DANILO COSTA
# UNIVERSIDADE ESTADUAL DO MARANHÃO
# GRADUANDO EM ENGENHARIA DE COMPUTAÇÃO
n = int(input('DIGITE UM NUMERO: '))
if n % 2 == 0:
print('NUMERO PAR')
else:
print('NUMERO IMPAR') |
d4d899baec5ea0a43009d5ff5fe2adb004459b5b | DaniloDalessandro/PROGRAMAS-EM-PYHTON | /PYTHON BRASIL/LISTA 03/013.py | 216 | 3.8125 | 4 | # POR: DANILO COSTA
# UNIVERSIDADE ESTADUAL DO MARANHÃO
# GRADUANDO EM ENGENHARIA DE COMPUTAÇÃO
n1 = int(input('DIGITE O PRIMEIRO NUMERO: '))
n2 = int(input('DIGITE O SEGUNDO NUMERO: '))
resul = n1 ** n2
print(resul) |
92509f5f8bc79218173660292679d32a6eebe285 | DaniloDalessandro/PROGRAMAS-EM-PYHTON | /PYTHON BRASIL/LISTA 02/013.py | 397 | 4.03125 | 4 | # POR: DANILO COSTA
# UNIVERSIDADE ESTADUAL DO MARANHÃO
# GRADUANDO EM ENGENHARIA DE COMPUTAÇÃO
n = int(input('DIGITE UM NUMERO: '))
if n == 1:
print('DOMINGO')
elif n == 2:
print('SEGUNDA')
elif n == 3:
print('TERÇA')
elif n == 4:
print('QUARTA')
elif n == 5:
print('QUINTA')
elif n == 6:
prin... |
9ec3eada671c71abb68cc88a8c9b887c28613532 | DaniloDalessandro/PROGRAMAS-EM-PYHTON | /PYTHON BRASIL/LISTA 03/010.py | 316 | 4.03125 | 4 | # POR: DANILO COSTA
# UNIVERSIDADE ESTADUAL DO MARANHÃO
# GRADUANDO EM ENGENHARIA DE COMPUTAÇÃO
n1 = int(input('DIGITE O PRIMEIRO NUMERO: '))
n2 = int(input('DIGITE O SEGUNDO NUMERO: '))
num = []
while n1 < n2 - 1:
n1 = n1 + 1
num.append(n1)
while n1 > n2 + 1:
n1 = n1 - 1
num.append(n1)
print(num) |
0bf6e894c304cc1e39907e4ed762ce597a2047a5 | DaniloDalessandro/PROGRAMAS-EM-PYHTON | /PYTHON BRASIL/LISTA 01/005.py | 179 | 3.890625 | 4 | # POR: DANILO COSTA
# UNIVERSIDADE ESTADUAL DO MARANHÃO
# GRADUANDO EM ENGENHARIA DE COMPUTAÇÃO
n = float(input('DIGITE UM NUMERO: '))
n = n * 100
print('{} CENTIMENTOS'.format(n))
|
22f5a142bc8254a59e276696c411fcf65a2358ab | DaniloDalessandro/PROGRAMAS-EM-PYHTON | /PYTHON BRASIL/LISTA 02/010.py | 314 | 4.03125 | 4 | # POR: DANILO COSTA
# UNIVERSIDADE ESTADUAL DO MARANHÃO
# GRADUANDO EM ENGENHARIA DE COMPUTAÇÃO
turno = input('QUAL TURNO VC ESTUDA: ')
if turno == 'm':
print('ESTUDA PELA MANHÃ!')
elif turno == 't':
print('ESTUDA PELA TARDE!')
elif turno == 'n':
print('ESTUDA PELA NOITE!')
else:
print('ERRO!')
|
0f4e60352e860d45e1d8c32903de20d231900fab | DaniloDalessandro/PROGRAMAS-EM-PYHTON | /PYTHON BRASIL/LISTA 01/014.py | 251 | 3.828125 | 4 | # POR: DANILO COSTA
# UNIVERSIDADE ESTADUAL DO MARANHÃO
# GRADUANDO EM ENGENHARIA DE COMPUTAÇÃO
peso = int(input('QUANTOS DE PEIXE? '))
if (peso <= 50):
print('SEM MULTA!')
elif(peso > 50):
m = (peso - 50)*4
print('MULTA DE {}'.format(m))
|
bf67d4490d69d830015b179e1063ae06d5a34cdf | tteeoo/ctlz | /ctlz/text.py | 1,754 | 3.875 | 4 | from ctlz import exceptions
def color(text, fg=None, bg=None):
"""Function to easily color printed text
fg and bg kwargs can be set to any standard 4 bit terminal color, prefix with bright (as in 'bright_red') for the bright variant"""
if fg == None and bg == None:
return text
elif fg == None:... |
b2662a69eedef7be937a9cf18e0413d6a75161b8 | kandarpck/networksecurity2018 | /pytest/pytest_simplewebclient.py | 760 | 3.515625 | 4 | import requests
import argparse
HOST_NAME = 'http://127.0.0.1'
PORT_NUMBER = "9000"
def get_file(path, port):
file = requests.get(HOST_NAME + ":" + port + "/" + path)
print(file.text)
return file
def save_file(file):
with open('web_response_1.txt', 'w') as f:
f.write(file.text)
def get_ar... |
391beb262cd335da36c273513a80b7287d11d6c1 | yuribyk/school-bodmas-rule-on-string-input | /bodmas_main_program.py | 1,023 | 3.5625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 13 23:36:24 2019
@author: yuribyk
"""
#a="+3dcb(-10+5a)"
#a="-3(-10+5a)dcb"
#a= "-(-10+5a)(-2)"
#a= "a-b(c+d)-(a-b)cd-a"
#a= "(-1)(a+b)(a-b)(a+b)(a-b)(-1)"
#a= "-(a+b)(a-b)"
a= "(a-b)(a-b)(a-b)"
def simplify_b(a):
b=""
for i in a:
... |
98d0f99178b2752857897263a71cdcc2a866fbab | patrickrop-cloud/password_locker-App | /run.py | 4,489 | 4.4375 | 4 | #!/usr/bin/env python3.8
import random
# import string
from user import User
from credentials import Logins #importing credential class.
#create a user account
def create_acc(username,password):
'''
This function creates a new user account.
'''
new_acc = User(username,password)
return new_acc
... |
c92b9bf7088702e015284eeebc4debdb14b22e00 | CrawfishPress/psp_scan | /src/masks.py | 3,966 | 3.625 | 4 | """
Mask computations
"""
from utils import Rect
def find_intersection_rect(rect_one, rect_two):
""" Given two rectangles, find the common section. """
new_tl_x = max(rect_one.tl_x, rect_two.tl_x)
new_tl_y = max(rect_one.tl_y, rect_two.tl_y)
new_br_x = min(rect_one.br_x, rect_two.br_x)
new_br_y ... |
eb6b5ad51d840a9252bcd194b1789ae9e30a8718 | Mutan0105/func2 | /classtest.py | 233 | 3.546875 | 4 | #!/usr/bin/env python
# encoding: utf-8
class RoundFloatManual(object):
def __init__(self,val):
self.value = round (val, 2)
def __str__(self):
return '%.2f' % self.value
a = RoundFloatManual(6.33333)
print a |
18fec51287c02111d516da9512927551d91617d4 | Mutan0105/func2 | /easymath_with_mul&div.py | 1,293 | 3.75 | 4 | #!/usr/bin/env python
# encoding: utf-8
from operator import add, sub, mul, truediv
from random import randint, choice
ops = {'+':add, '-':sub, '*':mul, '/':truediv}
maxtries = 2
def doprob():
op = choice('+-*/')
nums = [randint(1,10) for i in range(2)]
nums.sort(reverse=True)
if op == '/':
num... |
28d76b2fe13a96e9e766eb186e723752f548bd23 | derekmerck/DIANA | /examples/nltk_corpus_analysis.py | 973 | 3.59375 | 4 | """
Example of reading a report corpus and generating a concordance and bi-grams
Create a NLTK plaintext corpus using `examples/nltk_create_report_corpus.py`
"""
from pprint import pprint
import nltk
from nltk.corpus import CategorizedPlaintextCorpusReader, stopwords
import logging
CORPUS_ROOT = "/Users/derek/Data/R... |
1028fee3051ff59278ee4feaff67a4738d038f24 | SimonLee118/Project1 | /main.py | 3,368 | 3.796875 | 4 | """
Searches deep inside a directory structure, looking for duplicate file.
Duplicates aka copies have the same content, but not necessarily the same name.
"""
__author__ = "Simon Lee"
__email__ = "lees118@my.erau.edu"
__version__ = "1.0"
# noinspection PyUnresolvedReferences
from os.path import getsize, join
... |
7288275733374cd9db40c94ea20cfa716d82041a | barisser/nodeciv | /city.py | 1,785 | 3.5625 | 4 | import economics
import resources
import settings
class City:
def __init__(self, name, x, y, population):
self.x = x
self.name = name
self.y = y
self.population = population
self.commodity_stocks = [0] * len(resources.resources)
self.prices = [0] * len(resources.reso... |
634661c3605e7051bfb2f4781f8cdefe111b2aa9 | Ozarrian2026/all-programs- | /Hangman.py | 2,657 | 3.921875 | 4 | import time
import os
ASCII = ['''
+----+
| |
|
|
|
=========''','''
+----+
| |
O |
|
|
=========''','''
+----+
| |
O |
| |
|
=========''','''
+----+
| |
\O |
| ... |
3b50527fa48b73d04d1660ab232e7034064bf382 | Ozarrian2026/all-programs- | /practice1.py | 505 | 3.84375 | 4 | # Ozarrian John, 9/23/2019, B-1, practice1.py
print("Solving equations...")
print("4 * 8 = " + str(4 * 8))
print("12 / 2 = " + str(12 / 2))
print("-5 - 6 * 3 = " + str(-5 - 6 * 3))
age = input("What is your age?")
age = int(age) + 10
print("in ten years you will be... " + str(age))
print("Go Vipers!\n" * 20... |
b5a104236a250896e8518a61d9e8b31dfa96eec0 | nathangiusti/PythonCodingQuestions | /MeetingRoomsNeeded.py | 1,198 | 3.765625 | 4 |
# Given a collection of meetings (each has a start time and an end time, positive integer type, start time is inclusive and end time is exclusive, input is always valid).
# Return how many meeting rooms are needed at least to hold all the meetings.
# [(1,3), (6,8), (4,5)] -> 1
# ##*******
# *****##**
# ***#*****
#
# [... |
2bcfdf2d2db4d32103e6f4f5bb9c809f7408d191 | uorocketry/Cistern | /code/Format.py | 1,673 | 3.515625 | 4 | #Force gauges calibration
def force1(num):
return num * 1 + 0
def force2(num):
return num * 1 + 0
#Pressure gauges calibration
def press1(num):
return num * 1 + 0
def press2(num):
return num * 1 + 0
def format(data):
out = [0,0,0,0]
#we only want to modify the first four elements... |
cb1f1dffb1915de4f2ff1557861afe9072e5747c | MANISH007700/Competitive-Programming | /Problem1.py | 1,803 | 3.53125 | 4 | # Python3 implementation of the approach
DIGITS = 4; MIN = 1000; MAX = 9999;
# Function to return the minimum element
# from the range [prev, MAX] such that
# it differs in at most 1 digit with cur
def getBest(prev, cur) :
# To start with the value
# we have achieved in the last step
maximum = ma... |
3539e858188a499d9ecda0c90a093a2458dc349a | xiaodongxiexie/python-widget | /PythonWidget/utils/simple_init.py | 2,752 | 3.671875 | 4 | import math
class Structure1:
# Class variable that specifies expected fields
_fields = []
def __init__(self, *args):
if len(args) != len(self._fields):
raise TypeError('Expected {} arguments'.format(len(self._fields)))
# Set the arguments
for name, value in zip(self._... |
b4d364f33b6724a344007fdedd7f2da568f7d177 | xiaodongxiexie/python-widget | /PythonWidget/utils/delay_calc.py | 984 | 3.859375 | 4 | class lazyproperty:
def __init__(self, func):
self.func = func
def __get__(self, instance, cls):
if instance is None:
return self
else:
value = self.func(instance)
setattr(instance, self.func.__name__, value)
return value
import math
cla... |
73295e8eee60e3affa4390a9743935cb4d6ea8d1 | yarden/paper_metachange | /paper_metachange/time_unit.py | 2,872 | 3.96875 | 4 | ##
## Representation of time
##
import numpy as np
import utils
class Time:
"""
Representation of time interval.
Terminology:
- 'bins' represent bins of time interval.
- 'step size' means the duration that is relevant
for an event to occur in.
"""
def __init__(self, t_start, t_end, ... |
24779aad8a2a15b6b0975734ceb03cbdb7d6433e | vivanov1410/pickled-brain | /002/vivanov/tests.py | 5,372 | 4.0625 | 4 | import unittest
from pickle002 import Calculator
class AddTest(unittest.TestCase):
"""Test for add() function"""
def setUp(self):
self.calc = Calculator()
def test_add_positive_numbers(self):
self.assertEquals(self.calc.add(1, 2), 3)
def test_add_positive_numbers2(self):
se... |
1fe99e942fe4f146f1cf006b9098ec0a0ca7431c | vivanov1410/pickled-brain | /002/vivanov/pickle002.py | 1,034 | 3.78125 | 4 | class Calculator:
def __init__(self):
self.number_of_operations = 0
@staticmethod
def _is_number(number):
return type(number) == int
def add(self, number1, number2):
self.number_of_operations += 1
if not self._is_number(number1) or not self._is_number(number2):
... |
939ea148a19002e33c1c2cb23fd2a984a8093c48 | TroyArrandale/python-review-questions | /week8_4_panadas.py | 461 | 3.625 | 4 | import pandas as pd
import unittest
nested_dict = {'white_wine': {1998:1, 1999:1, 2000:2},
'red_wine': {1998:3, 1999:2, 2000:0}}
df = pd.DataFrame(nested_dict)
class TestForBasicMath(unittest.TestCase):
def test_df_white_wine_1998(self):
pass
#TODO: Test the value of white wine is expect in the ... |
caad0af5c1760f227bea65dfc82fd9e863b282af | mramdanf/hackerrank_regex | /alien_username.py | 261 | 3.703125 | 4 | import re
N = int(input())
pattern = '^[_\.]\d+[a-zA-Z]*[_]?'
for n in range(0, N):
text = input()
m = re.search(pattern, text)
if m != None:
if m.end() == len(text):
print('VALID')
else:
print('INVALID')
else:
print('INVALID')
|
694bceb3cea897a3517e1d4420bf299314d4b3d8 | cha63506/767_information_retrieval_project | /llist.py | 1,128 | 3.578125 | 4 | class posting:
def __init__(self):
self.file_name = None # String value
self.word_num = None # List of ints
self.term_f = None # Int value
self.next = None # contains the reference to the next posting
class posting_list:
def __init__(self):
self.head = None
self.tail = None
self.length = 0
def add(s... |
5baf869bdf4538c8c57c396b693337c0b4e01184 | IllyaKol/CheckIO-Solutions | /home/most-wanted-letter.py | 1,208 | 3.671875 | 4 | import re
def checkio(text):
text = text.replace(' ', '').lower()
text = re.sub(r'!|,|\.|-|\d', '', text)
new_text = set(text)
if len(new_text) != len(text):
count = 0
letter = []
for i in text:
if text.count(i) > count:
letter = []
c... |
686069473b4abdc74b821ab90092743069c4fd9b | Alexander-Espinoza/Vehiculo-para-Herencia | /vehiculo.py | 1,787 | 3.90625 | 4 | class Vehiculo():
def __init__(self, marca, modelo):
self.marca=marca
self.modelo=modelo
self.enMarcha=False
self.acelera=False
self.frena=False
def arrancar(self):
self.enMarcha=True
def acelerar(self):
self.acelera=True
def frenar... |
278ba3bef7de00916a1959ad1c29fda56b7590c4 | Abob888/Rep2 | /str82-2.py | 698 | 3.84375 | 4 | a = ['Red', 'fox', 'jumped', 'up', 'the', 'low', 'wall', '.']
a = ' '.join(a) # объединение списка в строку
a = a[0:-2] + '.' # срезаем два последних символа и заменяем их точкой
print(a)
print('Children are the mirrow of parents activity'.replace('r', '$'))
''' Замена в строке
буквы r на $.
'''
print('Хемингуэй'... |
2c194681f72aa01abea343537dda801a6a656bf0 | Abob888/Rep2 | /files09022020-4.py | 127 | 3.53125 | 4 | import csv
with open('st.csv', 'r') as f:
q = csv.reader(f, delimiter=',')
for row in q:
print(','.join(row))
|
10f68ad8ed5fee0683e4eeb171068aa850e910ba | Abob888/Rep2 | /test-p121.py | 174 | 3.75 | 4 | class Square():
def __init__(self, s1):
self.side = s1
def change_size(self):
return self.side + 5
squ = Square(3)
print(squ.change_size())
|
7634afd515684f382a9e9e0afdb4c8d1b719fcbb | saveroz/DTL-AI | /Quiz & Jawaban/Muhammad_Savero_soal1.py | 1,147 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Oct 19 20:57:48 2018
@author: OREVAS
"""
def soal_1():
jumlah_orang=input(" ") #jumlah orang beserta uangnya
lists_orang=[]
lists_duit=[]
for i in range(int(jumlah_orang)):
uang=input(" ")
lists=uang.split(" ")
lists_oran... |
3723764b03c94e60a1432371af503f832e2dd1d4 | zahera-fatima/day2 | /line.py | 443 | 4 | 4 | def word_score(word):
total = 0
for i in word:
i = i.lower()
total += score[i]
return total
score = {"a":1,"b":2,"c":3,"d":4,
"e":5,"f":6,"g":7,"h":8,
"i":9,"j":10,"k":11,"l":12,
"m":13,"n":14,"o":15,"p":16,
"q":17,"r":18,"s":19,"t":20,
... |
ce1dfc1cb226112f3990719587afc4e452cbb81b | fpaezespe37/POO2963 | /WorkShop/Unit 1/WorkShop04_Python/Edades.py | 172 | 3.9375 | 4 | names = ['Stiven', 'Dennis', 'Adrian', 'Jerico','Javier']
ages= [18, 60, 23, 22, 26]
names_with_ages = zip(names,ages)
for student in names_with_ages:
print(student) |
1b75304c772f1d93a1bc86d57cbc021e9a425698 | fpaezespe37/POO2963 | /WorkShop/Unit 1/WorkShop05_FunctoinsPy/Funciones.py | 981 | 3.84375 | 4 | class Student:
university = 'ESPE'
def __init__(self,_id,_name,_age,_career,_cell_number):
self.id = _id
self.name = _name
self.age = _age
self.career = _career
self.cell_number = _cell_number
class Phone:
def __init__(self, _number):
... |
959c3e5e84a57ca4743383af77219e211673ba85 | Rayyan98/DS2-Project | /Collision_detection.py | 407 | 3.75 | 4 | # Collision Detection class
class Collision_Detection:
def takra(self, rect1, rect2):
if rect1.x > rect2.x:
rect1,rect2 = rect2,rect1
if rect1.x + rect1.w > rect2.x:
if rect1.y + rect1.h < rect2.y:
return False
elif rect1.y > rect2.y + re... |
17b11e255a7942dd3d1c383809d421dcf1627761 | Rayyan98/DS2-Project | /QuadTree.py | 5,501 | 3.515625 | 4 | from Collision_detection import Collision_Detection
from MyScreen import MyScreen
from MyRectangle import MyRectangle
from MyRectangle import MyRectangle
import math
class Node(Collision_Detection):
def __init__(self, rect):
self.rect = rect
self.rects = set()
self.tl = None
self.tr = None
self... |
8e1ec16ede56905db61ac18b0002ea4e8e10997b | HoanVanHuynh/InterTools | /accumulate.py | 720 | 4 | 4 | import operator
def accumulate(iterable, func = operator.add, *, initial=None):
it = iter(iterable)
total = initial
if initial is None:
try:
total = next(it)
except StopIteration:
return
yield total
for element in it:
total = func(total, element)
... |
7dc2187249f3a8e117cd2c70febc8189dcddc7c4 | benoucakar/programiranje-1 | /razredi.py | 1,203 | 3.53125 | 4 | class Pes():
# Argumenti
def __init__ (self, ime, starost):
self.ime = ime
self.starost = starost
self.sreca = 5
self.lakota = 5
# Metode
def podatki(self):
print("Ime: " + self.ime)
print("Starost: " + str(self.starost) + " let")
print("Sreča: ... |
36f1263ebdbaf546d5e6b6ad874a0f8fc51ef65a | andredupontg/PythonInFourHours | /pythonInFourHours.py | 1,628 | 4.1875 | 4 | # Inputs and Outputs
"""
name = input("Hello whats your name? ")
print("Good morning " + name)
age = input("and how old are you? ")
print("thats cool")
"""
# Arrays
"""
list = ["Volvo", "Chevrolet", "Audi"]
print(list[2])
"""
# Array Functions
"""
list = ["Volvo", "Chevrolet", "Audi"]
list.insert(1, "Corona")
list.remo... |
c6a7fad8362397aada270409b30e9f97dd2cff4e | Zapix/mtpylon | /mtpylon/crypto/random_prime.py | 2,321 | 3.984375 | 4 | # -*- coding: utf-8 -*-
import random
first_primes_list = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59, 61, 67,
71, 73, 79, 83, 89, 97, 101, 103,
107, 109, 113, 127, 131, 137, 139,
149, 151, 157, 163, 167, 173, 179,... |
ddb5306a9f99f64c033cee565dfc3f939a05530a | tqt129/pythonexercise | /pythonexercise/inputexercise.py | 371 | 4.03125 | 4 | user_input = input('What would you like the cat to say')
text_length = len(user_input)
# print underline based on length of user input
print(' {}'.format('_' * text_length))
print(' < {} >'.format(user_input))
print(' {}'.format('-' * text_length))
print(' /')
print(' ... |
c4f411dc62e5749f1e813da02ff1a89f881b14d0 | jgarrone82/Datacademy | /Python/reto4.py | 1,098 | 4 | 4 | import math
def convertidor():
i=0
while i==0:
opcion=int(input("Por favor,ingre el numero de la opcion que quiera :"))
if opcion == 1:
altura=float(input("Ingrese la altura del cilindro:"))
radio=float(input("Ingrese el radio del cilindro:"))
volumen=m... |
bb2a319abc3ac552e0bc062b234d1b47b259c3dc | choidslab/teamlab-python-basic | /chapter15/ex_json1.py | 487 | 3.953125 | 4 | """
json 파일은 읽은 후, dict type으로 처리하면 됨!
"""
import json
with open('json_example.json', 'r', encoding='utf-8') as f:
contents = f.read()
json_data = json.loads(contents)
print(json_data)
print(json_data['employees'])
print(json_data['employees'][0])
print(json_data['employees'][1])
print(jso... |
8b2ca4958725ab3c88bdd7f1cd17cb5244303a7c | heiretodemon/python_interview_question | /python_code/39.py | 354 | 4 | 4 | '''
def multi():
return [lambda x: i*x for i in range(4)]
print([m(3) for m in multi()])
'''
# 关于闭包的理解:https://zhuanlan.zhihu.com/p/22229197
# 但仍存在疑问
from six.moves import xrange
flist = []
for i in xrange(3):
def func(x):
return i*x;
flist.append(func)
print(flist)
for f in flist:
print... |
2c82ae9fe4a4d93aba3cde1e778b9d4afdad117a | heiretodemon/python_interview_question | /python_code/32.py | 181 | 3.890625 | 4 | def even_list(nums):
return [i for i in nums if i%2 == 0 and
nums.index(i)%2 == 0]
if __name__ == "__main__":
nums = [0,1,2,3,4,5,6,7,8,9,10]
print(even_list(nums)) |
bc52d9a2dad43d3f38c9a92e199d66d69537279c | heiretodemon/python_interview_question | /python_code/6.py | 279 | 4 | 4 | # 字典推导式
A = {'a':1, 'b':2, 'c':3}
d = {key:value for (key, value) in A.items()}
print(d)
# 列表推导式
ls = [i**2 for i in range(10) if i % 3 == 0]
print(ls)
# 集合推导式(输出结果集合中不会出现重复的)
sq = {i*3 for i in [1,2,2,3,4,5]}
print(sq) |
43e5b0370029071ff5170f48a25a18d1c1899c89 | heiretodemon/python_interview_question | /python_code/44.py | 522 | 3.515625 | 4 | class Test:
__list = []
def __init__(self):
print("construction")
def __del__(self):
print("destruct")
def __str__(self):
return "a string version of Test"
def __getitem__(self, key):
return self.__list[key]
def len(self):
return len(self.__list)
... |
dc9f803ea9c259d7e2da8443a7c3dc09e4fe081f | codebyzeb/Part-II-Project | /analysis/plotting.py | 13,661 | 3.546875 | 4 | """
Analysis module used for plotting graphs of the simulation
"""
import argparse
import matplotlib.pyplot as plt
from matplotlib import style
from scipy.stats import pearsonr
import sys
import pickle
import numpy as np
class Plotter:
""" Represents a simulation environment for a population of entities.
At... |
180d0d036d95e7129f6db72bf8116eb6079cd6f5 | AIHackerTest/Gouwal_Py101-004 | /Chap0/project/ex09.py | 681 | 4 | 4 | # Advanced Task
from random import randint
data = randint(0,21)
guess = int(input("> "))
if guess > data:
print ("What you guess is bigger")
elif guess < data:
print ("What you guess is smaller")
else:
print ("Excellent, you are right")
i = 0
while guess != data and i < 9:
times = 9 - i
print (... |
fa292c7008d58f6b294cce00b87a642cd18a8e87 | AIHackerTest/Gouwal_Py101-004 | /Chap0/project/ex05.py | 586 | 3.828125 | 4 | # Tase5 Previous 19
def cheese_and_cracker(cheese_count, boxes_of_crackers):
print("You have %d chesses!" % cheese_count) #when I use %d, it always have a warning"TypeError: %d format: a number is required, not str"
print("You have %d boxes of crackers!" % boxes_of_crackers)
print("Man that's enough for a p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.