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 |
|---|---|---|---|---|---|---|
2539e1965cf3e3df19acc8c1e7a9f65c734a4c12 | gelisa/sandbox | /working-with-spark/run_spark.py | 2,129 | 3.8125 | 4 | # run_spark.py
"""
a sandbox to test spark and learn how it works
to run it: put some (at least a couple) text files to the data folder
type in command line: python run_spark.py
or <path to spark home folder>/bin/spark-submit run_spark.py
to understand very basics of spark read: http://mlwhiz.com/blog/2015/09/07/Spark... |
30850c4f1d5a5d986941cd04d8e17178e15a835d | johnabfaria/bambus.py | /main.py | 771 | 3.8125 | 4 | import pic_it
import tweet_it
import txt_it
import drop_it
import pin
import time
"""
This is the main program that will use pin to id inputer from raspberry pi using RPi.GPIO
If input from IR motion sensor is positive, camera will be activated, photo snapped and saved locally
Photo will be tweeted and then uploaded ... |
fe957545e1dc512e5d3a2a28defc654281ae82ee | YunYouJun/python-learn | /primer/first_program.py | 437 | 3.984375 | 4 | def isEqual(num1, num2):
if num1 < num2:
print(str(num1) + ' is too small!')
return False
elif num1 > num2:
print(str(num1) + ' is too big!')
return False
else:
print('Bingo!')
return True
from random import randint
num = randint(1, 100)
print('Guess what I... |
87de1f7da5274947664161b3e54d2913720b59e9 | Om-Jaiswal/Python | /Python_Programs/FizzBuzz.py | 643 | 4.03125 | 4 | # for number in range(1,101):
# if number % 3 == 0 and number % 5 == 0:
# print("FizzBuzz")
# elif number % 3 == 0:
# print("Fizz")
# elif number % 5 == 0:
# print("Buzz")
# else:
# print(number)
print("Welcome to FizzBuzz!")
Fizz = int(input("Enter a number for fizz :\n"))
Buzz... |
c0549fa722759a574c69585d0e0767c47d8d1be1 | Om-Jaiswal/Python | /Python_Programs_OPP/Dash_Square.py | 326 | 3.5 | 4 | import turtle as t
from turtle import Screen
tim = t.Turtle()
tim.shape("turtle")
def dash_line():
for _ in range(15):
tim.forward(10)
tim.penup()
tim.forward(10)
tim.pendown()
for _ in range(4):
dash_line()
tim.right(90)
screen = Screen()
screen.exitonc... |
5f168aeaf97ebb2100fafcbaef59928522f86d70 | sha-naya/Programming_exercises | /reverse_string_or_sentence.py | 484 | 4.15625 | 4 | test_string_sentence = 'how the **** do you reverse a string, innit?'
def string_reverser(string):
reversed_string = string[::-1]
return reversed_string
def sentence_reverser(sentence):
words_list = sentence.split()
reversed_list = words_list[::-1]
reversed_sentence = " ".join(reversed_list)
... |
4196ac75509c5eff3227c1e8bff9ad00cc83ddd0 | frfanizz/PressureChess | /pressurechess.py | 5,374 | 3.75 | 4 | import sys
from pieces import *
'''
Considerations:
allow buring pieces
'''
class tile:
"""
(Board) tile objects
"""
def __init__(self, piece, hp = 6):
"""
Tile classs constructor
:param self tile: the current object
:param piece piece: the current object
:param hp int: the current obj... |
2e61bac1d6b08105532a2c34e96b98e5e6886b0f | rabahbedirina/HackerRankContests | /CatsandaMouse.py | 207 | 3.65625 | 4 | def catAndMouse(x, y, z):
X = abs(x - z)
Y = abs(y-z)
if X < Y:
cat = "Cat A"
elif X > Y:
cat = "Cat B"
else:
cat = "Mouse C"
return cat
catAndMouse(x, y, z)
|
0e599494c99b1d05d0162c5cf66b98f0b0301be1 | rabahbedirina/HackerRankContests | /Big Sorting.py | 526 | 3.625 | 4 | def bigSorting(unsorted):
for i in range(n):
unsorted[i] = int(unsorted[i])
print(unsorted)
list_sorted = sort(unsorted)
print(list_sorted)
for j in range(n-1):
print(str(list_sorted[j]))
return str(list_sorted[-1])
n = 6
unsorted = ['31415926535897932384626433832795', '1', '3... |
a336bb76c0bce019135ea4a775ab09f434a5b01d | skyrusai/code_training | /others/FizzBuzz.py | 327 | 3.96875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 13 09:44:32 2018
@author: shenliang-006
"""
for l in range(101):
if l==0:
continue
if l%3==0:
if l%5==0:
print("FizzBuzz")
else:
print("Fizz")
elif l%5==0:
print("Buzz")
else:
print(l)
... |
e2584e9dda14afad7ca6aa5eebf4f23d56ac01f9 | ardieorden/electrical_circuits | /circuit_initial.py | 6,626 | 3.671875 | 4 | import cmath
import numpy as np
import matplotlib.pyplot as plt
from sympy import Symbol, simplify, Abs
from sympy.solvers import solve
from scipy.signal import sawtooth
# We set our unknowns: vo, vr, ir, ic and il
vo = Symbol("V_O")
vr = Symbol("V_R")
ir = Symbol("I_R")
ic = Symbol("I_C")
il = Symbol("I_L")
r = Sy... |
18fae6895c6be30f0a3a87531a2fafe965a3c89f | pkdoshinji/miscellaneous-algorithms | /baser.py | 1,873 | 4.15625 | 4 | #!/usr/bin/env python3
'''
A module for converting a (positive) decimal number to its (base N) equivalent, where
extensions to bases eleven and greater are represented with the capital letters
of the Roman alphabet in the obvious way, i.e., A=10, B=11, C=12, etc. (Compare
the usual notation for the hexadecimal numbers.... |
60a99e1a6a1a8ab2c8a5827d36b891fdafb5035f | DimitrisParris/Bootcamp-AFDE | /Exercises in Python/ex.8(part2).py | 290 | 3.703125 | 4 | num = input("Give sequence of numbers:")
sum = 0
for i in range(len(num)):
if i%2 == 0 and i<(len(num)-1):
a = int(num[i])*int(num[i+1])
sum+=a
if len(num)%2 !=0 and i==(len(num)-1):
sum += int(num[-1])
print("This is the sum of the sequence:", sum)
|
653e3c2184e36a5a05ea9e77d7f8214e4be9d770 | DimitrisParris/Bootcamp-AFDE | /Exercises in Python/ex.2(part 2).py | 410 | 3.703125 | 4 | number=input('Give 8-bit number:')
num=str(number)
if len(num)!=8:
print('Not an 8-digit number. False. Check again.')
else:
neo=num[:7]
print(neo)
sum=0
for i in neo :
if int(i)==1:
sum+=1
if sum%2==0 :
print('sum even')
else :
print('sum odd')
if (int... |
5d9d9ee735c83028145dda4bbc9a615cab916d6c | DSJ-23/DS_Algorithms | /valid_parenthesis.py | 1,039 | 3.890625 | 4 | from stack import Stack
class Solution:
def isValid(self, s):
valid = Stack()
for p in s:
if p == "(" or p == "[" or p =="{":
valid.add(p)
# elif p == ")" or p == "]" or p == "}":
print(valid.get_stack())
return True
a= Solu... |
7c53f978351f9de8b446810c5fbd0d87160806cf | DSJ-23/DS_Algorithms | /DS/queue.py | 316 | 3.5 | 4 | class Queue:
def __init__(self):
self.data = []
def push(self, x: int) -> None:
self.data.append(x)
def pop(self):
return self.data.pop(0)
def peek(self):
return self.data[0]
def empty(self):
return bool(self.data == []) |
28b99002de36b734fe2f53b72ac863075f594ebc | DSJ-23/DS_Algorithms | /all_duplicates.py | 549 | 3.578125 | 4 | class Solution:
def findDuplicates(self, nums):
for i in range(1, len(nums) +1):
if i in nums and nums.count(i) == 1:
nums.remove(i)
elif i in nums and nums.count(i) > 1:
self.remove_nums(nums, i)
else:
continue
retu... |
d7cae30b5df626903234bce52cde315a602603cb | DSJ-23/DS_Algorithms | /binary_search.py | 495 | 3.671875 | 4 | a = list(range(1001))
def binary_search(nums, num):
lower = 0
upper = len(nums) - 1
mid = 0
while lower <= upper:
mid = (lower + upper)//2
# print(nums[mid])
if nums[mid] > num:
upper = mid -1
elif nums[mid] < num:
lower = mid + 1
... |
becb9a7d85b964a23e2a9e416b3654a2a4e8b7d5 | tomchor/scivis | /plots/ex0/ex0.py | 665 | 3.9375 | 4 | import numpy as np
from matplotlib import pyplot as plt
# Create some made up simple data
y1=[1,4,6,8]
y2=[1,2,3,4]
# Create a new figure with pre-defined sizes and plot everything
plt.figure(figsize=(3,4))
plt.plot(y1)
plt.plot(y2)
plt.savefig('bad_ex.pdf')
plt.close('all')
# Create another figure with defined size... |
c901957b592edc23c8b162ab5483e8f005bf3de2 | cbrandao18/python-practice | /math-practice.py | 564 | 4.0625 | 4 | import math
numbers = [5, 8, 27, 34, 71, 6]
n = len(numbers)
def getSum(numbers):
summation = 0
for num in numbers:
summation = summation + num
return summation
def getSD(numbers):
avg = getSum(numbers)/n
numerator = 0
for num in numbers:
numerator = numerator + (num - avg)**2... |
fe03952ad6982e0e51a9218b01dc9231df641b41 | cbrandao18/python-practice | /celsius-to-f.py | 226 | 4.1875 | 4 | def celsiusToFahrenheit(degree):
fahrenheit = degree*1.8 + 32
print fahrenheit
celsiusToFahrenheit(0)
celsiusToFahrenheit(25)
n = input("Enter Celsius you would like converted to Fahrenheit: ")
celsiusToFahrenheit(n)
|
edeff33f8b00a449bab826aa2b05a50108ea335f | luciengaitskell/csci-aerie | /csci0160/3-data/athome3_sorting_algos.py | 6,579 | 4.15625 | 4 | """
Sorting Algos Handout
Due: October 7th, 2020
NOTES:
- Reference class notes here: https://docs.google.com/document/d/1AWM3nnLc-d-4nYobBRuBTMuCjYWhJMAUx2ipdQ5E77g/edit?usp=sharing
- Do NOT use online resources.
- If you are stuck or want help on any of them, come to office hours!
Completed by Lucien Gaitsk... |
a07ada7c787f741ef1884b2a455b69fdab98f28c | Nawod/Hactoberfest2021-1 | /Python/Guess_Number_Game.py | 1,416 | 4.03125 | 4 | import random
import sys
print('GUESS THE NUMBER')
#function for genarate random numbers according to the levels
def level(lvl):
global randNo
if lvl == 'E':
randNo = random.randint(1,10)
print('Guess a number between 1 & 10..')
elif lvl == 'N':
randNo = random.randint(1,20)
... |
8040f07a2775078bcdc058cd58e49ef3c9fc2f96 | lydxlx1/icpc | /src/codeforces/_1131F.py | 883 | 3.5625 | 4 | """Codeforces 1131F
Somehow, recursive implementation of Union-Find Algorithm will hit stack overflow...
"""
from sys import *
n = int(stdin.readline())
parent, L, R, left, right = {}, {}, {}, {}, {}
for i in range(1, n + 1):
parent[i] = i
L[i] = R[i] = i
left[i] = right[i] = None
def find(i):
root... |
c49b8274518bd59b4ba0fdfc75e6370afaec562b | lydxlx1/icpc | /src/adventofcode/2021_04.py | 2,430 | 3.53125 | 4 | import sys
import math
def readln_str():
return input().split(" ")
def readln_int():
return [int(i) for i in readln_str()]
class Board:
def __init__(self, A):
self.A = A
self.visited = [ [False for _ in range(len(A[0]))] for _ in range(len(A))]
def place(self, num):
A = sel... |
36f9546b9a292d58f205ff22c9895fa65b0a70d9 | Meldanen/kcl | /scientific_programming/algorithm_optimisation/pathing.py | 10,269 | 3.578125 | 4 | from itertools import chain
import math
from algorithmType import AlgorithmType
import numpy as np
def getAdjustedImageArray(image, algorithmType, size=None):
"""
Returns an image with the best path based on the selected method
:param image: The image from which we'll look for the best path
:param siz... |
4b01cbf0895f080bfee152a52c3bcceed8b2df6e | nicoleta23-bot/instructiunea-if-while-for | /prb2.py | 151 | 3.921875 | 4 | import math
n=int(input("dati numarul natural nenegativ n="))
s=0
for i in range (1,n+1):
s+=(math.factorial(i))
print("suma 1!+2!+...n!= ",s) |
1a7fcc21c19fe743f7517e5221b4de3fe871cf7c | tbgdwjgit/python3 | /baseTest/first.py | 6,425 | 4.15625 | 4 | __author__ = 'Test-YLL'
# -*- coding:utf-8 -*-
import os
print("Hello Python interpreter!")
print("中文也没问题!")
print('翻倍'*3)
print('45+55')
print(45+55)
#注释
'''
多行
print("Hello World")
print('What is your name?') # ask for their name
myName = input()
print('It is good to meet you, ' + myName)
print('The length of you... |
ebc8d4374db54e557755d67cfe9d39631575fb3e | chm7374/linera_algebra_final | /linear_algebra_final/main.py | 3,078 | 3.625 | 4 | import numpy as np
import fractions
def create_matrix():
print("2x2 matrix:\n[ m11 m12 ]")
print("[ m21 m22 ]")
m11 = float(input("Enter the value of m11: "))
m12 = float(input("Enter the value of m12: "))
m21 = float(input("Enter the value of m21: "))
m22 = float(input("Enter the ... |
5c9d24c0cc24a7f0346fe7cee3239a467c51dd6d | zainiftikhar52422/Perceptron-learning-gates-given-theta | /perceptron learning And gate.py | 1,127 | 3.71875 | 4 | import random
def andGate():
# Or gate Learning
# in and gate you can increase decimal points as much as you want
weight1=round(random.uniform(-0.5,0.5), 1) # to round the out to 1 decimal point
weight2=round(random.uniform(-0.5,0.5), 1) # to round the out to 1 decimal point
print("Weighte... |
3009d64a201ffd4616985588111ec747f510925c | m-blue/prg105-Ex-16.1-Time | /Time.py | 331 | 4.09375 | 4 | class Time():
"""
This will hold an object of time
attributes: hours, minutes, seconds
"""
def print_time(hour, minute, sec):
print '%.2d:%.2d:%.2d' % (hour, minute, sec)
time = Time()
time.hours = 4
time.minutes = 30
time.seconds = 45
print_time(time.hours, time.minutes, time... |
2cee626ca8bbdd1c78751e9df019279d323d1e06 | Philngtn/pythonDataStructureAlgorithms | /Arrays/ArrayClass.py | 1,291 | 4.15625 | 4 | # # # # # # # # # # # # # # # # # # # # # # # #
# Python 3 data structure practice
# Chap 1: Implementing Class
# Author : Phuc Nguyen (Philngtn)
# # # # # # # # # # # # # # # # # # # # # # # #
class MyArray:
def __init__(self):
self.length = 0
# Declare as dictionary
self.data = {}... |
e96d19e436a77fcca9e16e143a81ea58eee15997 | Philngtn/pythonDataStructureAlgorithms | /String.py | 3,163 | 4 | 4 | # # # # # # # # # # # # # # # # # # # # # # # #
# Python 3 data structure practice
# Chap 0: String
# Author : Phuc Nguyen (Philngtn)
# # # # # # # # # # # # # # # # # # # # # # # #
# Strings in python are surrounded by either single quotation marks, or double quotation marks.
print("Hello World")
print('Hello Worl... |
9fb22d73c2c5983d48283c648ab5ef1527cb4c1e | Philngtn/pythonDataStructureAlgorithms | /LinkedList/LinkedListClass.py | 3,734 | 4.03125 | 4 | # # # # # # # # # # # # # # # # # # # # # # # #
# Python 3 data structure practice
# Chap 3: Linked List
# Author : Phuc Nguyen (Philngtn)
# # # # # # # # # # # # # # # # # # # # # # # #
from typing import NoReturn
class Node:
def __init__(self, data):
self.value = data
self.next = None
... |
280fbe40b133e0b47f101f5855014fdb1fcb8815 | Philngtn/pythonDataStructureAlgorithms | /Algorithm/Sorting/BubbleSort.py | 338 | 4.0625 | 4 | def bubble_sort(array):
count = len(array)
while(count):
for i in range(len(array) - 1) :
if(array[i] < array[i+1]):
temp = array[i]
array[i] = array[i + 1]
array[i + 1] = temp
count -= 1
a = [1,2,4,61,1,2,3]
bubble... |
875635c71286360aef3af5b485e87d195974fa32 | sepej/162P | /Lab6/main.py | 478 | 3.859375 | 4 | # Joseph Sepe CS162P Lab 6B
from helper import *
def main():
employees = []
# get number of employees to enter
print("How many employees work at the company?")
num_employees = get_integer(5, 10)
# create an employee and add it to the list for num_employees
for i in range(num_employees):
... |
bc1fb8b5ec979d6031e2dfaf934defff52e6d45b | sepej/162P | /Lab1/functions.py | 4,197 | 4.03125 | 4 | # Display instructions
def display_instructions():
print('\nWelcome to Tic-Tac-Toe\nTry to get 3 in a row!')
# Reset board, rewrites the board list with ''
def init_board(board):
for idx, value in enumerate(board):
board[idx] = ''
# Get the player name, Returns X or O
# Adds the possibility of letting... |
8557893e7488d2eb1993bbaf96b4e87a88a91bc4 | sepej/162P | /Lab6/Sepe_Lab6A/employee.py | 460 | 3.671875 | 4 | from person import *
class Employee:
# init employee class composition
def __init__(self, first_name = "", last_name = "", age = None):
self.__person = Person(first_name, last_name, age)
# return employee name
def get_employee_name(self):
return self.__person.get_first_name() + " "... |
6470b470180117635b5e5515ee39d08951ca1118 | Spencer-Weston/DatatoTable | /datatotable/typecheck.py | 4,509 | 4.125 | 4 | """
Contains type checks and type conversion functions
"""
from datetime import datetime, date
from enum import Enum
def set_type(values, new_type):
"""Convert string values to integers or floats if applicable. Otherwise, return strings.
If the string value has zero length, none is returned
Args:
... |
f371d7904f943099dd17d251df171b63592d8c9c | hhost-madsen/prg105-drawingObject | /House.py | 633 | 3.515625 | 4 | import turtle
bob = turtle.Turtle()
alice = turtle.Turtle()
def square(t):
for i in range(4):
t.fd(100)
t.lt(90)
square(bob)
square(alice)
def square(t, length):
for i in range(4):
t.fd(length)
t.lt(90)
square(bob, 100)
def polygon(t, n, leng... |
d3c36626dce89bafc3df9b8e63adaab05bdd4c30 | etx77/protostar-write-up | /alpha.py | 170 | 4.0625 | 4 | #!/usr/bin/env python
import string
# this program is generate string to calculate return address
text = ""
for c in string.ascii_uppercase:
text += c*4
print text
|
9d7b65b56e55b02b6ff598018da15c9ce16ac4e2 | yitu257/pythondemo | /filterSquareInteger.py | 902 | 3.765625 | 4 | #过滤出1~100中平方根是整数的数:
import math
def is_sqr(x):
return math.sqrt(x)%1==0
templist=filter(is_sqr,range(1,101))
newlist=list(templist)
print(newlist)
# 通过字典设置参数
site = {"name": "菜鸟教程", "url": "www.runoob.com"}
print("网站名:{name}, 地址 {url}".format(**site))
print(globals())
#a=input("input:")
#print(a... |
ba97831c540e5109dd1cfe338c885f4004b191b8 | avshrudai1/recommedation_engine_chrome | /main.py | 1,044 | 3.625 | 4 | # importing the module
import pandas as pd
import csv
import numpy
from googlesearch import search
# taking input from user
val = input("Enter your command: ")
#splitting the command to subparts
K = val.split()
T = len(K)
def queryreform():
search_name = 'Brooks'
with open('tmdb_5000_movies.csv', 'r')... |
b9bdcf609dd73187034012475399c0eda465fb79 | yarlagaddalakshmi97/python-solutions | /python_set1_solutions/set1-4a.py | 173 | 3.5 | 4 | '''
a) The volume of a sphere with radius r is 4/3pr3. What is the volume of a sphere with radius 5?
Hint: 392.7 is wrong!
'''
r=5
volume=(4/3)*3.142*(r*r*r);
print(volume) |
5ab66decbeb7f56a685d621d6eb7695d6021ac47 | yarlagaddalakshmi97/python-solutions | /python_practice/cmd-args1.py | 470 | 4.0625 | 4 | from sys import argv
if(len(argv)<3):
print("insufficient arguments..can't proceed..please try again..")
elif argv[1]>argv[2] and argv[1]>argv[3]:
print("argument 1 is largest..")
elif argv[1]>argv[2] and argv[1]<argv[3]:
print("argument 3 is largest..")
elif argv[2]>argv[1] and argv[2]>argv[3]:
print("... |
1b2b5047eaa337f94083a7b09e7b8103cc8170ca | yarlagaddalakshmi97/python-solutions | /python_practice/nested for loop.py | 792 | 4.0625 | 4 | '''
for i in range(1,10):
for j in range(1,i+1):
print(i,end=" ")
print("\n")
for i in range(1,10):
for j in range(1,i):
print(j,end=" ")
print("\n")
for i in range(1,10):
for j in range(1,i):
print("*",end=" ")
print("\n")
for i in range(1,5):
for j in range(1,5)... |
9c3f2d4f7813d13d83db9c1b19108ac1dc2260ed | yarlagaddalakshmi97/python-solutions | /python_set3_solutions/set3-8.py | 617 | 4.0625 | 4 | '''
8.Write a function called is_abecedarian that returns True if the letters in a word appear in alphabetical order (double letters are ok).
How many abecedarian words are there? (i.e) "Abhor" or "Aux" or "Aadil" should return "True" Banana should return "False"
'''
def abecedarian(words):
for i in words:
... |
0606f08dfe5a4f9f41b38c60330ed5de7852c64e | yarlagaddalakshmi97/python-solutions | /python_practice/factorial.py | 101 | 3.578125 | 4 | def fact(n):
if n>0:
return 1
else:
return n*fact(n-1)
res=fact(7)
print(res) |
e3814888ad456dbcd5e9fc3ae048ff8395dfad80 | yarlagaddalakshmi97/python-solutions | /python_set2_solutions/set2-6.py | 790 | 4 | 4 | '''
6.Implement a function that satisfies the specification. Use a try-except block.
def findAnEven(l):
"""Assumes l is a list of integers
Returns the first even number in l
Raises ValueError if l does not contain an even number"""
'''
'''
try:
list1 = list(input("enter list of integers..:\n"))
num = 0
... |
94c4554eea473193dff5415d66e7fe3253fd7d36 | yarlagaddalakshmi97/python-solutions | /python_set2_solutions/set2-4.py | 229 | 4.03125 | 4 | '''
4.Write a program that computes the decimal equivalent of the binary number 10011?
'''
string1='10011'
count=len(string1)-1
number=0
for char in string1:
number=number+(int(char)*(2**count))
count-=1
print(number)
|
7842f4fb35ab747fba9c8207b7eb4f1ec7a20a92 | MDLR29/python_class | /entrenamiento.py | 243 | 3.828125 | 4 | np=int(input(" usuarios a evaluar: "))
lm=1
sumed=0
while lm<=np :
genero=input(" cual es tu genero: ")
edad=int(input("escriba su edad: "))
lm = lm + 1
sumed=sumed+edad
promedio=sumed/np
print("el promedioes: ",promedio)
|
b515031a176de8d788207e9a53fafa3ae2e86559 | wnsdud4206/stockauto | /test2.py | 809 | 3.5625 | 4 | # from datetime import datetime
# t_now = datetime.now()
# t_9 = t_now.replace(hour=9, minute=0, second=0, microsecond=0)
# t_start = t_now.replace(hour=9, minute=5, second=0, microsecond=0)
# t_sell = t_now.replace(hour=15, minute=15, second=0, microsecond=0)
# t_exit = t_now.replace(hour=15, minute=20, second=0,micr... |
8e17ae60197afe42c01addf2cf79aafcae6cd01e | Abhra-Debroy/Udacity-ML-Capstone | /utilties.py | 6,889 | 3.6875 | 4 | ## Disclaimer : Reuse of utility library from Term 1 course example
###########################################
# Suppress matplotlib user warnings
# Necessary for newer version of matplotlib
import warnings
warnings.filterwarnings("ignore", category = UserWarning, module = "matplotlib")
#
# Display inline matplotlib ... |
358c68067412029677c59023d1f4b35af58c54ff | yuniktmr/String-Manipulation-Basic | /stringOperations_ytamraka.py | 1,473 | 4.34375 | 4 | #CSCI 450 Section 1
#Student Name: Yunik Tamrakar
#Student ID: 10602304
#Homework #7
#Program that uses oython function to perform word count, frequency and string replacement operation
#In keeping with the Honor Code of UM, I have neither given nor received assistance
#from anyone other than the instructor.
#--... |
189da51101c163022df6d8b417da004cba11c649 | annamunhoz/learningpython | /exercise01.py | 476 | 4 | 4 | # Exercise 01: create a python program that takes 2 values
# and then select between sum and sub. Show the result.
print("Submit your first number")
first_number = float(input())
print("Submit your second number")
second_number = float(input())
print("Choose the basic arithmetic: type SUM for sum or SUB for... |
904398e1e75159b8047dc94757e5a7ac0dfb16e8 | wxb-gh/py_test | /demo3.py | 363 | 3.796875 | 4 | # coding:gbk
colours = ['red', 'green', 'blue']
names = ['a', 'b', 'c']
for colour in colours:
print colour
for i, colour in enumerate(colours):
print i, ' -> ', colour
for colour in reversed(colours):
print colour
for colour in sorted(colours, reverse=True):
print colour
for name, colour in zip(na... |
7345117ef887ad5049d57e2688e1ce8d5601f001 | AndrewsDutraDev/Algoritmos_2 | /Tabelas/Teste.py | 886 | 3.53125 | 4 | from Tabelas import Table
tamanho_tabela = 5
tabela = Table(tamanho_tabela) # Inicializa a tabela com tamanho 3
tabela.insert("xyz", "abc") #Insere um valor e uma key
tabela.insert("dfg","dfb") #Insere um valor e uma key
tabela.insert("ffg","dfb") #Insere um valor e uma key
tabela.insert("hfg","dfb") #Insere um valor... |
5ccf9390ee5678a3c21acbd019df5673c7ff08a5 | AndrewsDutraDev/Algoritmos_2 | /Recursão/recursao2.py | 1,623 | 3.734375 | 4 | # Busca Encadeada Recursiva
def busca_encadeada():
if (len(lista) == 0):
return
else:
if (lista[0] == produto):
return cont
else:
cont = cont + 1
return busca_encadeada(lista[1:], produto, cont)
# Busca Linear Recursiva
def busca_linear_recursiva(list... |
3b2a0f4b8f0a7c1f9e480ded60b1a2aaf2c75603 | taniarebollohernandez/progAvanzada | /ejercicio7.py | 85 | 3.6875 | 4 | n = float(input('Inserta un numero positivo: '))
print('suma',int(((n*(n+1)/2))))
|
124e7250acd99e2668d71cf4717f0b54db63f7ab | taniarebollohernandez/progAvanzada | /ejercicio5.py | 792 | 4.03125 | 4 | #In many jurisdictions a small deposit is added to drink containers to encourage peopleto recycle them. In one particular jurisdiction, drink containers holding one liter or less have a $0.10 deposit, and drink containers holding more than one liter have a $0.25 deposit. Write a program that reads the number of contain... |
de52a7dc06b7dcd402a07e8d76a00f487f5e84b8 | kazimuth/python-mode-processing | /examples/misc/triflower/triflower.pde | 999 | 3.65625 | 4 | """
Adapted from the TriFlower sketch of Ira Greenberg
"""
#
# Triangle Flower
# by Ira Greenberg.
#
# Using rotate() and triangle() functions generate a pretty
# flower. Uncomment the line "# rotate(rot+=radians(spin))"
# in the triBlur() function for a nice variation.
#
p = [None]*3
shift = 1.0
fade = 0
fillCol... |
f6a909d7e0d878aaf314109c6b594bc80964da83 | LucasFerreira06/ExercicioProva4Dupla | /Questao2.py | 1,306 | 3.921875 | 4 | def adicionarSorteado(sorteados):
numAdd = random.randint(0, 100)
sorteados.append(numAdd)
print(sorteados)
def adicionarAluno(alunos, matricula, nome):
alunos[matricula] = nome
def exibirAlunos(alunos):
for chave, valor in alunos.items():
print("Matricula:", chave, "Aluno:", val... |
48c6bbe599a6444304766b3f23a51a43adb8103a | PrashantMittal54/Data-Structures-and-Algorithms | /String/Look-and-Say Sequence String.py | 927 | 4.09375 | 4 | # Look-and-Say Sequence
# To generate a member of the sequence from the previous member, read off the digits of the previous member
# and record the count of the number of digits in groups of the same digit.
#
# For example, 1 is read off as one 1 which implies that the count of 1 is one. As 1 is read off as “one ... |
5e1c85a492b786dcb674a436f3bb7fb9ad6f8559 | PrashantMittal54/Data-Structures-and-Algorithms | /LinkList/Deletion.py | 1,778 | 3.796875 | 4 | # Deletion by Value and Position
class Node:
def __init__(self, data):
self.data = data
self.next = None
class Linklist:
def __init__(self):
self.head = None
def delete_node_at_pos(self, pos):
cur = self.head
if pos == 0:
self.head = c... |
19013fbbb00b4c43c334ccf48a52b13c278932ee | PrashantMittal54/Data-Structures-and-Algorithms | /LinkList/Move Tail to Head.py | 1,023 | 3.859375 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Linklist:
def __init__(self):
self.head = None
def append(self, data):
new_node = Node(data)
curr = self.head
if curr is None:
self.head = new_node
... |
db4df4d10e3392349cb74bb36f5614c794e59eff | PrashantMittal54/Data-Structures-and-Algorithms | /Array/Arbitrary Precision Increment Array.py | 353 | 3.65625 | 4 | def plus_one(A):
A[-1] += 1
carry = 0
for x in range(1,len(A)+1):
if (A[-x] + carry) == 10:
carry = 1
A[-x] = 0
else:
A[-x] += carry
break
if A[0] == 0:
A[0] = 1
A.append(0)
return A
print(plus_one([2,9... |
5ee72868552ba9c802f653357564b241c00ca020 | bsspirit/mytool | /src/md5_rdict.py | 282 | 3.875 | 4 | # -*- coding: utf-8 -*-
#读字典文件
def dict_read(file):
lines = []
f = open(file,"r")
line = str(f.readline())
lines.append(line.split(','))
while line:
line = f.readline()
lines.append(line.split(','))
f.close()
return lines |
e5098b5399a500afcf7d5c140b2a5aed46d613f7 | hdjewel/Markov-Chains | /lw_markov.py | 3,792 | 3.765625 | 4 | #!/usr/bin/env python
from sys import argv
import random, string
def make_chains(corpus):
"""Takes an input text as a string and returns a dictionary of
markov chains."""
# read lines --- we don't need to read the lines. We are reading it as one long string
# strip newlines, punctuation, tabs and mak... |
5649dabbf39457cb906368ebc3591f964108713c | ijoshi90/Python | /Python/hacker_rank_staricase.py | 460 | 4.3125 | 4 | """
Author : Akshay Joshi
GitHub : https://github.com/ijoshi90
Created on 30-Oct-19 at 08:06
"""
# Complete the staircase function below.
"""def staircase(n):
for stairs in range(1, n + 1):
print(('#' * stairs).rjust(n))
"""
def staircase(n):
for i in range(n-1,-1,-1):
for j in range(i):
... |
cc0dbeccd0b265b09bf10f8aa12881d5e245acae | ijoshi90/Python | /Python/loop_while.py | 534 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Aug 20 20:47:00 2019
@author: akjoshi
"""
import time
# While Loop
x = 5
y = 1
print (time.timezone)
while x >=1:
print (time.localtime())
time.sleep (1)
print ("X is "+ str (x))
x-=1
while y <= 5:
time.sleep(1)
print ("Y is "+str(y))
... |
035e8af4d681ae42fa9ce31a9a22f2430aaa1531 | ijoshi90/Python | /Python/array_operations.py | 579 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Aug 25 18:21:20 2019
@author: akjoshi
"""
from array import *
arr = array('i', [])
l = int (input ("Enter the length : "))
print ("Enter elements")
for i in range (l):
x = int (input("Enter the " + str (i) + " value : "))
arr.append(x)
key = int (input ("Enter v... |
e3b10157dafc23d144d1a2db892f055a8f2d608f | ijoshi90/Python | /Python/prime_or_not.py | 391 | 4.09375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 24 16:40:46 2019
@author: akjoshi
"""
# Prime or not
number = int (input ("Enter a number to print prime numbers between 0 and number : "))
for num in range(2,number + 1):
# prime numbers are greater than 1
if num > 1:
for i in range(2,num):
if ... |
4c951106721a49a06d1e6a95f6461e5d8da18c44 | ijoshi90/Python | /Python/dictionary.py | 1,448 | 3.875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Aug 7 18:05:09 2019
@author: akjoshi
"""
#dictionary
dictionary_car = {
"Brand" : "BMW",
"Model" : "X1",
"Year" : "2020",
"Owner" : "Sanaksh"
}
print (dictionary_car)
# Accessing
this_dictionary = dictionary_car["Model"]
print (thi... |
75aabcea6f84ac4f13a725080c9858954074472c | ijoshi90/Python | /Python/maps_example.py | 1,385 | 4.15625 | 4 | """
Author : Akshay Joshi
GitHub : https://github.com/ijoshi90
Created on 19-12-2019 at 11:07
"""
def to_upper_case(s):
return str(s).upper()
def print_iterator(it):
for x in it:
print(x, end=' ')
print('') # for new line
#print(to_upper_case("akshay"))
#print_iterator("joshi")
# map() with st... |
00e0422cf41f40f287b9d72f42881b3afcb93ce1 | ijoshi90/Python | /Python/bubble_sort_trial.py | 364 | 3.984375 | 4 | """
Author : Akshay Joshi
GitHub : https://github.com/ijoshi90
Created on 09-01-2020 at 10:15
"""
list = [1, 3, 8, 9, 2, 5, 2, 3, 6, 5, 8, 10, 19, 12, 14, 7, 20]
def bubble (list):
for i in range(len(list)):
for j in range(i+1, len(list)):
if list [i] > list [j]:
list [i], list... |
6fc2d2631238c25c2d2e30ed887c4abbe8a0083c | ijoshi90/Python | /Python/set.py | 851 | 4.03125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Aug 6 20:40:20 2019
@author: akjoshi
"""
# Set Example
thisset = {"1 apple", "2 banana", "3 cherry","4 kiwi"}
print(thisset)
for i in thisset:
print (i)
print ("5 banana" in thisset)
print ("2 banana" in thisset)
thisset.add("5 Strawberry")
print (thisset)
thiss... |
3f28a1970aa458cfde8700646e1adecf1bb63634 | ijoshi90/Python | /Python/string_operations.py | 421 | 4 | 4 | """
Author : Akshay Joshi
GitHub : https://github.com/ijoshi90
Created on 17-12-2019 at 14:43
"""
string = "Hello, World!"
# Strings as array
print (string[2])
# Slicing
print (string[2:5])
# Negative indexing - counts from the end
print (string[-5:-2])
# Replace
print (string.replace("!","#"))
print((string.replac... |
2733ce9698980790023690e311fd8ab37e46fb8f | ijoshi90/Python | /Python/iterator.py | 383 | 3.859375 | 4 | """
Author : Akshay Joshi
GitHub : https://github.com/ijoshi90
Created on 18-12-2019 at 15:18
"""
# Iter in tuple
mytuple = ("apple", "banana", "cherry")
myit = iter(mytuple)
print(next(myit))
print(next(myit))
print(next(myit))
# Iter in strings
string = "Akshay"
myit1 = iter(string)
print(next(myit1))
print(next(... |
bbcdeafd4fdc92f756f93a1a4f990418d295c643 | ijoshi90/Python | /Python/variables_examples.py | 602 | 4.375 | 4 | """
Author : Akshay Joshi
GitHub : https://github.com/ijoshi90
Created on 26-Sep-19 at 19:24
"""
class Car:
# Class variable
wheels = 2
def __init__(self):
# Instance Variable
self.mileage = 20
self.company = "BMW"
car1 = Car()
car2 = Car()
print ("Wheels : {}".format(Car.wheels)... |
d17f55a72be36d93dd6c5dc553d312e5c26beda4 | romilpatel-developer/CIS2348_projects | /Homework 4/pythonProject24/main.py | 1,398 | 3.671875 | 4 | # Romilkumar Patel
# 1765483
# Homework 4 (Zybooks 14.13)
# Global variable
num_calls = 0
# TODO: Write the partitioning algorithm - pick the middle element as the
# pivot, compare the values using two index variables l and h (low and high),
# initialized to the left and right sides of the current elements being sort... |
69b5f175d2e3f8d6899fac183143e2ad75eef120 | Faeylayn/Phonebook-Excercise | /phonebook.py | 4,698 | 3.859375 | 4 | import sys
import os
def create_phonebook(phonebook_name):
filename = '%s.txt' % phonebook_name
if os.path.exists(filename):
raise Exception("That Phonebook already exists!")
with open(filename, 'w') as f:
pass
def add_entry(name, number, phonebook_name):
if not os.path.exists('%s.... |
f3cf383e0ff6bf61193548a33fec789b12ac58e5 | JuanMVP/repoPastis | /raspberry/motores1.py | 527 | 3.5 | 4 | import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BOARD)
Motor1A = 16
Motor1B = 18
Motor1E = 22
GPIO.setup(Motor1A,GPIO.OUT)
GPIO.setup(Motor1B,GPIO.OUT)
GPIO.setup(Motor1E,GPIO.OUT)
print "Going forwards"
GPIO.output(Motor1A,GPIO.HIGH)
GPIO.output(Motor1B,GPIO.LOW)
GPIO.output(Motor1E,GPIO.HIGH)... |
8c7beedf3a39bb9db58390f80df6e2beaa200ab4 | Fuzerii/CIV5-Drafter | /Drafter.py | 1,119 | 3.515625 | 4 | import random
Civit = ["Morocco", "Goths", "Greece", "Assyria", "Songhai", "Rome", "Germany", "Celts", "Poland", "Russia",
"Franks", "Persia", "Carthage", "Australia", "England", "Jerusalem", "Indonesia", "India",
"Sumeria", "Sweden", "Vietnam", "Ethiopia", "Denmark", "Norway", "Iroquoes", "Spain", "... |
e41d966e65b740a9e95368d7e5b9286fe587f2cb | donwb/whirlwind-python | /Generators.py | 537 | 4.28125 | 4 | print("List")
# List - collection of values
L = [n ** 2 for n in range(12)]
for val in L:
print(val, end=' ')
print("\n")
print("Generator...")
# Generator - recipie for creating a list of values
G = (n ** 2 for n in range(12))
#generator created here, not up there...
for val in G:
print(val, end=' ')
# Genera... |
08a9f4d381c95ec311c6df11fc06a3bc1ae7b10e | ashishkhiani/Daily-Coding-Problems | /challenges/problem_237/Node.py | 633 | 3.515625 | 4 | import json
from typing import List
class Node(object):
def __init__(self, name, children=None):
"""
:type name: str
:type children: List[Node]
"""
if children is None:
children = []
self._name = name
self._children = children
def __repr__(... |
3e9a48e9fc4349e668fe26e26a55f38aa6de3068 | ashishkhiani/Daily-Coding-Problems | /challenges/problem_001/unit_test.py | 1,191 | 3.515625 | 4 | import unittest
from challenges.problem_001.solution import problem_1
class SumsToK(unittest.TestCase):
def test_example_1(self):
num_list = [10, 15, 3, 7]
k = 17
actual = problem_1(num_list, k)
self.assertTrue(actual)
def test_example_2(self):
num_list = [10, -15, 3,... |
96e9b049e63ad519eebcf39dc26a6e73f684b716 | amanda-posey/python_basics | /basic_loops.py | 365 | 3.765625 | 4 | monday_temperatures = [9.1, 8.8, 7.6]
for temperature in monday_temperatures:
print(round(temperature))
#for letter in 'hello':
# print(letter)
colors = [11, 34.1, 98.2, 43, 45.1, 54, 54]
for color in colors:
if isinstance(color, int):
print(color)
for color in colors:
if (isinstance(color, ... |
9dbe30b304d60b787ecea043d7fa43aa558cc4d8 | marcospb19/python_brasil_19_talk | /arquivos/1.py | 350 | 3.546875 | 4 | import re
# Ver todas as funções e constantes
# print(dir(re))
from re import findall
print(re.findall("f" , "fff"))
result = re.findall("xu" , "xu")
print(type(result) , len(result))
print(result)
result = re.findall("xu" , "xuxu")
print(type(result) , len(result))
print(result)
# Como é feita a leitura?
print... |
cbc5fc685a74b4ebd5ec15b4f022adb78c8625a2 | pradeesi/IoT_Framework | /google_drive_test.py | 1,845 | 3.578125 | 4 | from google_drive.google_drive_upload import gDrive
Obj = gDrive()
#Upload a file (if file is not in current directory pass full path)
print "Uploading file on Google Drive:"
print "File ID:"
file_id = Obj.upload_File('test.txt')
print file_id
#Upload a file in a Folder (if file is not in current directo... |
46ae324b58a1f33734ef18f4828db11599d408fa | marwa-mohamed-dev/Matrice_couts_alignements_Python | /DM5.py | 4,040 | 3.578125 | 4 | #########################################################
# DM5 : matrice de score d'alignement #
#########################################################
#Introduction DM 5
import time
print("Bienvenue dans notre programme!!!")
time.sleep (1)
print("Celui-ci permettra de calculer les coûts... |
c7c0ad43ffa4af13130fe893b0e33a8c730f6fcf | hemakl/reader-flask-project | /readerwishlist/booklist.py | 2,032 | 3.5625 | 4 | """
booklist.py
Adding or listing all books associated to one user
endpoint - /users/<id>/books
"""
from readerwishlist.db import query_db, get_db
from flask import (g, request, session, url_for, jsonify)
from flask_restful import Resource, reqparse
class BookList(Resource):
def get(self, user_id):
""" retrieve... |
d3dd23e8f5e164ca4378e7817f983fca0bf89e1b | DylanGuidry/PythonFunctions | /dictionaries.py | 1,098 | 4.375 | 4 | #Dictionaries are defined with {}
friend = {
#They have keys/ values pairs
"name": "Alan Turing",
"Cell": "1234567",
"birthday": "Sep. 5th"
}
#Empty dictionary
nothing = {}
#Values can be anything
suoerhero = {
"name": "Tony Stark",
"Number": 40,
"Avenger": True,
"Gear": [
"f... |
5db196a739555685758fa3ff22e38a948b114b99 | kkandiah/Prime-Factors_Revisited | /tests/test_prime.py | 1,634 | 4.03125 | 4 | #test_prime.py
"""
A unit test module for prime module
"""
import prime
def test_valueerror():
"""
asserts that when prime_factors is called with a data type
that is not an integer (e.g. a string or float), a ValueError is raised.
"""
p_1 = prime.PrimeFactors('a')
assert p_1.number == ValueEr... |
1251944a75d11f26744bd86a72b32ca6cf6610ad | amisha-tamang/json | /question3.py | 188 | 3.625 | 4 | # Q.3 Python object ko json string mai convert karne ka program likho?
import json
a={'nisha': 3 , 'komal': 5 , 'amisha': 8 , 'dilshad': 12}
mystring = json.dumps(a)
print(mystring)
|
109aebf88bfac4cd1e7e097b085d3a3f909923fa | helinamesfin/guessing-game | /random game.py | 454 | 4.15625 | 4 | import random
number = random.randrange(1,11)
str_guess= input("What number do you think it is?")
guess= int(str_guess)
while guess != number:
if guess > number:
print("Not quite. Guess lower.")
elif guess < number:
print("Not quite. Guess higher.")
str_guess= input("W... |
2b36b5442c034edfccbeeed712c571f63b55c2e1 | fhylinjr/2020-PYTHON-PROJECTS | /Hash Tables.py | 3,080 | 3.921875 | 4 | class HashTables:
def __init__(self, size): # constructor which initializes object.
self.size = size # set number of buckets you want in your hashmap
self.hashtable = self.create_buckets() # creates hashtable with createbucket method.
def create_buckets(self):
return [[] for i ... |
a2fd87ae78e812b344d5eedc9a2547cf9270eaf8 | KiD21606/PicoCTF | /Codes and Commands/CaesarDecoder.py | 345 | 4.09375 | 4 | Ciphertext = "ynkooejcpdanqxeykjrbdofgkq"
Ciphertext = Ciphertext.upper()
Ciphertext = [ord(Letter)-65 for Letter in Ciphertext]
for Shift in range(26):
print("Shift:{}, plantext:{} or {}".format(
Shift, "".join([chr( (Int+Shift)%26 + 65 ) for Int in Ciphertext]), "".join([chr( (Int+Shift)%26 + 97 ) for In... |
723023c06cb8f8cdbdcaa543fa18ad3a2984affe | johnywith1n/InterviewStreet | /Equations/equations.py | 1,538 | 3.71875 | 4 | import sys
def getPrimeNumbers (upperBound):
result = [True] * (upperBound + 1)
primes = [i for i in range(2, upperBound+1) if i*i <= upperBound]
for i in primes:
if result[i]:
for j in range(i*i, upperBound + 1, i):
result[j] = False;
return [i for i in ran... |
9bbdd57d6ea5652874b270fc2fb118ad94d96fd4 | asktalk/Ubuntu16.04-llaptop-Code | /PycharmProjects/TestPython20180515/Python3_1.py | 3,504 | 3.84375 | 4 | #! /usr/bin/python3
if True:
print("XiaoGongwei10")
print("good")
else:
print("XiaoXiao")
print("AAA")
all_array = {"Xiao","Gong","Wei"}
#input("\n\ninput Enter:")
import sys
x = "runoob"
sys.stdout.write(x + "\n")
if 1==2:
print(x)
elif True:
print(x + "aaa")
else:
print("Error")
print("a"); p... |
69c02edda8ceb27210487f5ce97bbe69a595be44 | mapkn/Other-Examples | /dictionaries.py | 3,474 | 4 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Apr 17 11:38:32 2018
@author: patemi
"""
#https://chrisalbon.com/python/basics/compare_two_dictionaries/
# empty dictionary
my_dict = {}
# dictionary with integer keys
my_dict1 = {1: 'apple', 2: 'ball'}
# dictionary with mixed keys
my_dict2 = {'name': 'J... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.