blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
57442e4aa8b9f92750dc9336bbc0addefdaedf31
haticerdogan/python-3-sandbox
/basics.py
1,584
4.4375
4
# Lesson 3 - Numbers # https://www.youtube.com/watch?v=Gqby4v5JOu4&list=PL4cUxeGkcC9idu6GZ8EU_5B6WpKTdYZbK&index=3 # everything in Python is an object, and objects have attributes & methods that are functions type(500) # <class 'int'> type(5.1) # <class 'float'> 5 / 5 # 1.0 <= retruns a float 5 / 5 # 1 <= retruns...
false
36f66aa5e656cc03fe2997b5c1817d454ee6566f
haticerdogan/python-3-sandbox
/lessons/intro_to_classes.py
2,572
4.1875
4
name = 'Me' age = 92 qaimah = [1, 2, 3] qamous = {"A":1, "B":2, "C":3} type(name) #=> <class 'str'> type(age) #=> <class 'int'> type(qaimah) #=> <class 'list'> type(qamous) #=> <class 'dict'> # class name must have capitol letter class Planet: # initializer (init function) that runs when we create a new insta...
true
478d373625d0e07326947865540f964ac667d96f
haticerdogan/python-3-sandbox
/projects/ipsum_gen.py
1,205
4.125
4
# Lesson 28 # https://www.youtube.com/watch?v=iLS4Hk-kJXE&list=PL4cUxeGkcC9idu6GZ8EU_5B6WpKTdYZbK&index=28 from random import randint # we will take these ninja works and randomly inject them into the loreum ipsum text ninja_words = [ 'Aiki', 'Buyu', 'Chimonjutsu', 'Cho sen', 'Dojo', 'Gakusei', 'Haiboku', 'Jin', '...
false
c3939d358034b7645abb3cf0502b4a5541f927be
haticerdogan/python-3-sandbox
/lessons/comprehension.py
835
4.53125
5
# let's say we have a list of prizes and we want to double each one prizes = [5, 10, 50, 100, 1000] double_prizes = [] # create an empty array for prize in prizes: double_prizes.append(prize*2) print(double_prizes) # comprehension method: this gives the same values as above but is much shorter double_prizes = [pri...
true
77c108253545d0b02b5928afd024cc83d5937158
haticerdogan/python-3-sandbox
/lessons/dictionary.py
1,622
4.625
5
# Lesson 14 - Dictionaries # https://www.youtube.com/watch?v=Gqby4v5JOu4&list=PL4cUxeGkcC9idu6GZ8EU_5B6WpKTdYZbK&index=14 # Dictionaries are the same as Javascript objects or Ruby hashes. people_ages = {'ron':12, 'bob':5, 'tom':36, 'dan':41, 'cat':39, 'alf':73} print(people_ages) # check to see if a key exists insid...
true
955a214fdc776fff7f4d5d1771dffebdb8bdac7a
TungTNg/itc110_python
/Mon_07_09/volumArea.py
568
4.375
4
# volumeArea.py # a program which calculates the volume and surface are of a sphere from its radius, given as input import math def main(): print('# This is a program which calculates the volume and surface are of a sphere') print() radius = float(input('Enter the radius of the sphere: ')) volume...
true
5cc1874098689afa851baf216a254d2259dfa46f
TungTNg/itc110_python
/Assignment/wordCalculator.py
600
4.375
4
# wordCalculator.py # A program to calculate the number of words in a sentence # by Tung Nguyen def main(): # declare program function: print("This program calculates the number of words in a sentence.") print() # prompt user to input the sentence: sentence = input("Enter a phrase: ") ...
true
a61f6d3b35429b5596e9eca89cac63e55b3e2160
ottersome/progra_class
/python2/HW/0616115_hw9-2.py
2,154
4.53125
5
#!/usr/bin/python import math #this function is always run to check the validity of the input def filterinput(inputo): #the given string is stripped from its parenthesis and then split into three through at the commas divider = inputo[1:] divider = divider[:-1] divider = divider.split(",") #we test ...
true
3bbf75477b3424bc848e21ee6b6c161a7e60853c
Candy-Sama/Python-Mini-Programs
/Validating Inputs.py
1,071
4.1875
4
def user_choice(): #Variables #inital variables choice = 'Wrong' #initialise the variable as a false non-digit acceptable_range = range(0,10) within_range = False #Check for two conditions in while loop #digit OR within_range == False while choice.isdigit() == False or with...
true
0012a3e390179373f71989e4154dc4f383042efb
muthuguna/python
/Sample4.py
583
4.15625
4
myDictionary ={} def addItem(): inptCity = input("Enter the City:") inptZip = input("Enter the Zip:") myDictionary[inptCity]=inptZip def printItem(): print(myDictionary); def deleteItem(): itemToDelete = input("Enter the City to delete:") myDictionary.pop(itemToDelete) while(1): ...
true
674e8f75bfc2d8087dcbfdec8721e8fd268e9401
muthuguna/python
/Sample3.py
929
4.15625
4
""" myDictionary= {} def add(): nameValue = input("Enter name to add:") movieValue = input("Enter movie to add:") myDictionary[nameValue] = movieValue def printItems(): print(myDictionary) def deleteItem(): nameValue = input("Enter name to delete:") del myDictionary[nameValue] while(...
true
364f3e308398fe7d589bd48345d8bea3ff9e1e8b
anneharris4/Hackbright-Intro-to-Programming-Assignments
/Lesson_8/ultimatebillcalc.py
1,200
4.125
4
total_bill = 0.0 tip = 0.0 bill_before_tip = 0.0 people_number = 1.0 bill_per_person= 0.0 def prompt_user(): global total_bill global tip global bill_before_tip global people_number bill_before_tip = float(raw_input('how much is on the bill not including tip?')) dine_alone = raw_input('did you dine alone? y/n')...
false
1c7b12aae485cd956ed12bb8d3c4b8dc34950de0
RiddhiDamani/Python
/Ch3/dates_start.py
1,142
4.375
4
# # Example file for working with date information # # we are telling the python interpreter here that from the datetime standard built in module that comes with the standard library - importing date, time, datetime classes. These are the predefined pieces of functionality in the Python library. To use it, you need to ...
true
c94ea9fb0e996c7c1bd777a4562f347c2bc2ad7e
RiddhiDamani/Python
/Chap11/hello.py
2,075
4.6875
5
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ # Strings are the first class objects in Python3. # The below is a literal string. You can call methods on it. # A string is immutable - it cannot be changed. So, when we use one of the below transformation methods, # the return string is a different obje...
true
353faed27acb5088ba6d0fa4bb25e32bdf25cea2
RiddhiDamani/Python
/Chap06/while.py
461
4.25
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ secret = 'swordfish' pw = '' auth = False count = 0 max_attempt = 5 # the below loop ends when u enter 'swordfish' as the password. then, pw == secret breaks the loop. while pw != secret: count += 1 if count > max_attempt: break if count == 3...
true
4a6a6028a00df460c4de1e2ae9f539c16a4b215f
RiddhiDamani/Python
/Ch6/definition_start.py
1,672
4.21875
4
# Python Object Oriented Programming by Joe Marini course example # Basic class definitions # TODO: create a basic class class Book: # pass statement is used as a placeholder for future code. # When the pass statement is executed, nothing happens, but you avoid getting an error when empty code is not allowe...
true
027eb6a226bc7d565613976080d423cdafdde799
RiddhiDamani/Python
/Chap09/methods.py
1,973
4.21875
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ # A function that is associated with a class is called a method. # This provides the interface to the class and its objects. class Animal: def __init__(self, **kwargs): self._type = kwargs['type'] if 'type' in kwargs else 'kitten' self...
true
434a299748a5986e50b528d80351206bb7e618b7
maxawolff/code-katas
/src/find_outlier.py
746
4.25
4
"""Find the pairity outlier. best practice solution: def find_outlier(int): odds = [x for x in int if x%2!=0] evens= [x for x in int if x%2==0] return odds[0] if len(odds)<len(evens) else evens[0] """ def find_outlier(integers): """Return whatever number is an outlier from a list, even or odd.""" ...
false
f455463a341d56c4005d6000fb83fd840a9d53fb
ThompsonBethany01/Python_Practice_Problems
/Codeup_Challenges/Alphabet_Soup.py
1,007
4.375
4
# Alphabet Soup Solution # By Bethany Thompson # 1/20/2021 def alphabetize_words(my_string): ''' This functions accepts a string and returns the string sorted alphabetically by each word. ''' # splitting string by spaces my_string_list = str.split(my_string) # initialzing variable as...
true
e8004ef41a316324731cc23854912343acdda8d9
HanBao224/code_sample
/code_sample/data-cleansing-sample/dir_to_file.py
2,711
4.125
4
import os def dir_to_file(dir, file="dir.txt"): """ Find the files and directories in 'dir', remove hidden files, also get the files at the next level, and put everything into 'file' with this format: Contents of dir f1 f2 D: d1 ...
true
dde0477c5129a5a37fc7136e36ffaec4c897360a
MohammedHmmam/Python_a-z
/lists/map_function.py
1,266
4.5
4
#The map() Function executes a specified for each item in an iterable. ##The item is sent to the function as a parameters #### Syntax: map(Function , iterable) ############# Parameters : ############################# Function: Required|| - The function to execute for each item ############################# Iterab...
true
cb5cefb219b9ca70489678e164e45ac1c4258f7e
Levijom/nth_Digit_of_PI
/nth_Digit_of_PI.py
611
4.21875
4
import math #find the nth digit of PI userInput = int(input("what digit of PI would you like?: ")) if userInput <= 0: print("You must input a value larger than 0!") #get the nth value to one's place, convert to int digit = userInput - 1 power = 10 ** digit digit = math.pi * power integer = ...
true
337d1156a06f5202b51579a0defeb4c1b6bb6ad3
Anurag-Bharati/pythonProjectLab
/First.py
1,476
4.25
4
# Program to convert Binary to Decimal or vice versa import keyboard print("\nPress 'b' to convert decimal number into binary, 'd' to convert binary to decimal or 'e' to exit.\n") while True: if keyboard.is_pressed("b"): keyboard.send("backspace") print("\nDecimal to binary\n") keyboard....
true
d1622fc0447894b03a0e125dfb7a695304fb5bfa
VijayUpadhyay/python
/PythonBasics/com/vijay/basics/GeekForGeeks/ClosureTest1.py
391
4.1875
4
#As we can see innerFunction() can easily be accessed inside the outerFunction body #but not outside of it’s body. Hence, here, innerFunction() is treated as nested #Function which uses text as non-local variable. def outerFunction(text): custName = text def innerFunction(): print(custName) in...
true
58e4039bc04d16727bebc574ccbec57f98e2a8c6
VijayUpadhyay/python
/PythonBasics/com/vijay/basics/GeekForGeeks/ItrTest3.py
539
4.15625
4
import itertools from collections import Counter list1 = [1, 2, 3, 4, 5, 6, 44] list2 = [44, 55, 77, 55, 68, 88] list3 = [44, 77, 854, 545, 8, 89] print("Summation of 1st list: ", list(itertools.accumulate(list1))) print("Summation of 2nd list: ", list(itertools.accumulate(list2))) print("Summation of 3rd list: ", list...
true
ed6f77bd9d80c0279fb339215ee6f1c008a0885a
MananKavi/assignment
/src/assignment2/que6.py
881
4.125
4
# Program to display grade bigData = int(input("Enter marks of Big Data out of 100 : ")) dataMining = int(input("Enter marks of Data Mining out of 100 : ")) python = int(input("Enter marks of Python out of 100 : ")) java = int(input("Enter marks of Java out of 100 : ")) computerGr...
false
5e73e6155f45815605950c6411eb592aa1863347
Joes-BitGit/LearnPython
/DataStructs_Algos/list_based/stacks.py
1,638
4.21875
4
class Element(object): def __init__(self, value): self.value = value self.next = None class LinkedList(object): """ Linked list class is used to hold elements but will act as a stack. Which means it will delete and insert only from the top of the Stack """ def __init__(self, he...
true
1e08a1107ea947c001972670f2a7d8a1d24901ff
mikewarren02/PythonReview
/palindrome.py
518
4.375
4
def palindrome(): word = str(input("Pick a word: ")) reverse = word[::-1] if word == reverse: print(f"{word} is a Palindrome!") else: print(f"{word} is Not a Palindrome!") # palindrome() #another way # word = input("Please enter word: ") # reversed_word = "" # for index in range(len...
false
253602612d0e10cfa6c1af5e39ea8b3c7af46b5b
mikewarren02/PythonReview
/strings.py
671
4.21875
4
# Data types in Python print("Hello World") company = "digitalCrafts" cohort = "Feb 2021" message = f"Welcome to {company} and cohort is {cohort}" print(message) full_name = input("Please ener your full name: ") car_make = input("Please ener your car make: ") car_model = input("Please ener your car model: ") add...
true
76b5f30ed149e32b4435d8859678e1355a3eb3b2
EmanuelGP/pythonScripts
/dataStructuresAlgorithms/poo/pooEjemplo6/claseSequence.py
974
4.125
4
from abc import ABCMeta, abstractmethod class Sequence(metaclass=ABCMeta): """Our own version collections.Sequence abstrac base class.""" @abstractmethod def __len__(self): """Return the length of the sequence.""" @abstractmethod def __getitem__(self, j): """Return the element at index j of the sequence.""...
true
df52733153c04a2aebf6b3d74e5056d3d15062c2
billputer/project-euler
/problem9.py
870
4.5
4
#!/usr/bin/env python # coding: utf-8 import math # 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. def is_pythagorean_triplet(a, b, c): return math.pow(a, 2) + math.pow(b, 2) == math.pow(c, 2) def get_triplets(n): ...
false
2532033dbec188409ffa1434369c059414268151
justanotheratom/Algorithms
/Python/DynamicProgramming/Fibonacci/Staircase/staircase_bottomup.py
567
4.375
4
def countways(n): ''' Given a staircase with n steps, find the number of was you can climb it by taking 1 step, 2 steps, or 3 steps at each turn. :param n: Number of steps in the staircase :return: Number of possible ways. >>> countways(0) 1 >>> countways(1) 1 >>> countways(2) ...
true
308c1b45a02cda333a5e053f23e101132bd398f3
charleenchy/Task3
/Question2.py
392
4.25
4
#Write a Python program to convert temperatures to and from celsius, fahrenheit ans=int(input("1 for cel to Fah, 2 for Fah to cel")) If ans == 1: cel = int(input("enter a temp in cel")) fah = (cel - 9/5) + 32 print('%.2f Celsius is: %.2f Fahrenheit' %(cel, fah)) else: fah = int(input("yourtemp in Fah")) cel = (...
false
120826e3f3a0455de2ca9b6ba33ea664a949a86a
overnightover/git-test
/src/py/f05.py
638
4.15625
4
# 水仙花数是指一个 n 位数,它的每个位上的数字的 n 次幂之和等于它本身。例如:1^3 + 5^3 + 3^3 = 153。 # 在Python中,我们可以使用一个简单的循环来找出所有的水仙花数。以下是一个示例代码: for num in range(100, 1000): # 将数字转换为字符串,方便获取每一位数字和位数 str_num = str(num) n = len(str_num) # 计算每一位数字的n次幂之和 sum_of_powers = sum(int(digit) ** n for digit in str_num) # 如果这个和等于原来的数字,那么这个数...
false
9c15808f00f1964de2dfc605b3e106a0ed6b56af
jmwoloso/Python_2
/Lesson 8 - GUI Layout/grdspan.py
1,603
4.125
4
#!/usr/bin/python3 # # A Program Demonstrating the 'rowspan' and 'columnspan' Keywords # for the grid() Method Geometry Manager in Tkinter # # Created by: Jason Wolosonovich # 03-11-2015 # # Lesson 8 - Exercise 3 """ Demonstrates the 'rowspan' and 'columnspan' keywords of the Geometry Manager for the grid() method. "...
true
a81209dbff0df01c8f4324bcb93d0a917abb24a6
jmwoloso/Python_2
/Lesson 3 - TDD/adder.py
521
4.34375
4
#!/usr/bin/python3 # # Lesson 3 Exercise 1 Adder Module # adder.py # # Created by: Jason Wolosonovich # 02-20-2015 # # Lesson 3, Exercise 1 """adder.py: defines an adder function according to a slightly unusual definition.""" import numbers def adder(x, y): if isinstance(x, list) and not isinstance(y, lis...
true
be3e61e14026462d2014682dc71d6d511610f628
jmwoloso/Python_2
/Lesson 11 - Database Hints/animal.py
1,910
4.21875
4
#!/usr/bin/python3 # # A Program That Uses a Class to Represent an Animal in the Database # animal.py # # Created by: Jason Wolosonovich # 03-20-2015 # # Lesson 11 - Exercise 2 """ animal.py: a class to represent an animal in the database """ class Animal: def __init__(self, id, name, family, weight): ...
true
19dd21f1ee8babc06d3b444dfdbb06fdee9480e5
philipslan/programmingforfun
/2_basicds/queuelist.py
567
4.34375
4
# Implement the Queue ADT, using a list such that the rear of the queue # is at the end of the list. class Queue: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def enqueue(self, item): self.items.append(item) print self.items def dequeue(self): a= self.items[0] del s...
true
c70f0169560febece4f7f18e8c57ecc9055e073a
PeterELytle/LTCTHW-Python
/ex18.py
1,328
4.28125
4
# This line defines the "print_two" function, and it will have arguments. def print_two(*args): # This line defines two arguments to be used in the function. arg1, arg2 = args # This line displays some text, and both variables (which are defined as the function arguments). print "arg1: %r, arg2: %r" % (arg1, arg2) ...
true
4198371c811f2f7eab2395c816dae90267f43c9c
PeterELytle/LTCTHW-Python
/ex3.py
1,621
4.4375
4
print "I will now count my chickens:" # This line displays some text describing what the next lines will do. print "Hens", 25.00 + 30.00 / 6.00 # This line displays a descriptor and the result of an arithmetic equation. print "Roosters", 100.00 - 25.00 * 3.00 % 4.00 # This line displays a descriptor and the result of...
true
af47e372315456ee4ec7b3d2f1875404c3e66ce1
Hallad35/Development
/5.py
735
4.25
4
name=input('please, give me your name ') surname=input('please, give me your surname') telnumber=input('please, give me your telephone number') print("Czy imię składa się tylko z liter?", name.isalnum()) print("Czy nazwisko składa się tylko z liter?", surname.isalnum()) print("Czy numer telefonu składa się z cyfr", t...
false
da90149afebf3c0afc560a90b3c7583ede002ba3
nordhagen/cs
/python/3-lists.py
1,358
4.3125
4
bicycles = ['trek', 'cannondale', 'redline', 'specialized'] print bicycles # Python has string operation functions like .title() for title casing. print bicycles[0].title() # Negative array access will count from the end print bicycles[-1] message = 'My first bicycle was a '+ bicycles[0].title() + '.' print message ...
true
efd841d774d8cdb7ccfe887fb158d3432ccfa0b1
chintaluri/Coding-Exercises
/p-prac-ex1.py
892
4.1875
4
# Create a program that asks the user to enter their name and their age. # Print out a message addressed to them that tells them the year that they will turn 100 years old. # Extras: # # Add on to the previous program by asking the user for another number and printing out that many copies of the previous message. # (H...
true
deb01bf8f07f75fd93feb197f5bdaf5a7aa3db16
adityakaria/3-Sem
/py/labs/lab3/mystack.py
865
4.3125
4
class Stack: """Define the Stack class here. Write a constructor and implement the push, pop and isEmpty functions using Python lists. """ def __init__(self): self.my_stack = [] self.top = -1 def push(self, x): self.my_stack.append(x) self.top += 1 print ("Push Successful\nThe stack now is: " + s...
true
a08ace17e89a52ed82d2467cb7dea5823fac6923
RansomBroker/self-python
/Recursive/binarySearchTree.py
1,101
4.15625
4
class Node: #make constructor for insert data def __init__(self, key): self.left = None self.right = None self.value = key #insert item based on root def insertTree(self, root, node): if root is None: root = node else: #insert value ...
true
36be5969915f5f20c67366462148ba4e34d2528b
marlavous/intro-to-programming-class
/listproject.py
1,792
4.4375
4
master_list = {"Target": ["socks", "soap", "detergent", "sponges"], "Safeway": ["butter", "cake", "cookies", "bread"]} test_list = ["apples", "wine", "cheese"] def main_menu(): print "Select one" print "0 - Main Menu" print "1 - Show all lists." print "2 - Show a specific list." print "3 - Add a new shopping lis...
true
d05b00a2b2b153f4c3908047c55b0c432dff4c08
aguecig/Project-Euler
/Problems 11 - 20/pe_15.py
1,456
4.125
4
# -*- coding: utf-8 -*- """ Created on Thu Jan 3 17:42:18 2019 @author: aguec """ def pascal_middle(n): # 1 # 1 1 # 1 2 1 # 1 3 3 1 # 1 4 6 4 1 # 1 5 10 10 5 1 # 1 6...
false
4fa482193c3c69a6f7fdb43d7a936bb34ebc12f3
osiddiquee/SP2018-Python220-Accelerated
/Student/osiddiquee/lesson09/Acitivity09.py
1,824
4.125
4
''' Notes for concurrency and async ''' import sys import threading import time from Queue import Queue ''' This is an intengration function def f(x): ''' return x**2 def integrate(f, a, b, N): s = 0 dx = (b-a)/N for i in xrange(N): s += f(a+i*dx) return s * dx ''' This starts...
true
615773162eb00f0f6052e5165174a3085d5e40b1
Bdnicholson/Python-Projects
/Imperial-To-Metric/Bora_Nicholson_Lab3a.py
1,311
4.25
4
print('Hello, Please input the Imperial values!') #Miles Miles = float(input('Miles to Kilometers: ')) totalKilometers = (1.6 * Miles) if Miles < 0: print('Please no negative numbers') else: if Miles > 0: print("The metric conversion is ", totalKilometers) #Fahrenheit Fahrenheit = float(input('Fahrenhe...
true
6f2ff90aa2e66dd4eb578b26ee00ed4b84c4a9ec
YabZhang/algo
/kth_largest_element.py
1,080
4.15625
4
#!/usr/bin/env python3 # coding: utf8 """ @Author: yabin @Date: 2017.5.21 Find K-th largest element in an array. Example In array [9,3,2,4,8], the 3rd largest element is 4. In array [1,2,3,4,5], the 1st largest element is 5, 2nd largest element is 4, 3rd largest element is 3 and etc. Note You can swap elements i...
false
703a54f231c85e320e10950ed1c7403daa6a6d09
YabZhang/algo
/remove_element.py
798
4.15625
4
#!/usr/bin/env python3 # coding: utf8 """ @Author: yabin @Date: 2017.5.20 “Given an array and a value, remove all occurrences of that value in place and return the new length. The order of elements can be changed, and the elements after the new length don't matter. Example Given an array [0,4,4,0,0,2,4,4], value=4 ...
true
745304d06b6afc863d2b76b498f0370f6d05cff2
JARVVVIS/ds-algo-python
/sorting_algo/rec_bubble.py
674
4.21875
4
## just for fun things def rec_bubble(arr): ## bring the largest element to the last for i in range(len(arr)-1): if arr[i] > arr[i+1]: temp = arr[i] arr[i] = arr[i+1] arr[i+1] = temp ## now call the function on last-1 elements ## we are basical...
true
38057ac597ef329b7afc371c8cc7b9225d0072fb
reesep/reesep.github.io
/classes/summer2021/127/lectures/examples/calculator.txt
1,186
4.21875
4
# Write a calculator program that will ask for # two numbers from the user. The program # should then as the user what operation they # want to do (addition, subtraction, # multiplication, division). The program # should then do the requested operation and # print out the answer. def addition(num1, num2): return ...
true
0c7cf800ec9927506315dfdac8ce5c83fe3f560b
reesep/reesep.github.io
/classes/snowmester2020/127/lectures/examples/pizza_price.py
343
4.3125
4
# Write a program that will calculate the cost per square inch of a # circular pizza, given its diameter (inches) and price. diameter = float(input("Enter diameter of pizza: ")) price = float(input("Enter price of pizza: ")) area = (3.14159) * (diameter / 2) ** 2 ppsi = price / area print("The price per square i...
true
9613d7aff69a1ece0a9da7c99c3a0063d11d6866
OmgMrRobot/XLAM
/X or 0.py
867
4.125
4
board = [" "," "," "," "," "," "," "," "," ",] def print_state(state): for i,c in enumerate(state): if (i+1)%3==0: print(f'{c}') else: print(f'{c}|', end='') print_state(board) winnig_combination = [(0,1,2), (3,4,5),(6,7,8),(0,3,8),(1,4,7),(2,5,8),(0,4,8),(2,4,6)] def get_winner(state, combination): fo...
false
1a821d4a20223b0cd5ec519fbc91e062ae3582ed
andpet27/Python
/StringFormatting/StringsEx2.py
716
4.28125
4
string = "Strings are awesome!" print("Lenghts of string = %d" % len(string)) print("The first occurence of letter a = %d" %string.index("a")) print("a occures %d times" %string.count("a")) print("the first five characters are '%s'" %string[:5]) print("the next five characters are '%s'" %string[5:10]) print("the 13th c...
true
39525d30ac77a038f0277bcd6d39838b7df14912
olugbengs12/pythonlearn
/classwork.py
454
4.40625
4
#program that takes count of numbers entered by a user and also notes the number, do a sum and return an average total = 0 count = 0 average = 0 while True: number = input("Enter a number:") try: if number == "done": break total += float(number) count += 1 ...
true
48f2ba2e155b451e7934815738bad75cb9123f58
GenerationTRS80/JS_projects
/python_starter/tuples_sets.py
912
4.3125
4
# A Tuple is a collection which is ordered and >> unchangeable <<. Allows duplicate members. # Create tuple # You create a tuple using parenthese in stead brackets like lists fruits = ('Appels', 'Grapes', 'Oranges') #fruits2 = (('Apples','Grapes','Oranges')) #Trailing value needs a single comma fruits2 = ('Apple',)...
true
40d316229ad3450f817516625f950fa29d9af9df
srithanrudrangi/PythonCoding
/color.py
224
4.15625
4
color1 = input('Enter one primary color: ') color2 = input('Enter another primary color: ') if ((color1 == 'red' and color2 == 'blue') or (color1 == 'blue' and color2 == 'red')): print('Your secondary color is Purple.')
true
2472673124d46f00d6f260fcf33d9c27205ac68a
srithanrudrangi/PythonCoding
/rectangle.py
239
4.125
4
length = int(input('What is the length of your rectangle? ')) width = int(input('What is the width of your rectangle? ')) area = length*width perimeter = 2 * (length+width) print('The perimeter is ', perimeter) print('The area is ', area)
true
49ba51faa633d6244d4dfe8a176fe03c63d20ec8
srithanrudrangi/PythonCoding
/4_5_averagerainfall.py
546
4.21875
4
numOfYears = int(input('How many years? ')) for i in range(numOfYears): totalInchesOfrainfall = 0 currentMonth = 1 for currentMonth in range(1, 13): inchesOfrainfall = int( input('How many inches of rainfall for the month of ' + format(currentMonth, "d") + ': ')) totalInchesOfra...
true
aa5625505ad49e331dbd94d844f553da327065b2
dheerajgopi/Algorithmic-Thinking---Coursera
/Week1/project1.py
1,418
4.25
4
"""Project 1 of Algorithmic Thinking MOOC""" EX_GRAPH0 = {0:set([1,2]), 1:set([]), 2:set([])} EX_GRAPH1 = {0:set([1,4,5]), 1:set([2,6]), 2:set([3]), 3:set([0]), 4:set([1]), 5:set([2]), 6:set([])} EX_GRAPH2 = {0:set([1,4,5]), 1:set([2,6]), 2:set([3,7]), 3:set([7]), 4:set([1]), 5:set([2]), 6:set([...
false
2ee3775ee7145d9f9483874807811f5dc29fb1b5
david-assouline/personal-projects
/Sudoku Solver.py
2,848
4.28125
4
import time board = [ [0,8,0,4,0,0,1,2,0], [6,0,0,0,7,5,0,0,9], [0,0,0,6,0,1,0,7,8], [0,0,7,0,4,0,2,6,0], [0,0,1,0,5,0,9,3,0], [9,0,4,0,6,0,0,0,5], [0,7,0,3,0,0,0,1,2], [1,2,0,0,0,7,4,0,0], [0,4,9,2,0,6,0,0,7] ] def board_generator(): """ optional function. gives...
true
8d6f9acabce91efaf453dbe5210beef138fed0c4
motasimmakki/Basic-Python-Programming
/EncryptionUsingPython.py
587
4.15625
4
myStr=input("Enter A String To Encrypt :") i=0 encStr="" decStr="" def reverseString(x): return x[::-1] #string encryption while i<len(myStr) : if i%2==0 : ch=ord(myStr[i])+3 else : ch=ord(myStr[i])+5 encStr+=str(chr(ch)) # print(ch,end=" ") i-=-1 encStr=reverseString(encStr) print...
false
8c9a759f3dcb91db4437c531b790033554b5df57
KlymenkoDenys/lesson
/Tasks_p49.py
733
4.25
4
# Воображаемы благодарности # Образец применения escape -последовательностей print("\t\t\tВоображаемые благодарности") print("\t\t\t \\ \\ \\ \\ \\ \\ \\ \\") print("\t\t\tРазработчика игры") print("\t\t\tМайкла Доусона") print("\t\t\t \\ \\ \\ \\ \\ \\ \\ \\") print("\nОтдельное спасибо хотелось бы сказать: ") print("...
false
10d9a50c6d91af3a77f1c6fb04d0b3ebf51b525f
Jgoschke86/Jay
/Classes/py3interm/EXAMPLES/specialmethods.py
1,348
4.375
4
#!/usr/bin/python3 class Special(object): def __init__(self,value): self._value = str(value) # all Special objects are strings # define what happens when a Special object is added to another Special object def __add__(self,other): return self._value + other._value # defi...
false
0797d7477b5d70f632c94b42dbc381b6e84b2bd3
Jgoschke86/Jay
/Classes/py3intro/ANSWERS/calc.py
588
4.1875
4
#!/usr/bin/python3 def add(x,y): return x + y def sub(x,y): return x - y def mul(x,y): return x * y def div(x,y): return x/y while True: expr = input("Enter a math expression: ") if expr.lower() == 'q': break (v1,op,v2) = expr.split() v1 = float(v1) v2 = float(v2) ...
false
06e4663d0c88fafcc266ed5bcf7923beb22778b9
karenseunsom/python102
/todos.py
1,312
4.15625
4
# want to ask user what they want to add to list. import json # todos = ["pet the cat", "go to work", "shop for groceries", "go home", "feed the cat"] with open('todos.json', 'r') as file_handle: # contents = file_handle.read() # print(contents['name']) todos = json.load(file_handle) def print_todos(): ...
true
0cab04ced071bd9934491d37203139f2c9e9cbbb
MarcosAllysson/python-basico-fundamento-da-linguagem
/ex028.py
670
4.21875
4
""" Escreva um programa que faça o computador pensar em um número inteiro entre 0 e 5 e peça para o usuário tentar descobrir qual foi o número escolhido pelo computador. O programa deverá escrever na tela se o usuário venceu ou perdeu. """ from random import randint from emoji import emojize print('JOGO DA ADIVINHAÇÃO'...
false
bc701a95028d7c76f519cfde5b862b5b1b9472fa
MarcosAllysson/python-basico-fundamento-da-linguagem
/ex058.py
1,520
4.1875
4
""" Melhore o jogo do desafio 28 onde o computador vai pensar em um número entre 0 e 10. Só que agora o jogador vai tentar adivinhar até acertar, mostrando no final quantos palpites foram necessários para vencer. """ from random import randint from emoji import emojize print('\033[4;36mJOGO DA ADIVINHAÇÃO 2.0\033[m') ...
false
8c8441e88e6f5185a9958bfd542e35e6c954818b
MarcosAllysson/python-basico-fundamento-da-linguagem
/prova-mundo-2.py
1,542
4.53125
5
""" Em uma condição composta, qual das cláusulas de estrutura pode se repetir dentro de uma mesma condição? """ #print('vários elif em um mesmo if composto') """ Qual das opções a seguir vai somar 3 unidades à variável t em Python? """ t = 0 t += 3 """ Qual é o jeito certo de verificar se a primeira letra de uma stri...
false
59906a734f2dcbd536610ef649844341d82510ce
MarcosAllysson/python-basico-fundamento-da-linguagem
/ex059.py
1,243
4.3125
4
""" Crie um programa que leia 2 valores e mostre um menu na tela: [1]somar [2]multiplicar [3]maior [4]novos números [5]sair do programa Seu programa deverá realizar a operação solicitada em cada caso. """ print('\033[1;36mCRIANDO UM MENU DE OPÇÕES\033[m') valor1 = int(input('Digite valor 1: ')) valor2 = int(input('Dig...
false
68e4b4215a683e0e9522a64b1fab426fd4bfa241
MarcosAllysson/python-basico-fundamento-da-linguagem
/ex033.py
367
4.21875
4
""" Faça um programa que leia 3 números e mostre qual é o maior e o menor. """ print('MAIOR E MENOR VALORES') num1 = int(input('Digite primeiro número: ')) num2 = int(input('Digite segundo número: ')) num3 = int(input('Digite terceiro número: ')) print('Maior valor digitado {}'.format(max(num1, num2, num3)), ', e o m...
false
b4daa31904d580ad5ca7cc5501625d56b55514f0
MarcosAllysson/python-basico-fundamento-da-linguagem
/ex051.py
727
4.125
4
""" Desenvolva um programa que leia o primeiro termo e a razão de uma PA. No final, mostre os 10 primeiros termos dessa progressão. Progressão aritmética (PA) é uma sequência numérica que possui a seguinte definição: a diferença entre dois termos consecutivos é sempre igual a uma constante, geralmente chamada de razão...
false
4f1be934e1980c02c9daa348e4da50cabe0f303f
MarcosAllysson/python-basico-fundamento-da-linguagem
/ex062.py
657
4.15625
4
""" Melhore o desafio 61, perguntando para o usuário se ele quer mostrar mais alguns termos. O programa encerra quando ele disser que quer mostrar 0 termos. """ print('SUPER PROGRESSÃO ARITMÉTICA 3.0') primeiro = int(input('Primeiro termo: ')) razao = int(input('Razão: ')) termo = primeiro cont = 1 total = 0 mais = 10...
false
73dd0a768454a0b28cb11f503a67e280241394b4
MarcosAllysson/python-basico-fundamento-da-linguagem
/ex010.py
571
4.1875
4
""" Crie um programa que leia quanto dinheiro uma pessoa tem na carteira e mostre quantos dólares ela pode comprar. Considere = US$ = 1,00 = R$ 3,27 """ print('DÓLARES NA CARTEIRA') valor = float(input('Quanto você tem na carteira? R$ ')) if valor < 5.27: print('Você não pode comprar nenhum dólar, por que 1 dólar ...
false
113ab8c6b2245a74fbcce68168c463a8f8550eaf
MarcosAllysson/python-basico-fundamento-da-linguagem
/ex011.py
548
4.21875
4
""" Faça um programa que leia largura e a altura de uma parede em metros, calcula a sua área e a quantidade de tinta necessário para pintá-la. Sabendo que, cada litro de tinta, pinta uma área de 2m**2 (2 metros quadrados). """ print('LITROS DE TINTA') largura = float(input('Qual largura da parede? ')) altura = float(i...
false
60ff157dd08174723fd53794c323a35e61a3cb76
aly22/cspython
/week1/return_day.py
208
4.1875
4
day1 = int(input("Please enter the starting day number: ")) length_of_stay = int(input("Please enter the length of your stay: ")) leave_day =day1+length_of_stay%7 print("The leaving day will be: ",leave_day)
true
77dc3f01c0e6e865de7a863e51fb67dc344c4082
Ziweili-12/BigData
/Assignment1_MapReduce/babynames.py
2,087
4.21875
4
#!/usr/bin/python import sys import re def extract_names(filename): """ Given a file name for baby<year>.html, returns a list starting with the year string followed by the name-rank strings in alphabetical order. ['2006', 'Aaliyah 91', Aaron 57', 'Abagail 895', ' ...] If this seems too daunting, r...
true
f1d1023de7cdc6db4723f1f44df605b550890639
anmsuarezma/Astrof-sica-Computacional
/02. Plotting and classes/code/curveplot1.py
649
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on 23 Dec 2018 @author: ashcat Curve Plotting """ import numpy as np import matplotlib.pyplot as plt def f(t): return t**2*np.exp(-t**2) # range of the independent variable # 50 points between 0 and 3 t = np.linspace(0, 3, 50) # values of the functio...
true
ffa1662468fe13c126535cae3c4a68d6c3dbe9c6
Harelyac/Python-PROJECTS
/Wikipedia Network/article.py
2,085
4.59375
5
class Article: """ The constructor of Article make an Article object that consist of 2 fields which are title and neighbor - a list that contains more Article objects! """ def __init__(self, article_title): self.__title = article_title self.__neighbors = [] def get_titl...
true
c86f34b28f333c39877855cb0d5555f80e1035e0
nsm-lab/principles-of-computing
/practice_activity3.py
2,484
4.34375
4
# Practice Activity 3 for Principles of Computing class, by k., 07/04/2014 # Analyzing a simple dice game (see https://class.coursera.org/principlescomputing-001/wiki/dice_game ) # skeleton code: http://www.codeskulptor.org/#poc_dice_game_template.py # official solution: http://www.codeskulptor.org/#poc_dice_game_solut...
true
3e840900dee1013038c152b6a6410999b2987e56
sreit/temp_converter
/temp.py
2,124
4.375
4
while True: try: start_degree = float(input('Enter a temperature: ')) break except ValueError: print('ERROR. Not a number.') continue start_unit_list = ['C', 'F', 'K'] start_unit = input('What unit is this? (C, F, K): ').upper() while start_unit not in start_unit_list: print...
true
62f3131125935949819ec706228572e18949a43a
neelchavan/Python
/Dictionary.py
325
4.34375
4
#here we are using dictionaries to give the meaning of some words to the user d1 = {'mes':'In english it means \'more\'','que':'In english it means \'Than\'','un':'In english it means \'A\'','club':'In english it means \'Club\''} #Enter the word to get the meaning of it Word = input("Enter the word\n",) print(d1[Word...
true
642813fb40fa3b52729d1354b74ccb02e6b5e087
neelchavan/Python
/get2ndlargest.py
274
4.125
4
#Unsorted list with duplicates numbers = [3,4,2,4,6,6] #removing duplicates numbers = list(dict.fromkeys(numbers)) #sort the list numbers.sort() #remove first max number numbers.remove(max(numbers)) #then print second highest number as the first highest print(max(numbers))
true
d8d8606d1460657f3b2775228ef03a1bc59f3836
markfj81/Geog565_Assign1
/Assignment1_Part1_[Johnson].py
644
4.3125
4
# Instructions: # Create a script that examines the following string for a particular letter. # "Python in GIS makes work easier". # If the string does contain your letter, the script should print # "Yes, the string contains the letter." # If not, the script should print "No, the string does not contain the lett...
true
306c87093bb07bd010f215455f2c13f0312cf161
ComradYuri/Statistics-LinearRegression
/script.py
1,790
4.125
4
import pandas as pd import matplotlib.pyplot as plt import numpy as np from sklearn import linear_model # Setting up pandas so that it displays all columns instead of collapsing them desired_width = 320 pd.set_option('display.width', desired_width) np.set_printoptions(linewidth=desired_width) pd.set_option('display.ma...
true
6abd018955ab20d6756c7003351bdb0701f80b01
AishaE/Python
/hello_world.py
833
4.15625
4
# 1. TASK: print "Hello World" print("Hello World") # 2. print "Hello Noelle!" with the name in a variable name = "Aisha" print("Hello" , name ) # with a comma print("hello" + name ) # with a + # 3. print "Hello 42!" with the number in a variable name = 7 print("Hello" , name ) # with a comma # print("Hello" + name ) #...
true
18c220bfbf8f7bcd14673ebe0ad26271a83975cc
TiagoJLeandro/uri-online-judge
/python/uri_3303.py
908
4.4375
4
""" Recentemente Juquinha aprendeu a falar palavrões. Espantada com a descoberta do garoto, sua mãe o proibiu de falar qualquer palavrão, sobre o risco de o menino perder sua mesada. Como Juquinha odeia ficar sem mesada, ele te contratou para desenvolver um programa que informe para ele se uma palavra é um palavrão ...
false
1489ff679d4ee25c2610e4389815f2cf079d7790
ko28/homework
/cs/cs540/p1/p1_weather.py
2,785
4.21875
4
# Name: Daniel Ko # Project 1, CS 540 # Email: ko28@wisc.edu # Some comments were taken from the homework directly import datetime # Distance between points in three-dimensional space, # where those dimensions are the precipitation amount (PRCP), # maximum temperature (TMAX), and minimum temperature for the day (T...
true
24712a41292d204f783818546321cdfc0af3b4bd
Douglass-Jeffrey/Unit-3-08-Python
/leap_year_determiner.py
571
4.3125
4
#!/usr/bin/env python3 # Created by: Douglass Jeffrey # Created on: Oct 2019 # This program determines if a user inputted year is a leap year def main(): # variables leap_year = " is not" # process # input useryear = int(input("Enter a year of your choice:")) print("") # Output if ...
true
b81601d4963cda59a132282ed2fe2627aeb32de0
valleyjo/cs0008
/project-2/activity-4.py
1,936
4.125
4
#Email: amv49@pitt.edu #Name: Alex Vallejo #ID: 3578411 #Date: 2/19/2014 #Description: This program is the game of craps! import random user_name = input("Enter your name: "); #Get the user's name print("\nWelcome " + user_name + "!"); #Print a nice welcome message print("This game of craps was written by Alex Valle...
true
712889dc38bb100d13d8f24e93cd99e9a9a2e19f
Pratik-20/Python-Projects.-
/0038.py
617
4.25
4
""" #PracticeCode: 0038 🎯 FORWARD IF YOU LIKE IT 🎯 Task: Create a program to input a number and check if it is multiple of 2 than print "Sel" , if multiple of 5 then print "fish" or if multiple of both then print "Selfish". Sample :- input - 5 output - fish input - 10 output - Selfish _________&___________________...
true
eb0477cf1ceffeedb167c1dd6ef938210f461e61
kyletruong/epi
/9_binary_trees/1_height_balanced.py
1,711
4.1875
4
# Check if binary tree is height-balanced # Difference in height of left sub-tree and right-subtree is at most 1 from binarytree import BinaryTree, Node from collections import namedtuple def is_balanced(root): # namedtuple makes it more expensive but more readable Node = namedtuple('Node', ['balanced', 'heig...
true
1827f2b72badd7a47848e114b18b69076c919d9a
AshrafulH1/Blackjack
/hand.py
2,967
4.40625
4
""" Module with the class definition of Hand. """ from card import Card class Hand(object): """A Hand is a list of at most 5 Cards. Attributes (hidden): __cards: a list of objects from class Card. Initialized to to an empty list. The length of __cards is no greater than ...
true
a9112fd648eb272506b86824cc1ef86eef57f29e
CREESTL/GrokkingAlgorithms
/selection_sort.py
1,018
4.21875
4
''' Сортировка выбором - это когда каждый выбранный элемент помещается в новый список Здесь приведен пример сортировки массива по возрастанию сортировкой выбором. O(n^2) ''' import time import random def find_smallest(arr): smallest = arr[0] smallest_index = 0 for i in range(1, len(arr)): if arr[i]...
false
d4361f36f8ecabef3d8de25fe870b4ceff073ff4
piresalexsandro/cursoPython
/stdr-3305-dicionarios.py
1,720
4.28125
4
# Em Python, como vimos anteriormente, as listas são sequências de # elementos identificados por um índice representado por um número inteiro. # Às vezes, no entanto, queremos utilizar alguma informação como índice de # algum dado em vez de um índice numérico. Para isso, usamos os # dicionários. # Um dicionário nada ma...
false
b2eb6c860482f26f8a2f35a176191681ee5d9a02
lubchenko05/python-examples
/task_4.py
657
4.125
4
""" Написать функцию, принимающую последовательность словарей, содержащих имена и возвращающую имена через запятую, кроме последнего, присоединённого через амперсанд. [{'name': 'John'}, {'name': 'Jack'}, {'name': 'Joe'}] -> 'John, Jack & Joe' [{'name': 'John'}, {'name': 'Jack'}] -> 'John & Jack' [{'name': 'John'}] -> ...
false
c56e5fa4fb2acbedd0fc1b58bc94721419fe280e
wanqiangliu/python
/5_9.py
854
4.1875
4
#访问复制的列表、删除原列表 users = ['zhangsan','admin','lisi','wangwu'] for user in users[:]: if user == 'admin': print("Hello admin,would you like to see a status report?") else: print("Hello " + user + ",thank you for logging in again") users.remove(user) if users: print("remove:" + user) else: print("We need to fin...
false
12860a786e3e82f215c8693cf1c8d3a04a88fd6a
Aakash7khadka/Data-Structures-and-algorithm-in-python
/gpa.py
655
4.28125
4
print('This is a gpa calculator') print('Please enter all your letter grades, one per line. ') print('Enter a blank line to designate the end. ') points = { 'A+' :4.0, 'A' :4.0, 'A-':3.67, 'B+':3.33, 'B' :3.0, 'B-' :2.67,'C+' :2.33, 'C' :2.0, 'C' :1.67, 'D+' :1.33, 'D' :1.0, 'F' :0.0} num_courses=0 total_points=0 done=...
true