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 |
|---|---|---|---|---|---|---|
6d14dc8c0cd59fd0a69bf57f98bd0b685729a507 | js4683/CS172 | /Week 7/maze.py | 1,522 | 3.90625 | 4 | from room import Room
class Maze:
#Inputs: Pointer to start room and exit room
#Sets current to be start room
def __init__(self,st=None,ex=None):
#Room the player starts in
self.__start_room = st
#If the player finds this room they win
self.__exit_room = ex
#What room is the player currently in
self.__cu... |
d96aeb80b95436660630262c61cef3cabfbef7b0 | js4683/CS172 | /Week 4/lab4.py | 3,114 | 3.765625 | 4 | from monster import Satyaa, Ibe
from monster2 import Jashan, Hamza
import random
#This function has two monsters fight and returns the winner
def monster_battle(m1, m2):
#first reset everyone's health!
m1.resetHealth()
m2.resetHealth()
#next print out who is battling
print("Starting Battle Betwee... |
3829ef10225249115d5a376bc5e7f9830cb5e5c0 | js4683/CS172 | /Homework 1/main.py | 3,944 | 3.890625 | 4 | #File: main.py
#Purpose: Homework for CS172
#Date: April 15, 2019
#Author: Jashanpreet Singh
from question import Question
#Set of questions stored in a list which are called by using the list's index
QuestionSet = [Question("Which of the following is a synonym for good?", "Work", "Bad", "Stupid", "Nice", "d"),
Q... |
260e63255da207d2cd0302588349827eb8322fd3 | PanZeYong/Python | /Python 编程从入门到实践/第 11 章 测试代码/test_employee.py | 426 | 3.546875 | 4 | import unittest
from employee import Employee
class TestEmployee(unittest.TestCase):
def setUp(self):
self.employee = Employee('Julian', 'Pan')
def test_give_default_raise(self):
salary = self.employee.give_raise()
self.assertEqual(10000, salary)
def test_give_custom_raise(self):
... |
476f0f5deb87c36f8e1064ef6e37932ccdd292ab | PanZeYong/Python | /Python 编程从入门到实践/第 9 章 类/electric_car.py | 589 | 3.6875 | 4 | from car import Car
from battery import Battery
class ElectricCar(Car):
"""电动汽车的独特之处"""
def __init__(self, make, model, year):
"""初始化父类的属性,再初始化电动汽车特有的属性"""
super().__init__(make, model, year)
self.battery = Battery()
def fill_gas_tank(self):
"""电动汽车没有邮箱"""
print("T... |
2b365887a3fa20d9a924163a12557224f46b7852 | izayoi-ami/algorithm | /codility/python/longest_password.py | 786 | 3.6875 | 4 | ##
class LongestPassword:
test_cases = {
"case1":{
"case": ("test 5 a0A pass007 ?xy1",),
"ans": "pass007",
},
}
@classmethod
def solution(self, S):
def is_valid_password(word):
from string import digits
if not word.isalnum(): retur... |
dddd4adfd6808c1830d2ebfca982b007d2c85fc8 | mariololo/EulerProblems | /problem25.py | 255 | 3.5625 | 4 |
import sys
def first_fib_digits(n_digits = 1000):
F_n1 = 1
F_n2 = 1
i = 2
while len(str(F_n2)) < int(n_digits):
c = F_n2
F_n2 += F_n1
F_n1 = c
i += 1
return i, F_n2
if __name__ == '__main__':
print(first_fib_digits(sys.argv[1])) |
81a32bc4a6aa1876b5555ac14271ec3d347d6b3d | mariololo/EulerProblems | /problem17.py | 1,201 | 4.03125 | 4 | """
If the numbers 1 to 5 are written out in words:
one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
If all the numbers from 1 to 1000
(one thousand) inclusive were written out in words, how many letters would be used?
"""
ONES = ["zero", "one", "two", "three", "four", "fiv... |
df78a002fdb80aa75916d98777f5036f53c24082 | mariololo/EulerProblems | /problem41.py | 1,162 | 4.25 | 4 | """
We shall say that an n-digit number is pandigital if it makes use of
all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime.
What is the largest n-digit pandigital prime that exists?
"""
def is_pandigital(n):
digits = []
for dig in str(n):
if dig in digits:
return ... |
873126169befd287e7c63c45dbb1da05289221a3 | 06kaylee/Automation-Scripts | /PDF/cars.py | 2,473 | 3.71875 | 4 | import json
import locale
import sys
import emails
import reports
import pathlib
def load_data(filename):
"""Reads json data into a python object (dictionary)"""
with open(filename) as json_file:
data = json.load(json_file)
return data
def format_car(car):
"""Given a car dictionary, returns a formatted n... |
28785e79791f208e24240290142fd8bb87680e92 | boquer/Python | /condicionales.py | 477 | 4.125 | 4 | numero = int(input("Digite un número: "))
if numero>0: #Si el número es mayor a cero, imprime lo de abajo.
print("El número que ingresó es positivo")
#Si el número no es mayor a cero, pasa a elif
elif numero==0:#Si el número es igual a cero, imprime lo de abajo.
print("El número que ingresó es cero")
#Si n... |
2ba4964b38386b5bccaae1e8c04893276bcab164 | dquejim/PythonPOO_DavidQuesada_2DAM | /Ejercicio03/Videojuego.py | 1,729 | 3.765625 | 4 | class Videojuego:
titulo = ''
horas_estimadas = 10
entregado = False
genero = ''
compania = ''
entregados_totales = 0
def __init__(self,titulo,horas_estimadas,genero,compania):
self.titulo = titulo
self.horas_estimadas = horas_estimadas
self.entregado
self.ge... |
05da4dd28a64b06ea3c827850c6c8c9816972561 | AshTiwari/Standard-DSA-Topics-with-Python | /Matrix/Search_Element_in_a_Sorted_Matrix.py | 581 | 4.09375 | 4 | # Search an element in a matrix which is sorted by rows.
from binarySearch import lessThanEqualBinarySearch
def binarySearch(matrix, m, n, element):
i = j = 0
row_begs = [matrix[i][0] for i in range(m)]
row_no = lessThanEqualBinarySearch(row_begs, element)
if row_no != -1:
for i in range(0,n):
if matrix[row_... |
97cc0a8e13f2517cd8c55c0741cc5d94bfa4d7ea | AshTiwari/Standard-DSA-Topics-with-Python | /Array/Array_Merge_Sorted_Array_in_O(1)_Space.py | 772 | 4.28125 | 4 | # Merge two sorted array in O(1) time.
from binaryInsertion import binaryInsertion
######### Increase the Efficiency by using binaryInsertion function to add element in sorted arr2 ###########
def addElement(arr,element):
index = 0
# alternate way is to use binaryInsertion.
while(index < len(arr)-1):
if arr[in... |
d5fa1e99347b68639179a90f25072dfea85cba49 | AshTiwari/Standard-DSA-Topics-with-Python | /Array/Array_Merge_Intervals_Array.py | 893 | 4.03125 | 4 | # merge overlapping interval in the intervals array.
def insertionSort(intervals, n):
for i in range(1,n):
j = i
while(j>0 and intervals[j][0] < intervals[j-1][0]):
intervals[j], intervals[j-1] = intervals[j-1], intervals[j]
j -= 1
return intervals
def simpleMerge(intervals,n):
i = 0
while(i < n-1):
i... |
34c6989274bb41c29de722fe303843dd11d22cce | quatroka/python_para_zumbis | /lista_de_exercicios_1/questao07.py | 198 | 4.03125 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
temp = float(input('Digite a temperatura em Celcius(°C):'))
temp_em_f = ((9 * temp) / 5) + 32
print('Temperatura em Fahrenheit(°F): %.2f.' % temp_em_f)
|
9ac6bd60ecd7e86baa27f8bc470d21962d802818 | Astromax/miscellaneous_atlas | /Walkinator.py | 1,715 | 3.5625 | 4 | #!/usr/bin/env python
import os
import math
def Walkinator():
July_steps = [10156, 10348, 10467, 8489, 9889, 13185, 13135, 12643, 10340, 17668, 9638, 14728, 14015, 10848, 11753, 16085, 11503, 10078, 12510, 22763, 13379, 12406, 11012, 14061, 11554]
August_steps = [6626, 19069, 17266, 13865, 13605, 12403, 6559,... |
620373a29ec0380c1c2d4aaf6378ea5658c910fc | butterflylady/exercism | /bank-account/bank_account.py | 1,169 | 3.71875 | 4 | """
Exercism solution for "bank-account"
"""
class BankAccount:
def __init__(self):
self.balance = 0
self.state = "unopened"
def error_if_not_opened(self):
if self.state == "unopened":
raise ValueError("Account is not opened!")
elif self.state == "closed":
... |
8709771c3fa755bc510d848559d7b9c30ae80902 | UnifoxPythonSquad/realsung | /Section5/class.py | 1,034 | 3.734375 | 4 | #문제1
class Calculator:
def __init__(self):
self.value = 0
def add(self, val):
self.value += val
cal = Calculator()
cal.add(3)
cal.add(4)
print(cal.value)
#문제2
class Calculator2:
def __init__(self, init_value=0):
self.value = init_value
def add(self, val):
self.value += v... |
0084ebc213fa0cdefe5babe1e9996888a8af0439 | UnifoxPythonSquad/realsung | /Section4/function.py | 585 | 3.5 | 4 | #문제1
def is_odd(num):
if num % 2 == 0:
print("짝수")
else:
print("홀수")
is_odd(3)
#문제2
def avg(*args):
result = 0
for i in args:
result += i
return result / len(args)
print(avg(1,2,3,4,5,6,7,8,9,10))
#문제3
def ggdan(j):
for n in range(1,10):
print(n*j)
ggdan(3)
#... |
2c48c54e0e993a74f445b340fc74c7c2f79a9721 | UnifoxPythonSquad/realsung | /Section3/if_sentence.py | 698 | 3.78125 | 4 | #문제1
money = 5000
card = False
if money >= 4000 or card:
print("택시를 탈 수 있습니다.")
else:
print("택시를 탈 수 없습니다.")
#문제2
lucky_list = [1, 9, 23, 46]
if 23 in lucky_list:
print("야호")
#문제3
num = 123782193799
if num % 2 == 0:
print("짝수")
else:
print("홀수")
#문제4
i = "나이:30,키:180"
ex = i.split(",")
age = ex[0... |
69b48ce89a8c80ce4ae6cb3b1b21da1bdc4a4604 | avdhoot-1/pythoncode | /Percentgain.py | 449 | 3.765625 | 4 | a =input('what was the purchase price? ')
b =input('what was the sale price ? ')
c = float(b) - int(a)
if c>0:
print ('net profit was', c)
else: print ('net loss was',c)
d = ((float(c)/float(a))*100)
print ('percent gain /loss was',d)
x =input('what was the investment amount ')
y =(float(d)*(float(x))/100)
... |
8a6e26de0ea0546311716943ac322c207d6cfc58 | Ferranm/M03-OFIMATICA | /Python/ejercicio-edad-3.py | 162 | 3.640625 | 4 | # coding: utf8
# Ferran March Azañero
# 08/02/2018
edad=input("Introduce la edad:")
if (edad>=18 and edad<=23) or (edad==17):
print "Puedes entrar en la sesión de jovenes"
|
3b1f06e7ce6eb3dcb001d4e735f25f0a99e8ec31 | busraugurx/pythonProject18 | /denklemin_köklerini_bulma.py | 376 | 3.78125 | 4 | print("2. dereceden 1 bilinmeyenli denklemin köklerini hesaplama")
"denklem= a*x^2 + bx + c"
"delta= b*b-4*a*c"
a=int(input("a değerini giriniz:"))
b=int(input("b değerini giriniz:"))
c=int(input("c değerini giriniz:"))
delta= b * b - 4 * a * c
x1= (-b - delta ** 0.5) / (2 * a)
x2= (-b + delta ** 0.5) / (2 * a)
pr... |
0e8f62a86e0f3c706acc111bfd844e5d87e460e2 | nov314k/exercism | /python/matching-brackets/matching_brackets.py | 410 | 3.9375 | 4 | def is_paired(input_string):
matching_brackets = {
')': '(',
']': '[',
'}': '{'
}
stack = []
for c in input_string:
if c in matching_brackets.values():
stack.append(c)
elif c in matching_brackets.keys():
if not stack or stack[-1] != matchin... |
6a1eca4e0de88bbc0011063abdc51225226daf07 | nov314k/exercism | /python/anagram/anagram.py | 214 | 3.75 | 4 | def find_anagrams(word, candidates):
return [candidate
for candidate in candidates
if sorted(candidate.lower()) == sorted(word.lower())
if candidate.lower() != word.lower()]
|
e606a5f5731f269c80d2729a51ec98de3f05e89b | vinf100/ProgCompPractice | /palindromes.py | 283 | 3.921875 | 4 | import re
phrase = input('Input phrase')
def print_palindrome(line):
text = re.sub('\W+', "", line.lower())
rev_text = text[::-1]
if text == rev_text:
print('Yes, "{}"'.format(line))
else:
print('No, "{}"'.format(line))
print_palindrome(phrase)
|
b07bc6365e0f55724f5b36c0872a06f0d48ffefc | FisicaComputacionalOtono2018/20180816-clase-diagramadeflujoparprimo-israelgal | /primo2.py | 333 | 3.921875 | 4 | import math
def isPrimeFor(num):
flag=True
raiz=int(round(math.sqrt(num),0))
for i in range (2,raiz+1):
if num%i==0:
flag=False
break
return flag
num=input("<Numero: ")
if num==1:
print("No es primo")
if num==2:
print("Es Primo")
if num>2:
if isPrimeFor(num):
print("ES Primo")
else:
print("No... |
90de273a332914dee97a1a2e12d276e9899a1693 | AnaTomomi/tscfat | /build/lib/tscfat/Utils/file_names.py | 1,171 | 3.5 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 22 11:26:36 2021
@author: ikaheia1
A helper class for storing the filenames / paths used in the analysis.
The filenames are stored in the __dict__ dictionary by using an alias name as
the key.
"""
class FileNames(object):
def list_filen... |
020ea2219ecf9d45e43d0b231b66e803b1439fcc | AnaTomomi/tscfat | /build/lib/Utils/analysis_parameters.py | 1,142 | 3.84375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 22 11:26:36 2021
@author: ikaheia1
A helper class for storing the parameters used in the analysis.
The parameters are stored in the __dict__ dictionary by using an alias name as
the key.
"""
class AnalysisParameters(object):
def list_p... |
d76bd9070633b80888b79051c02fa61c190119c1 | Terfno/learn_DL | /2/logic.py | 447 | 3.59375 | 4 | def AND(x1, x2):
w1, w2, theta = 0.5, 0.5, 0.7
tmp = x1 * w1 + x2 * w2
if tmp > theta:
return 1
else:
return 0
def NAND(x1, x2):
w1, w2, theta = -0.5, -0.5, -0.7
tmp = x1 * w1 + x2 * w2
if tmp > theta:
return 1
else:
return 0
def OR(x1, x2):
w1, w2, theta = 1, 1, 0.5
tmp = x1 * w1 ... |
f0219858a06073f5d8d9fff419589d9b5bb8b42b | techemmy/Python-Beginner-Projects | /calculator.py | 123 | 3.734375 | 4 | from math import *
while True:
expr = input(":>")
if not expr:
continue
if expr == "q":
break
print(eval(expr))
|
5ff9075958d744680e14f1d9acdae69bd3e81f90 | techemmy/Python-Beginner-Projects | /rock_paper_scissors.py | 921 | 3.953125 | 4 | import random
MOVES = ['R', 'P', 'S']
def get_player_input():
move = input("Enter your move (R, P, S)?").upper()
while move not in MOVES:
move = input("Enter your move (R, P, S)?").upper()
return move
def check_winner(p1, p2):
if (p1 == 'R' and p2 == 'S') or\
(p1 == 'S' and p2 == 'P') ... |
ec5da24a0bad19bb535c23a0dac0babd527210a2 | govindansriram/Lenge | /backend/StrengthCard.py | 1,345 | 3.53125 | 4 | from StrengthWorkouts import StrengthWorkouts
class StrengthCard:
def __init__(self, difficulty):
self.difficulty = difficulty
self.exercise_one = StrengthWorkouts(self.difficulty)
self.exercise_two = StrengthWorkouts(self.difficulty)
self.exercise_three = StrengthWorkouts(self.dif... |
81514921ea8894f1d58bdbc7d6cf646038164739 | NatalieTehranchi/learning_python | /codons.py | 268 | 3.96875 | 4 | #!/usr/bin/env python3
# Print out all the codons for the sequence below in reading frame 1
# Use a 'for' loop
dna = 'ATAGCGAATATCTCTCATGAGAGGGAA'
codon= 3
for i in range (0,len(dna)-codon+1,3):
print(i, dna[i: i+3])
"""
ATA
GCG
AAT
ATC
TCT
CAT
GAG
AGG
GAA
"""
|
00746b3817bcaa3d2ae727bf2f811ff4bd0bae28 | avishith/hotel | /CHOISE.py | 818 | 3.671875 | 4 | #MAIN PAGE
import LOGIN
import newhotel
from os import system
from time import sleep
#for clear the screen
def clear():
_=system('clear')
#prgm start from here
print('1. Sign In')
print('')
print('2. Login')
print("")
# a loop is created for avoid invalid entry
loop=1
cut=1
while cut==loop:
choise=int(input("P... |
6d8253563345953b1a9e5d0a8e3cb79e0ad9055f | MarauderPixie/MethAI_warehouse_task | /algorithms/simulated_annealing.py | 4,849 | 4.09375 | 4 | """
Class generates a neighborhood and explores it using
simulated annealing algorithm.
"""
import random
import numpy as np
import math
from warehouse import Warehouse
class SimulatedAnnealing(Warehouse):
def __init__(self, filepath_warehouse, filepath_order):
self.warehouse = Wareh... |
1e23a602ac5270671b8417c35021507f64484edb | ParulProgrammingHub/assignment-1-henitvaghasiya | /pr2.py | 147 | 4.1875 | 4 | PI=3.14
r=input("enter radius of circle :")
area=PI*r*r
circum=2*PI*r
print "area of circle :",area
print "circumferemce of circle :",circum
|
76b916d3eda53fb976697cb745c469efcf30bb39 | DKLynch/HackerRank-Challenges | /Algorithms/Implementation/Grading Students/gradingStudents.py | 304 | 3.578125 | 4 | #Problem URL: https://www.hackerrank.com/challenges/grading/problem
def gradingStudents(grades):
for x in range (0, len(grades)):
if(grades[x] >= 38):
difference = 5 - (grades[x] % 5)
if(difference < 3):
grades[x] += difference
return grades
|
7444938415d3fe12d27e9e370dd7a5b3f1275b1b | GeoregTraynro/Homeauto-stuff | /led.py | 379 | 3.53125 | 4 | import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(4, GPIO.OUT)
GPIO.output(4, GPIO.HIGH)
sleep(0.5) # Waits for half a second
GPIO.output(4, GPIO.LOW)
GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP)
state = GPIO.input(26)
while True:
if state == False:... |
f4f8f20e19f1c8757d4969b7174c05a9becc9b50 | aqfaridi/Competitve-Programming-Codes | /SPOJ/SPOJ/SOLDIERS.py | 1,073 | 3.78125 | 4 | """
SPOJ Problem Set (classical)
10334. SOLDIERS
Problem code: SOLDIERS
Soldiers
Problem Statement:
How many maximum number of soldiers(chess) can be placed in a mxn
board so that none of them attack the other.
Input Specification:
The first line is an integer t, denoting the number of test cases.
Each test case i... |
835cfbcb2ebd756769226a1b3745427f70c17c50 | LucioOSilva/HackerRankPython-PS | /LinkedList-PrintTheElementsOfALinkedList.py | 1,868 | 4.375 | 4 | """
If you're new to linked lists, this is a great exercise for learning about them. Given a pointer to the head node of a
linked list, print its elements in order, one element per line. If the head pointer is null (indicating the list is
empty), don’t print anything.
Input Format:
The first line of input contains "n"... |
385c54498e3ee4a5adddee575990b9e5975749af | SunKing2/pythonlearningstuff | /diveintopython/humansize.py | 1,024 | 3.515625 | 4 | '''
Created on Sep 19, 2017
@author: louie
'''
SUFFIXES = {
1000: ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
1024: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'],
}
def approximate_size(nbytes, real_1024=True):
'''Returns string showing approximate bytes converted to KiB, KB, MiB, or... |
73ad5466badc49b6342db1f2ddd6ba321c99ddcf | li459461891/Algorithms | /hanoi/hanoi.py | 1,050 | 4.09375 | 4 | """
Tower of Hanoi, is a mathematical puzzle which consists of three towers (pegs)
and more than one rings is as depicted
The mission is to move all the disks to some another tower without violating
the sequence of arrangement. A few rules to be followed for Tower of Hanoi are
Only one disk can be moved among t... |
9ee970f71b578eb3b4cb5d19bd7e9f68de843390 | JustinJmnz/SodukuSolver | /Soduku Solver/Soduku/main.py | 4,760 | 4.03125 | 4 | '''
Created on Sep 26, 2014
@author: justin
'''
import sys
import numpy as np
from __builtin__ import False, str
from numpy.matrixlib.defmatrix import matrix
global finished
def next_coordinate(row, col):
"""
Returns the next coordinate to explore in a sudoku puzzle, regardless of
whether or... |
c8e7514daf194b0f48b6ec69b987a36db36635e7 | Shubham9123/py | /main.py | 437 | 3.84375 | 4 | class Person:
def __init__ (self, name, surname, age):
self.name = name
self.surname = surname
self.age = age
def greetings (self):
print ("Hello", self.name, self.surname + ". Glad you are", self.age,"years old.")
name = input("Enter your name: ")
surname = input("Enter your... |
8db7becd41ea2f645a1f523a662ca9715da4121b | MrKonrados/PythonTraining | /Change Calculator/change_calc.py | 1,369 | 4.3125 | 4 | """
BASIC GOAL Imagine that your friend is a cashier, but has a hard time counting back change to customers.
Create a program that allows him to input a certain amount of change, and then print how how many quarters, dimes,
nickels, and pennies are needed to make up the amount needed.
For example, if he inputs 1.47... |
393492c970c349b49cc63d282ab8cc521308f462 | shebilantony/3numlar | /3lar.py | 262 | 4.25 | 4 | num1=float(input("Enter first no:"))
num2=float(input("Enter second no:"))
num3=float(input("Enter third no:"))
if(num1>num2) and (num1>num3):
largest=num1
elif(num2>num1) and (num2>num3):
largest=num2
else:
largest=num3
print("the largest no is",largest)
|
5de9cf7cd68f84c4fda940bf17dd45ca39a6189e | mengqqq/-pracitce | /Keras Lab准备录取学生.py | 2,255 | 4.0625 | 4 | #研究数据
#数据集包含以下列:
#学生GPA(成绩)
#GRE考试成绩(考试)
#级别(1-4)
import pandas as pd
data=pd.rad_csv("http://www.ats.ucla.edu/stat/data/binary.csv")
print(data)
#在这里可以看到第一列是标签y它对应于接受、拒绝。即标签1表示学生被录取,标签0表示学生不被录取
#预处理数据
#看起来的情况是学生的成绩越好,越有可能被录取。等级与此有关。所以要做的是,对排名等级进行一次性彪马,6个输入变量是:
#考试(GPA)
#成绩(GRE)
#等级1
#等级2
#等级3
#等级4
#最后4个输入僵尸二进制变量,如果学生具... |
84227468d678c5fcb4d358e867574601245ae26c | afprati/python_summer2020 | /HW/HW3/aprati_hw3.py | 14,418 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Sep 4 15:17:35 2020
@author: miame
"""
"""
Assignment:
For the purposes of this exercise, we define three types of Twitter users.
- Layman: Users with less than 100 followers
- Expert: Users with 100-1000 followers
- Celebrity: Users with more than 1000 followers
Using ... |
22e88a2a55c095a5375f026a4676c0af5637a19a | afprati/python_summer2020 | /Day8/Lecture/day08p1.py | 5,224 | 4.34375 | 4 | # Python - 2020 Summer Course
# Day 8
# Topic: More on SQL and Database (Jin's question on True/False)
# Instructor: Patrick Cunha Silva
# Former Instructors: Ryden Buttler, Erin Rossiter
# Michele Torres, David Carlson, and
# Betul Demirkaya
# First Instructor: Matt Dickenson
# ... |
f67cc7087e6ff253c855b21ecb61df5b0525e131 | afprati/python_summer2020 | /HW/HW4/aprati_hw4.py | 7,662 | 3.75 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Sep 12 10:54:13 2020
@author: miame
"""
import matplotlib.pyplot as plt
import time
import numpy as np
import statistics
import os
os.chdir('C:/Users/miame/Documents/GitHub/python_summer2020/HW/HW4')
# different efficiencies reference:
# https://www.geeksforgeeks.org/time-... |
bae6fac1a923ae131bebcac02a7fa1a5ac8d8746 | parth2347/python | /csv_file.py | 1,674 | 3.5625 | 4 | import csv
import re
import datetime
from itertools import islice
b=[]
def file_reader(obj):
reader=csv.reader(obj)
next(reader)
for row in reader:
s="".join(row)
x=re.findall(r'\$(.*)\$',s) #use of regular exprssion to extract the email address
y="".join(x)
b.app... |
c91fd4ed4aec5e2468687b2d306dcd4d291fd308 | TechClubPro/Python-Robotics-Projects | /Light Intensity based Brightness Control/Gesture Controlled Image Rotation/AnalogSensorBasedImageRotation.py | 3,555 | 3.796875 | 4 | """
Program to scale an Image
depending on the values read through IR Distance Sensor.
IR Distance Sensor is connected at IO pin 1 (Pin 27 of ESP32)
scaling width & Height is adjusted by mapping
Highest Width(700), Highest Height (640)
to Heighest Analog Reading by sensor(4095)
IO Pin 1 is configured to... |
42c74e2836e0f2b00b2998b4fde803744481f761 | horacio2307/Machine-Learning-Masterclass | /1 python_desde_0/listas.py | 402 | 3.859375 | 4 |
sabores = ["chocolate","crema americana"]
sabores2 = ["vainilla","dulce de leche"]
sabores.remove("crema americana")
print(sabores)
"""
sabores.insert(0,"primer elemento")
print(sabores[0])
print(sabores[1])
sabores.append("ultimo elemento")
print(sabores[6])
elemento_eliminado = sabores.pop(2)
print(sab... |
8d0d1635aa45672d6fbf6c98311ee839b87bd71e | horacio2307/Machine-Learning-Masterclass | /1 python_desde_0/comparadores.py | 129 | 3.515625 | 4 | print(6=="6")
"""
es distinto
!=
es distinto
<>
es menor
<
es mayor
>
es mayor o igual que
>=
es menor o igual que
<=
""" |
b5a2d916fe67d85c3bf6870879c9c3069c054ef7 | alejandro-parra/Programming-Fundamentals---Python | /ER1_A01229618.py | 240 | 3.71875 | 4 | x= int(input("Dame un valor en ohmios: "))
y= int(input("Dame el segundo valor en ohmios: "))
z= int(input("Dame el tercer valor en ohmios: "))
r=1/(1/x+1/y+1/z)
print ("El valor de la resistencia combinada es de %s ohmios" % (r))
|
c9942b6af38302f7bf42d5deb827335f3ce3228a | alejandro-parra/Programming-Fundamentals---Python | /Act2.5.py | 193 | 3.875 | 4 | import math
print("Escribe el radio A: ")
A=input()
print("Escribe el radio B: ")
B=input()
A=float(A)
B=float(B)
C=math.pi*math.sqrt(2**2*(A+B)**2)
print("Circunferencia: "+str(C))
|
ed173220c28d189d62c8ae68557dcfa5279aef95 | alejandro-parra/Programming-Fundamentals---Python | /Adivinador2_A01229618.py | 951 | 3.828125 | 4 | #Funciones:
def validarint(x):
while True:
try:
num=int(input(x))
break
except ValueError:
print("Valor inválido. Solo puedes introducir un entero.")
return num
def funcionamiento():
resultado=False
contador=1
numero=random.randrange(... |
267a1e2d2f27708ca2e7de9c5edfc25171ee1315 | alejandro-parra/Programming-Fundamentals---Python | /Divisiblepor3.py | 179 | 4.1875 | 4 | x= int(input("Dame un numero: "))
if x%3 == 0:
print ("El número %s es divisible entre 3"%(x))
else:
print("Este número no es divisible entre 3")
|
f11c35af93c8093b10a95b4a87b72aa83c10cad3 | alejandro-parra/Programming-Fundamentals---Python | /Act2.3.py | 303 | 3.984375 | 4 | print("Escribe una medida en pies que desea convertir:")
x=input()
x=float(x)
yarda=x/3
pulgada=x*12
centimetro=pulgada*2.54
m=centimetro/100
print("Valor en pies: "+str(x))
print("Valor en yardas: "+str(yarda))
print("Valor en metros: "+str(m))
print("Valor en pulgadas: "+str(pulgada))
|
b017de724c850cdc2c2dd757d7508ee2083db0f6 | lmitchell4/Python | /ch_3_collatz.py | 428 | 4.3125 | 4 | ## Collatz sequence
def collatz(number):
if number % 2 == 0:
print(number // 2)
return(number // 2)
else:
print(3*number + 1)
return(3*number + 1)
inputOK = False
while not inputOK:
try:
print('Enter an integer to start the Collatz sequence:')
n = int(input())
inputOK = True
excep... |
14caf7b3d9e591637e90bc0f677d6653b7ecd639 | tburette/adventofcode2017 | /day4.py | 858 | 3.59375 | 4 | # Partie 1 : 7:16
# Partie 2 : 8:40
# ralenti par exception
# return len(passphrase) == len(set(passphrase))
# TypeError: unhashable type: 'list'
# Le probleme vient du fait que sorted(str) génère une list
# et une liste ne peut être hashée donc set([ [] ]) ne fonctionne pas
# hashing voir:
# https://docs.python.org/3/... |
6adc11b9ebb24b30f9ee254734ff7a51f55eeb04 | CanyonAtwood/monopoly | /classes/card_definitions.py | 2,484 | 4.09375 | 4 | """
@author: Aleph Aseffa
"""
class Card:
def __init__(self, card_name, color_group, card_cost, house_cost, houses_built, rent_prices, mortgage_amt, owner, mortgaged):
self.card_name = card_name # str
self.color_group = color_group # str
self.card_cost = card_... |
da9fd9a5f460b5f7381b3e3adf8624681af4cc82 | marthagb/StatDescriptor | /find_stats.py | 456 | 3.53125 | 4 | from permuta import Perm, PermSet, MeshPatt
def find_stats(meshpatt, n):
"""Find the number of occurrences of meshpatt in all permutations of length up to n.
Returns a list of tuples (p,s) where p is a permutation and s is the number of
occurrences of meshpatt in p.
"""
all_perms = []
for i in range(n+1):
... |
14a4794a9bb687bde03256a168de4a58fd3014e6 | AdityaMishra9667/Pygame-Experiments | /particles.py | 2,578 | 3.5 | 4 | import pygame
import random
WIDTH = 1000
ROWS = 25
WIN = pygame.display.set_mode((WIDTH,WIDTH))
pygame.display.set_caption("Particle Physics")
clock = pygame.time.Clock()
RED = [255, 0, 0]
WHITE = [255,255,255]
BLUE = [0,0,255]
GRAVITY = 2
wid = 5
pwidth = 400
plength = 20
class Square:
def _... |
d6dc50dc9d4c29b02fbd1fea9e0ec8a1be214dca | mano1199/mano | /ex.1.py | 111 | 3.859375 | 4 | n=int(raw_input())
if (n>0):
print('Positive')
elif (n<0):
print('Negative')
elif (n==0):
print('Zero')
|
d1cb4a13559adeef6547180f4de2b01ad0e71ff0 | mano1199/mano | /ex8.py | 58 | 3.59375 | 4 | m=0
a=int(input())
for i in range(0,a+1):
m=m+i
print(m)
|
4bb7aa6e204a2b01c7a52d0ceb981539f0fea45a | DarshanKale/hello-world | /HelloWorld.py | 196 | 3.546875 | 4 | a = [1,2,3]
b=[1,2,3]
language = 'Testing'
print (id(a))
print(id(b))
if True:
print('Thanks for using ' + language)
elif a==b:
print('The values are equal')
else:
print('Whatever') |
12f76c2204bc484f1ab2df9b6e19ff3a0be99356 | shubhamx939/Python_Codes | /gui.py | 414 | 3.515625 | 4 | #importing numpy and pandas
import pandas as pd
import numpy as np
#import tkinter package
from tkinter import *
from mywindow import LRwindow
window = Tk() #Creating a window for the GUI
lrw = LRwindow(window)
window.title("Californian Housing Price Prediction") #Title of the window
... |
7d41708cc25e99aefab88d657dba5463cc424062 | cockscl/EcpPython | /Palindrome Tasks/single palindrome/palindrome.py | 319 | 3.859375 | 4 | def palindrome(word):
chars = list(word)
state = False
end = len(chars) - 1
for i in range(len(chars)):
if chars[i] != chars[end]:
state = False
break
elif i >= end:
state = True
break
else:
end -= 1
return state
|
4f9e4a8aa78c371d061586ea2b7467ee666bfe09 | cockscl/EcpPython | /basics/for loops/main.py | 306 | 3.9375 | 4 | if __name__ == "__main__":
# loops through the string
word = "mathematics"
for letter in word:
print(letter)
# loops through a list
numbers = [1,2,3,4,5,6,7,8,9,10]
total = 0
for i in range(len(numbers)):
total = total + numbers[i]
print(total)
pass
|
a95914f8996bc96b2e60ca8951bdeaf3611652d5 | igelritter/learning-python | /ex35-lphw.py | 2,759 | 4.125 | 4 | #This is basically a text style adventure. Each room is defined as a function
#as well as the starting and dying text.
#importing the exit function
from sys import exit
#gold room.
def gold_room():
print "This room is full of gold. How much do you take?"
next=(raw_input(">"))
#This 'if/else' statement is brok... |
aa4e4e9f3f69af579d0f62498167fc4cdf087f91 | igelritter/learning-python | /ex34-lphw.py | 512 | 4.28125 | 4 | #demonstarting the difference between ordinal numbers and
#the cardinal numbers of indices in lists
animals = ['bear' ,'python' ,'peacock' ,'kangaroo' ,'whale' ,'platypus']
print animals
print "The animal at 1"
print animals[1]
print "The 3rd animal"
print animals[2]
print "The 1st animal"
print animals[0]
print "The a... |
0c95064743ffeb391fe9023269833c0b7d55a81d | rbaas293/pythonr-final-project | /Final Project.py | 6,226 | 3.953125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Apr 24 18:07:08 2019
@author: issac
"""
import math
import matplotlib.pyplot as plt
def cartoon():
Vel = float(input ('enter the velocity the projectile was shot (in meters/second): '))
angle = float(input ('enter the angle the projectile was shot at (in degree... |
ac47d5ff2530ba4d339067a8e9cf5c17cc742ff1 | csllucas/nufit | /neighbor.py | 2,650 | 3.703125 | 4 | # list all zips that are within 5mi from the target zip for every zip code in the USA
import math
import csv
def main():
locations = getData()
locations = calc(locations)
writeCSV(locations)
def distance(lat1, long1, lat2, long2):
# calculate the distance according to their latitude and longitude
r = 3958
pi ... |
a9750a1061a5d472eb3b26c48112aa17795bc7b7 | abhisek08/python-tuple | /unpacking.py | 144 | 4.375 | 4 | '''
Write a Python program to unpack a tuple in several variables.
'''
tpl=(1,2,3,4)
for i in tpl:
print(i)
tpl=1,2,3
x,y,z=tpl
print(x+y+z) |
8689eb275ba86ba3d947d62712c7c81ef7de9797 | abhisek08/python-tuple | /show 1 item.py | 111 | 4.03125 | 4 | '''
Write a Python program to create a tuple with numbers and print one item.
'''
tpl=(0,1,2,3,4)
print(tpl[4]) |
26e865496c79894b04b41d05143eedcbe61427ad | Jbssnnt/CyberSecurityProject | /fileIO.py | 1,168 | 3.75 | 4 | import csv
def csvWrite(outputData, filename):
"""
A simple function to write data to a
csv file.
Args:
outputData: The data to be written.
A list of lists.
filename: A string with the name of
the file to write to.
Returns:
Nothing
"""
with ... |
95af2966515dd3cfca5459096762f8c0d5790ab3 | dao-heart/Leetcode-solutions | /pythonDataStructures/llist.py | 2,157 | 4.1875 | 4 | # Linked List
class Node:
def __init__(self, data):
self.data = data
self.next = None
## Test the nodes
n1 = Node("Mon")
n2 = Node("Tues")
n1.next = n2
print(n1)
class LinkedList:
print_list = []
def __init__(self):
self.headval = None
def __repr__(self):
return "->".j... |
4ea7e4ec4a35f38679ad84b9cbc877da8d98e66b | chenxu0602/LeetCode | /156.binary-tree-upside-down.py | 1,763 | 3.984375 | 4 | #
# @lc app=leetcode id=156 lang=python3
#
# [156] Binary Tree Upside Down
#
# https://leetcode.com/problems/binary-tree-upside-down/description/
#
# algorithms
# Medium (53.70%)
# Likes: 243
# Dislikes: 786
# Total Accepted: 56.9K
# Total Submissions: 105.9K
# Testcase Example: '[1,2,3,4,5]'
#
# Given a binary ... |
82977b0f973568f47b095b2a550f4d089000bade | chenxu0602/LeetCode | /1067.digit-count-in-range.py | 1,533 | 3.5 | 4 | #
# @lc app=leetcode id=1067 lang=python3
#
# [1067] Digit Count in Range
#
# https://leetcode.com/problems/digit-count-in-range/description/
#
# algorithms
# Hard (39.91%)
# Likes: 39
# Dislikes: 10
# Total Accepted: 1.7K
# Total Submissions: 4.2K
# Testcase Example: '1\n1\n13'
#
# Given an integer d between 0 ... |
bfe6f6afe0bb7b9a3d2878db275b3fde8ef6b996 | chenxu0602/LeetCode | /non_leetcode/No13_implement_orderedSet.py | 1,930 | 3.890625 | 4 | #!/usr/bin/python
# coding=utf-8
################################################################################
'''
https://leetcode.com/discuss/interview-question/395045/Facebook-or-Phone-Screen-or-Caesar-Cipher
Question 2:
Implement OrderedSet
.add(num)
.remove(num)
.toArray()
.contain(num)
'''
#################... |
ce530090155307b3d8834103ea0a0cd902fb466a | chenxu0602/LeetCode | /367.valid-perfect-square.py | 1,729 | 3.609375 | 4 | #
# @lc app=leetcode id=367 lang=python3
#
# [367] Valid Perfect Square
#
# https://leetcode.com/problems/valid-perfect-square/description/
#
# algorithms
# Easy (39.83%)
# Likes: 458
# Dislikes: 107
# Total Accepted: 113.2K
# Total Submissions: 283.5K
# Testcase Example: '16'
#
# Given a positive integer num, w... |
fc1459bd75604c9b459ae99bb30e6852b61e4c50 | chenxu0602/LeetCode | /1317.convert-integer-to-the-sum-of-two-no-zero-integers.py | 1,344 | 3.734375 | 4 | #
# @lc app=leetcode id=1317 lang=python3
#
# [1317] Convert Integer to the Sum of Two No-Zero Integers
#
# https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers/description/
#
# algorithms
# Easy (56.88%)
# Likes: 129
# Dislikes: 129
# Total Accepted: 18.6K
# Total Submissions: 32.8K
#... |
65069ff8d18f98a59c41d70276d4566c4b51bbff | chenxu0602/LeetCode | /640.solve-the-equation.py | 1,354 | 3.890625 | 4 | #
# @lc app=leetcode id=640 lang=python3
#
# [640] Solve the Equation
#
# https://leetcode.com/problems/solve-the-equation/description/
#
# algorithms
# Medium (40.49%)
# Likes: 172
# Dislikes: 411
# Total Accepted: 19K
# Total Submissions: 46.9K
# Testcase Example: '"x+5-3+x=6+x-2"'
#
#
# Solve a given equatio... |
4a4fa031c55f51e94899539a6bab97facb02e35d | chenxu0602/LeetCode | /96.unique-binary-search-trees.py | 1,005 | 3.53125 | 4 | #
# @lc app=leetcode id=96 lang=python3
#
# [96] Unique Binary Search Trees
#
# https://leetcode.com/problems/unique-binary-search-trees/description/
#
# algorithms
# Medium (47.26%)
# Likes: 2117
# Dislikes: 82
# Total Accepted: 226K
# Total Submissions: 469.5K
# Testcase Example: '3'
#
# Given n, how many stru... |
e68f824c49b0cb413518dd6e1dfb24dee874b9bc | chenxu0602/LeetCode | /395.longest-substring-with-at-least-k-repeating-characters.py | 1,079 | 3.6875 | 4 | #
# @lc app=leetcode id=395 lang=python3
#
# [395] Longest Substring with At Least K Repeating Characters
#
# https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/description/
#
# algorithms
# Medium (38.72%)
# Likes: 746
# Dislikes: 70
# Total Accepted: 48.7K
# Total Submissions: ... |
27372b596fbd09b721f50b5c738aec6f03bc1fab | chenxu0602/LeetCode | /2588.count-the-number-of-beautiful-subarrays.py | 818 | 3.578125 | 4 | #
# @lc app=leetcode id=2588 lang=python3
#
# [2588] Count the Number of Beautiful Subarrays
#
# @lc code=start
from collections import Counter
from itertools import accumulate
from operator import xor
class Solution:
def beautifulSubarrays(self, nums: List[int]) -> int:
# Prefix XOR
# pre record... |
25be4234bd92c21d3f5dae347f15746c568bff42 | chenxu0602/LeetCode | /1259.handshakes-that-dont-cross.py | 2,895 | 3.625 | 4 | #
# @lc app=leetcode id=1259 lang=python3
#
# [1259] Handshakes That Don't Cross
#
# https://leetcode.com/problems/handshakes-that-dont-cross/description/
#
# algorithms
# Hard (52.56%)
# Likes: 43
# Dislikes: 2
# Total Accepted: 1.9K
# Total Submissions: 3.7K
# Testcase Example: '2'
#
# You are given an even nu... |
9f14e45466245ad56134d30f80fcd6ffe86e3684 | chenxu0602/LeetCode | /544.output-contest-matches.py | 3,215 | 3.640625 | 4 | #
# @lc app=leetcode id=544 lang=python3
#
# [544] Output Contest Matches
#
# https://leetcode.com/problems/output-contest-matches/description/
#
# algorithms
# Medium (75.11%)
# Likes: 273
# Dislikes: 93
# Total Accepted: 20.9K
# Total Submissions: 27.8K
# Testcase Example: '4'
#
#
# During the NBA playoffs, w... |
32307fd9449d667f6bccd1457f328242e54b5cc6 | chenxu0602/LeetCode | /527.word-abbreviation.py | 3,992 | 3.5 | 4 | #
# @lc app=leetcode id=527 lang=python3
#
# [527] Word Abbreviation
#
# https://leetcode.com/problems/word-abbreviation/description/
#
# algorithms
# Hard (54.00%)
# Likes: 207
# Dislikes: 128
# Total Accepted: 16.2K
# Total Submissions: 29.8K
# Testcase Example: '["like","god","internal","me","internet","inter... |
a1683295da2ec9ca3cec616c871d443d7b9fb710 | chenxu0602/LeetCode | /2249.count-lattice-points-inside-a-circle.py | 583 | 3.65625 | 4 | #
# @lc app=leetcode id=2249 lang=python3
#
# [2249] Count Lattice Points Inside a Circle
#
# @lc code=start
class Solution:
def countLatticePoints(self, circles: List[List[int]]) -> int:
ans = set()
for x,y,r in circles:
for dx in range(r+1):
y_upper = int((r**2-dx**2)*... |
506fef1e61435e615548e7ee244a827acf60e09c | chenxu0602/LeetCode | /1017.convert-to-base-2.py | 1,362 | 3.828125 | 4 | #
# @lc app=leetcode id=1017 lang=python3
#
# [1017] Convert to Base -2
#
# https://leetcode.com/problems/convert-to-base-2/description/
#
# algorithms
# Medium (58.87%)
# Likes: 185
# Dislikes: 167
# Total Accepted: 12.1K
# Total Submissions: 20.5K
# Testcase Example: '2'
#
# Given a number N, return a string c... |
0cbe69b86c4cb1a6b2bdac5ea09b94d1c4f690ab | chenxu0602/LeetCode | /1636.sort-array-by-increasing-frequency.py | 1,310 | 3.984375 | 4 | #
# @lc app=leetcode id=1636 lang=python3
#
# [1636] Sort Array by Increasing Frequency
#
# https://leetcode.com/problems/sort-array-by-increasing-frequency/description/
#
# algorithms
# Easy (66.27%)
# Likes: 158
# Dislikes: 4
# Total Accepted: 9.3K
# Total Submissions: 14K
# Testcase Example: '[1,1,2,2,2,3]'
#... |
40df3eb7d72e24e7582c6822f2cdefae918718ac | chenxu0602/LeetCode | /2671.frequency-tracker.py | 926 | 3.515625 | 4 | #
# @lc app=leetcode id=2671 lang=python3
#
# [2671] Frequency Tracker
#
# @lc code=start
from collections import defaultdict
class FrequencyTracker:
def __init__(self):
self.count = defaultdict(int)
self.freq = defaultdict(int)
def add(self, number: int) -> None:
self.freq[s... |
32eca75a3cf7e2e1ddf929086b26649b68cd0a69 | chenxu0602/LeetCode | /1498.number-of-subsequences-that-satisfy-the-given-sum-condition.py | 2,047 | 3.5 | 4 | #
# @lc app=leetcode id=1498 lang=python3
#
# [1498] Number of Subsequences That Satisfy the Given Sum Condition
#
# https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/description/
#
# algorithms
# Medium (37.95%)
# Likes: 392
# Dislikes: 29
# Total Accepted: 11.3K
# Total S... |
994ec98915c834dc421f81d041b86d0856805bc0 | chenxu0602/LeetCode | /1178.number-of-valid-words-for-each-puzzle.py | 3,150 | 3.796875 | 4 | #
# @lc app=leetcode id=1178 lang=python3
#
# [1178] Number of Valid Words for Each Puzzle
#
# https://leetcode.com/problems/number-of-valid-words-for-each-puzzle/description/
#
# algorithms
# Hard (37.11%)
# Likes: 151
# Dislikes: 13
# Total Accepted: 4.7K
# Total Submissions: 12.8K
# Testcase Example: '["aaaa"... |
5a2c040425b719acf2c76916e191c2b976fb9292 | chenxu0602/LeetCode | /1837.sum-of-digits-in-base-k.py | 1,055 | 3.578125 | 4 | #
# @lc app=leetcode id=1837 lang=python3
#
# [1837] Sum of Digits in Base K
#
# https://leetcode.com/problems/sum-of-digits-in-base-k/description/
#
# algorithms
# Easy (75.24%)
# Likes: 52
# Dislikes: 8
# Total Accepted: 9.5K
# Total Submissions: 12.6K
# Testcase Example: '34\n6'
#
# Given an integer n (in bas... |
38d264ea013d750771af7bbc1e75ce454fdcb96d | chenxu0602/LeetCode | /1328.break-a-palindrome.py | 1,192 | 3.6875 | 4 | #
# @lc app=leetcode id=1328 lang=python3
#
# [1328] Break a Palindrome
#
# https://leetcode.com/problems/break-a-palindrome/description/
#
# algorithms
# Medium (44.88%)
# Likes: 188
# Dislikes: 192
# Total Accepted: 17.4K
# Total Submissions: 38.6K
# Testcase Example: '"abccba"'
#
# Given a palindromic string ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.