blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
462d2b7e8520f86dd1a470ef9188d1ca4881734a
TheGoodReverend/LetterCode
/LetterCode.py
1,640
4.125
4
#! /user/bin/env python3 #Letter Code by KBowen from LetterCodeLogic import LetterCodeLogic #from filename import class def getChoice(): choice = -1 #while (choice > 0 and choice <3) while (choice!=0): try: choice = int(input("Choice? (1=Encode, 2=Decode, 0=Quit...
true
dd9568201e6adbfd7aaf05e57716e20a70e28aa4
yeon4032/STUDY
/GIT_NOTE/03_python/chap03_DateStucutre/exams (1)/exam01_3.py
1,231
4.125
4
''' step01 문제 문3) 리스트(list)에 추가할 원소의 개수를 키보드로 입력 받은 후, 입력 받은 수 만큼 임의 숫자를 리스트에 추가한다. 이후 리스트에서 찾을 값을 키보드로 입력한 후 리스트에 해당 값이 있으면 "YES", 없으면 "NO"를 출력하시오. <출력 예시1> list 개수 : 5 1 2 3 4 5 3 <- 찾을 값 YES <출력 예시2> list 개수 : 3 1 2 4 3 <- 찾을 값 NO ''' size = int(input('list 개수 : ')) # list 크기 입력 ...
false
dd4e8ebb6559bc46730e00239a63d1f576a34fe5
Mr-MayankThakur/My-Python-Scripts
/Algorithms/Sorting/merge_sort.py
1,118
4.5625
5
def merge_sort(lst, reversed = False): """ Sorts the given list using recursive merge sort algorithm. Parameters ---------- lst (iterable)- python which you want to search reversed (bool): sorts the list in ascending order if False Returns ------- sorted_list """ if len(ls...
true
b4579540cb8f9b77209d2019ae7528bcf64efd26
chttrjeankr/codechef2k19-dec6
/MUL35/program.py
670
4.28125
4
""" Problem Statement: If we list all the natural number below 20 that are multiples of 3 or 5, we get 3,5,6,9,10,12,15,18. The sum if these multiples is 78. Find the sum of all the multiples of 3 or 5 below N. """ def SumDivisibleBy35(n,target): """ Returns the sum of all the multiples of 3 or 5 below N ...
true
0a078dc2a9ec31df291f13cedb133988f99900b3
mehaktawakley/Python-Competitive-Programming
/ArmstrongNumber.py
849
4.3125
4
""" For a given 3 digit number, find whether it is armstrong number or not. An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3^3 + 7^3 + 1^3 = 371 Input: First line contains an integer, the number...
true
ec5e4826b8bbe03f8c0b73d22258bf42b363c73d
rigo5632/CS-2302-Data-Structures
/Lab1/lab1C.py
1,058
4.25
4
# Lab 1 # By: Rigobeto Quiroz # Class: 1:30 PM - 2:50 PM MW # This program will draw a binary Tree. The tree will create a center point # and will generate branches to the left and to the right according to center point # the more recursion calls the more branches the tree will have. Each branch will have # two childre...
true
834a62bd5a68029a4ad27a7a0b4807b591de29f7
icebowl/python
/ed1/3.4.1.py
530
4.125
4
''' Input a word. If it is "yellow" print "Correct", otherwise print "Nope". What happens if you type in YELLOW? YellOW? Does the capitalizing make a difference? color = input("What color? ") if (color == "yellow"): print ("Correct") else: print ("Nope") color = input("What color? ") cString = color.lower(...
true
2a3dbfc45a73b2173af5b4cd3a0afeaf6869687d
icebowl/python
/ed1/3.5.py
368
4.125
4
# your code goes here ''' Input a grade number (9 - 12) and print Freshman, Sophomore, Junior, Senior. If it is not in [9-12], print Not in High School. ''' g = int(input("What grade are you in ? ")) if(g == 9): print("Freshman") elif (g==10): print("Sophomore") elif (g==11): print("Junior") elif (g==12): prin...
true
b7f6a92c8b7e6bca2f68535ecbdaf8d43a39fbdf
icebowl/python
/net/valid-ip.py
923
4.4375
4
# Python program to validate an Ip addess # re module provides support # for regular expressions import re # Make a regular expression # for validating an Ip-address regex = '''^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 25[0-5]|2[0-4][0-9...
false
7015096513fd7e28650960e928e4c53010024992
icebowl/python
/tkinter/drive_turtle_1.py
472
4.125
4
#apt install python3-tk import turtle wn = turtle.Screen() # create a turtle t = turtle.Turtle() t.color('green') # set the color t.forward(50) # draw a green line of leng t.up() # lift up the tail t.forward(50) # move forward 50 without drawing t.right(90) # change dir...
true
19890d597a8050926402d054d783d608cfaf4c66
icebowl/python
/sift/example-ord.py
230
4.21875
4
#Python ord() #The ord() method returns an integer representing Unicode code point for the given Unicode character. print(ord('5')) # code point of alphabet print(ord('A')) # code point of character print(ord('$')) print(ord(0))
true
f6f7f1143b8ee417fb1ed800e7fa0a370de48804
UKDR/eng57_2
/Week_3_Python/lists_basics.py
1,607
4.5625
5
# List # list are exactly what you expect. They are lists # they are organised with index. This means it starts at 0 # syntax # [] = list print(type([])) print([]) # just prints the brackets [] print(len([])) # counts the number of items in the list # example # defining a list and assigning it to a variable contact_...
true
6f982282d53e973469174fdc4e139ec68699aea0
Jasplet/my-isc-work
/python_work/IO_ex.py
1,961
4.34375
4
#! /usr/bin/python # Exercise on input and output to files print 'Part One. \nReading a csv file' with open( './example_data/weather.csv', 'r') as readfile: #using with means we dont have to worry about closing the file. Readfile is a variable holding the open file pointer data = readfile.read() #Actually reads ...
true
8d94faca022abfdeff8c5e2da1a179d7a8ab5596
EchoZen/Basics
/13. Dictionary.py
1,367
4.46875
4
# Use {} for dictionary # variable= {"key":"value", "key":"value"...} #1key:value is considered as 1 element in the dictionary # To access value in variable, you can use the key monthConversions= {"Jan": "January", "Feb": "February", "Mar": "March", "Apr":...
true
129bdb0deee49b5b715dcf6b070611fc62651c6d
WT955/Codecademy_DataScience_Projects
/Python_SalesShipping.py
1,428
4.125
4
# Sal's Shipping # 1 def ground_shipping(weight): ground_cost = "" if weight <= 2: ground_cost = weight * 1.5 + 20.0 elif weight <= 6: ground_cost = weight * 3.0 + 20.0 elif weight <= 10: ground_cost = weight * 4.0 + 20.0 else: ground_cost = weight * 4.75 + 20.0 return ground_cost # 2 print...
false
3e47955a3c3ddaa01d12b198b1e7b09f46d08fa4
MiYoShi8225/python-flask-dev
/unit2(python base)/unit2/basic8.py
1,692
4.1875
4
#セット型 ''' ・同じ値を持たない! ・順序が保持されない! ・集合処理を高速化する! ''' set_a = {'a', 'b', 'c', 'd', 'a', 12} #aが2つあるが実際は1つしか入らない print(set_a) #実行するタイミングで毎回順番が違う print('e' in set_a) #'e'がset_aに入っていないのでFalse print('a' in set_a) #'a'がset_aに入っているのでTrue print(len(set_a)) # add remove discard pop clear set_a.add('A') print(set_a) set_a.rem...
false
a1e8336a366d8c6ce2a7cf086be50799ed654593
KHulsy/Project_Echo
/App/spaceturtles.py
1,096
4.125
4
(Disclaimer: This was found via Google Fu. I in no way, shape or form coded this. This is absolutely not my work. This is inspiration for Project 3). # Click in the righthand window to make it active then use your arrow # keys to control the spaceship! import turtle screen = turtle.Screen() # this assures that the si...
true
65e23e31dbc4ac23ae5b274408141566e30d9a99
fgokdata/python
/extra/classes..py
899
4.25
4
# car is object and it has methods (in functions) class car: def __init__(self, brand, model, year): #starts the attribiutes self.brand = brand self.model = model # shows the features when it is created self.year = year def brandmodel(self): return f'brand of the car {se...
true
8819dedaa14cf1324ef2276dbcc5d2427720b5e7
tomvdmade/LearnPython3
/ex15.py
885
4.4375
4
# from the module named sys, import argv (argument vector > parameters). # argv is a list containing all the command line arguments passed into the python script you're currently running. (run in the command line vs input) from sys import argv # define argv 0 and 1 as script and filename respectively script, filename...
true
94f3aaa071e89f5217efc356a35eb97c65ce5e98
rafaelgustavofurlan/basicprogramming
/Programas em Python/02 - If Else/Script9.py
1,056
4.125
4
# A secretaria de meio ambiente que controla o # indice de poluicao mantem 3 grupos de industrias # que sao altamente poluentes do meio ambiente. # O indice de poluicao aceitavel varia de 0.05 ate # 0.25. Se o indice sobe para 0.3 as industrias do # 10 grupo sao intimadas a suspenderem suas atividades, # se o ind...
false
4287ef8e5e9b41ec960621b9b8893061e8e44042
samsonfrancis/core_python_practice
/src/com/sam/IfElseTest.py
284
4.28125
4
name = "samson" # test if else if name is "samson": print("Name is samson") else: print ("Name is not samson") # test if elif else if name is "samson1": print("Name is samson1") elif name is "samson": print("Name is samson") else: print ("Name is not samson")
false
c4934517e47b92cd457dab5d1a87220f4ba7f465
rcjacques/Hexapod
/Simulation/more testing.py
2,522
4.125
4
from graphics import * import math width = 500 height = 500 NORTH = 0 EAST = 1 SOUTH = 2 WEST = 3 win = GraphWin('Polygon Rotation Testing',width,height) def drawGrid(): for i in range(10): line = Line(Point(i*width/10,0),Point(i*width/10,height)) line.draw(win) for j in range(10): line ...
true
4a15586920f3a7803b527a503a2a8f9e62fe0cff
cash2one/BHWGoogleProject
/pyglib/elapsed_time.py
1,202
4.1875
4
# Copyright 2004-2005 Google Inc. # All Rights Reserved. # # Original Author: Mark D. Roth # def ElapsedTime(interval, fractional_seconds=0, abbreviate_days=0): """ Returns a string in the form "HH:MM:SS" for the indicated interval, which is given in seconds. If the time is more than a day, prepends "DD day(...
true
a332dcb77ef3acc6c6446df070e5d621648be2d4
bymestefe/Python_Task
/random_module_example/rock_paper_scissors.py
1,562
4.21875
4
import random # rock-paper-scissors (taş-kağıt-makas) # whoever reaches 3 is winner (3'e ulaşan kazanır) def control_of_winner(u,p): if u == 0 and p == 1: print("winner of this stage is pc") return 0 elif u == 0 and p == 2: print("winner of this stage is user") return 1 ...
true
03ff68ef13e367df0d1b6f953c04392843a48509
gerard-geer/Detergent
/Shower/logger.py
1,737
4.15625
4
from datetime import datetime class Logger: __slots__ = ('filename', 'buffer', 'maxBufferSize') def __init__(maxBufferSize): """ Creates an instance of Logger. The output file will be named the date and time of this instance's creation. Parameters: -maxBufferSize(Integer): The maximum number of mess...
true
ae19d0ea8605c8306f265576d16894dd7657cd14
annehomann/python_crash_course
/02_lists/numbers.py
597
4.375
4
""" for value in range (1,11): print (value) """ # Takes numbers 1-10 and inputs them into a list numbers = list(range(1,11)) print(numbers) # Skipping numbers in a range # Starts with the value 2, adds 2 to the value until it reaches the final value of 11 even_numbers = list(range(2,11,2)) print(even_numbers) # ...
true
3d3d84f1e1df87f19bf47e31b39f5839829af2aa
annehomann/python_crash_course
/03_if_statements/hello_admin.py
538
4.15625
4
# usernames = ['anne', 'somerset', 'admin', 'sally', 'darius'] # for username in usernames: # if 'admin' in username: # print("Hello " + username.title() + ", would you like to see a status report?") # else: # print("Hello " + username + ", thank you for logging in today.") # Using the if s...
true
b2f93d7064571516d7485ceb9338f76f57a3ac33
Umangsharma9533/DataStructuresWithPython
/Stack_isParenthesisBalanced.py
1,144
4.25
4
#Import Stack class from the CreatingStack.py file from CreatingStack import Stack #define a function for comparing 2 character, Return True if both matches, False if no match def is_match(top,paren): if top=='{' and paren=='}': return True elif top=='[' and paren==']': return True elif top=...
true
3a9fc64d5d991be4f1bab97747ca1d6482f0d172
felixzhao/questions
/Linked_Lists/Merge_Sorted_Array.py
1,136
4.21875
4
class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: """ Do not return anything, modify nums1 in-place instead. time O(M + N), M is |copy_num1| which is less then |nums1| space O(M) logic: - copy values from...
true
dcf02197a487701312bf636007bdd108880e86c6
felixzhao/questions
/Trees_and_Graphs/Lowest_Common_Ancestor_of_a_Binary_Tree.py
1,124
4.125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def __init__(self): self.ans = None def find(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> bool: """ ...
true
da32faa6129dc6ec82c5746137f516d668bc721f
leoanrdoaguayo/Unidad-3
/LIAG_Ejercicios/Patterns/adapter.py
1,186
4.125
4
"""is used to transform an interface into another. Name:Leonardo Israel Aguayo González""" class Korean: """Korean speaker""" def __init__(self): self.name = "Korean" def speak_korean(self): return "An-meyong?" class British: """English speaker""" def __init__(sel...
false
72d3888348e76741712c9d591a128f0d38a044e6
ajpiter/PythonProTips
/Stats/%ModuloDivison.py
910
4.5
4
#In addition to standard division using '/' in python you can also use '%' to get modulo or remainder division ----- #Leftover Calculator ----- #Think of % as the leftover calcualtor if you shared everything evenly #If you have an 8 slice pizza and 3 friends leftovers = 8 % 3 print(leftovers) #[output] 2 ----...
true
49dde09fe3d711e05f1c055cb46308f6a72d4b86
ajpiter/PythonProTips
/Databases/OrderingResults.py
1,129
4.25
4
#Ordering Query Results in SQL Alchmy #The order_by() command orders from lowest to highest, or alphabetically by default #Example of building a select statement, appending an order_by() clause and executing the statement #By Default this sorts alphabetically stmt = select([tablename.columns.columnname]) stmt = st...
true
d8a9b8f3f280c85293d01a2f3e108fe53f61fb36
ajpiter/PythonProTips
/PythonBasics/Function/CreatingFunctions/Basics.py
2,762
4.71875
5
#Functions are useful when you will have to preform the same tasks repeatedly #Creating your own Function 1. define the function def function(parameter): print(parameter + "string") 2. call the function, function() ----- #Basic Function: Outputs a Print Statement ----- def function(parameter, parameter...
true
3b0ac51f4dfe49fcae7757f3c0403267714eb55d
ajpiter/PythonProTips
/Stats/BinomialDistribution.py
760
4.125
4
#A binomial distrubution is the number of r successes in n Bernoulli trials with probability p of success. #Example, The number of heads in 4 coin flips of a fair coin. np.random.binomial(The number of coin flips, the proability of success) np.random.binomial(4, 0.5) #To conduct the experiment repeatedly use the ...
true
8ff1b79dabf59fc2ff3d746878d3f891b602c1ad
ajpiter/PythonProTips
/PythonBasics/Lists/CopyingLists.py
617
4.40625
4
#Usually you want to create a new list, but by using the '=' you accidential create a reference to a list ----- #This creates a copy of the reference to the list ----- x = ['a', 'b', 'c'] y = x #Which means this will change the elements in both list x and y y[1] = 'z' print(x) print(y) #output ['a', 'z', 'c'] #...
true
82c6394b591153d264668ab7784b2efb48df3db2
ajpiter/PythonProTips
/DataVisualization/ScatterPlots.py
820
4.1875
4
#Scatter plots are best used to show the relationship bewteen two numeric variables or #to flag potential errors not found by looking at one variable. #To create a scatter plot using matplotlib import matplotlib.pyplot as plt lista = [2001, 2002, 2003, 2004] listb = [1, 2, 3, 4] plt.plot(lista, listb) plt.show() ...
true
bb9b9d74a269478d6fd491dbf37df0ef5fd2b6ab
ajpiter/PythonProTips
/PythonBasics/Function/Method.py
822
4.125
4
### Methods call functions on objects #Objects (Lists, Strings etc) have built in methods and you cannot run the method on the wrong object type. #A method used on a list will not work on a string. ### List Methods #Example, use the function index() on a list to see the index number of a specified value basiclist = ...
true
8b1f7b65588a94e86983856c089d94a5ec0bf7dc
ajpiter/PythonProTips
/Stats/ExploratoryDataAnalysis.py
1,289
4.28125
4
#The process of organizing, plotting, and summarizing a data set #Graphicial Exploratory Data Analysis, involves taking data from a table, and converting it into a graph #Below is how to take a table and convert it into a histogram #for EDA _ are used as a placeholder(dummy variable) when you don't care about the var...
true
a1c5a32f3e9ace0630e97cbe0792b2811203a66b
vikmreddy/D09
/keys.py
1,150
4.375
4
""" Write three functions: sort1(langauges) sort2(languages) sort3(langauges) Goal: Print exactly the below w/ three functions: 1: Arabic English Koine Greek Latin Romanian C++ JavaScript Python R 2: R C++ Latin Arabic Python English Romanian JavaScrip...
true
ad7b6bd5d407d631e6c9f8d6ba0d0e7d7a5f29ea
GeorgiusKurli/GeorgiusKurli_ITP2017_Exercises
/4-11. My Pizzas, Your Pizzas.py
437
4.1875
4
#Taken from 4-1. Pizzas pizzas = ["Pepperoni", "Deluxe Cheese", "Tuna Melt"] for pizza in pizzas: print("I like " + pizza + " pizza.") print("\nI love pizza!") friend_pizzas = pizzas[:] pizzas.append("Meat Lover") friend_pizzas.append("Sausage") print("\nMy favourite pizas are:") for pizza in pizzas: print(pi...
true
a720af16e5184b18331943faf8d99774ca269c9f
cococ0j/ThinkPython-answers
/11-11.py
980
4.125
4
""" Setting return True or False is essential in this part. """ from pronounce import read_dictionary def make_word_dict(): fin = open("words.txt") d = {} for line in fin: word = line.strip() word = word.lower() d[word]= word return d def homephones(a, b, phonetic): if a ...
true
07262adbfdfe29e9b5394a5103a2f21e405fba1c
enigmatic-cipher/basic_practice_program
/Q59) WAP onvert height (in feet and inches) to centimeters.py
369
4.1875
4
print("Feet & Inch Converter") value = float(input("Enter the value: ")) con = int(input("Press 1 to convert feet into centimeter or Press 2 to convert inch into centimeter: ")) if con == 1: print(f"{value} feet in centimeter is {value * 30.48} cm") elif con == 2: print(f"{value} Inch in centimeter is {valu...
true
e5e40e8f0b20ac4428a073d467697cbd300e2814
Priya-dharshini-r/practice
/KMP_algo.py
690
4.15625
4
# Knuth Morris and pratt algorithm to find if there is a pattern in given text. ''' Step-1: Find an LPS(Longest purpose prefix which is also suffix) --> Working of LPS: 1. Create an 1D array with the size of the given pattern. LPS = []*len(Pattern) 2. Set LPS[0] = 0 3. Have two variable for iteration i and j res...
true
f3889a806e21c723449d890ef0bd534f0813d31a
Priya-dharshini-r/practice
/multiply_elements_in_list.py
522
4.28125
4
# defining a function to multiply all the elements in a list def multiply_all_elements_in_a_list(mylist): length = len(mylist) result = 1 for i in range(length): element = mylist[i] result = result*element return result if __name__ == "__main__": n = int(input("Enter number of elements to be in list: ")) myl...
true
b65cd1b868ea9e9e33789a7dc81a89089dafce56
Priya-dharshini-r/practice
/linear_search.py
810
4.21875
4
# Initialize a empty list and get elements from the user. list = [] n = int(input("Enter number of elements:")) # Use a for loop to get each element in the list. for i in range(n): elements = int(input()) list.append(elements) print(list) # Ask the element to be searched. search_element = int(input("Enter the elem...
true
e1523bf2dc7b1da5c23c7cf3b98509a2108909e7
Comphus/five_tasks
/AWS_Docker_CentOS/flask/app/Task1/task_one.py
980
4.125
4
""" First Python Task. Reads a CSV file and output two CSV files First output file is a copy of the input, and second output file is the transposed version of the CSV file Written by Gabriel Lopez """ import pandas as pd def create_csv(file_name, output_one, output_two): """ The main function used to complete Task...
true
8948bb91ecc62872f15ceebd11947e5e8761bb8f
DongYao01/Meijingzhuang-Python
/Grade.py
494
4.21875
4
score = input('Please enter your scores:') try : score = float(score) if score >= 0.9 and score < 1 : print('Grade is "A"') elif score >= 0.8 and score < 0.9 : print('Grade is "B"') elif score >= 0.7 and score < 0.8 : print('Grade is "C"') elif score >= 0.6 and score < 0.7 :...
true
608d42f0253576b66e40ebbe958f4391106babaf
Mehrnoush504/Miniature_Assembler
/assembler/decimal_and_binary_converter.py
239
4.125
4
# function for turning decimal into binary def decimal_to_binary(num): s = bin(num) s = s[2:] print(s) return s # function for turning binary to decimal def binary_to_decimal(binary): return int(binary, 2)
false
d6a0d47b411cb4e43944923922150cae4a1dc820
SimonWong35/daily-coding-problem-examples
/chapter-03-linked-lists/example-3-3-1.py
472
4.21875
4
#!/usr/bin/python def alternate(linkedlist): even = True current = linkedlist while current.next == True: if current.data > current.next.data and even: current.data, current.next.data = current.next.data, current.data elif current.data < current.next.data and not even: ...
true
ff506e9d27a830d6054d29c08df363b08043afb9
ark229/CodeAcademy_Python
/concatenating_strings.py
393
4.3125
4
###Write a function called account_generator that takes two inputs, first_name and last_name and ###concatenates the first three letters of each and then returns the new account name. first_name = "Julie" last_name = "Blevins" def account_generator(first_name, last_name): return first_name[:3] + last_name[:3] n...
true
cfb3a939ce87417b8b6f4cf6e7a6da889d31f46b
ark229/CodeAcademy_Python
/iterating_strings_practice.py
299
4.125
4
###Write a new function called get_length() that takes a string as an input and returns the number of characters in that string. ###Do this by iterating through the string, don’t cheat and use len() def get_length(string): counter = 0 for length in string: counter += 1 return counter
true
710015293631e8dac8fac805ff16eaa56cd69a91
Semuca/PyConsole
/assets/jamesstuff/UsefulFile/shimport.py
2,076
4.125
4
import __main__ def Add (items): #Adds all floats passed - Takes two or more parameters if (len(items) >= 2): result = 0 for item in items: try: item = float(item) result = result + item except: return __main__.ThrowInvalidValu...
true
8dcc3baccc3c3c0ee09ff4cb2ece986542565f06
0as1s/leetcode
/225_MyStack.py
1,590
4.1875
4
import queue class MyStack: def __init__(self): """ Initialize your data structure here. """ self.q1 = queue.deque() self.q2 = queue.deque() self.last = None def push(self, x: int) -> None: """ Push element x onto stack. """ if ...
true
5bbf71c627eea671325457b209805558dd174d7c
saribalarakeshreddy/Python-3.9.0
/Packages/Patterns_Package/alp/sml_alp/d.py
860
4.125
4
def for_d(): """ Pattern of Small Alphabet: 'd' using for loop """ for i in range(7): for j in range(5): if j==4 or i%3==0 and i>0 and j>0 or j==0 and i in (4,5): print('*',end=' ') else: ...
false
7fe079dfb56acb38df785ec5b455b606db693c3f
saribalarakeshreddy/Python-3.9.0
/Packages/Patterns_Package/symbols/line_symbols/Square.py
432
4.25
4
def for_Square(): """ Pattern for : Square using for loop""" for i in range(7): for j in range(7): if i in (0,6) or j in(0,6): print('*',end=' ') else: print(' ',end=' ') print() def while_Square(): """ Pattern for : Square using while loop""" i=0 while i<7: j=0 while j<7: i...
false
f9012f4d21ce0f3d4536fb9e3208060383460382
saribalarakeshreddy/Python-3.9.0
/Packages/Patterns_Package/alp/sml_alp/f.py
868
4.1875
4
def for_f(): """ Pattern of Small Alphabet: 'f' using for loop""" for i in range(8): for j in range(5): if j==1 and i>0 or i==0 and j in(2,3) or i==1 and j==4 or i==4 and j<4: print('*',end=' ') else: ...
false
8b4571501c14d5419f2a218c46a57a098e1d2c24
zixk/pyBasics
/dataStructs/Stack.py
1,032
4.125
4
class Stack: class Node: def __init__(self, data: int): self.data = data self.next = None def __init__(self): self.top= None def isEmpty(self) -> bool: return self.top is None def peek(self) -> int: return self.top.data def push(self, d...
false
169580f806ce588eca48e78a42bfe5b754977b16
maato-origin/PythonPractice
/1-16.py
582
4.3125
4
#dictionary型 #初期化 dic={'key1':110,'key2':270,'key3':350} print(dic) #値へのアクセス print(dic['key1']) #print(dic['hoge']) #KeyError #getメソッド dic={'key1':110,'key2':270,'key3':350} print(dic.get('key1')) print(dic.get('hoge')) #値の更新 dic={'key1':110,'key2':270,'key3':350} dic['key1']=200 print(dic['key1']...
false
1cb7d231402624ef09ea9d694dddb3872f495c9e
maato-origin/PythonPractice
/2-4.py
303
4.4375
4
#dictionary型のループ処理 #キーのループ dic = {'key1':110, 'key2':270, 'key3':350} for key in dic: print(key) print(dic[key]) #値のループ for value in dic.values(): print(value) #キーと値のループ for key, value in dic.items(): print(key, value)
false
af449683103bee78b3c995b9b8bc2c2a5a3ab55b
ChrisDel86/EDU.
/Timer_projekt/hello world.py
1,083
4.46875
4
# a simple miles calculator # Program make a simple calculator # This function multiplies two numbers def multiply(x, y): return x * y # This function divides two numbers def divide(x, y): return x / y print("Select form of calculation") print("1. Time Usage") print("2. Drive distance") whil...
true
ef069d6fa48b0bf1b9492df1d0b5bf5f64f7c359
rodobedrossian/python.io
/python.py
568
4.28125
4
# Test básico print("Esto es una suma") numero_uno = 2 numero_dos = 6 resultado = numero_uno + numero_dos print(resultado) print("Hola") print(55) print("Mi nombre es Rodrigo y tengo",24,"años") print("Mi nombre es {} y tengo {} años".format("Rodrigo",24)) print("2 + 2 is {}".format(2*2)) # Booleans a = 45 b = 10...
false
46cf2c58fa3b6bb0a96b2544cef50acd4f547f64
SyedYousha/PythonProjects
/Rock Paper Scissors.py
2,391
4.90625
5
#rock, paper, scissors from random import randint #to import random numbers user = input('rock (r), paper (p), scissors (s)?') #Let's the user input something and assigns #it to whatever option it picked. So the next line, user will show as r, p, or s. print(user, 'against') #Just prints out the user input and...
true
17b0a29aa63fa0f84a49bab35f6a4eae61a3c6eb
arianjewel/Python_with_oop
/Python_OOP/class_n_object.py
2,041
4.25
4
'''class Car: name='' color='' def __init__(self,name,color): #constructor self.name=name self.color=color def start(self=0): print('Starting the engine') Car.name='Axio' Car.color='black' print('Name of car is',Car.name) print('color:',Car.color) Car.start() print(dir...
true
3708b7832c2a4fb65565b88ed2c1052095a00e19
GeoffreyRe/python_exercices
/exercice_11_1/distance.py
1,528
4.4375
4
""" exercice 11.1 de la page 174 du livre de référence "apprendre à programmer en python 3" de Gérard swinnen ENONCE : Écrivez une fonction distance() qui permette de calculer la distance entre deux points. (Il faudra vous rappeler le théorème de Pythagore !) Cette fonction attendra évidemment deux objets Point() com...
false
bc83b89e87778e75102f04f2124a4e6480c0600d
xx-m-h-u-xx/Natural-Language-Processing
/Supervised-Classification.py
2,411
4.125
4
''' Feature Extraction prog ''' ''' Classification is the task of choosing the correct class label for a given input ''' """The first step in creating a classifier is deciding what features of the input are relevant, and how to encode those features. The following feature extractor function builds a dictionary conta...
true
7d5fa74a8179873d43fe7afee286a1878c400d7f
catherinealvarado/data-structures
/algorithms/sorting/quicksort/test_quick_sort.py
1,238
4.1875
4
import unittest from quick_sort import sort class QuickSortTests(unittest.TestCase): """ These are several tests for the function sort that is an implementation of quick sort. """ def test_empty_list(self): """Is an empty list sorted to an empty list?""" self.assertTrue(sort([])==[]...
true
2079d4b550729ad517735ec9bed419062603e9f6
fleimari/PythonMultiThreading
/ex2/main.py
809
4.34375
4
"""" Exercise 2. Write similar program than in exercise 1 but this time use subclass of Thread of threding module and hello_world() -function printing the text should be member function (method) of class you created. The console output should look similar than in exercise 1. Hello World: 0 Hello World: 2 Hello World:...
true
32577919b341d4c5d58b45008a2df990f5a7c04d
mindful-ai/teq-b5-py-dsc-ml
/WEEK01/difference.py
385
4.25
4
# Program to identify if the result of subtraction # is positive, negative or zero # input a = int(input('Enter first number: ')) b = int(input('Enter second number: ')) # process d = a - b # output print('RESULT:' , d) if( d > 0 ): print('The result is positive') elif(d < 0): print('T...
true
06c7ac7e4f8c5f0e7e614ba75a0ba9bfa9532410
goncalossantos/Algorithms
/Sorting/sorting.py
1,200
4.15625
4
import operator def insertion_sort(array, reverse=False): lt = operator.lt if not reverse else operator.gt for index in range(1, len(array)): currentvalue = array[index] position = index while position > 0 and lt(currentvalue, array[position - 1]): array[position] = arra...
true
5e7fed9f5a1de854328aa9668bbd222163cf8824
goncalossantos/Algorithms
/Challenges/CCI/Chapter 02/remove.py
519
4.15625
4
from Algorithms.LinkedLists.linked_list import LinkedList def remove(node): if node.next: node.value = node.next.value node.next = node.next.next else: # Node at the end of the list raise Exception("Node not in the middle") def test_remove(): test_list = LinkedList([1, 2...
true
e1b35ffa48c27ed608f44a04aa84e4077259cd27
Pranay2309/Python_Programs
/tuple concepts.py
426
4.1875
4
t1=10,20,30 #type=tuple t2=(10,20,30) #type=tuple #conversion of list into tuple a=[10,20,30,2,12] print(type(a)) t=tuple(a) print(t,type(t),"length of tuple =",len(t)) print(t[0]) #slice operator in tuple print(t[1:3]) print(t[::-1]) #reversing with the help of slice operator #sorting the tup...
true
455bcc2376e475467f991bef419e2b4fcf82cbe1
Phil-U-U/leetcode-practice-2
/valid-binary-search-tree.py
1,798
4.3125
4
''' Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the node's key. Both the left and right subtrees m...
true
a56692a0dc54cb47bf6772fc08582cb44997de14
dragonOrTiger/pythonDemo
/sortFunc.py
951
4.3125
4
#Python内置的sorted()函数就可以对list进行排序, print(sorted([36,5,-12,9,-21])) #sorted()函数也是一个高阶函数,它还可以接收一个key函数来实现自定义的排序,例如按绝对值大小排序 print(sorted([36,5,-12,9,-21],key=abs)) #默认情况下,对字符串排序,是按照ASCII的大小比较的 print(sorted(["bob","about","Zoo","Credit"])) #忽略大小写来对字符串排序 print(sorted(["bob","about","Zoo","Credit"],key=str.lower)) #反向排序,不必改动k...
false
a83652453c60311b310f8e4abfedeba9446b3d2f
vandanagarg/practice_python
/learning_python/mit_lectures/functions/Coordinate.py
1,377
4.65625
5
''' Creating a Class/ random abstract datatype of type Coordinate This is an example for OOPS concept in programming ''' class Coordinate(object): def __init__(self, x, y): self.x = x self.y = y def distance(self, other): x_diff_sq = (self.x - other.x) ** 2 y_diff_sq = (self.y...
true
084f6702316d76e460457ed6e4281fb4c730c253
vandanagarg/practice_python
/learning_python/classes/Circle.py
425
4.21875
4
class Circle: # Class Object Attribute PI = 3.14 def __init__(self, radius= 1): self.radius = radius self.area = radius*radius*self.PI # self.pi can also be written as Circle.pi #Method def get_circumference(self): return self.radius * self.PI * 2 my_circle = Circle(30)...
true
a0c0c1090d1f7e4a2f336762a2efe66ef4e06875
vandanagarg/practice_python
/learning_python/hacker_rank/problem23.py
692
4.15625
4
''' Given an integer, print the following values for each integer: Decimal Octal Hexadecimal (capitalized) Binary ''' n = int(input()) width = len("{0:b}".format(n)) for i in range(1, n+1): print("{0:{width}d} {0:{width}o} {0:{width}X} {0:{width}b}".format( i, width=width)) # 2nd option STDIN = 17 # print...
false
c730fc75c052e419e7cd1748421a87bda129739a
vandanagarg/practice_python
/learning_python/data_structures/lists/lists_basic_operations.py
2,763
4.625
5
#Lists ,we have to use [] these brackets to store a bunch of values and thus we create a list of some related data that we wish to have #We can put anything in a list i.e: a number, boolean or a string #list is mutable friends = [ "Peeyush Singla", "PS", "groom", "VG"] friends_two = [ "Peeyush Singla", "PS", "groom", ...
true
6594a05a236f4db69f0e71d0f3cc181afc967b2d
vandanagarg/practice_python
/learning_python/functions/functions/multiply.py
244
4.1875
4
#Q5: multiply all numbers in a list numbers = [2,5,8,4] def multiply(numbers): mul_result = 1 for item in range(0, len(numbers)): mul_result = mul_result * int(numbers[item]) return mul_result print(multiply(numbers))
true
d5dd531c6fa57baff853c95fb649ab83d96a50d4
vandanagarg/practice_python
/learning_python/problems/numbers_problems/valid_card.py
2,016
4.1875
4
#Problem 13 #Credit Card Validator - Takes in a credit card number from a common credit card vendor (Visa, MasterCard, American Express, Discoverer) # and validates it to make sure that it is a valid number (look into how credit cards use a checksum). # cc = str(raw_input("Enter a credit card number to validate (Maste...
false
d761b068c2046f5ad0e9886a416f30f647ac1b03
vandanagarg/practice_python
/learning_python/branching_statements/statements.py
1,601
4.25
4
''' Pass/ Continue/ Break statements ''' ''' The break statement in Python terminates the current loop and resumes execution at the next statement ''' print("\n break examples:") # First Example print("\n Example 1st \n") my_sum = 0 for i in range(5, 11, 2): my_sum += i if my_sum == 5: break ...
true
595c7f9c7d393a3c757add264fd0e71e837f49ce
vandanagarg/practice_python
/learning_python/hacker_rank/problem2.py
269
4.15625
4
# swapcase and reversing the string def reverse_words_order_and_swap_cases(sentence): return sentence = "aWESOME is cODING" # print(len(sentence)) s = sentence.split() print(s) s.reverse() print(s) text = " " new = text.join(s) print(new) print(new.swapcase())
true
bb99751daf0c097ce76c2c3e2b3e4fc8de96c452
vandanagarg/practice_python
/learning_python/inheritance/Chef/ChineseChef.py
1,125
4.15625
4
#lets say we have a chinese chef who has all qualities of generic chef (Chef.py) and it makes something extra as well class ChineseChef: def make_chicken(self): print("The chef makes a chicken.") def make_salad(self): print("The chef makes a salad.") def make_special_dish(self): p...
true
bd57a1f076b12e7cd5f278b832061c86e921d865
juniorppb/arquivos-python
/ExerciciosPythonMundo1/35. Import math 2.py
493
4.1875
4
from math import sqrt num = int(input('Digite um número: ')) raiz = sqrt(num) print('A raiz quadrada de {} é igual a {:.3f}.'.format(num, raiz)) print('_' * 25) from math import sqrt, floor num = int(input('Digite um número: ')) raiz = sqrt(num) print('A raiz quadrada de {} é igual a {}.'.format(num, floor(raiz))) pri...
false
27f25895ffbfb386e04cbf925ebbb6dfbd232f8f
rvaishnavigowda/Hackerrank-SI-Basic
/compute fibonacci number.py
521
4.4375
4
''' For a given positive integer - N. Compute Nth fibonacci number. Input Format Input contains a positive integer - N. Constraints 1 <= N <= 20 Output Format For given input, print the Nth fibonacci number. Sample Input 0 4 Sample Output 0 3 Explanation 0 The fibonacci series: 1, 1, 2, 3, 5, 8,...... At 4th ...
true
095c60da97bb1967ab80b83b71db16acada6980e
pshushereba/Data-Structures
/singly_linked_list/singly_linked_list.py
2,536
4.15625
4
class ListNode: def __init__(self, value, next=None): self.value = value self.next = next class LinkedList: def __init__(self, node=None): self.head = node self.tail = node self.length = 1 if node is not None else 0 def add_to_tail(self, value): node = List...
true
1ea82532b088aa28d7ecf5e26a59532b969cc4ca
jtutuncumacias/tekturtle
/dict.py
1,446
4.375
4
import turtle #Dictionaries visualization lab (using turtle) #----------STARTER CODE BEGINS----------# grid = turtle.Turtle() grid.color("gray") grid.hideturtle() grid.speed(0) for num in range(-10, 11): grid.penup() grid.goto(-200, num * 20) grid.pendown() grid.goto(200, num * 20) for num in range(...
false
eff62d6bf7cee49e3d70be04d6924ee75392a3f2
mmcgee26/PythonProjects
/6_2.py
2,055
4.28125
4
class Node: def __init__(self,data): self.val = data self.next = None # create a linked list (adding nodes) that is identified as 'head' head = Node(None) n1 = Node(10) n2 = Node(20) n3 = Node(30) head.next = n1 n1.next = n2 n2.next = n3 # print the linked list def print_linked_list...
true
435480dc29ac57b67823cac19ec5b0b114e7d164
mmcgee26/PythonProjects
/hw3example.py
2,226
4.1875
4
print("Post-fix Calculator") print("For help, type \"help\" or \"?\"") while True: str_in = raw_input("> ") tokens = str_in.split(" ") stack = [] if tokens[0] == "help" or tokens[0] == "?": print("Post-fix calculator takes in post-fix formatted equations and evaluates them.") print("In...
true
cd28b6cfa1510ca81f8ec70d98e422ed92f167a9
maayansharon10/intro_to_cs_python
/ex2/temperature.py
606
4.3125
4
def is_it_summer_yet(best_temp, first_temp, second_temp, third_temp): """ the function recieves 4 arguments - the first is the 'best temperature' which is the pre-condition. function will return True when the 2nd and 3rd and 4th arg are larger then best_temp. Otherwise will return False """ i...
true
d45cf56b1772f426995514d004e71895e75f0765
maayansharon10/intro_to_cs_python
/ex2/shapes.py
1,567
4.3125
4
""" זה אוטומטית חוזר לי לNONE לא משנה מה אני מקלידה""" import math def circle_area(): """ receives input from user about the radius and calculates the area of a circle""" radius = float(input("choose radius")) circle_calc = radius*radius*math.pi return circle_calc def rectangle_...
true
982fde0bb1d327f7f05692a652c8f74730ef14da
kdgreen58/is210_lesson_06
/task_02.py
818
4.40625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Task 02 code.""" import task_01 import data def get_average(numbers): """Finds the average of a list. Args: numbers(num): A numeric type that reads in number(s). Returns: numeric (float): returns the average of a list Example: ...
true
f47e7289d64bac0638fa9fdceacfb8297ca0bc1a
Lior303/NumAnalytics
/root/secant_method.py
1,330
4.34375
4
def secant_method(f, x0, x1, epsilon=10**-4, nMax=100): """ secant method to calculate x's (roots) of a function :param f: the function :param x0: start value :param x1: start value :param epsilon: fault degree allowed :param nMax: maximum of iterations """ n=1 while n<=nMax: ...
true
0d52c863746f5bbf169e94e7d61a8569d5a648ea
nevosial/learnpy
/refresh/sets.py
685
4.21875
4
#Sets in 3.6 p = {True, 3, 'nev', 4, 6, 7} q = {False, True, 1,2,'vic', 'zoe',6, 7, 'nev'} # union will return new set with all elements r = p.union(q) print(r) # intersection will return only the common elements found in both s = p.intersection(q) print(s) # difference will return only the uncommon elements found ...
true
fcbf8c044c03803243cf850f225f6ccdceb6caa0
Shridevi-PythonDev/quotebook
/day6_learning.py
1,640
4.15625
4
### Conditions # if a = 90 b = 60 if b<a: print("Yes a is greater than b") print(b) print(a*b) else: print("b is greater") print(a) #### elif a = 25 b = 18 if b > a: print("if condtion, b greater") elif a == b: print("you are in elif condition, equal") else: print("else condition,...
true
e408596819cc7e6e54a9b5581e90e694854ae231
Desnord/lab-mc102
/lab01/tiago-dalloca.py
1,096
4.34375
4
# DESCRIÇÃO # Escreva um programa que calcule a circunferência C de um determinado # planeta, com base na observação do ângulo A, entre duas localidades C1 e # C2, e na distância D, em estádios, entre elas. # Suponha que as localidades estejam no mesmo meridiano de um planeta # esférico. O seu programa deverá imprimi...
false
3287cbc23a4aaa096004f94cf7ece69f4029ac5f
Kodermatic/SN-web1
/07_HW - Python (write into file)/Storing_data_into_file.py
1,279
4.34375
4
# Plan: # User enters lines of file # User can exit adding new lines with :q # User is asked if file shall be saved. If yes file is saved and user is asked if file shall be printed. path = "./07_HW - Python (write into file)/" new_line = "" file_text = "" while True: if new_line != ":q\n": file_text = file_text...
true
80694ad66007e718d884ced92f79c7ef5c9eab6a
yash872/PyDsa
/Array/Search_a_2D_Matrix.py
1,086
4.15625
4
''' Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: - Integers in each row are sorted from left to right. - The first integer of each row is greater than the last integer of the previous row. Example 1: Input: matrix = [[1,3,5,7], ...
true
d1274fc5de939a7e26602bc32c150f9f38b98736
thithick/selenium-python
/D1_reverse_method1.py
319
4.25
4
# Method2 # Using function def reverseNumber(number): reverse = 0 while (number > 0): lastDigit = number % 10 reverse = (reverse * 10) + lastDigit number = number // 10 print(reverse) number = int(input("Please input a number to be reversed.\n")) reverseNumber(number);
true
b5dd39b448ae8e248f7a62a5be894596606fbfae
learnMyHobby/if_python
/leapYear.py
498
4.3125
4
# Write a program to check whether the entered year is leap year or not. # leap year means it has to be 366 days and it will occur once every four years year = int(input("Enter a year: ")) if (year % 4) == 0: if (year % 100) == 0: if (year % 400) == 0: print("{0} is a leap year".format(year)) ...
true