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 |
|---|---|---|---|---|---|---|
e3020e5fdbd0b00b7c58e5898c42e0363823b025 | reneses/cloud-cli | /logic/sns.py | 3,280 | 3.53125 | 4 | from connections import Connection
class Sns:
"""
Amazon Simple Notification Service
This service provided by Amazon can be used as a message queue and notification service
For our purposes, it will be used to send emails regarding CloudWatch alerts
"""
# Topic name for cloudwatch alerts
... |
ce3399dcdfc212a588de430f21cb81735264b258 | Mario-D93/habit_tracker | /t_backend.py | 1,885 | 4.21875 | 4 | import sqlite3
class Database():
'''
The Database object contains functions to handle operations such as adding,
viewing, searching, updating, & deleting values from the sqlite3 database
The object takes one argument: name of sqlite3 database
Class is imported to the frontend script (t_fronted.py)
'''
def _... |
758ab6383babf6b278796074b9fccc28177e4409 | SKeerthi02/PythonBasics | /encapsulation.py | 3,751 | 4.28125 | 4 | """
Encapsulation in python works differently compared to Java (I guess!)
In python we use "_" and "__" for protected and private variables
Definition: Encapsulation is an ability to hide part of variables and its behaviors from outside the class
Important Links:
1. https://medium.com/@manjuladube/encapsulation-abstr... |
9a43b1d555c06fb38837847e9bfe75a575adfb91 | cajogos/easy-steps | /python/chapter-009/tk_message.py | 406 | 3.71875 | 4 | from tkinter import *
import tkinter.messagebox as box
window = Tk()
window.title('Message Box Example')
def dialog():
var = box.askyesno('Message Box', 'Proceed?')
if var == 1:
box.showinfo('Yes Box', 'Proceeding...')
else:
box.showwarning('No Box', 'Cancelling...')
btn = Button(window,... |
552131769f3dadf50dd9e8a7370162dce594dbff | cajogos/easy-steps | /python/chapter-006/format.py | 225 | 3.578125 | 4 | snack = '{} and {}'.format('Burger', 'Fries')
print('\nReplaced:', snack)
snack = '{1} and {0}'.format('Burger', 'Fries')
print('Replaced:', snack)
snack = '%s and %s' % ('Milk', 'Chocolate')
print('\nSubstituted:', snack)
|
7381f02a0f630794196a377300819f91ab4d662e | xiami1107/python_level_2 | /2-7.py | 105 | 3.75 | 4 | s = input("请输入一段文字:")
i = len(s) -1
while i >= 0:
print(s[i],end="")
i=i-1
|
67e71162d06455912856ac12bdba1123ac026372 | tkmroz/PythonProjects | /league.py | 409 | 3.765625 | 4 | import random
abc = ["Ogre","jedi","Lizard terrorist","b1 battle droid","Dragon",
"Elvent Huntress","CHuck Norris","TREX","SPino","tables","chicken","santa claus"]
print("Your character is: "+ abc[random.randint(0,len(abc)-1)])
print("Your number is: "+ str(random.randint(0,10000)))
print("Your character is: "+ ab... |
9be134115bdf0f6744701a422fb264437aca69d3 | clucle/code_test | /prob4.py | 1,567 | 3.609375 | 4 | dict_hangul = {}
cnt_dict_init_call = {}
g_init_word = ""
def find_word(_word):
init_word = _word[-1:]
if init_word not in dict_hangul.keys():
print("not in my dictionary")
return -1
if len(dict_hangul[init_word]) == cnt_dict_init_call[init_word]:
print("not enough word")
... |
e7a3bd23b339f3864496cda140c0048517307897 | yaritzaelena/EXAMENES-Y-TRABAJO-EN-CLASE | /Recursion.py | 3,008 | 3.828125 | 4 | #Recursion de pila
def simple_pila (num, n):
if isinstance (num, int) and isinstance (n, int):
return simple_pila_aux(num, n-1)
def simple_pila_aux(num, n):
if n == 0:
return 0
else: return (num * n) + simple_pila_aux(num, n-1)
#Recursion de cola
def simple_cola(num, n):
if... |
b8efdace3226a2585ddbb803f039efdc584f0bcb | yaritzaelena/EXAMENES-Y-TRABAJO-EN-CLASE | /Gato.py | 1,537 | 3.765625 | 4 | class Pila:
def __init__(self):
self. __pi = []
def len (self):
return len(self.__pi)
def is_empty(self):
return len(self.__pi) == 0
def push (self, e) :
return self.__pi.append(e)
def pop(self):
if self.is_empty():
raise MiGatito('Stack... |
cd727c4c48ac43ef6ee1f494f2072a98566ad60b | HongSic/AI | /numpy_2(type).py | 2,308 | 3.734375 | 4 | import numpy as np
'''
x = np.array([[1, 2, 3], [4, 5, 6]], np.int32) # type : np.int32, np.float64
print(x)
x = x.astype(np.float64) #astype : type 바꾸기
print(x)
'''
# 연산
arr1 = np.array([[1, 2], [3, 4]])
arr2 = np.array([[2, 3], [4, 5]])
#print (arr1)
#print (arr2)
# arr3 = arr1 + arr2 #두 배열의 차수가 맞아야 함
#arr2 = np.... |
30ada70850dac58a81cea738d41f14c492d8ddd5 | ronnie173/kevin-linux | /WafTest/python/study.py | 493 | 3.75 | 4 | #!/usr/bin/python
def bar(x):
try:
return 1.0 / x
except ZeroDivisionError, message:
print "Can't divide by zero:", message
def test(a, b):
"this is a test function"
while a != 0:
a, b = b % a, a
return b
def main():
if 0 :
print "in if statement\n"
... |
26ef394e2feb4e9773ee53965541809102b827bf | Magnum-07/Python-projects | /Day 25/main.py | 1,147 | 3.734375 | 4 | import pandas as pd
import turtle
screen = turtle.Screen()
screen.title("U.S. States Game")
image = "blank_states_img.gif"
screen.addshape(image)
turtle.shape(image)
# reading csv data
data = pd.read_csv('50_states.csv')
states = data["state"].to_list()
guessed_states = []
while len(guessed_states) < 50:
answer_s... |
675b2c8ef85b49febea7547ae269384f985474a3 | kowalczykadam/WD-AdamKowalczyk-155586- | /wd_cw03/Zad.4.py | 275 | 3.859375 | 4 |
def monotonicznosc(a, b):
if(a>0):
return "Funkcja jest rosnaca"
elif(a<0):
return "Funkcja jest malejaca"
else:
return "Funkcja jest stala"
print(monotonicznosc(1,2))
print(monotonicznosc(-1,2))
print(monotonicznosc(0,3))
|
230f1551d1793e1138c8e9624453808e416715a4 | fabiusdefly/mapreduce | /avg.py | 436 | 3.546875 | 4 | #!/usr/bin/env python3
import sys, re
regex = re.compile('[^a-zA-Z]')
listparisnum = []
for line in sys.stdin:
line = line.strip()
words = line.split(':')
if len(words) == 3:
listparisnum.append(words[1])
print('%s:%s:%s' % (words[0], words[1], words[-1]))
elif len(words) == 2:
... |
9663959eab7d43ea7f4056b9250f11c5a45f079e | ssamanjot/ProblemsUsingPython | /FactorialDigitSum.py | 112 | 3.5625 | 4 | def Factorial(n):
for i in range(1,n+1):
Factorial = Factorial*1
print(Factorial)
Factorial(4)
|
b0c6a2dabb9bb1b3309d223c0839ab1c171c14b7 | Y-EK/Machine_Learning_KNN_Python | /KNN_script.py | 2,093 | 3.65625 | 4 | # libraries
from sklearn.datasets import fetch_mldata
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn import neighbors
# load data
#mnist = fetch_mldata('MNIST original', data_home='E:/y_elk/Documents/PROJETS_GIT/ML_python/mnist')
mnist = fetch_mlda... |
226f14c3bc4181acbe482effb4cf8f538c593a7d | dfkigs/helloworld | /python/projects/regex/review_module_contents.py | 1,662 | 3.734375 | 4 | #!/usr/bin/python
import re
# 1) flags
# re.compile(pattern, flags=0)
# Compile a regular expression pattern into a regular expression object
# flags A) re.DEBUG
# re.DEBUG , display debug information about compiled expression
pattern = re.compile(r'\w+', flags=re.DEBUG)
m = pattern.search('this is a foo')
if... |
64bc6099d5a9beb05a63204ac8c9f2ab63a07f14 | dfkigs/helloworld | /python/basic/abstract/property.py | 824 | 3.640625 | 4 | #!/usr/bin/python
__metaclass__ = type
class Rectangel:
def __init__(self):
self.width = 0
self.height = 0
def setSize(self,size):
self.width,self.height = size
def getSize(self):
return self.width,self.height
# property (fget,fset,fdel,doc)
size = property(getSize,setSize)
r = Rectangel()
r.size = (1... |
2d3c635595510e9fa20c5babd9733b64b7b3908d | dfkigs/helloworld | /python/basic/abstract/object/class.py | 1,274 | 3.625 | 4 | #!/usr/bin/python
__metaclass__ = type
#
# basic
class Person:
def setName(self,name):
self.name = name
def getName(self):
return self.name
def greet(self):
print "Hello, I'm",self.name
# private
def __inaccessable(self):
print "cannot see outside"
# protected
def _inaccessable2(self):
print "cannot... |
c93ea29aafd03ee6e05efb2a460b9f93fa017107 | dfkigs/helloworld | /python/basic/generator/generator.py | 1,114 | 4.1875 | 4 | #!/usr/bin/python
# keyword : yield
def flatten(nested):
for sublist in nested:
for element in sublist:
yield element
def flatten_recursion(nested):
try:
try:
nested + ''
except TypeError:
pass
else:
raise TypeError
for sublist in nested:
for element in flatten_recursion(sublist):
yie... |
bc6c67bed27c847874b2023c00781d9edc83e6d5 | ChinaisGARBAGE/codingapes_first | /seventh.py | 240 | 3.609375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Aug 13 16:20:53 2020
@author: USER
"""
A=10
B=24
C=31
D=45
if A>B:
T=A
A=B
B=T
if B>C:
T=B
B=C
C=T
if A>B :
T = A
A = B
B = T
print(A,B,C) |
3c087f58868069416ece8584c8eb9dd340a7d64d | abatista6/pythonProjects | /Batista_airlines.py | 3,712 | 4.125 | 4 | # Adrianna Batista
# 10/5/18
# Write a program for airlines to allow the customer to purchase flights and perform calculations
ansCheck=False
ansFlag=False
ansOkay=False
ansTrue=False
dayTime=False
weekDay=False
cost=float(0)
#Display program welcome
print("\n********************************************************"... |
cb445c427630c0f1b33861cd6d38f9cd43eb6f52 | mrubio-chavarria/MNIST_exercise | /main_tf_scratch.py | 3,493 | 3.671875 | 4 |
"""
DESRIPTION:
In this script I code from scratch the solution proposed
in main_tf.py.
"""
# Libraries
from keras.datasets import mnist
import numpy as np
import random
# Classes
class Network:
# Methods
def __init__(self, sizes):
"""
DESCRIPTION:
Network constructor.
:para... |
ab0ec3dfd953988e5a90bbf12100a0660500dd6a | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/Textbook_01A.py | 851 | 3.578125 | 4 | #!/usr/bin/env python
'''
A solution to a code challenges that accompanies Bioinformatics Algorithms: An Active-Learning Approach by Phillip Compeau & Pavel Pevzner.
The textbook is hosted on Stepic and the problem is listed on ROSALIND under the Textbook track.
Problem Title: Creating a Distance Matrix
Chapter #: 01
... |
47310b060c9d8aca0bf106ca0027f21b57ae3a36 | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/Textbook_03B.py | 1,655 | 4.09375 | 4 | #!/usr/bin/env python
'''
A solution to a code challenges that accompanies Bioinformatics Algorithms: An Active-Learning Approach by Phillip Compeau & Pavel Pevzner.
The textbook is hosted on Stepic and the problem is listed on ROSALIND under the Textbook Track.
Problem Title: Median String Problem
Chapter #: 03
Probl... |
89fafeb66a04184fb1f8fe490ecde074c68ae4bc | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/Algorithmic_009_BFS.py | 1,705 | 4.21875 | 4 | #!/usr/bin/env python
'''
A solution to a ROSALIND problem from the Algorithmic Heights problem area.
Algorithmic Heights focuses on teaching algorithms and data structures commonly used in computer science.
Problem Title: Breadth-First Search
Rosalind ID: BFS
Algorithmic Heights #: 012
URL: http://rosalind.info/probl... |
0bac5e697bb0ece5dc6badd1d479eb021bd50ff9 | 0n1udra/Learning | /Python/Python_Problems/Interview_Problems-master/python/sum_target_bool.py | 1,251 | 3.890625 | 4 | '''
Sum Target / Combination Validation
n is an int
Returns True if some integer combination of 6, 9 and 20 equals n
Otherwise returns False.
'''
from __future__ import division # brings in math from python 3.0
import time
# O(n^3)
def target_combo(n):
a = b = c = 0
while (6 * a) <= n:
while (9 * b)... |
a578d5f29a743bf166c9c27ebda0b3643064c294 | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/Textbook_01E.py | 977 | 3.859375 | 4 | #!/usr/bin/env python
'''
A solution to a code challenges that accompanies Bioinformatics Algorithms: An Active-Learning Approach by Phillip Compeau & Pavel Pevzner.
The textbook is hosted on Stepic and the problem is listed on ROSALIND under the Textbook track.
Problem Title: Minimum Skew Problem
Chapter #: 01
Proble... |
2f2313908ec8e469fa386c379530a1b86151ed1c | 0n1udra/Learning | /Python/Python_Problems/Interview_Problems-master/python/hangman/hangman_helper.py | 3,222 | 4.09375 | 4 | import string
def isWordGuessed(secretWord, lettersGuessed):
'''
secretWord: string, the word the user is guessing
lettersGuessed: list, what letters have been guessed so far
returns: boolean, True if all the letters of secretWord are in lettersGuessed;
False otherwise
'''
for letter in s... |
e65422c03de84991c78f5fff563540931897662f | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/025_LONG.py | 2,194 | 3.609375 | 4 | #!/usr/bin/env python
'''
A solution to a ROSALIND bioinformatics problem.
Problem Title: Genome Assembly as Shortest Superstring
Rosalind ID: LONG
Rosalind #: 025
URL: http://rosalind.info/problems/long/
'''
from scripts import ReadFASTA
def MergeMaxOverlap(str_list):
'''Given a list of strings, returns the list o... |
3ffdec5f6dbe48204b35332ab9deedfc4da3b8cd | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/087_ROOT.py | 1,007 | 4.03125 | 4 | #!/usr/bin/env python
'''
A solution to a ROSALIND bioinformatics problem.
Problem Title: Counting Rooted Binary Trees
Rosalind ID: ROOT
Rosalind #: 087
URL: http://rosalind.info/problems/root/
'''
CUNR = __import__('068_CUNR')
def count_rooted_binary_trees(n):
'''Returns the number of unrooted binary trees wit... |
9250748f48c8297d9384d9f1c65912fc794dfde9 | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/Textbook_06C.py | 2,389 | 3.53125 | 4 | #!/usr/bin/env python
'''
A solution to a code challenges that accompanies Bioinformatics Algorithms: An Active-nearning Approach by Phillip Compeau & Pavel Pevzner.
The textbook is hosted on Stepic and the problem is listed on ROSALIND under the Textbook Track.
Problem Title: 2-Break Distance Problem
Rosalind ID: 6C
... |
7bc496f3183da034730fad98d0b6bc26b27573c2 | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/001_DNA.py | 934 | 4.1875 | 4 | #!/usr/bin/env python
'''
A solution to a ROSALIND bioinformatics problem.
Problem Title: Counting DNA Nucleotides
Rosalind ID: DNA
Rosalind #: 001
URL: http://rosalind.info/problems/dna/
'''
from collections import Counter
def base_count_dna(dna):
'''Returns the count of each base appearing in the given DNA se... |
639e11d9a3950785404c0688d0969d73f8a42cf2 | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/Textbook_03E.py | 2,287 | 3.828125 | 4 | #!/usr/bin/env python
'''
A solution to a code challenges that accompanies Bioinformatics Algorithms: An Active-Learning Approach by Phillip Compeau & Pavel Pevzner.
The textbook is hosted on Stepic and the problem is listed on ROSALIND under the Textbook Track.
Problem Title: Greedy Motif Search with Pseudocounts
Cha... |
c24d5e463f78d6c61b2142825e432855993a945f | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/088_SEXL.py | 912 | 3.6875 | 4 | #!/usr/bin/env python
'''
A solution to a ROSALIND bioinformatics problem.
Problem Title: Sex-Linked Inheritance
Rosalind ID: SEXL
Rosalind #: 088
URL: http://rosalind.info/problems/sexl/
'''
# This solution is more mathematics than programming.
#
# Recall from Rosalind Problem 065: Counting Disease Carriers that if... |
4c9250f42012e2459d873be00ef7d961e2bc082a | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/Textbook_07A.py | 1,383 | 3.875 | 4 | #!/usr/bin/env python
'''
A solution to a code challenges that accompanies Bioinformatics Algorithms: An Active-Learning Approach by Phillip Compeau & Pavel Pevzner.
The textbook is hosted on Stepic and the problem is listed on ROSALIND under the Textbook Track.
Problem Title: Trie Construction Problem
Rosalind ID: 7A... |
afd0b28bb71635809c8e12ad6b10eeba52016e03 | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/Algorithmic_013_PAR.py | 1,118 | 3.9375 | 4 | #!/usr/bin/env python
'''
A solution to a ROSALIND problem from the Algorithmic Heights problem area.
Algorithmic Heights focuses on teaching algorithms and data structures commonly used in computer science.
Problem Title: 2-Way Partition
Rosalind ID: PAR
Algorithmic Heights #: 013
URL: http://rosalind.info/problems/p... |
8d0dce694997c3156a1e25699dd20da650ead572 | 0n1udra/Learning | /Python/Python_Problems/Rosalind-master/Textbook_03C.py | 1,883 | 3.78125 | 4 | #!/usr/bin/env python
'''
A solution to a code challenges that accompanies Bioinformatics Algorithms: An Active-Learning Approach by Phillip Compeau & Pavel Pevzner.
The textbook is hosted on Stepic and the problem is listed on ROSALIND under the Textbook Track.
Problem Title: Profile-most Probable k-mer Problem
Chapt... |
19d3d81c985ebdcb7b791ea6706399d0e57667e1 | 0n1udra/Learning | /Python/Projects/Newegg_Scraping.py | 2,197 | 3.5625 | 4 | from urllib.request import urlopen
from bs4 import BeautifulSoup as soup
graphicsCardURL = "https://www.newegg.com/Video-Cards-Video-Devices/Category/ID-38?Tpk=graphics%20card"
# link of website
uClient = urlopen(graphicsCardURL)
# opens connection to site
pageHTML = uClient.read()
# gets the html from site and save... |
ec16ca3f2a870b1191465f043aa18abad95e9ae5 | 0n1udra/Learning | /Python/other/madLib.py | 810 | 3.953125 | 4 |
# Prints Letter with number next to them
def printNumsLetters():
import string
Letters = string.ascii_lowercase
for i in range(len(Letters)):
print(i, Letters[i])
# Creates a setence from lists
def sentenceGen():
nouns = ['dog', 'computer', 'cat', 'phone', 'arrow', 'tablet', 'people', 'fire', ... |
c8508b6bba66b1052ca57cc2b9b31af313f805da | 0n1udra/Learning | /Python/Python_Problems/Interview_Problems-master/python/logarithm.py | 732 | 4.1875 | 4 | '''
Compute Logarithm
x: a positive integer
b: a positive integer; b >= 2
returns: log_b(x), or, the logarithm of x relative to a base b.
Assumes: It should only return integer value and solution is recursive.
'''
def myLog(x, b):
if x < b:
return 0
else:
return myLog(x/b, b) + 1
if __nam... |
16188fda57073ca45165930938325953166ed467 | kmzn128/atcoder | /b144/d.py | 373 | 3.515625 | 4 | import sys
input = sys.stdin.readline
import math
def Main(a, b, x):
h = x / (a*a)
r = 0
if(h >= b/2):
r = math.atan2(b-h, a/2)
else:
y = 2*x/(a*b)
r = math.atan2(b,y)
return math.degrees(r)
def main():
A, B, X = map(int, input().split())
print(Main(... |
df8a5381a52640a8745c550901033b57c0305a31 | kmzn128/atcoder | /b159b/c.py | 150 | 3.609375 | 4 | def Main(L):
return (L/3)**3
def main():
L = int(input())
print('{:.12f}'.format(Main(L)))
if __name__ == '__main__':
main() |
5272bef9024567e61a42d39dc18821468de52135 | kmzn128/atcoder | /b164/b.py | 296 | 3.515625 | 4 | def Main(A,B,C,D):
while True:
C -= B
if C <= 0:
return "Yes"
A -= D
if A <= 0:
return "No"
def main():
A, B, C, D = map(int, input().split())
print(Main(A, B, C, D))
if __name__ == '__main__':
main() |
02f908ad83258cbb1a860906eb98deede75de62f | ongechi/python-strings | /apostrophe.py | 97 | 3.625 | 4 | # writting apostrophe in python
print("this is anne's number")
print("This is patrick's number")
|
c7be33ec3dea467842ac9da87578e081fa306907 | sm2774us/Data-Structures-And-Algorithms-In-Python | /tests/test_stack.py | 1,315 | 3.53125 | 4 | """Test for Stack implementation."""
import pytest
@pytest.fixture
def test_stack():
"""Fixture for testing."""
from src.stack import Stack
empty = Stack()
one = Stack(5)
multi = Stack([1, 2, 'three', 4, 5])
return empty, one, multi
def test_stack_is_initialized(test_stack):
"""Test sta... |
84051d70209e0f4e81890269db36db9c9da265da | arukaminado/captains-log | /cl.py | 1,395 | 3.875 | 4 | import os, sys, datetime
def main():
#this is so the user will always enter their name if logs do not exit
if(not os.path.isfile("entries.log")):
print("Please enter your name")
#reading, storing, writing and pretty printing
cl_name = raw_input("Name: ")
cl_logfile = open("entri... |
946c7174d3281bc516cd4a6ed7a2364529a4093f | nightjarrr/gtf | /src/getthefacts/rules.py | 10,903 | 4.125 | 4 | # coding=UTF-8
"""
Module: rules.
Description:
This module contains classes that define the logical rules - a set of
simple expressions that can be combined into complex expressions.
Each instance of logical rule can take some object is input value,
and produce a boolean result: whe... |
576be61cefea15d7f1d408962d58c175eb20c84a | TheJoeCollier/cpsc128 | /code/python3/pythagoras_a.py | 595 | 4.0625 | 4 | # pythagoras.py
# S. Bulut 2019
# T. Topper 2015
print('''
===========================
Right-angle tirangle tester
---------------------------
Enter the lengths of the sides of your \triangle and I will let you know
if it has a right angle or not
''')
a = eval(input("Length of the first side ="))
b = eval(input("Le... |
6fce67d9137f5433404a916f7a0849cde8aa8517 | TheJoeCollier/cpsc128 | /code/python3/ip_extractor.py | 215 | 3.84375 | 4 | # ip_extractor.py
fname = input('What file do you want to scan? ')
ip = input('What IP address do you want to scan for? ')
print()
f = open(fname, 'r')
for line in f:
if line.find(ip) != -1:
print(line)
|
07797287c6eb6fdffc276d8d0cf956d4bf85a56c | TheJoeCollier/cpsc128 | /code/python3/wordfrequencies.py | 1,494 | 3.9375 | 4 | # WordFrequencies.py
# Get the string:
test_string = '''The programmer, who needs clarity, who must talk all day to
a machine that demands declarations, hunkers down into a low-grade annoyance.
It is here that the stereotype of the programmer,
sitting in a dim room, growling from behind Coke cans, has its o... |
6fb3874538b010fa6367cfd1ef6ed6fd392e91c3 | TheJoeCollier/cpsc128 | /code/python2/tmpcnvrt.py | 1,242 | 4.5 | 4 | ###########################################################
## tmpcnvrt.py -- allows the user to convert a temperature
## in Fahrenheit to Celsius or vice versa.
##
## CPSC 128 Example program: a simple usage of 'if' statement
##
## S. Bulut Spring 2018-19
## Tim Topper, Winter 2013
#############################... |
ce46d113449291fe839b02042bec5f66dd84e61d | TheJoeCollier/cpsc128 | /code/python3/read_coords.py | 232 | 3.53125 | 4 | # read_coords.py
coords = []
fname = input('Name of file to read from? ')
f = open(fname, 'r')
for line in f:
x_string, y_string = line.split()
coords.append([int(x_string),int(y_string)])
f.close()
print('coords =', coords) |
2aaa27bc9a79e45cf385ce8176c46e93d15492c0 | TheJoeCollier/cpsc128 | /code/python3/exception_handling_example.py | 306 | 3.515625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jun 20 16:29:00 2019
@author: sbulut
"""
#with open('hellox.txt','r') as f:
# for line in f:
# print(line)
try:
with open('hellox.txt','r') as f:
for line in f:
print(line)
except FileNotFoundError:
print("Caught it!") |
25696773591e8dddeaf9662cf93daad4dcf75eb4 | TheJoeCollier/cpsc128 | /code/python3/may21_snippets.py | 802 | 4.09375 | 4 | # simple class definiton
# afterwards do
# x=MyClass
# dir(x)
# to see built-in operators
class MyClass:
"""A simple example class"""
i = 12345
def f(self):
return 'hello world'
#string
name = "Joe"
"m" in name
"o" not in name
min(name)
max(name)
name = name + " " + "Sixpack"
print(n... |
bb623beab3b595b4685c733ca9063fa0da1e6683 | gowrimanickam/operation | /evint.py | 117 | 3.671875 | 4 | lower_limit=int(input())
upper_limit=int(input())
for i in range(lower_limit,upper_limit):
if(i%2==0):
print(i)
|
0e0ff9dddf527c9e949aa596d0df577db27d443c | inisoye/First_Exploration | /Solo Seshes/Sesh 1 - May 24/Sesh1_Code1.py | 127 | 3.71875 | 4 | #Code written to grow understanding of certain operators
#Starting with assignment operators
a = 10.5
b = 20
print(b)
help(str) |
f775f24efd8c636e66cf5dbe61c69315bffb7745 | outpw/WorldCatLocations | /GeoPy_Dist.py | 583 | 3.5625 | 4 | from geopy.distance import geodesic
import pandas as pd
Home = (40.005956, -105.26552) #Home location from which distance from each set of coordinates in input spreadsheet will be calculated.
df = pd.read_csv('FILE PATH TO INPUT CSV') #CSV with coordinate data. xy column should be formatted as such: (40.005956, -105.... |
33fb8a74b1eee97661031834fe470d8f1a3307ad | sergorl/recommender-service | /test/just_test.py | 941 | 3.53125 | 4 |
class Foo:
def __init__(self, id):
self.id = id
self.data = 777
def __eq__(self, other):
return self.id == other.id
def __hash__(self):
return hash(self.id)
def __repr__(self):
return 'Foo id = {}, data = {}\n'.format(self.id, self.data)
def test0():
s ... |
cd0183d338edef20fc3976291c0be2ea669a8440 | kotadakku/CSE423_Distributed_Programming | /Python/Fibonacci/Fibonacci.py | 738 | 3.8125 | 4 | from threading import Thread
class Fibonacci(Thread):
def __init__(self, n):
Thread.__init__(self)
self.n = n
self._result = 0
def run(self):
if self.n == 1 or self.n == 2:
self.result = 1
else:
f1 = Fibonacci(self.n - 1)
f2 = Fibonacc... |
071b1be1f46e43a1161be6aa53d2b2b7257bf15a | MCAlmond/uip-iig-pc3 | /atributos privados.py | 1,268 | 3.953125 | 4 |
class Cliente(object):
__total_clientes = 0
def __init__(self, nombre, saldo=0.0):
self.nombre = nombre
self.saldo = saldo
Cliente.__total_clientes += 1
def retirar(self, cantidad):
if cantidad > self.saldo:
raise RuntimeError("Cantidad superior al s... |
194f25a6634006290766e10aef0bac3ce34a5f87 | MCAlmond/uip-iig-pc3 | /practica 2 (contactos de telefono).py | 1,416 | 3.859375 | 4 |
if __name__ == '__main__':
contactos = 'D:\\Ali\\UNIVERSITY 2016-2019\\2018\\Cuart. 7\\Programación de Computadoras III\\.vscode\\contactos.txt'
archivo = open(contactos, 'r')
contactos1 = (archivo.readlines())
numero_telefonico = input("¿Cual es el numero de telefono que quieres marca?:")
fo... |
0048afa92e4b1d09b35e2d7ae5c1dbe074f0b60e | shraddhaagrawal563/learning_python | /numpy_itemsize.py | 705 | 4.28125 | 4 | # -*- coding: utf-8 -*-
#https://www.tutorialspoint.com/numpy/numpy_array_attributes.htm
import numpy as np
x = np.array([1,2,3,4,5])
print ("item size" , x.itemsize) #prints size of an individual element
x = np.array([1,2,3,4,5,4.2,3.6])
print ("item size" , x.itemsize) #converts every element to the largest of si... |
579cc33520a26b0c5aeaa34bff7f407f5ad11814 | shraddhaagrawal563/learning_python | /numpy_datatype3.py | 236 | 3.859375 | 4 | # -*- coding: utf-8 -*-
#creating a structured datatype
import numpy as np
print("creating a structured datatype")
dt=np.dtype([('age',np.int64)])
print("datatype dt is", dt)
a=np.array([(10),(20),(30)], dtype=dt)
print("array is:", a)
|
73b47f11a387c8b15723490f8d67b829510803d5 | shraddhaagrawal563/learning_python | /myfirstprog.py | 85 | 3.640625 | 4 | # -*- coding: utf-8 -*-
a=20
print(a)
b="shraddha563"
print("string slicing",b[0:5])
|
9325c97aa35eaba0bbda7050d2ca554a9024783d | shraddhaagrawal563/learning_python | /pandas1.py | 1,561 | 4 | 4 | # -*- coding: utf-8 -*-
#series
import pandas as pd
import numpy as np
print("creating empty series")
emptyser= pd.Series() #s should be capital in Series
print("empty series is", emptyser)
"""
series-- size immutable, data mutable, homogenous
"""
print("creating series from ndarray")
data=[12,34,56,76]
data= np.arr... |
bbc9cafee151a6f603473cdbaccd4214ec76c530 | jordanbailey10/Python_projects | /abstraction.py | 420 | 3.59375 | 4 | from abc import ABC, abstractmethod
class bike(ABC):
def reciept(self, amount):
print("Your total cost: ",amount)
@abstractmethod
def chargeAmount(self, amount):
pass
class CreditCardPayment(bike):
def chargeAmount(self, amount):
print('Your total cost of {} exeeds your 200 dol... |
c3f89251a7cfe558c95036fd4431559c866e014b | 9hw/loginregister | /LogNRegister.py | 999 | 3.75 | 4 | #start
users = {}
status = ""
def displayMenu():
status = input("[Login & Register] Are you registered user? yes/no?")
if status == "yes":
oldUser()
elif status == "no":
newUser()
def newUser():
createLogin = input("[Login & Register] Create your username!: ")
... |
0d7a7a6d3a8571419f3ad0c09d53a9f127dbda6c | lpetrich/kids_math_practice | /multiplication.py | 374 | 3.625 | 4 | import random
while True:
print "###########################################################################\n"
a = random.randint(0, 10)
b = random.randint(0, 10)
print "%4d" % a
print "x%3d" % b
ans = input("------\n")
while int(ans) != a*b:
print "Incorrect, please try again"
print "%4d" % a
print "x%3... |
5cca8f56d07ca81a167dc4c01c244856029de4c7 | Peniel123/Surviving-the-Titanic | /Will You Survive the Titanic.py | 13,064 | 3.5 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Introduction
#
#
# The sinking of the Titanic is one of the most infamous shipwrecks in history.
#
# On April 15, 1912, during her maiden voyage, the widely considered “unsinkable” RMS Titanic sank after colliding with an iceberg. Unfortunately, there weren’t enough lifeboa... |
21ff5084c841bc1aed2d5f47026fbbf4b95716c8 | cam-mackay/Intro-Python---Assignment-8.1 | /campbell_python_8.1.py | 6,893 | 4.34375 | 4 | #Python Assignment 8.1
#Campbell Mackay
#parent class - BankAccount
class BankAccount:
def __init__(self, num, bal):
self.accountNumber = num
self.balance = float(bal)
print("A bank account has been created")
print("The account number is " + str(self.accountNumber))
pr... |
1e0b7b0aed95cfb2db8b1f382bd898fef6c5e595 | hyetigran/Sorting | /src/recursive_sorting/recursive_sorting.py | 1,465 | 4.125 | 4 | # TO-DO: complete the helpe function below to merge 2 sorted arrays
def merge(arr, arrA, arrB):
# TO-DO
left_counter = 0
right_counter = 0
sorted_counter = 0
while left_counter < len(arrA) and right_counter < len(arrB):
if arrA[left_counter] < arrB[right_counter]:
arr[sorted_co... |
05b1f8eec6d28bd0c9206e6f58a7588b8bb57cc9 | let369/Using-Python-to-Access-Web-Data | /scraper.py | 280 | 3.515625 | 4 | import urllib
from BeautifulSoup import *
url = raw_input('Enter - ')
html = urllib.urlopen(url).read()
soup = BeautifulSoup(html)
tags = soup('span')
total_sum = 0;
count = 0;
for tag in tags:
count += 1
total_sum += int(tag.contents[0])
print 'Count',count
print total_sum |
068ca74f9ea5f115e398a34fcaf6a3fed4494ffe | davidangulocorcuera/python_minigames | /venv/minijuegos/bigbang_juego.py | 3,989 | 3.8125 | 4 | import os
import sys
count =1
user1 = raw_input("Eres el primer jugador, escribe tu nombre --> ")
user1_option = input("Escribe el numero de la opcion que quieras elegir" + '\n' +
"1 - Piedra" + '\n' + "2 - Papel" +'\n' + "3 - Tijera" + '\n'+ "4 - Lagarto" + '\n'+ "5 - Spock" + '\n'+ "--> " )
wh... |
f16355876ca6a9080e0a819ca9cc4a9a6a5dc902 | domicphp008/pythonAulas | /aula-04.py | 590 | 3.625 | 4 | Python 3.4.4rc1 (v3.4.4rc1:04f3f725896c, Dec 6 2015, 16:42:12) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> x = 'hello'
>>> y = 42
>>> z = 'there'
>>>
>>> print(x +z)
hellothere
>>> print x,y)
SyntaxError: Missing parentheses in call to 'print'
>>> print (x... |
2d4f911e9ee2521d748b6dd094423cd6a7fcaf70 | kimdaniels1999/Weather_Project | /starter/weather.py | 6,022 | 4.25 | 4 | import csv
from datetime import datetime
from sqlite3.dbapi2 import converters
DEGREE_SYBMOL = u"\N{DEGREE SIGN}C"
def format_temperature(temp):
return f"{temp}{DEGREE_SYBMOL}" # no change required
# """Takes a temperature and returns it in string format with the degrees and celcius symbols..
# Args:
... |
90b0c64dc63d10b347eb2621f5cfbd34db8104fa | PacktPublishing/Complete-Python-Scripting-for-Automation | /Section 22/3.Document-using_init_method.py | 301 | 3.9375 | 4 | class Emp(object):
def __init__(self,name,salary):
self.name=name
self.salary=salary
return None
def display(self):
print(f"The name is: {self.name}\nThe salary is: {self.salary}")
return None
emp1=Emp('Ramu',56000)
emp2=Emp("Naren",90000)
emp1.display()
#emp2.display() |
a9449688c8d46a8395f1990896a06c86fd143ae8 | PacktPublishing/Complete-Python-Scripting-for-Automation | /Section 15/3.Document-create-csv-file.py | 577 | 3.5625 | 4 | import csv
#req_file="C:\\Users\\Automation\\Desktop\\hi\\new_info.csv"
'''
fo=open(req_file,'r')
csv_reader=csv.reader(fo,delimiter="|")
for each_row in csv_reader:
print(each_row)
fo.close()
'''
req_file="C:\\Users\\Automation\\Desktop\\hi\\demo.csv"
fo=open(req_file,'w',newline="")
csv_writer=csv.writer(... |
3ec00a24707bcf819fa64f21a7e1cbfeace59d0a | PacktPublishing/Complete-Python-Scripting-for-Automation | /Section 11/4.Document-read-string-print-with-index-values.py | 125 | 4.15625 | 4 | usr_str=input("Enter your string: ")
index=0
for each_char in usr_str:
print(f'{each_char} -->{index}')
index=index+1 |
f47819fc59103439b301e5e72d51775b0468cec9 | PacktPublishing/Complete-Python-Scripting-for-Automation | /Section 19/7.Document-find-all-find-iter.py | 372 | 3.875 | 4 | import re
my_str="This is python and we are having python2 and python3 version"
my_pat=r'\bpython[23]?\b'
#print(re.search(my_pat,my_str))
#print(len(re.findall(my_pat,my_str)))
#print(re.findall(my_pat,my_str))
for each_ob in re.finditer(my_pat,my_str):
print(f'The match is: {each_ob.group()} starting index:... |
5b4b1cea5e01a539d288bde1bbc1ae264434f962 | farooqbutt548/Python-Path-Repo | /strings.py | 1,303 | 4.34375 | 4 | # Strings
# Simple String
'''string1 = ' this is 1st string, '
string2 = "this is 2nd string"
print(type(string1))
connect_string = string1+ " "+string2
print(connect_string)
# print("errer"+3) erreor
print('this is not error'+' ' + str(3))
print('this will print 3 ti... |
16f90e0611fa60516d4e2d8db3af97429c05f250 | farooqbutt548/Python-Path-Repo | /classesObject.py | 7,518 | 3.984375 | 4 | '''class Students:
def __init__(self, a, b, c):
self.fname = a
self.lname = b
self.salary = c
farooq = Students('farooq ', 'butt ', 23000)
zaheer = Students('zaheer ', 'irshaad ', 20000)
# print(f'the salary of {farooq.fname + farooq.lname}is {farooq.salary}')
# print(f'the salary of {zahe... |
5149529429c6bcae1995e794e35edc6d372efb5b | EduardoVaca/QuantitiveMethods | /Ejercicios/queues.py | 4,058 | 3.875 | 4 | """
Author: Eduardo Vaca
Queues
"""
import math
def print_dict(d):
"""Prints a dictionary in format
PARAMS:
- d : dictionary
"""
for k,v in d.items():
print('{}: {}'.format(k, v))
def little_law(lam, mu, w_q):
"""Computes Little Law's formulas
PARAMS:
- lam : rate of arrivals
... |
8e42427c9aa8ff2e06f671f4f19f445b48df5a1f | lvht04/banktellerproject | /BankTellerProjectLucas.py | 24,338 | 4.375 | 4 | #!/usr/bin/env python
# coding: utf-8
# # Bank Teller
#
# In this project you will be implementing code that emulates transactions performed between a bank-teller and a customer.
# The prerequisites for this project are Python 3 syntax, functions and control flow. Let's jump right into it!
# ### 1. Initializing s... |
d7d78510f30f66756e04b46eff02f47fcf1d5e2b | Navyashree008/more_exercise | /nav_gurukul.py | 516 | 3.609375 | 4 | # # through looping:-
i = 1
while i <= 1000:
if i % 21 == 0:
print("navgurukul")
elif i % 7 == 0:
print("gurukul")
elif i % 3 == 0:
print("nav")
else:
print(i)
i+=1
# fuction:-
def navgurukul(i):
for i in range(i,1001):
if i % 21 == 0:
... |
db222199c9731abc58270bef01602223d9700552 | AkhilB4/Loan_Calculator | /Problems/Sine and cosine/main.py | 80 | 3.75 | 4 | import math
radian = float(input())
print(math.sin(radian) - math.cos(radian))
|
9b3e7b4b203f22a48508b9190913cba596e8897b | CPMoviePHil/py-learning-2 | /main.py | 219 | 3.546875 | 4 |
class MainProgram:
@staticmethod
def sum_list(li_1):
total = 0
for item in li_1:
total += item
return total
list_1 = list(range(1,11))
print(MainProgram.sum_list(list_1))
|
2b37dcf8c3efc3bf40d690ac2779f21b690fa050 | evtodorov/aerospace | /SciComputing with Python/lesson_05-08/metatron.py | 994 | 3.625 | 4 | """
Created on Mon May 05 16:52:58 2014
Pygame drawing
@author: etodorov
"""
import pygame as pg
import math
pg.init()
screen = pg.display.set_mode((1280,960))
scrRect = screen.get_rect()
center = scrRect.center
x0 = scrRect.centerx
y0 = scrRect.centery
bg = (255,255,255) #background color
fg = (0,0,0) #foregr... |
1f9598d7a967215c4a15b585a939b757d00ea698 | evtodorov/aerospace | /SciComputing with Python/lesson_04-22/hello.py | 599 | 3.875 | 4 | import os
print 'T converter F and C'
scale = raw_input ("Enter F to convert F to C or C to convert C to F: ")
if(scale=='f' or scale=='F'):
tempIn = raw_input("Enter temperature in degrees F: ")
scaleIn = 'Fahrenheit'
tempOut = (float(tempIn)-32)*5/9
scaleOut = 'Celsius'
elif(scale=='c' or scale=... |
71080ea8f322dc8c05c50b16bac58afc75166b07 | evtodorov/aerospace | /SciComputing with Python/lesson_04-24/2-prime.py | 349 | 3.828125 | 4 | import math
n=1
primes = []
while len(primes)<10001:
i = 2
check = True
while (i<=math.sqrt(n)):
if(n%i==0):
check = False
break
i +=1
if(check): primes.append(n)
n+=1
print primes[-1]
#Put a number to check if it is prime:
#65845484531
#65845484531 is a pr... |
c1c9d29e79570b753d05f3c251750618656b90f5 | evtodorov/aerospace | /SciComputing with Python/lesson_04-22/1-cubicEquation.py | 1,039 | 3.78125 | 4 | import math
def cubRoot(x):
y = (abs(x))**(1.0/3.0)
if(x<0): y = -y
return y
print "To solve x3+ax2+bx+c=0: "
p = float(input("Enter a value for a: "))
q = float(input("Enter a value for b: "))
r = float(input("Enter a value for c: "))
A = (3.0*q-p*p)/3.0
B = (2.0*p*p*p-9.0*p*q+27.0*r)/27.0
D = A*A*A/27.0+... |
58bf34ffb39ae7126209ffe8c91e3a7485559455 | JieqiongZhao/RouteVis | /routing_vis/filterdata.py | 10,187 | 3.71875 | 4 | #required document in the current folder: lists.json, outputX.txt
from osgeo import ogr
import json
import pprint
import collections
import copy
import sys
pp = pprint.PrettyPrinter(indent=4)
class hullNum():
def __init__(self, route, num):
self.route = route # .route is the route number
self.... |
94ab8af7d8a3f8f814eefe198d316fb6daa31e69 | Khepanha/Python_Bootcamp | /week01/ex/e09_random_loop.py | 198 | 3.828125 | 4 | import random
number = input("Enter a number: \n>> ")
try:
number = int(number)
for i in range(number):
print(random.randint(0,100))
except:
print(random.randint(0,100))
|
8fa74a8a9d3a3094abad387f7d05bb5b4fc28ad7 | Khepanha/Python_Bootcamp | /week02/ex/e29_list_sort_str.py | 320 | 3.828125 | 4 | def list_sort_str (S):
A = []
for x in S:
if (type(x) != type(1) and x.isdigit() == False):
x = x.replace("-","")
if (type(x) != type(1) and x.isdigit() == False):
A.append(x)
return A
print (list_sort_str(['abc', 'def', -1, 2, 3, '-123', '888', 'hello']))
|
ca3a1dd438800a6fe54d718c14592568c6813b0f | Khepanha/Python_Bootcamp | /week02/ex/e26_list_set.py | 135 | 3.828125 | 4 | def list_set (L):
A = []
for i in (L):
if i not in A:
A.append(i)
return A
print (list_set([]))
|
8b8f9374e4084d763f3b4195f5be59c95deeea50 | Khepanha/Python_Bootcamp | /week01/ex/e07_calcul.py | 287 | 4.125 | 4 | total = 0
while True:
number = input("Enter a number: \n>> ")
if number == "exit":
break
else:
try:
number = int(number)
total += number
print("TOTAL: ",total)
except:
print("TOTAL: ",total)
|
4b8e7d39f77139597792d2e9f0895f21b9f63f2e | Khepanha/Python_Bootcamp | /week01/projects/p01_dice.py | 623 | 4.09375 | 4 | import random
i = 1
sum = 0
print ("Welcome to the dice game!")
while True:
num = input ("Enter the number of dice you want to roll: ")
if num.isdigit() == False:
print ("USAGE: The number must be between 1 and 8")
continue
num1 = int(num)
if num1 > 8 or num1 < 1:
prin... |
a0e5dd6245f96a108a66bc153587b4e10a841b1a | gelaim/legalnlp | /legalnlp/mask_functions.py | 4,076 | 3.78125 | 4 | import re
def mask_email(txt):
"""
Finds an email pattern and then masks it.
Parameters
-----------
txt: str
A piece of text containing the email pattern
Returns
-----------
str
masked email string as ' [email] '
list
... |
1e6256f37beb11209485fd334e4ddddcba13f74b | FernandoJbp06/proyecto_plantas | /funciones.py | 1,914 | 3.578125 | 4 | import data1.PlantaElec as plel
def validar_planta(planta):
plantas=list(plel.consumo_energia.keys())
while planta not in plantas:
planta=input('No existe esta planta: Ingrese el nombre de una planta: ').title()
return planta
def validar_CiudadEnPlanta(planta,ciudad):
while ciudad not in plel.consumo_ene... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.