blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ffc5c4eb524cd11e8e452e0e75c50b6ac0933e2b
rsp-esl/python_examples_learning
/example_set-3/script_ex-3_6.py
2,966
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ############################################################################## # Author: Rawat S. (Dept. of Electrical & Computer Engineering, KMUTNB) # Date: 2017-11-17 ############################################################################## from __future__...
true
091be1a39775ef12d7eacc6b90c2ab563fddb340
rsp-esl/python_examples_learning
/example_set-1/script_ex-1_34.py
1,238
4.4375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ############################################################################## # Author: Rawat S. (Dept. of Electrical & Computer Engineering, KMUTNB) # Date: 2017-11-17 ############################################################################## from __future__...
true
7f2111375c9fde24f8e238a901f59fd2b338c4b1
theymightbepotatoesafter/School-Work
/CIS 210/p11_quiz_christian_carter.py
2,320
4.3125
4
''' Prior programming experience quiz. CIS 210 Project 1-1 Hello-Quiz Solution Author: Christian Carter Credits: N/A Add docstrings to Python functions that implement quiz 1 pseudocode. (See p11_cricket.py for examples of functions with docstrings.) ''' def q1(onTime, absent): ''' (bool, bool) -> string ...
true
c42d57a4c634bae031e0dc1085cf88e95f1464d3
tartlet/CS303E
/DaysInMonth.py
1,512
4.40625
4
# File: DaysInMonth.py # Student: Jingsi Zhou # UT EID: jz24729 # Course Name: CS303E # Unique Number: 50695 # # Date Created: 09/25/2020 # Date Last Modified: 09/25/2020 # Description of Program: User inputs a month and year in integer form and program # outputs how many days the month has for any given year. Intende...
true
dff846be18fcde38c697f81272231da3beccc779
Johnwei386/Warehouse
/Exercise/Python/2017-09-21.py
261
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- num = raw_input("please submit a num:"); num = int(num) if num%2 == 0: if num%4 == 0: print "%d can be division by 4" % num else: print "%d can be division by 2, is even" % num else: print "%d is odd" % num
false
6275743572e4abdd7c0a00d5852bb8b58cb4bd8f
anirudhn18/msba-python
/Lab5/Lab5_Ex1.py
988
4.3125
4
class Point: """ Represents a point in 2D space """ def __init__(self, x=0.0, y=0.0): self.x = x self.y = y def __str__(self): return '({},{})'.format(self.x,self.y) class Rectangle: """Represents a rectangle. attributes: width, height, corner.""" # def __init__...
true
a72254ff8fee355dd7d06d31f9a3e30457704777
tdhawale/Python_Practise
/Swap.py
1,871
4.59375
5
# One method to swap variable is using another variabl print("--------------------------------------------------------") print("Using the conventional method for swap") a = 5 b = 6 print("The value of a before swap is :", a) print("The value of b before swap is :", b) temp = a a = b b = temp print("The value of a after...
true
ea9471de778308a17a7a553ab37b9aaf40695b31
bradszalach/pythonbeginnerscripts
/CurrencyConverter.py
2,960
4.28125
4
#Currency Converter.py #Scripted by Brad Szalach #Converts USD to Euro or other way around #1 USD = .81 Euro #1 USD = .71 GBP #1 USD = 106.28 JPY #1 Euro = 1.23 USD #1 Euro = .88 GBP #1 Euro = 131.02 JPY #1 GBP = 1.40 USD #1 GBP = 1.14 Euro #1 GBP = 149.08 JPY #1 JPY = .0094 USD #1 JPY = .0076 Euro #1 JPY = .0067 GBP ...
false
73cdeadb0220dc1917c47b2e78eacc772f48cb6e
rwedema/BFVP3INF2
/fixme2.py
846
4.25
4
#!/usr/env python3 """ Draw a tree using turtle """ __author__ = "Fenna Feenstra" import sys def tree(branchLen): """ function that draws the tree with stem and branches upwards""" if branchLen > 5: t.backward(branchLen) t.right(20) tree(branchLen-16,t) t.left(40) tr...
false
fb7512ed6162e479f0e8b2a669af7d9115171355
maliaditya/Python-code-snippets
/Algorithms/Sorting/insertionsort.py
238
4.21875
4
def insertion_sort(arr): for i in range(1,len(arr)): for j in range(i): if arr[j]>arr[i]: arr[i],arr[j] = arr[j],arr[i] return arr arr = [2,1,5,4,3,9,8] print(arr) sorted_array = insertion_sort(arr) print(sorted_array)
false
2fae6de3cc45cae76936c8253f9951cfad720848
tinadotmoardots/learning
/python/RPSv3.py
1,223
4.375
4
# This is a version of rock, paper, scissors that you can plan against a computer opponent import random player_wins = 0 computer_wins = 0 print("Rock...") print("Paper...") print("Scissors...") while player_wins < 2 and computer_wins < 2: print(f"Player Score: {player_wins} Computer Score: {computer_wins}") play...
true
dc9fd2bce543366b0a1f196397aeb8ba82c80bea
Tomxp32/Python-proyects
/math_main/clases/Clase1_logica.py
1,502
4.5
4
# CLase 1 Logica logica = ''' La lógica es la ciencia formal y rama tanto de la filosofía como de las matemáticas que estudia los principios de la demostración y la inferencia válida, las falacias, las paradojas y la noción de verdad. La lógica matemática es la rama más matemática de la lógica, que estudia ...
false
fe065712a5b6500d9b9a8dc88ce1b7910a3990a6
Jacob-Bankston/DigitalCrafts-Assignments
/Week1/Week1-Tuesday-Assignments/add-two-numbers.py
876
4.34375
4
#Defining a function to add two numbers together from user input def add_numbers(input_1, input_2): total = input_1 + input_2 return print(f"Your two numbers added together are: {total}") #Seeking user input for the add_numbers function while 1: try: #Checking for integer input on the first number's input ...
true
bff9e6911ee84b2424d298daa4ded0fd29e417f7
acrane1995/projects
/Module 1/absolute beginners.py
2,855
4.15625
4
#my_num = 123 #num_intro = "My number is " + str(my_num) #print(num_intro) #total_cost = 3 + 45 #print(total_cost) #45 was represented as a string and therefore could not be executed #school_num = 123 #print("the street number of Central School is " + str(school_num)) #school_num is an int and needed to be converted...
true
b36975217050a1e3a8af54e7e7a4d1d0e7ae3e1a
divyansh1235/Beta-Algo
/python/tree/PostorderTraversal.py
2,087
4.375
4
#POSTORDER BINARY TREE TRAVERSAL # In this algorithm we print the value of the nodes present in the binary tree in postorder # fashion. # Here we first traverse the left subtree and then traverse the right subtree and finally we # print the root # The sequence is as follows - # Left->Right->Root class node (): ...
true
41c9233b4165f4da13629a007e24dfbc248cff9d
jasonluocesc/CS_E3190
/P4/shortest_cycle/solution.py
1,791
4.34375
4
# coding: utf-8 def get_length_of_shortest_cycle(g): """Find the length of the shortest cycle in the graph if a cycle exists. To run doctests: python -m doctest -v solution.py >>> from networkx import Graph >>> get_length_of_shortest_cycle(Graph({1: [2, 3], 2: [], 3: []})) >>> get_length_o...
true
aca7b1cf5d55a62b67f6156c9b633b7bc811e1ab
hansrajdeshpande18/geeksforgeeksorg-repo
/printreverse.py
206
4.28125
4
#Print first and last name in reverse order with a space between them firstname = (input("Enter your first name:")) lastname = (input("Enter your last name:")) print("Hello " +lastname + " " +firstname)
true
839102579223d22c81a0f54a816f585f7c70262e
skrall3119/prg105
/MyProject/Practice 9.1.py
2,704
4.5625
5
import pickle def add(dic): # adds a new entry to the dictionary name = input('Enter the name you wish to add: ') email = input('Enter the email you wish to associate with this name: ') dic[name] = email print(dictionary) def remove(dic): # removes the entry of the dictionary na...
true
8611ef35c047b7362cb965eb1d07c713cf327d3e
LaxmanMaharjan/Python
/venv/Codes/Polymorphism/Operator_Overloading.py
1,060
4.15625
4
""" The purpose of these so-called “magic methods” is to overload Python operators or built-in methods. """ class Polynomial: def __init__(self,*args): self.coeffs = args def __add__(self, other): #overloading + return Polynomial(*(x+y for x,y in zip(self.coeffs,other.coeffs))) def __sub_...
false
d8ca1f9146fa6dad6de66701e10e45f054f37c39
dgervais19/Eng74_Python
/dictionaries.py
1,694
4.65625
5
# What is a dictionary # Dictionary (arrays) is another way managing data more Dynamically # Key value pairs to store and manage data # Syntax : {"name": "James"} # a = {"key": "value"} # what type of data can store/manage # Let's create one devops_student_data = { "key": "value", "name": "james", "stream"...
true
8d8a4983bc39fb8c6870cb7e7f275b43d160baea
bhawnabhatt2012/python_lab_exp
/2.b.py
497
4.21875
4
index = 0 string = input("Enter the string: ") substring = input("Enter the substring: ") if substring in string: print(substring," is present in ",string) while index < len(string): index = string.find(substring, index) if index == -1: break print(substring, ' found...
true
edc8eefa43d0a05859412b8ca21107af71e8237c
lanaelsanyoura/CommentedPythonIntermediateWorkshop
/Person.py
1,226
4.25
4
from datetime import date, datetime #for date class Person: """ A person class ==== Attributes ==== firstname: str lastname: str birthdate: date YEAR, MONTH, DAY address: str """ def __init__(self): #, firstname, lastname, birthdate, address): #self.firstname = firstname ...
true
13c0b258a492922a560d61c522efd7d6217fc045
michaelkemp2000/vader
/ex20.py
1,186
4.375
4
from sys import argv # Pass in an argument from command line script, input_file = argv # Function to print the whole file def print_all(f): print f.read() # Function to go the the begining of a file def rewind(f): f.seek(0) #Function to print a line of the file that you pass in def print_a_line(line_count, f): p...
true
d6edafab430c4d6585a2edc62ca1336901199f95
michaelkemp2000/vader
/ex3.py
1,104
4.375
4
# Print the text print "I will now count my chickens." # Print test and the sum answer after the comma print "Hens", 25.645 + 30.5943 / 6 # Print test and the sum answer after the comma print "Roosters", 100 - 25 * 3 % 4 # Print the text print "Now I will count the eggs." # Prints the answer to the sum. Not sure w...
true
210c5757a96f915bfdcba3d80cda9a7dddae74c1
miguelgaspar24/BoardgamePrices
/utilities.py
728
4.65625
5
#!/usr/bin/env python # coding: utf-8 def convert_chars(string): ''' Converts problematic characters. Usually, tend to be accented vowels. Takes the following parameters: string (str): a string where one or more characters raise a UnicodeEncodeError. Returns a modified string. ''' ...
true
71eca0bfe16eb700afb7dc2b38bea1977e7ab911
oliverxudd/pytorch-gist
/numpy_basics.py
1,398
4.1875
4
"""basics of numpy""" # 1. deep copy of numpy arrays B = numpy.empty_like(A) B[:] = A # 2. rearrange axes for numpy array np.transpose(A, axes=[2,0,1]) A.transpose(2,0,1) # 3. set elements to 0 if element meet some condition out = np.where(A<3, A, 0) # 将矩阵A中小于3的元素置为0 # 4. show nonzero elements of numpy array A = np...
false
ee8549863440f5c92a6abc80b55c7e0d4eb3b05f
brinquisruben/evaluacion1
/par y multiplo3.py
395
4.15625
4
# -*- coding: cp1252 -*- def par_y_divisble_para_tres(): a= input("introduzca n: ") if(a%2==0): if(a%3==0): print "multiplo de 2 y 3" else: print "par y no multiplo de 3" else: if(a%3==0): print "impar y multiplo de 3" else: ...
false
ecccdec592c1cccb123c9ab92170438df90e8fed
jeffkt95/ProjectEuler
/problem0005.py
945
4.15625
4
import sys import os import math def main(): highestNumber = 20 maxCheck = highestNumber * 100000000 # Starting with highestNumber, go up by multiples of highestNumber # e.g. if your highestNumber was 10, check 10, 20, 30, 40, etc. for numForCheck in range(highestNumber, maxCheck, highestNumber): #Assume it'...
true
60cfdeffffb011a932a51daf21ddfb9d42c50bb4
gvnaakhilsurya/20186087_CSPP-1
/cspp1-pratice/m10/biggest Exercise/biggest Exercise/biggest_exercise.py
1,025
4.125
4
#Exercise : Biggest Exercise #Write a procedure, called biggest, which returns the key corresponding to the entry with the largest number of values associated with it. If there is more than one such entry, return any one of the matching keys. def biggest(aDict): ''' aDict: A dictionary, where all the values a...
true
f3b2c0443d86d4b7deedc30384e3a0aa7868b4c0
gvnaakhilsurya/20186087_CSPP-1
/cspp1-pratice/m3/hello_happy_world.py
234
4.125
4
''' @author : gvnaakhilsurya Write a piece of Python code that prints out the string 'hello world' if the value of an integer variable, happy,is strictly greater than 2. ''' HAPPY = int(input()) if HAPPY > 2: print("hello world")
true
68cc3286321708fcf077d10f169acfbe5e326715
dineshagr/python-
/multiDimentionalLists.py
641
4.40625
4
# this is a one dimentional list x = [2,3,4,5,6,7,8] # this is a 2 dimentional list y = [[5,4], [3,4], [7,9], [2,8]] # 0 1 0 1 0 1 0 1 these are the individual positions of inner lists # 0 1 2 3 these are the positions of outer lists print(y) print(y[3][1]) # this is a multidimenti...
true
cf108fc7d5b54022363eb5d5ced17ec540c0256d
mfirmanakbar/python
/operators/comparation_operators.py
270
4.21875
4
a = 5 b = 10 print("a == b is", a == b) print("a != b is", a != b) print("a > b is", a > b) print("a < b is", a < b) print("a >= b is", a >= b) print("a <= b is", a <= b) ''' a == b is False a != b is True a > b is False a < b is True a >= b is False a <= b is True '''
false
04acf60a4d97dc23ddc43b30798db72ccdbbc549
mfirmanakbar/python
/data_types/string_operations.py
968
4.375
4
my_str = "welcome to the tutorial" my_str_2 = "this is my string" print(my_str) print(my_str_2, end="\n\n") print("print all: ", my_str[:]) print("from index 2 until index 9 and skip index 10: ", my_str[2:10]) print("from index 0 until index 13 and skipping 1 element: ", my_str[0:14:1]) print("from index 0 until index...
false
03ed3c22fe20ae1738041d24a62001328a870734
mfirmanakbar/python
/data_types/tuple_operations.py
1,200
4.46875
4
# initialize tuples my_tuple = () my_tuple_2 = tuple() print("empty my_tuple:", my_tuple) print("empty my_tuple_2:", my_tuple_2) my_tuple = my_tuple + (1, 2, 3) print("init my_tuple from plus: ", my_tuple, end="\n\n") # initialize elements to the tuple my_tuple = (1, 2, 3) my_tuple_2 = tuple(("python", "for", "firman"...
false
e90cfacd47c60099592b03dba2948da5dca2d141
jarehec/holbertonschool-webstack_basics
/0x01-python_basics/101-print_diagonal.py
261
4.15625
4
#!/usr/bin/python3 """ module containing print_diagonal function """ def print_diagonal(n): """ draws a diagonal line @n: integer:q """ if n <= 0: print() else: [print(' ' * i + '\\') for i in range(n)] print()
false
b689d8c576b9731b116d987bb1282437803f63a9
onatsahin/ITU_Assignments
/Artificial Intelligence/Assignment 2/block_construction_constraint.py
2,980
4.125
4
#Onat Şahin - 150150129 - sahino15@itu.edu.tr #This code include the Block class and the constraint function that is used for the csp problem. #This code is imported from csp_str_1.py and csp_str_2.py which create the model and solve the problem. blocklist = [] #A list that holds block objects. Filled in the other co...
true
41eec34b60ce8f0152543d9464e064039a974cae
sebutz/python101code
/Chapter 4 - Conditionals/conditionals.py
2,148
4.34375
4
# a simple if statement if 2 > 1: print("This is a True statement!") # another simple if statement var1 = 1 var2 = 3 if var1 < var2: print("This is also True") # some else if var1 > var2: print("This should not be printed") else: print("Ok, that's the good branch") # -1 -----0 ----...
true
1d76d63c49fba58705754cb77cc6228a3bb891c0
isaiahb/youtube-hermes-config
/python_publisher/logs/logger.py
957
4.1875
4
"""This module creates a logger that can be used by any module to log information for the user. A new logger is created each time the program is run using a timestamp to ensure a unique name. """ import logging from datetime import datetime class Logger(): """Creates a timestamped log file in the logs/ directory a...
true
c3298fa7e323160b821295148c7e7094e9d47364
lradebe/simple_programming_problems
/largest_element.py
219
4.1875
4
def largest_element(mylist): largest_element = 0 for element in mylist: if element >= largest_element: largest_element = element print(largest_element) largest_element([1, 2, 3, 4, 5])
true
0177a475d7829b46e61a98456b99d438e3250bb8
lradebe/simple_programming_problems
/find_intersection.py
726
4.375
4
def find_intersection(Array): '''This function takes in a list with two strings \ it must return a string with numbers that are found on \ both list elements. If there are no common numbers between \ both elements, return False''' first = list(Array[0].split(', ')) second = list(Array[1].split(', ')) s...
true
361d5439ded4c00ad770618c6c99cf927c8117a7
Harsh-Modi278/dynamic-programming
/Fibonacci Sequence/solution.py
534
4.3125
4
# Initialising a dictionary to store values of subproblems memo_dict = {} def fibonacci(n): # If answer to the nth fibonacci term is already present in the dictionary, return the answer if(n in memo_dict): return(memo_dict[n]) if n <= 2: return (1) else: # Store the answer to t...
true
ff45174dacc0319d4cb1faa28984f5ed10cf6662
TheBrockstar/Intro-Python
/src/days-1-2/fileio.py
468
4.1875
4
# Use open to open file "foo.txt" for reading foo = open('foo.txt', 'r') # Print all the lines in the file print(foo.read()) # Close the file foo.close() # Use open to open file "bar.txt" for writing bar = open('bar.txt', 'w') # Use the write() method to write three lines to the file bar.write('''"To be, or not to...
true
f1acef2e2802c79c6ffd74b1b357fb84aeaf2d26
Kyrylo-Kotelevets/NIX_python
/Trainee/9.py
762
4.46875
4
""" создайте функцию-генератор, которая принимает на вход два числа, первое - старт, второе - end. генератор в каждом цикле должен возвращать число и увеличивать его на 1 при итерации генератор должен начать с числа start и закончить итерации на числе end т.е. при вызове for i in my_generator(1, 3): print(i...
false
899ff27333c1927fc535d670fd4cf0dd4754ed9e
Kyrylo-Kotelevets/NIX_python
/Beginner/4.py
615
4.34375
4
""" Дан список из строк. Создайте однострочное решение (при помощи list comprehension), которое приведёт к верхнему регистру все строки, содержащие слово 'price') """ strings = ["Given a list of strings", "Create a one line solution", "(with a list comprehension)", "which will convert"...
false
ac3e0974a676ea2cec4025da88171668aafa7062
mukesh25/python-mukesh-codes
/pattern/pattern9.py
332
4.1875
4
# 1 # 2 2 # 3 3 3 # 4 4 4 4 # No. of spaces in every row:(n-i-1) # which symbol: (i+1) # How many times: (i+1) # with in each row same symbol are taken # inside row symbol are not changing that's why nested loop is not required. n= int(input('Enter n value: ')) for i in range(n): print(' '*(n-i-1)+(str(i+1)+'...
true
55c3bccfa073b942813d86a3764aa4237e55486c
mukesh25/python-mukesh-codes
/stringpattern/strpattern5.py
333
4.21875
4
# write a program to REVERSE internal content of each word? # input = mukesh software solutions # output = hsekum erawtfos snoitulos s = input('enter some string to reverse: ') l = s.split() print(l) #['mukesh','software','solutions'] l1=[] for word in l: l1.append(word[::-1]) print(l1) output = ' '.join(l1) p...
false
90ee5d614355f201a11e5a5f8d64dd2632427dac
urskaburgar/python-dn
/naloga-8/calculator/calculator.py
417
4.21875
4
first_number = int(input("Enter the first number: ")) second_number = int(input("Enter the second number: ")) operation = input("Choose operation (+, -, *, /): ") if operation == "+": print(first_number + second_number) elif operation == "-": print(first_number - second_number) elif operation == "*": prin...
true
f0eb2816abe1464ed57b923664a5a97737c8f1f0
dgampel/passion-learn
/examples/binary_search.py
908
4.28125
4
def binary_search(array,first,last,x): array.sort() if last >= 1: #base case middle = 1 + (last - 1) // 2 if array[middle] == x: #if element is present at middle return middle if array[middle] > x: #if element is in left half ...
true
182ea9db6515bbed025a04d7cca1bef7bbac5c2c
Anshul-Swarnkar/Oops
/InheritanceSuperMethod.py
465
4.34375
4
class BaseClass: def hello_world(self): print("Hello Python from Base") def Bye(self): print("Bye Bye") class ChildClass(BaseClass): def hello_world(self): #BaseClass.hello_world(self) #here we are calling same method of BaseClass super().hello_world() # here you can use ...
false
e89644f9ae975b08815394c47a0669ee65627f07
gopalanand333/Python-Basics
/dictionary-basic.py
333
4.71875
5
#! /usr/bin/env python03 # a dictionary is searchable item with key-value pair x = {"one": 1, "two":2, "three":3, "four":4,"five":5} # a dictionary for key in x: print(key) # this will print the keys for key, v in x.items(): print('key: {} , value:{}'.format(key, v)) # this will return the key val...
true
cd93ecfa1c20132aa72909ed314b4ba3d2fe177b
blakexcosta/Unit3_Python_Chapter5
/main.py
1,208
4.3125
4
def main(): # booleans number1 = 1 number5 = 5 # boolean values are written as True and False if (number1 > number5): print("this statement is true") else: print("this statement is false") # list of comparison operators # https://education.launchcode.org/lchs/chapters/b...
true
ba025910735dc60863ef5b6525cc20bace3675cb
CAWilson94/MachineLearningAdventures
/ex2/python/iris.py
2,446
4.4375
4
# Charlotte Wilson # SciKit learn example # How starting from the original problem data # can shaped for consumption in scikit-learn. # importing a dataset from sklearn import datasets # data member is an n_sample and n_features array iris = datasets.load_iris(); digits = datasets.load_digits(); # digits.data access...
true
42733c4983449b3967f4b450f35c6b319f8cbd9b
alexgneal/comp110-21f-workspace
/exercises/ex01/hype_machine.py
273
4.15625
4
"""Use concantonations to build up strings and print them out using my name.""" __author__ = "730332719" name: str = input("What is your name? ") print(name + ", you are awesome!") print("You're killing it, " + name) print("Wow, " + name + ", you are an absolute queen!")
true
617bcc056e3011b6b303ab1c1de87d3e9af49417
Benneee/PythonTrips
/Assignment_Wk4_Day1_QuadRoots_App.py
2,135
4.34375
4
#The Quadratic Roots Programme #ALGORITHM #1 Introduce the program to the user #2 Give the required instructions to run program appropriately #3 Request values for a, b, c #4 Define a variable for the discriminant #- Solve the discriminant #- Solve the square root of the discriminant #- import math m...
true
b70d695f70fc311d4e81a1c0461d6638711f011b
jerthompson/au-aist2120-19fa
/1000-B/calc.py
468
4.125
4
running_total = 0 # accumulator running_prod = 1 while True: print("The total so far is", running_total) print("The prod so far is", running_prod) num = int(input("enter a number: ")) # num = input("enter a number: ") # num = int(num) if num == 0: break else: running_total =...
false
c76cf6d1d8d193a0f2a9036d06558344caf2f066
jerthompson/au-aist2120-19fa
/1130-A/0903-primeA.py
300
4.25
4
n = 2 max_factor = n//2 is_prime = True # ASSUME it is prime for f in range(2, max_factor + 1): # INCLUDE max_factor by adding 1 if n % f == 0: print(n, "is not prime--it is divisible by", f) #exit() is_prime = False break if is_prime: print(n, "is prime")
true
f28949cd50fe4a1d5e80c4f0fad20d6172a0531a
hbinl/hbinl-scripts
/Python/C5 - MIPS/T3 - new_power.py
1,762
4.21875
4
""" FIT1008 Prac 5 Task 3 @purpose new_power.py @author Loh Hao Bin 25461257, Derwinn Ee 25216384 @modified 20140825 @created 20140823 """ def binary(e): """ @purpose: Returns a binary representation of the integer passed @parameter: e - The integer to be converted to binary @precondition: A positive i...
true
6f5abd237c95b6590f222c0e5c2dbaf1c7243e99
itsformalathi/Python-Practice
/iteratingdictionery.py
473
4.78125
5
#No method is needed to iterate over a dictionary: d = {'A': 'Apple', 'B': 'Ball', 'C': 'Cat'} for Key in d: print(Key) #But it's possible to use the method iterkeys(): for key in d.iterkeys(): print(key) #The method itervalues() is a convenient way for iterating directly over the values: f...
true
8beb44bb1abf99b16cc7b4a05f3dca7b6b3f6c93
derekyang7/WSIB-Coding-Challenge
/code-obfuscation.py
811
4.15625
4
def myfunction(): num = input("Enter string:") a = "" b = num while len(b) > 0: if len(b) > 0: c = b[-1] b = b[:-1] a += c else: break if a == num: return True else: return False """Function that reverses the order ...
true
a086ad53f58f18ede70ba9eff3eb6d474ec49457
hrd005/lab3_inf
/lab_03_01.py
1,142
4.375
4
''' Кортежи ''' # создание кортежа a1 = tuple() a2 = 1, 2, 3, "abc" a3 = (1, 2, 3, "abc") print("Tuple a1 = ", a1) print("Tuple a2 = ", a2) print("Tuple a3 = ", a3) # создание кортежа из других структур данных l = [1, 2, 3, "abc"] # из списка a4 = tuple(l) print("Tuple a4 from list l = ",...
false
6fd271c5a9306bbd737e223d2d0236547ba033a2
tvrt0001/CodeWars-Python
/SolutionsByTobi/challenges_6kyu/tribonacci.py
846
4.15625
4
##################################################################################### # # # NAME: Tribonacci Sequence # # RANK: 6kyu ...
false
b1e254e649b83072a1ea2a09f3e40d5a7f6b5a5d
siggij91/TileTraveller
/tile_traveller.py
2,353
4.1875
4
##Project 5 Tile Traveler https://github.com/siggij91/TileTraveller #Create tile structure and label it #Append allowable moves to file structure #N = +1 in second index and S = -1 #E = +1 in first index and W = -1 #Once in new tile, show the allowable moves #Once player enters 3, 1 show them that they win. def can...
true
4a578dd7fcd9cc12e0a6e28051f5641d2a9c22fe
vijaypal89/algolib
/ds/linkedlist/intro2.py
593
4.125
4
#!/usr/bin/python import sys class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def printList(self): temp = self.head while temp: print temp.data, temp = temp.next ...
true
9114541f1b9aa4b177fafd0ac50ef8b81ce76da0
AlreadyTakenJonas/pythonBootCamp2021
/easyExercise_12_regression/easyExercise_12_regression.py
2,208
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Mar 14 17:20:35 2021 @author: jonas """ # IMPORT MODULES # Handling linear regression from sklearn.linear_model import LinearRegression # Handling exponential regression from scipy.optimize import curve_fit # Handling numbers and arrays import numpy as...
true
7736bd8f305be6ea6e633d1fd34a7fe4e3ec33e3
missweetcxx/fragments
/segments/sorting/d_insert_sort.py
2,061
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- class InsertSort: """ Insert Sort divide list into two lists: sorted one and unsorted one; each time insert an element from unsorted list into sorted one at correct position; Complexity: O(n^2) in worst case Memory: O(1) """ @staticmethod...
true
25d5e2d5f13b3580b96f8a8496ba1377b28171a6
missweetcxx/fragments
/segments/binary_tree/binary_tree.py
1,895
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from segments.binary_tree.node import Node class BinaryTree(object): """ generate binary tree """ def __init__(self): self.root = None pass # create a binary tree with nodes def _add_node(self, val): # create root node of...
true
c6028097760cbb32a3c9a52d82dd94d8fd23dccc
tunnelview/Sandbox
/Prac_03/password_check.py
729
4.1875
4
def main(): MINIMUM_LENGTH = 16 get_password(MINIMUM_LENGTH) def get_password(MINIMUM_LENGTH): get_password = input("Enter Password of at least {} characters: ".format(MINIMUM_LENGTH)) while len(get_password) < MINIMUM_LENGTH: print(f"please enter password of {MINIMUM_LENGTH} characters") ...
false
6779b061c38dfb54b977a2bee0f34ca70a86ddc7
qadaidi/tp01-qadaidi-python
/tp01_ex1.py
1,697
4.15625
4
""" Programme permettant de convertir une quantité en plusieurs unités d'énergie. 1J = 0.738 ft-lb = 0.239 cal = 6.24*10^18 eV Unités : joule, calorie, Ft-lb et eV Données : Une valeur et une unité Indications: Selon l'unité entrée par l'utilisateur, afficher la conversion dans les 3 autres ...
false
d238ca151039d1ef380bd4ea71ba2d6eab10afdb
catarcatar/cursopython
/ejercicio07.py
493
4.46875
4
''' Ejercicio 7 Escribe una función llamada hola que reciba un parámetro (una cadena de texto) y retorne "Hola " seguido del argumento y un signo de exclamación. # escribe la función hola acá # código de prueba print(hola("Pedro")) # "Hola Pedro!" print(hola("Juan")) # "Hola Juan!" print(hola("")) # "Hola !" ''' def...
false
3db4db9c93004441a249355b1a923a8439e78aa8
jgerity/talks
/2016/computing_workgroup/intro-to-python/firstclassfunctions_example.py
1,431
4.59375
5
#!/usr/bin/env python def makeAddFunction(x): """ This function represents breaking the operation x+y into two steps, by returning a function F(y) that "knows" what value of x to use. In more specific terms, the value of x is stored in the "closure" of the function that is created. """ de...
true
3efd34ad76ac8bc585692de0f0868b0a8c124001
Lguo0128/helloPython
/practice/chapter4/ex04_02.py
622
4.5
4
# 4-2 动物:想出至少三种有共同特征的动物,将这些动物的名称存储在一个列表中,再使用 for 循环将每种动物的名称都打印出来。 #  修改这个程序,使其针对每种动物都打印一个句子,如“A dog would make a great pet”。 #  在程序末尾添加一行代码,指出这些动物的共同之处,如打印诸如“Any of these animals would make a great pet!”这样的句子 animals = ['cat','dog','rabbit','bird'] for animal in animals: print('A ' + animal + ' would make a gre...
false
0be16c108fc4361fddf8fe0117804e88d4aa4adc
LucasMonteiroBastos/python3_mundo01
/ex028.py
611
4.28125
4
'''Exercício Python 28: 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.''' import random a = int(input('Em que numero estou pensando...
false
0062eb73333fbb36791f164a7d3743691eb36490
vbanurag/python_set1
/set_1/Ques_2.py
687
4.125
4
a=[1,1,2,3,5,8,13,21,34,55,98] #part 1 #prints all elements of the list which are less than 5 print "\nThe no. are less than 5 is : ",[x for x in a if x<5] #part 2 #print a seperate list and stored a no which is less than 5 new_a=[] for x in a: if x<5: new_a.append(x) print "\n New list is ",new_a #...
true
aed55c61659e5efbc2c9330ca54947651c00bb67
KareliaConsolidated/CodePython
/Basics/08_Functions.py
1,431
4.125
4
# Create variables var1 and var2 var1 = [1, 2, 3, 4] var2 = True # Print out type of var1 print(type(var1)) # Print out length of var1 print(len(var1)) # Convert var2 to an integer: out2 out2 = int(var2) # Create lists first and second first = [11.25, 18.0, 20.0] second = [10.75, 9.50] # Paste together first and s...
true
23ce14c416b32d4aa28e7c342c9ab201b8f640df
KareliaConsolidated/CodePython
/Basics/49_Functions_Ex_09.py
312
4.25
4
# Write a function called multiply_even_numbers. This function accepts a list of numbers and returns the product all even numbers in the list. def multiply_even_numbers(li): total = 1 for num in li: if num % 2 == 0: total *= num return total print(multiply_even_numbers([1,2,3,4,5,6,7,8,9,10])) # 3840
true
873d59c466d5d1b9820cfb3ce30d8fce24f74876
KareliaConsolidated/CodePython
/Basics/17_Conditional_Statements.py
1,008
4.25
4
# Conditional logic using if statements represents different paths a program can take based on some type of comparison of input. name = "Johny Stark" if name == "Johny Stark": print("Hello, " +name) elif name == "John Fernandes": print("You are not authorized !" +name) else: print("Calling Police Now !") # In Pyth...
true
4dac05e28d6efd9441100f9d70a9f61318e8bb65
KareliaConsolidated/CodePython
/Basics/21_Loops.py
613
4.34375
4
# In Python, for loops are written like this: for item in iterable_object: # do something with item # An iterable object is some kind of collection of items, for instance; a list of numbers, a string of characters, a range etc. # item is a new variable that can be called whatever you want # item references the curr...
true
f6f144ae9939c97e2f3ee45dff82029100277512
KareliaConsolidated/CodePython
/Basics/166_Python_Ex_27.py
443
4.21875
4
# nth # Write a function called nth, which accepts a list and a number and returns the element at whatever index is the number in the list. If the number is negative, the nth element from the end is returned. # You can assume that number will always be between the negative value of the list length, and the list length ...
true
84dea473a9911b96684c54d1f339a442ecac41a6
KareliaConsolidated/CodePython
/Basics/158_Python_Ex_19.py
400
4.25
4
# Vowel Count # Write a function called vowel_count that accepts a string and returns a dictionary with the keys as the vowels and values as the count of times that vowel appears in the string. def vowel_count(string): lower_string = string.lower() return {letter:lower_string.count(letter) for letter in lower_string ...
true
c06f926ba0c3bf416e403eed81a0497605ab1eeb
KareliaConsolidated/CodePython
/Basics/160_Python_Ex_21.py
781
4.375
4
# Write a function called reverse_vowels. This function should reverse the vowels in a string. Any characters which are not vowels should remain in their original position. You should not consider "y" to be vowel. def reverse_vowels(s): vowels = 'aeiou' string = list(s) i, j = 0, len(s) - 1 while i < j: if string...
true
bbbb95519e1f58642b25b4642b7ef20bc0bbbf05
neoguo0601/DeepLearning_Python
/Python_basic/python_basic/python_basic_1.py
2,066
4.5
4
days = 365 print(days) days = 366 print(days) #Data Types #When we assign a value an integer value to a variable, we say that the variable is an instance of the integer class #The two most common numerical types in Python are integer and float #The most common non-numerical type is a string str_test = "China" int_tes...
true
d78a38eb6e954225d81984b05cd5cc782b5b93b8
bitlearns/TurtleGraphics
/Assignment14_RegularPolygonsWithTurtleGraphics.py
2,672
4.9375
5
#Program Description: The following program will use turtle graphics to draw #polygons based on the user's input of how many sides it will have. #Author: Madeline Rodriguez #Imports turtle graphics and random from turtle import * import random #The sides function will take in the user's input of number of sides and ...
true
7c2660f87a6b9ebe8e1151867c3d72328fc755fd
JoA-MoS/Python-DeckOfCards
/card.py
2,338
4.125
4
# -*- coding: utf-8 -*- # Check this out for cards display https://en.wikipedia.org/wiki/Playing_cards_in_Unicode # Create a Suit Class??? SUITS = {1: {'Suit': 'Clubs', 'Symbol': '♣'}, 2: {'Suit': 'Diamonds', 'Symbol': '♦'}, 3: {'Suit': 'Hearts', 'Symbol': '♥...
false
a64fee29b65474879949c905b005046e61298a8e
Isaac-Tait/Deep-Learning
/Python/scratchPad4.py
893
4.15625
4
# Exponent functions def raise_to_power(base_num, pow_num): result = 1 for index in range(pow_num): result = result * base_num return result print(raise_to_power(3, 2)) # 2D list number_grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], [10] ] print(number_grid[2][2]) print("It is time to...
true
e5dfd182fe3810d77335f56d8d73ff6d26603be0
paulram2810/Python-Programs
/armstrong.py
265
4.125
4
num = eval(input("Enter number to check for armstrong : ")) x = num flag = 0 while x!=0 : temp = x%10 flag = flag+(temp**3) x = x//10 if flag==num: print(num," is an armstrong number.") else: print(num," is not an armstrong number.")
true
3be02701f737d06284c9a26f1c719cdab2c721d1
bmlegge/CTI110
/P3T1_AreasOfRectangles_Legge.py
737
4.15625
4
#CTI-110 #P3T1: Areas of Rectangles #Bradley Legge #3/3/2018 print("This program will compare the area of two rectangles") recOneLength = float(input("Enter the length of rectangle one: ")) recOneWidth = float(input("Enter the width of rectangle one: ")) recOneArea = float(recOneLength * recOneWidth) rec...
true
f4757eb581419b63362df05cbdebee759ec302d3
flerdacodeu/CodeU-2018-Group7
/lizaku/assignment2/Q2.py
2,129
4.15625
4
from Q1 import Node, BinaryTree, create_tree def find_lca(cur_node, node1, node2): result = find_lca_(cur_node, node1, node2) if not isinstance(result, int): raise KeyError('At least one of the given values is not found in the tree') return result def find_lca_(cur_node, node1, node2): # This...
true
b93f8ec573992e03b78f890fc8218ff4404ed435
flerdacodeu/CodeU-2018-Group7
/EmaPajic/assignment4/assignment4.py
1,923
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: EmaPajic """ def count_islands(rows,columns,tiles): """ I am assuming that we can change tiles (set some values to false). If we couldn't do that, we could just make another matrix where we would store flags so that we don't visit same tile tw...
true
c318ca570f5bffa95560fc13a6db502472133dc5
oskarmampe/PythonScripts
/number_game/program.py
538
4.15625
4
import random print("----------------------------------") print(" GUESS THAT NUMBER GAME ") print("----------------------------------") the_number = random.randint(0, 100) while True: guess_text = input("Guess a number between 0 and 100: ") guess = int(guess_text) if the_number > guess: ...
true
8ed2ee72189b451698cfbc5b861cdbe5136cd3bc
StefGian/python-first-steps
/teenagerStory.py
588
4.375
4
#first method with or age = input("How old are you?") if(int(age)> 18 or int(age)<13) : print("you are not a teenager") else: print("you are a teenager") #second method with and age = input("How old are you?") if(int(age)< 18 and int(age)>=13) : print("you are a teenager") else: print("...
false
3049443c9a563cdcecd50556ecd1aeb8e1db0e6b
StefGian/python-first-steps
/maxOfThree.py
370
4.40625
4
#Implement a function that takes as input three variables, #and returns the largest of the three. Do this without using #the Python max() function! a = int(input("Type the first number: ")) b = int(input("Type the second number: ")) c = int(input("Type the thrid number: ")) if a>b and a>c: print(a) elif...
true
412a520a55edcaa026306556a477ff4fe01bed4a
Akhichow/PythonCode
/challenge.py
632
4.125
4
vowels = set(["a", "e", "i", "o", "u"]) print("Please enter a statement") sampleText = input() finalSet = set(sampleText).difference(vowels) print(finalSet) finalList = sorted(finalSet) print(finalList) # [' ', 'I', 'c', 'd', 'm', 'n', 'r', 's'] # My solution - # finalList = [] # # while True: #...
true
60d00c0a404a950786d0f83affd95e35f8fe00f3
JasmineEllaine/fit2004-algs-ds
/Week 1/Tute/8-problem.py
623
4.25
4
# Write code that calculates the fibonacci numbers iteratively. # F(1) == F(2) == 1 def fibIter(x): seq = [1, 1] # Return fib(x) immediately if already calculated. if (x <= len(seq)): return 1 for i in range(1, x-1): seq.append(seq[i]+ seq[i-1]) return seq[-1] """ Time complexity: ...
true
1693a547bd0278f0675a13ee34e1fa63ee86a00c
davidcotton/algorithm-playground
/src/graphs/bfs.py
1,790
4.1875
4
"""Breadth-First Search Search a graph one level at a time.""" from collections import deque from typing import List, Optional from src.graphs.adjacencylist import get_graph from src.graphs.graph import Graph, Vertex def bfs_search(start: Vertex, goal: Vertex) -> Optional[List[Vertex]]: """Search for the goal v...
true
7e64e845366f95123d34c8c766064cc6dcb42c6c
girishf15/Python-Data-Structures
/Data_Structures/Sorting/bubble.py
829
4.125
4
def bubble_sort(arr): swapped = True while swapped: swapped = False for i in range(len(arr) - 1): if arr[i] > arr[i + 1]: arr[i], arr[i + 1] = arr[i + 1], arr[i] swapped = True # print(arr) return arr arr = [5, 7, 2, 47, 11, 10, 2, 3, ...
false
ef9d8af15889c4cd8c9a4105b5022dbcfa43feed
girishf15/Python-Data-Structures
/Data_Structures/Stack/stack_using_list.py
755
4.21875
4
# __author__ : girish ''' Stack in Python can be implemented using following ways: list collections.deque queue.LifoQueue ''' class StackTest: def __init__(self, stack=[], length=0): self.stack = [] self.stack_length = length def push(self, element): if len(self.stack) ...
false
1cb441682be90079d43c9de98d42e4e4c0393725
raulmogos/uni-projects
/FP/labs/tema lab 01/set_A_p1.py
1,275
4.15625
4
''' PROGRAM THAT GENERATES THE FIRTS PRIME NUMBER AFTER A NUMBER N INPUT: N - a natural number OUTPU: P - THE FIRTS PRIME NUMBER AFTER N ''' def e_prim(x): ''' FUNCTION THAT CHECKS IF X PRIME OR NOT INPUT: X - a number OUTPUT: TRUE - IF X IS PRIEM FALSE - OTHER...
false
99f0af8b882d96b8f8bc6df1aa35110b17cbcea7
MihirMalani1712/PPL_LAB
/Assignment/Assignment6/shapes.py
1,190
4.15625
4
import turtle s = turtle.getscreen() t = turtle.Turtle() class shape: def __init__(self, sides = 0, length = 0) : self.sides = sides self.length = length class polygon(shape): def info(self): print("In geometry, a polygon can be defined as a flat or plane, two-dimensional with stra...
false
660aea75a1024b16e007b6dcdef4aca6cdf6ae77
blane612/for_loops
/tertiary.py
470
4.40625
4
# -------------------- Section 3 -------------------- # # ---------- Part 1 | Patterns ---------- # print( '>> Section 3\n' '>> Part 1\n' ) # 1 - for Loop | Patterns # Create a function that will calculate and print the first n numbers of the fibonacci sequence. # n is specified by the user. # # NOT...
true
44db8f0a764a4af6a94741f114a801c6c3ab5de9
JJBarata/python3oo
/fatorial.py
392
4.21875
4
# Calculando o fatorial de um número: def fatorial(num): if num < 0: print('Não existe fatorial de número negativo. tente novamente!') elif num == 1: return 1 else: fact = 1 while num > 1: fact *= num num -= 1 return fact num = int(input('Dig...
false