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
12e8ba3156789d6c79b5a2625070a898ef4d7eb3
curtisjm/python
/comp-138/hw01-dungeon-escape/main.py
3,120
3.921875
4
# node class for a binary tree class Node: def __init__(self, message): self.message = message self.left = None self.right = None # I organized the rooms in a way so they would appear in the proper order for appearing sequentially in a preorder traverse rooms = [ "\nA1: You are in a da...
7de2665bd9b5d91fab286fd7b09c4172d85363ad
curtisjm/python
/personal/basics/inheritance.py
1,890
4.5625
5
# create a parent class class Person: def __init__(self, fname, lname): self.firstname = fname self.lastname = lname def printname(self): print(self.firstname, self.lastname) x = Person("John", "Doe") x.printname() # to create a class that inherits the functionality from another class, # send the parent cla...
dd7b998fc5d4d32da2810bb1f25bc9818db4cad0
albertocueto/cracking-the-coding-interview
/chapter-vi:big-o/Python/example1-array-sum-and-product.py
383
3.890625
4
def arraySumAndProduct(list): sum = 0 product = 1 for value in list: sum += value for value in list: product *= value return (sum, product) list = [] for index in range(1, 10): list.append(index) print(list) print(arraySumAndProduct(list)) for index in range(1, 2000): l...
61146059d2bdd481e2236a3172367900fd26fbc0
reddigari/ESPyN
/espyn/utils.py
1,554
3.859375
4
import math from datetime import datetime, timedelta def current_season() -> int: """Get current NFL season After March, returns year of upcoming season. :return: current NFL season :rtype: int """ now = datetime.now() month, year = now.month, now.year if month < 4: year -= ...
ea5f66e0cb2fc04de9dfa1b1e7ab64f34698c6ce
Rokuzz/conversion-de-unidades-longitud
/operacions.py
2,070
4.1875
4
def programa(): pregunta_inicial = input("Escriba que operación matematica que usted quiera utilizar: ") if pregunta_inicial == "+": sum1 = int(input("Escribe el primer numero que quieras sumar: ")) sum2 = int(input("Ahora escribe el otro numero que quieras sumar: ")) print("La su...
e2bda89723a3193eafde99d7cc13bd50fbc00e4f
edianibarrola/python-lists-loops-programming-exercises
/exercises/09-Max_integer_from_list/app.py
245
3.875
4
my_list = [43,23,6,87,43,1,4,6,3,67,8,3445,3,7,5435,63,346,3,456,734,6,34] #Your code go from here: def biggestInt(list): aux = 0 for num in list: if num > aux: aux = num return aux print(biggestInt(my_list))
57bd696748910e3b2dae0e4fe2de7616e35cae6c
edianibarrola/python-lists-loops-programming-exercises
/exercises/15.2-Parking_lot_check/app.py
529
3.640625
4
parking_state = [ [1,1,1], [0,0,0], [1,1,2] ] slots = { "total_slots": 0, "available_slots": 0, "occupied_slots": 0} #Your code go here: def get_parking_lot(lot): for row_of_spots in lot: for spot in row_of_spots: if spot != 0: slots["total_slots"] += 1 ...
8f1040e9300721d13fac522bfb67c7ce7008dd85
LJamesHu/ProjectEuler
/Problem4.py
977
3.96875
4
# Largest palindrome product # Problem 4 # A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99. # Find the largest palindrome made from the product of two 3-digit numbers. # Set up numbers nmax = 999 nmin = 99 number = nmax*nmax # Iter...
f0c27da11efe0dfda2bc81b296bedfdc64303b2b
chettayyuvanika/Questions
/Easy/Pascals_Triangle_Problem.py
1,236
4.28125
4
# Problem Name is Pascals Triangle PLEASE DO NOT REMOVE THIS LINE. """ /* ** The below pattern of numbers are called Pascals Triangle. ** ** Pascals Triangle exhibits the following behaviour: ** ** The first and last numbers of each row in the triangle are 1 ** Each number in the triangle is the sum of t...
668d983e4b30e7a6e2c61cfd6a045a3f64b5208c
chettayyuvanika/Questions
/Easy/Prime_Factorization.py
1,280
3.6875
4
#Instructions to candidate. """ 1) Run this code in the REPL to observe its behaviour. The execution entry point is main(). 2) Consider adding some additional tests in doTestsPass(). 3) Implement primeFactorization() correctly. 4) If time permits, some possible follow-ups. """ """ Return an array containing ...
0311c673ba64df27b3acf07c4ade56ebbc823a87
chettayyuvanika/Questions
/Medium/Best_Average_grade_Problem.py
1,820
4.1875
4
# Problem Name is &&& Best Average Grade &&& PLEASE DO NOT REMOVE THIS LINE. """ Instructions: Given a list of student test scores, find the best average grade. Each student may have more than one test score in the list. Complete the bestAverageGrade function in the editor below. It has one parameter, scores, ...
a2a20fdc7a5d84eb8eb891b13fc6556e24fb748d
evimarp/scoring-pairs
/solution.py
1,565
3.71875
4
from typing import Tuple, List import heapq as hq def max_pair(words: List[str]) -> Tuple[str, str]: """ Given a list of words, find a word pair with the highest score. The score is determined by multiplying the lengths of the words by one another with none common char. """ def hash(word): ...
a074c6dfd5ab9da772102ab68cb3d7c7ad74c27e
HIST-VR/HIST-VR.github.io
/test1.py
231
3.734375
4
def checkio(array: list) -> int: result = 0 for i in range(0, len(array), 2): result += array[i] result = result * array[len(array)-1] print(result) return result checkio([0, 1, 2, 3, 4, 5])
4f5dba9a94b110bfbd8b72889652f03102717177
darlasunitha/python2
/100.py
207
3.65625
4
def product_of_digits(number): d, s = str(number), 0 while s <= (len(d)-5): print(int(d[s]) * int(d[s+1]) * int(d[s+2]) * int(d[s+3]) * int(d[s+4])) s += 1 product_of_digits(123456)
ec304864d363af08d7245df034c786523674b85d
kornel45/basic_algorithms
/quick_sort.py
533
4.15625
4
#!/usr/bin/python import random def quick_sort(lst): """Quick sort algorithm implementation""" if len(lst) < 2: return lst pivot = lst[random.randint(0, len(lst) - 1)] left_list = [] right_list = [] for val in lst: if val < pivot: left_list.append(val) elif ...
fdd7631795d0b948603e034edf32e8817af0b307
Ahmedamedy/AndelaBootcamp
/primeNumberTesting.py
1,313
3.796875
4
import unittest from prime_number import prime_number class primenumber(unittest.TestCase): def test_numbers_10(self): self.assertEqual( prime_number(10), [2, 3, 5, 7]) def test_strings_str(self): self.assertEqual( prime_number("Two"), "invalid input") def test_numbers_1(self): ...
a7faa8c5043ecf8405c113f3ef1b7e21bc690dc9
TarSen99/python3
/lab7_3.py
1,163
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def UI_input_string() -> str: '''Function input string''' checkString = input("Enter some string ") return checkString def UI_print_result(result: bool): '''Print result''' if result: print("String is correct") else: print("String is NOT correct") ...
b05ccc874f2193688f3175d92a4d12c4ceba0f9d
TarSen99/python3
/lab7_15.py
641
3.90625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import random import string def UI_print_result(result: str): '''prints result''' print(result) def pwd(): pwd = "" count = 0 length = 8 while count != length: upper = [random.choice(string.ascii_uppercase)] lower = [random...
875bb31378cf1de15998763dc39d985c906bd6d3
TarSen99/python3
/lab8_2.py
758
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import random def set_size() -> int: '''inputs size''' size = int(input("Enter size of list ")) return size def print_sorted(currList: list): '''print sorted list''' print(currList) def generate_list(size: int) -> list: '''generate list''' cu...
a51cbcf803b13929c0737ba36c30c2a189ec650b
TarSen99/python3
/lab52.py
552
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- print('Enter 2 dimensions of the door') width = int(input()) height = int(input()) print('Enter 3 dimensions of the box') a = int(input()) b = int(input()) c = int(input()) exist = False if (width > a and height > b) or (width > b and height > a): exist = True el...
b2a1434780cee3dd349e45b4fe569b54e4e2a0f8
kkitsara/Udacity_DisasterResponsePipeline
/data/process_data.py
3,263
3.703125
4
import sys import pandas as pd from sqlalchemy import create_engine def load_data(messages_filepath, categories_filepath): """ This is the function that load the data from csv files Input messages_filepath - the path of the messages csv dataset categories_filepath - the path of the categories ...
d381c34682f1a13ef799d6cf1183a44d30a218a9
debjyotigorai/Python
/circleArea.py
211
4.03125
4
#! /usr/bin/python import math # import math module r = input("Enter the radius: ") # circleArea.py if r>=0: print 'radius: ', r print 'circle area: ', math.pi*r*r else: print '-ve number'
fb0ca87f218614944dc58c71ca4d21b2dec9fc07
debjyotigorai/Python
/mnTonm.py
196
3.796875
4
#! /usr/bin/python # Larger of two: mnTonm.py x = raw_input("Enter a 2-digit +ve integer: ") if len(x) == 2 and x.isdigit(): y = x[1]+x[0] print x,'-->',y else: print 'Not a 2-digit integer'
73b211b27f035af9ab0cf264cb5da30d49341cc7
pk-pradeep/Milestone1
/ex.py
1,519
4
4
a = ['','X','O','X','O','X','O','X','O','X'] # def display_board(board): # print(board[0]) # print(board[1]+'|'+board[2]+'|'+board[3]) # print('-----') # print(board[4]+'|'+board[5]+'|'+board[6]) # print('-----') # print(board[7]+'|'+board[8]+'|'+board[9]) # def x_o(): # choice='non' # ...
6a443d34198cdda299c9e66c73323505e23a49b8
afreeland/TensorFlow
/Intro/EvaluateLinearModel.py
1,644
3.546875
4
import tensorflow as tf # Fourth Step W = tf.Variable( [.3], tf.float32) b = tf.Variable( [-.3], tf.float32) x = tf.placeholder(tf.float32) linear_model = W * x + b sess = tf.Session() # It is important to realize `init` is a handle to TensorFlow subgraph and variables remain # unitialized until we execute `sess.ru...
5d14e583cbd11ccc03dbb453c72629b2be23b771
apexx77/p_euler
/Project Euler Projects/file.8.py
323
3.59375
4
str = "" arr = [0] for i in range(20) : str = str+input() for i in range(len(str)-12) : p = int(str[i])*int(str[i+1])*int(str[i+2])*int(str[i+3])*int(str[i+4])*int(str[i+5])*int(str[i+6])*int(str[i+7])*int(str[i+8])*int(str[i+9])*int(str[i+10])*int(str[i+11])*int(str[i+12]) arr.append(p) print(max(ar...
f4d69ab19f30e894fc9a41ed27263cc2027b88df
apexx77/p_euler
/Project Euler Projects/file.29.py
142
3.578125
4
arr = [] for i in range(2, 6) : for j in range(2, 6) : if arr.count(i**j) == 0 : arr.append(i**j) print(len(arr))
af50587091793701f6e8dc1fca4705a91d3de2c4
apexx77/p_euler
/Project Euler Projects/file.15.py
143
3.75
4
def fact(n) : ans = 1 for i in range(1, n+1) : ans*=i return ans a = int(input()) print(fact(2*a)//(fact(a)*fact(a)))
686a18699fe10c3e1dbda171a9d4ce87176cbce8
Nagai-6548/python-scripts
/unzip.py
829
3.828125
4
import zipfile import glob import re import os def unzip_all(): files = glob.glob("*.zip") for filepath in files: unzip(filepath) def unzip(filepath): try: with zipfile.ZipFile(filepath, 'r') as inputFile: # 全て解凍するならextractall #inputFile.extractall("/Users/nagai/Downloads") # zipファイル内...
e6df0065573dfc229153a2e56bf76c473056f083
SakiFu/sea-c28-students
/Students/SakiFu/tests/test_series.py
669
3.578125
4
from series import fibonacci, lucas, sum_series def test_fibonacci(): assert fibonacci(0) == 0 assert fibonacci(1) == 1 assert fibonacci(2) == 1 assert fibonacci(3) == 2 assert fibonacci(4) == 3 assert fibonacci(5) == 5 assert fibonacci(6) == 8 assert fibonacci(7) == 13 def test_luc...
2316df0ac6a3db38ce6491df2447f4903bb8e570
SakiFu/sea-c28-students
/Students/SakiFu/tests/rot13.py
1,248
3.53125
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- import string def rot13(str): rot13 = string.maketrans( "ABCDEFGHIJKLMabcdefghijklmNOPQRSTUVWXYZnopqrstuvwxyz", "NOPQRSTUVWXYZnopqrstuvwxyzABCDEFGHIJKLMabcdefghijklm") return string.translate(str, rot13) if __name__ == '__main__': assert rot13...
9a1ddd72238f9b770e0e6754f82a6d1348ab757a
SakiFu/sea-c28-students
/Students/SakiFu/session03/pseudocode.py
991
4.3125
4
#!/usr/bin/env python This is the list of donors donor_dict = {'Andy': [10, 20, 30, 20], 'Brian': [20, 40, 30], 'Daniel': [30, 40,10, 10, 30]} prompt the user to choose from a menu of 2 actions: 'Send a Thank You' or 'Create a Report'. If the user chose 'Send a Thank You' Prompt for a Full Name. ...
37836355f0243afc966f2502b936629fbf32db7b
RatneshMallah/Data-Structure
/recursion_fibonacci.py
198
3.71875
4
__author__ = "Ratnesh Mallah" def fibonacci(n): assert n>=0 and int(n)==n, "Input must be positive integer" if n in [0,1]: return n else: return fibonacci(n-1) + fibonacci(n-2) print(fibonacci(6))
cac3e0a46d539c173ae3a0d7a99bef6f03d950bb
LiamS090/Course
/Game of Chance/Games-Of-Chance.py
3,212
3.84375
4
import random money = 100 #Write your game of chance functions here def coin_toss(bet, guess): print("Lets play a game of heads or tails") #validation if bet <= 0: print("Your bet needs to exceed 0 to play.") return 0 #Flip the coin print("Okay, let's flip! You guessed " + str(guess)) coin_resu...
fdc147be3dc9b4f4d0237ef999c78f85a529fe07
tanaymukherjee/Python-Practice
/Python Essentials/Concurrency/simple_example.py
545
3.8125
4
import threading from time import sleep, time tglobal = time() def wait(n, id_): print(f""" FUNCTION {id_}, called at: t={int(time()-tglobal)} SLEEPING FOR: {n}s""") sleep(n) if __name__=="__main__": print('threading') s0 = time() t1 = threading.Thread(target=wait, args=(2,"A")) t2 = ...
c8a59f22dc6345ed0d27c30a7eebbe0ca7e098fb
poleNgrek/NLP-G6
/NN/Baseline_Parser.py
8,423
3.578125
4
class Parser(object): """A transition-based dependency parser. This parser implements the arc-standard algorithm for dependency parsing. When being presented with an input sentence, it first tags the sentence for parts of speech, and then uses a multi-class perceptron classifier to predict a se...
64e084758d49d5ffdb62da90c6eef4dfb6ca2a24
MurdoMaclachlan/AdventOfCode
/2020/day2part1.py
979
3.75
4
#!/usr/bin/env python3 with open("inputday2.txt", "r") as file: content = file.read().splitlines() validPasswords = [] for line in content: num1, num2, nums = [], [], [] first = True for char in list(line): if char.isnumeric() and first: num1.append(char)...
0ab3652a74acf1b9ef486aebab26e0ac4d786a01
limjaein/python-study
/02_조건_반복문/01_조건문.py
577
3.53125
4
# 조건문 # 파이썬은 들여쓰기로 코드의 블록을 설정한다 # tab 1번 == space bar 4번 (표준) # 논리 연산자 and/or/not # c++, java 에서 사용하던 ! 개념은 없음 flag = False # print(!flag) print(not flag) # 기타 연산자 in/not in # 리스트, 튜플, 문자열, 사전 자료형에서 사용 가능 str = 'jaein' print('in' not in str) # 조건부 표현식 score = 85 result = "success" if score >= 80 else "fail" print(re...
7b3684d49171167d3a4038fbf27c183c82f74cbe
limjaein/python-study
/03_라이브러리/Itertools.py
665
4.0625
4
# 주요 사용 클래스는 permutations, combinations from itertools import permutations from itertools import product from itertools import combinations from itertools import combinations_with_replacement data = ['A', 'B', 'C'] result = list(permutations(data, 2)) print(result) # permatations 와 같이 순열이지만 중복 허용의 경우 # product 를 사용한다...
d6ca85c6f0ec379ebe21d4391beaa4686244a025
rchurch4/georgetown-data-science-fall-2015
/data_preparation/data_preparation_lib/json_to_csv_trip_advisor.py
7,913
3.5625
4
# Ravi Makhija # json_to_csv_trip_advisor.py # Version 4 # Python 2 # # Description: # This function takes as input the scraped restaurants from trip_advisor in # json format, and outputs a csv file with the same information, # but organized so that each observation is a review. The script # also encodes string inputs...
28134e3b9e95669a79e8fae1d0875b7b6e32f67d
rchurch4/georgetown-data-science-fall-2015
/data_preparation/data_cleanliness_yelp.py
5,040
3.671875
4
# Nathan Hauke # Drop Table - Teamname # Project 1 # Data Cleanliness Metric # # Usage: python data_cleanliness_yelp.py filename # # Description: # This code measures the cleanliness of our yelp data. # The input is a file containing data collected from yelp and processed to generate new features. # Each of our yelp d...
751fff6dc235ed9f921b5de62821606fff4e4acc
RolfHaakon/PythonExercises
/Exercises/Algorithms_Binary Search.py
3,131
4.09375
4
""" https://edabit.com/challenge/kfXz49avvohsYSxoe A "Binary Search" is a search algorithm that is used on an already sorted array. It compares the target value to the middle element of an array. If they don't match, the half in which the target cannot lie is ignored and the search continues on the remaining half, aga...
b40eef7652eb127b57006344e210ac647f3c9487
Bronsun/Python_labs_Broncel
/Parser/CSV.py
959
3.59375
4
import pandas as pd df = pd.DataFrame({ 'Marka':[], 'Model':[], 'Cena':[], 'Pojemność pamięci':[], 'Bateria':[], }) file = pd.read_csv("Phones.csv") print("Twoje telefony. Co chcesz zrobić: \n") print("1.Dodać telefon \n") print("2.Usunąć telefon \n") print("3. Wyświetl plik \n") x = input...
5a8de5497b1a058b9350051441a083f0d2bc9d8b
Bronsun/Python_labs_Broncel
/Algorytmy/równanie_kawdaratowe.py
675
3.765625
4
import math print("Wprowadź współczynniki\n") a =int(input("a: ")) b =int(input("b: ")) c =int(input("c: ")) delta = (b*b)-(4*a*c) print("Twoja delta jest równa: "+str(delta)) if delta > 0: x1 = -b-math.sqrt(delta)/(2*a) x2 = -b+math.sqrt(delta)/(2*a) print("x1 = "+str(x1)) print("x2 = "+str(x2)) if...
d9d29ea08a3c1bfab47c446fc02a8b11697acfb0
shohina01/gb_python3
/task2.py
329
3.859375
4
def user_info(name, surname, birth_year, city, email, phone_number): print(name, surname, birth_year, city, email, phone_number) user_info(name=input('Name: '), surname=input('Surname: '), birth_year=input('Birth year: '), city=input('City: '), email=input('Email: '), phone_number=input('Phone numb...
8c268ff9937ff52d67cdf51950e2489f5fb4505d
PaulKaynov/Lab4
/iterators.py
683
3.546875
4
# Итератор для удаления дубликатов class Unique(object): def __init__(self, items, **kwargs): self.ignore_case = kwargs.get('ignore_case', False) self.items = items self.i = 0 self.unique_data = [] def __next__(self): if (self.ignore_case == True): self.item...
a1f723ff0000d12f755c33700ffcda486cb7b7f5
Gal-Gilor/nyc-mhtn-ds-071519-lectures
/week-1/OOP/Calculator.py
2,133
4
4
class Calculator: ### google assert function #create attributes to hold the list if numbers and the length of the list #update changes if needed def __init__(self, data): # assert all(isinstance(x, (int, float))) for x in data), "give me numbers not letters man" import math self.d...
cf14f286672c8771fbc6c8e9bd87b8c9528ad862
MaciejAZak/Credit_Calculator
/Problems/The farm/task.py
914
3.796875
4
money = int(input()) if money >= 6769: no_animals = money // 6769 if no_animals > 1: print("{0} sheep".format(no_animals)) else: print("{0} sheep".format(no_animals)) elif money >= 3848: no_animals = money // 3848 if no_animals > 1: print("{0} cows".format(no_animals)) el...
902f01cf94a4d5274cf9a72935d90f7619006b39
MaciejAZak/Credit_Calculator
/Problems/Grade/task.py
242
4.03125
4
score = int(input()) max = int(input()) percentage = score / max if percentage < 0.6: print ("F") elif percentage < 0.7: print ("D") elif percentage < 0.8: print ("C") elif percentage < 0.9: print ("B") else: print("A")
a4af13cb904e44f6136e44e736591eb9fccb1d44
MaciejAZak/Credit_Calculator
/Problems/Palindrome/task.py
123
4.15625
4
word = input() word_backward = word[-1] if word == word_backward: print("Palindrome") else: print("Not palindrome")
ad43d34ca563c60c7987d0a02de482407b558d99
liberdamj/Cookbook
/python/ShapesProject/shape/circle.py
948
4.1875
4
# Circle Class import math class Circle: # Radius is passed in when constructor called else default is 5 def __init__(self, radius=5): self.radius = radius self.circumference = (2 * (math.pi * self.radius)) self.diameter = (radius * 2) self.area = (math.pi * (radius * radius)) ...
fbc1778edf0e60699b96779c58cadbe4cd710e06
bronbonsma/Python_project
/Ex5.py
237
3.828125
4
def build_pyramid(): try: rows = int(input("Enter the number of Rows: ")) for i in range(rows): print(' '*(rows-i-1) + '*'*(2*i+1)) except ValueError: print("That is not a number ") build_pyramid()
ab1391056f8fa92c2b9c80056259c7060a18720f
avinashtangudu/Python-Calculator
/Source Code.py
972
4.03125
4
# I have imported a regex library into Python# # https://en.wikipedia.org/wiki/Regular_expression # import re # Calculator Title and Instruction for Quit or Stop # print("Simplest Calculator") print("To 'Exit' enter Quit\n") # Assigning a Variable # first = 0 second = True # Used global options here# def MathCalci(...
bff1e256dbec610ee48f6b0e27440b9e54c130a5
klbinns/project-euler-solutions
/Solutions/Problem02.py
527
3.65625
4
''' Problem 2: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the ...
ff46a43fbb377a07fc38ecf781220c6cf1cad33d
klbinns/project-euler-solutions
/Solutions/Problem09.py
546
4.25
4
from math import floor ''' Problem 9: A Pythagorean triplet is a set of three natural numbers, a b c, for which, a**2 + b**2 = c**2 For example, 3**2 + 4**2 = 9 + 16 = 25 = 5**2. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. ''' s = 1000 a = 3 ...
cf178e7555cc8328e34236a426827dca48c0d61f
klbinns/project-euler-solutions
/Solutions/Problem19.py
1,600
4.21875
4
''' 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400. How many...
5956deccdf479c7e15e3cfbc71752957b9643d10
sethvillalon95/Python-101
/credits.py
368
3.859375
4
while True: name = raw_input("Hi, please tell me your name: ") print "Nice to meet you, " + name creString = raw_input("How many credits are have you taken? ") cre = int(creString) if cre < 0: break if cre < 30: print "Freshman" elif cre< 60: print "Sophomore" elif cre < 90: print "Juni...
f97bfea93b7a5e21e2a491adb98dcd0484235b19
gaibo/Python
/workshop/guesser2.py
301
3.84375
4
#Set 7 as the secret number number = 7 #Prepare a while loop with flag variable done_guessing = 0 while done_guessing == 0: guess = int(raw_input("Guess my number! ")) if guess == number: print "You got it right!" done_guessing = 1 elif guess > number: print "Lower!" else: print "Higher!"
517fb491157602b33ac19e5b7529a7064376a255
gaibo/Python
/workshop/guesser1.py
205
3.984375
4
number = 7 user_guess = raw_input("Guess my number ") guess = int(user_guess) print guess if guess == number: print "You got it right!" elif guess > number: print "Lower!" else: print "Higher!"
b0236ea2db6dfca86e3be647c9a1941b1275e017
jkufro/Snake
/snake.py
7,325
3.96875
4
#snake game #use the arrow keys to change the snake's direction import random import sys import tkinter import time from time import sleep square_width = 20 #pixels num_squares = 13 #changing this will change the size of the playable boardspace score_bar_height = 48 #pixels window_height = num_squares*square_width +s...
21ccb4e2c69f142865dd62fbd80614825d41bfbe
muhammed-ayman/CSCI-101-course-labs-solutions
/03/05.py
217
4.0625
4
value = int(input('Enter a value:')) L = input('Enter list of values:').split(' ') count = 0 for i in L: if int(i) <= value: count += 1 print(i) if count == 0: print('All items are greater')
81cc4c5e9f2c4cbecf6fdce009d3bcb493f71263
muhammed-ayman/CSCI-101-course-labs-solutions
/08/08/reverseString.py
96
3.8125
4
def reverse_string(string): string = ''.join([k for k in string][-1::-1]) return string
ccc431f34d0b293d20860c8ba7ebcd8225b59f7f
muhammed-ayman/CSCI-101-course-labs-solutions
/01/12.py
115
3.84375
4
u = input('Enter Units: ') t = input('Enter Tens: ') h = input('Enter Hundreds: ') print('The number is ',h+t+u)
a807034de5936810b903856c03cd30d42d5d49f3
muhammed-ayman/CSCI-101-course-labs-solutions
/05/06.py
311
3.765625
4
n1 = float(input('Enter #1 > ')) n2 = float(input('Enter #2 > ')) n3 = float(input('Enter #3 > ')) nums = [n1, n2, n3] for j in range(len(nums)): for i in range(len(nums)): if i+1 != len(nums): if nums[i] > nums[i+1]: nums[i],nums[i+1] = nums[i+1],nums[i] print(nums)
5fa46c5d2a9c52da3cdb32641d01b86f0ae28141
muhammed-ayman/CSCI-101-course-labs-solutions
/08/08/main.py
173
4.5625
5
import reverseString before_string = input('Enter a String: ') after_string = reverseString.reverse_string(before_string) print(f'The reversed string is: {after_string}')
d38fe5ad10de9595a1bb813f1cbb5eb5717e4f6d
muhammed-ayman/CSCI-101-course-labs-solutions
/10/05.py
211
3.96875
4
dict1 = {'Ten': 10, 'Twenty': 20, 'Thirty': 30} dict2 = {'Thirty': 30, 'Fourty': 40, 'Fifty': 50} # Answer 1: for i in dict2.keys(): dict1[i] = dict2[i] # Answer 2: dict1.update(dict2.copy()) print(dict1)
93b4cf187e2ef551d2b0431c7448dca41b36c9b7
muhammed-ayman/CSCI-101-course-labs-solutions
/10/02.py
87
3.734375
4
#True dict1 = {'key1':1, 'key2':2} dict2 = {'key2':2, 'key1':1} print(dict1 == dict2)
a21af1085c2e0689564a9790d5a8af9cce811e0e
muhammed-ayman/CSCI-101-course-labs-solutions
/05/08.py
328
3.65625
4
friends = input('Friends > ').split(',') presents = input('Presents > ').split(',') in_mind = input('What is in joy\'s mind > ') found = False for i in range(len(presents)): if presents[i] == in_mind: print(f'Oh {friends[i]}, Thank you friend :)') found = True if not found: print('Opps,Sorry ...
00069652dcb1d3adab681230ee43147a97f8b831
nmasamba/learningPython
/23_list_comprehension.py
819
4.5
4
""" Author: Nyasha Masamba Based on the lessons from Codecademy at https://www.codecademy.com/learn/python This Python program is an example of Python's expressiveness. Less is more when it comes to true Pythonic code, and list comprehensions prove that. A list comprehension is an easy way of automatically creatin...
2c0d1241ef7354776f28dbf02587b1c3ef705942
nmasamba/learningPython
/22_iteration.py
1,121
4.5
4
""" Author: Nyasha Pride Masamba Based on the lessons from Codecademy at https://www.codecademy.com/learn/python This Python program shows a way to iterate over tuples, dictionaries and strings. Python includes a special keyword: in. You can use in very intuitively, like below. In the example, first we create and i...
e88c2d3097b8f1eda62acb39223f4c5e2848a96b
nmasamba/learningPython
/14_anti_vowel.py
849
4.25
4
""" Author: Nyasha Pride Masamba Based on the lessons from Codecademy at https://www.codecademy.com/learn/python This Python program is an example of modularity, encapsulation and algorithmic thinking. It is simply a function that takes a string text as input. It will then return that string without any vowels. No...
c1e5a23c822dc77349e3ffd91817d59e71dd62f8
nmasamba/learningPython
/20_remove_duplicates.py
589
4.25
4
""" Author: Nyasha Pride Masamba Based on the lessons from Codecademy at https://www.codecademy.com/learn/python This Python program is an example of modularity, encapsulation and algorithmic thinking. It is simply a function that takes in a list of integers. It will then remove elements of the list that are the ...
826b764ebae1aa3dd7bab841dcca956209d77df3
Roopkanwal/AI-Python
/rectangle_summarizer.py
849
3.890625
4
import csv from statistics import mean # Open and Read the contents of CSV file with open("DATA475_lab_rectangles_data.csv",newline="") as f: reader = csv.reader(f) next(reader) # Calucate the area of rectangles areas=[float(line[1]) * float(line[2]) for line in reader] # Calculates and print the...
5cd1697583ad184d89c484c8cf0524fd99da2ac1
vikayata/hw
/problem2.2.py
717
3.90625
4
x = int(input('Введите координату X:')) y = int(input('Введите координату Y:')) def get_quarter_number(a, b): if a < 0: return 3 if b < 0 else 2 if b < 0: return 4 return 1 print('Точка лежит в', get_quarter_number(x, y), 'четверти.') ''' Не рассматриваются варианты с нахождением на оси ...
a754406c444ae23fa78f4a42ae2a802c0ee435fd
drublackberry/prove-it
/Markov/HMM.py
5,469
3.765625
4
# -*- coding: utf-8 -*- """ Created on Tue Feb 17 11:15:48 2015 @author: Andreu Mora Example script to demonstrate the fundamentals of Hidden Markov Models based on [Rabiner 89] A Tutorial on Hidden Markov Models and Selected Applications in Speech Recognition. """ import pandas as pd import numpy as ...
f635ac8a5d9cac2447d18fc8c4f887707f9fe56c
JUNoym/algo
/Sort/comb_sort.py
910
4.03125
4
# ポイント SwapがFalseになるまで並び替える # つまりGapを1.3で割って1になるまでSwapし続けて、交換が行われなくなるまで続ける # 計算量 O(n^2/2**g)安定はしていない def comb_sort(numbers): len_numbers = len(numbers) gap = len_numbers swapped = True while gap != 1 or swapped: gap = int(gap / 1.3) if gap < 1: gap = 1 swapped = F...
1c2fff3d0b5bf0832455244bd14506544132a881
gandhi56/Q3T
/server.py
15,052
3.734375
4
''' server.py is an implementation of the server for the Quantum Tic-tac-toe game engine. Features: - runs the game, performs updates and terminal tests. - calculates the winner of a game. - saves game to a file using grammar implemented in game.py. - loads game from a file with error-check execution. - previous mov...
de0f0a64ba89147a5d0a08d76d2b415ba3fa9aa9
KamSss/Python
/StudyCode/序列和字典/列表.py
361
3.84375
4
# 因为列表可以插入删除 所以可以当作栈、队列来使用 # 删除 a = [1,2,3,4] del(a[3]) print(a) a.pop(-1) print(a) # 队列 a.append(50) a.pop(0) print(a) # 返回一个对象出现次数 print(a.count(1)) # 列表的深浅拷贝 import copy a = [1,2,3,4] # 深拷贝只能针对可变对象使用 b = copy.deepcopy(a) a[0] = 100 print(b)
db559082668898dcf919194b860ddc0b06704e0b
KamSss/Python
/StudyCode/异常处理/函数中的异常处理.py
269
3.59375
4
# python中变量的作用域: # 1.有三个关键字:def,class,lambda会影响作用域 # 2.其他的都不会 # with 语句本质上就是try...finally def divide(x,y): if y == 0; #raise Exception('除以0') raise ZeroDivisionError('除以0')
9b8dd534ee56d8e2b2ef8f549d37d5bb3e74c133
utkarshdubey/Python-Works
/Barkhurdar/check_num_largest_in_three.py
169
4.0625
4
num1 = int(input("Please enter a number: ")) num2 = int(input("Please enter a number: ")) num3 = int(input("Please enter a number: ")) print(max(num1, num2, num3))
2f7babc6a8534a696d89cbb073d307f9b7eef0fb
amitagrahari2512/PythonBasics
/Sorting/BubbleSort.py
282
4.28125
4
def bubbleSort(list): for i in range(len(list)-1,0,-1): for j in range(i): if(list[j] > list[j+1]): list[j],list[j+1] = list[j+1],list[j] list = [2,1,3,89,43,90,66] print("Unsorted List : ",list) bubbleSort(list) print("Sorted List : ",list)
46d1f70fb0f3f02d4b4c89c091dd669a6126644b
amitagrahari2512/PythonBasics
/ForLoopBasics.py
675
4.40625
4
print("Iterate List") x = [2, 4, 'Amit'] for i in x: print(i) print("Iterate String") x = 'Amit' for i in x: print(i) print("Initialize List direct in for loop iteration") for i in [2,4 , 'PPPP'] : print(i) print("Initialize String direct in for loop iteration") for i in 'Amit': print(i) print("We ...
ef7ce42f2eabddec2e83fe8bc96d3bbef67fb1e3
amitagrahari2512/PythonBasics
/ListInFuction.py
288
3.890625
4
def countEvenAndOdd(lst): even = 0 odd = 0 for i in lst: if i%2 == 0: even+=1 else: odd+=1 return even,odd lst = [1,2,3,4,5,6,7,8,9,10,11,12,13] even , odd = countEvenAndOdd(lst) print("Even : {} and Odd : {} ".format(even,odd))
97509b7516410f2bb47ff98094ce9c49396f4716
amitagrahari2512/PythonBasics
/Imp.py
1,716
3.71875
4
a = 'good' print (a + a[::-1]) print (a + a[:-1]) print (a + a[0:3]) print("----------------------------------------------") a = 15/3; print(a) a = 15//3; print(a) print("----------------------------------------------") print("Divmod") print(divmod(10.5,5)) print(divmod(2.4,1.2)) print(divmod(10,5)) print(divmod(24,...
248a46e01c23a9a818ca88afc3e78b0f9e85269b
amitagrahari2512/PythonBasics
/Numpy_Array_ShallowAndDeepCopy.py
1,376
4.21875
4
from numpy import * print("Copy of array") arr1 = array([1,2,3,4,5]) arr2 = arr1 print(arr1) print(arr2) print("Both address is same") print(id(arr1)) print(id(arr2)) print("------------------------------Shallow Copy------------------------------------------------") print("So we can use view() method , so it will g...
ad79eef5ec788f5bf282a4e5158248c6bb63cedf
amitagrahari2512/PythonBasics
/NameFunction.py
1,150
3.671875
4
import CalculatorModule print("\n") print("------------------------------------------------------------------------") print("__name__ is a special variable in Python") print("__name__ variable have two work to done") print("1 : if we run particular file and its have __name__ in this file , it will return __main__ , be...
e66855f8845952bd0eaf49c3dc3a04b68321bae4
brainmentorspvtltd/MSIT_CorePython
/03-Functions.py
568
3.890625
4
def inputNumbers(): a = input("Enter first number: ") # local variable b = input("Enter second number: ") return a, b def calc(operator): x, y = inputNumbers() # eval("10 / 10") print(eval(x + operator + y)) # eval uses postfix expression evaluation print(''' 1. Add 2. Sub 3...
638e8300b2d31af1896c938f1e1b62d2b9e6050d
brainmentorspvtltd/MSIT_CorePython
/02-File-handling.py
933
3.859375
4
import csv fileStream = open("users.csv", "a") print(''' 1. Login 2. Register ''') choice = int(input("Enter choice: ")) emailExists = False if choice == 2: name = input("Enter name: ") email = input("Enter email: ") password = input("Enter password: ") with open("users.csv", "a") as fileSt...
745f4f65d9d148dddeb53a83bde505b53bf1e233
brainmentorspvtltd/MSIT_CorePython
/login practice.py
1,843
3.78125
4
import csv fileStream = open("users.csv", "a") print(''' 1. Login 2. Register ''') choice = int(input("Enter choices: ")) if choice == 1: # isLoginSuccessful = False # flag variable email = input("Enter Emails: ") password = input("Enter Password: ") with open("users.cs...
e890c2f667108b744fd62f446bd708cb4b5f2a3f
alessandroseidiinoue/Curso-Em-Video---Python
/Exercicios/Ex041.py
384
4.0625
4
from datetime import date atual = date.today().year ano = int(input('Ano de Nascimento: ')) idade = atual - ano print('O Aluno tem {} anos.'.format(idade)) if idade <= 9: print('Categoria MIRIN') elif idade <= 14: print('Categoria INFANTIL') elif idade <= 19: print('Categoria JÚNIOR') elif idade <= 25: ...
35cae03dff14c16600dbe4c339c1324be97186f5
wesleykchang/EIS_simulator
/Obtain_EIS_Input.py
3,032
3.578125
4
import matplotlib.pyplot as plt import numpy as np import cmath as cm print(30 * '-') print("WELCOME TO EIS SIMULATOR") print(30 * '-') print("Ciruit element codes: ") print("R. Resistor") print("C. capacitor") print("CPE. Constant Phase Element") print("W. Warburg impedance") print(30 * '-') #######################...
20f8295e4e21326cd34ea4658bb75ae8eb47a1d2
rwestwick/RadioactiveFunkyChickens
/test/wallDistanceAndAngle.py
3,046
4.03125
4
#!/usr/bin/python """ wallDistanceAndAngle.py Functions: wallAngle(distanceOne, distanceTwo, wallWidth) distanceFromWall(distanceOne, theta) For use with robot to help with wall following challenges """ # Import required libraries import logging import math import SetupConsoleLogger # Create a logger to both ...
ccd54ef9a23eab0c3d3eef6315f14e5b4bc59b87
pengjinfu/python-network-programming
/application_layer/http_server_v1.py
1,325
3.515625
4
import socket import multiprocessing def handle_client(client): # 接收客户端的数据 client_request_data = client.recv(1024) print("客户端的请求数据为:%s" % client_request_data) # 向客户端响应数据,一定要按照http协议规范,带上\r\n,并且一定要注意斜杠的方向 response_start_line = "HTTP/1.1 200 OK\r\n" response_headers = "Server:My server\r\n" ...
096b13bb8cbed4445f00448cc602df5ab8bf7fed
thomascastleman/racko
/ai.py
10,442
3.671875
4
import game class AI(game.RackoGame): possible = [] # all possible sets of statics current = [] # the current set of statics being constructed via our recursive approach statics = [] # static values in rack def __init__(self): pass # get move given choice and current rack d...
ac4d7e895e0d97b5153041fed1435b49240313da
ckiekim/Python-Lecture-1907
/Exam/ex03.py
405
3.734375
4
# 두 개의 정수를 입력받아 작은 수에서부터 큰 수까지(큰 수 포함) 홀수의 합을 # 구해서 출력하는 프로그램을 for loop을 사용하여 작성하시오. small, large = map(int, input('두개의 정수> ').split()) if small > large: small, large = large, small sum = 0 for i in range(small, large+1): if i % 2 == 1: sum += i print('홀수의 합 =', sum)
64d425b6fbafde4cba58a3e91cdfae761843a4a7
ckiekim/Python-Lecture-1907
/Exam/ex09.py
228
3.640625
4
# 다음과 같은 리스트 a가 주어졌을 때 a의 각 원소를 제곱한 값을 원소로 갖는 # 리스트 b를 람다표현식을 사용하여 구하시오. a = [1, 3, 5, 7, 9] b = list(map(lambda x: x*x, a)) print(b)
f7bcdef778866be25aa2feafac6e6d8c3b1738cc
ckiekim/Python-Lecture-1907
/Exercises/e03_file/p06_hexadump.py
1,122
3.53125
4
import binascii as ba import os def showHexa(addr, buf, size): if addr % 1024 == 0 and addr != 0: print() print('%08X: ' % addr, end = ' ') if size != 16: for i in range(size): if i == 8: print(end=' ') print('%02X' % buf[i], end=' ') for i in...
e521aa3cb2582358837bc3f4d292fbce6ca65058
ckiekim/Python-Lecture-1907
/Unit 30/u30_eval.py
1,267
3.796875
4
# 표준 입력으로 국어, 영어, 수학, 과학 점수가 입력됩니다. # 다음 소스 코드를 완성하여 가장 높은 점수, 가장 낮은 점수, 평균 점수가 # 출력되게 만드세요. # 평균 점수는 실수로 출력되어야 합니다. korean, english, mathematics, science = map(int, input().split()) def get_min_max_score(*args): min = 100 max = 0 for arg in args: if arg < min: min = arg if arg ...
fd7d3fe72741caa705c8afa82056b08bb348e0c5
me-shantanu/Ds
/LinkedList/DoubleLL.py
4,109
4.15625
4
class Node(object): def __init__(self,value): self.info = value self.prev = None self.next = None class DoubleLinkedList(object): def __init__(self): self.start = None def Display_List(self): if self.start is None: print("List is Empty") ...
c5d0ac40327c0e3da3d703cfde7f45e11fbb22cb
scottwedge/python-programs
/oops projects/test.py
569
3.578125
4
class strr(str): def __add__(self, other): other=strr(other) return super(strr, self).__add__(other) # def __str__(self): # return super.__str__(self) class intt(int): def __add__(self, other): m = strr(self) n = strr(other) return super(strr, m).__add__(n) ...