blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
db1143e720d5235473f01ca94cc39b6ef14e92fd
UnsupervisedDotey/Leetcode
/栈/155.py
1,464
4.5625
5
# 设计一个支持 push ,pop ,top 操作,并能在常数时间内检索到最小元素的栈。 class MinStack: def __init__(self): """ initialize your data structure here. """ self._the_min = [] self._data = [] def push(self, x: int) -> None: self._data.append(x) if len(self._the_min) == 0: ...
false
32969801992fefeeb0f6d49ce23b1cd6defc67ea
imcdonald2/Python
/9-7_admin.py
1,193
4.125
4
class User(): """User info""" def __init__(self, first_name, last_name, age): """User first name, last name, and age""" self.first = first_name self.last = last_name self.age = age def describe_user(self): print('First name: ' + self.first.title()) print('Las...
false
209880bc58394e1b26637a150f957699452642e9
gabcruzm/Basis-Python-Projects
/loops/loop_through.py
493
4.40625
4
#Loop through a string with For def run(): # name = input("Write your name: ") # for letter in name: #For letters in the name it will print each letter in each loop. # #letter is the variable that will represent each character in each repetition in the for loop. The characters are taken from the name w...
true
e471cb0845e9550d954db99e807ac0adebd115c0
maimoneb/dsp
/python/q8_parsing.py
1,295
4.3125
4
# The football.csv file contains the results from the English Premier League. # The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program t...
true
72e7171a13387c6fcd77caf8c2c3b03ddf82c155
pratikv06/python-tkinter
/Entry.py
520
4.1875
4
from tkinter import * root = Tk() # Define a function for button4 to perform def myClick(): msg = "Hello, " + e.get() + "..." myLabel = Label(root, text=msg) myLabel.pack() # Create a entry i.e. input area # setting width of the entry # changing border width of the entry e = Entry(root, widt...
true
21cae5cdc5b43d27e62d161e20d46712ae3d7282
mdelite/Exercism
/python/guidos-gorgeous-lasagna/lasagna.py
1,467
4.34375
4
"""Functions used in preparing Guido's gorgeous lasagna. Learn about Guido, the creator of the Python language: https://en.wikipedia.org/wiki/Guido_van_Rossum """ EXPECTED_BAKE_TIME = 40 PREPARATION_TIME = 2 def bake_time_remaining(elapsed_bake_time): """Calculate the bake time remaining. :param elapsed_bak...
true
1216602668067d9a17e4dd59c896d8fe2250be54
sssmrd/pythonassignment
/38.py
238
4.28125
4
#program to add member(s) in a set. l=input("Enter some elements=").split(); s=set(l); print(s) c=int(input("How many elements to enter=")) for i in range(0,c): n=input("Enter the element to be added in set=") s.add(n); print(s)
true
ca6341a13308ff63dc68f4546802e8f70b3db014
shreeyamaharjan/AssignmentIII
/A_a.py
534
4.125
4
def bubble_sort(nums): for i in range(n - 1): for j in range((n - 1) - i): if nums[j] > nums[j + 1]: temp = nums[j] nums[j] = nums[j + 1] nums[j + 1] = temp print(nums) else: print(nums) print("\...
false
55b8617e66a268c69ef5e2e14861dcc494034b11
edwardyulin/sit_project
/sit_il/utils/moving_average.py
623
4.15625
4
import numpy as np def moving_average(data: np.ndarray, window_size: int) -> np.ndarray: """Return the moving average of the elements in a 1-D array. Args: data (numpy.ndarray): Input 1-D array. window_size (int): The size of sliding window. Returns: numpy.ndarray: Moving average...
true
b5aa438957ab34145e3e8228f28ffddc91251e80
joshisujay1996/OOP-and-Design-Pattern
/oop/employee_basic.py
1,049
4.3125
4
""" Basic OOD Example In python everything is derived from a class and they have their own methods, like List, tuple, int, float, etc Everything is an Object in PY and they have there own methods and attributes we create instance out of the list class or tuple or etc pop, append,__str__, remove are methods of th list...
true
9d8d92fc2e55c20249dd984394faac14af74064e
TusharKanjariya/python-practicles
/8.py
252
4.15625
4
str1 = input("enter string") str2 = input("enter string") if len(str1) != len(str2): print("Length Not Equal") print(tuple(zip(str1, str2))) for x, y in zip(str1, str2): if x != y: print("Not Equal") else: print("Equal")
false
5b0d75ecbaebe98998a91200d2cb95d667a7d8d6
dhobson21/python-practice
/practice.py
1,794
4.1875
4
# 11/19/19-------------------------------------------------------------------------------- """Jaden Smith, the son of Will Smith, is the star of films such as The Karate Kid (2010) and After Earth (2013). Jaden is also known for some of his philosophy that he delivers via Twitter. When writing on Twitter, he is known ...
true
5654828bd965177fc7ef341aecaf1fb897e59a1e
weekswm/cs162p_week8_lab8
/Car.py
1,291
4.25
4
#Car class class Car: '''Creates a class Car attributes: make, color, and year ''' def __init__(self, make = 'Ford', color = 'black', year = 1910): '''Creates a car with the provided make, color, year. Defaults to Ford black 1910. ''' self.make = make self.color =...
true
2034276de5f99ed60e9ab3fd0d3e8d667c3e5ba0
mugwch01/Trie
/Mugwagwa_Trie_DS.py
2,267
4.21875
4
#My name is Charles Mugwagwa. This is an implementation of a Trie data structure. class Trie: def __init__(self): self.start = None def insert(self, item): self.start = Trie.__insert(self.start, item+"$") def __contains__(self,item): return Trie.__contains(self.sta...
true
c1940693fd3eface908ff33ad53698b00bccba0a
patrickbucher/python-crash-course
/ch07/pizza-toppings.py
294
4.125
4
prompt = 'Which topping would you like to add to your pizza?' prompt += '\nType "quit" when you are finished. ' topping = '' active = True while active: topping = input(prompt) if topping == 'quit': active = False else: print(f'I will add {topping} to your pizza.')
true
05a6e73545aba94442b52eb8cfcced8225292cad
qmisky/python_fishc
/3-3 斐波那契数列-递归.py
372
4.21875
4
def factorial(x): if x==1: return 1 elif x==2: return 1 elif x>2: result=int(factorial(x-1))+int(factorial(x-2)) return result elif x<0: print ("WRONG NUMBER!") number=int(input("please enter a positive number:")) result=factorial(number) print("the %d'th mont...
true
905976bf6c4a48cb5e3a9a10f8bf8dd4179f17da
AKArrow/AllPracticeProblemInPython
/week.py
289
4.15625
4
n=input("Enter A Week Day:") if n==1: print "monday" elif n==2: print "tuesday" elif n==3: print "wednesday" elif n==4: print "thursday" elif n==5: print "friday" elif n==6: print "saturday" elif n==7: print "sunday" else: print "There Is No Such Week Day!"
false
35dd288697bfe404b8f069973f4ca4e79091d445
Shivanshu17/DS-Algo
/Insertion_Sort.py
291
4.1875
4
def insertionsort(arr): l = len(arr) for i in range(1,l): j= i-1 key = arr[i] while(j>=0 and key<arr[j]): arr[j+1] = arr[j] j = j-1 arr[j+1] = key arr = [3,5,1,6,3,8,2,9] insertionsort(arr) for k in arr: print(k)
false
0165c1a06718db569cd1f53a94956a1508b5959e
DanWade3/belhard_8_tasks
/tasks/easy/inheritance_polimorphism/duck_typing.py
745
4.34375
4
""" Создать 3 класса: Cat, Duck, Cow в каждом классе определить метод says() Cat.says() - кошка говорит мяу Duck.says() - утка говорит кря Cow.says() - корова говорит муу Написать функцию animal_says(), которая принимает объект и вызывает метод says """ class Cat: def says(self): print("кошка говорит ...
false
5e86d3968b563d852e0dd68b67f48d12b37036d3
psgeisa/python_eXcript
/Excript - Aula 01 - Concatenar.py
698
4.28125
4
# Concatenando numero inteiro e str num_int = 5 num_dec = 7.3 val_str = "qualquer texto" # %d é um marcador padrão print("1ª forma - o valor é:", num_int) print("2ª forma - o valor é:%i" %num_int) # %i de "inteiro" print("3ª forma - o valor é:" + str(num_int)) # Essa concatenação necessita de conversão int >...
false
3c647ea21a894256099a43bf1835c741ca6aea32
bhuiyanmobasshir94/haker-rank
/Problem-Solving/stair_case.py
341
4.15625
4
#!/bin/python import math import os import random import re import sys def staircase(n): for i in range(1,n+1): str='' for k in range(1,((n-i)+1)): str +=' ' for j in range(1,i+1): str += '#' print(str) if __name__ == '__main__': n = int(raw_input(...
false
c3fbdb921f822e4d6ebfeeeb8c11459af4f8af50
jasonwsvt/Python-Projects
/db_sub.py
1,389
4.375
4
""" Use Python 3 and the sqlite3 module. Database requires 2 fields: an auto-increment primary integer field and a field with the data type “string.” Read from fileList and determine only the files from the list which end with a “.txt” file extension. Add those file names from the list ending with “.txt” file extension...
true
bdf21e232926951c456a4ddbbb11799289ea3f27
osho-sunflower/python_session_snippets
/console_io.py
489
4.15625
4
# Python2 ----> Python3 # input() ----> eval(input()) # raw_input() ----> input() # Python3 string = input('Enter a string: ') print('Got:', string) number = int(input('Enter a number: ')) print('Got:', number) expression = eval(input('Enter an expression: ')) print('Evaluated:', expr...
false
c526f0b569465e0e1a3cd10674793bff1debd6bf
luzap/intro_to_cs
/cs013/lab.py
1,389
4.21875
4
import random import helpers # # Each of the following functions have an arbitrary return value. Your # job is to edit the functions to return the correct value. You'll # know it's correct because when you run test.py, the program will # print "PASS" followed by the function name. # # Any code you add outside of these...
true
05f02174029e72f410f52517576d655cd297e8ab
chin269/proyectos-ie
/cli/cli_simple.py
1,572
4.4375
4
""" Argumentos de linea de comandos Modulo recibe argumentos de linea de comandos Módulo sys proporciona funciones y variables que se usan para manipular diferntes partes de Runtime de python y acceso a ciertas partes del interprete. """ import sys class Calc: """Provee metodos para operaciones basicas""" ...
false
ecddeb829aa78cd91843859c3e72093580f00279
Antrikshhii17/myPythonProjects
/DataStructure_Algorithm/Count_occurrences.py
485
4.28125
4
""" Program to count number of occurrences of each element in a list. Asked in Precisely interview for Software Engineer-I """ def count_occurrences(ourlist): # return dict((i, ourlist.count(i)) for i in ourlist) # List comprehension approach dicx = {} for j in ourlist: dicx.__setite...
true
1838b979bbf1c1b6ee4f1e872367325f2e3ea6da
Antrikshhii17/myPythonProjects
/DataStructure_Algorithm/Bubble_sort.py
516
4.3125
4
""" Bubble sort. Time complexity- Worst case = O(n^2) , when the array is in descending order. Average case = O(n^2) , when the array is jumbled. Best case = O(n) , when the array is already sorted. """ def bubblesort(list): for i in range(len(list)): for j in range(len(list) - i - 1): ...
true
aba880ab4100a7c30c4b9fe8dbc5fd52da08a225
vkhalaim/pythonLearning
/tceh/lection2/list_task_2.py
359
4.15625
4
objectList = ["Pokemon", "Digimon", "Dragon", "Cat", "Dog"] # first method for i in objectList: print("Element of list -> " + i + "[" + str(objectList.index(i)) + "]" + "(in square braces index of element)") # enumarate print("-------------------") for index, element in enumerate(objectList): print(...
true
94a22ec4cf15613bf3ccce939d29bf6ba89f4a51
J-Gottschalk-NZ/Random_String_generator
/main.py
721
4.21875
4
import string import random # Function to check string length is an integer that is > 0 def intcheck(question): error = "Please enter an integer that is more than 0 \n" valid = False while not valid: try: response = int(input(question)) if response < 1: print(error) else...
true
07c883f8fc0c761e210688b095c5c0e0d5cd82c8
MMGroesbeck/cs-module-project-recursive-sorting
/src/sorting/sorting.py
2,097
4.1875
4
# TO-DO: complete the helper function below to merge 2 sorted arrays def merge(arrA, arrB): elements = len(arrA) + len(arrB) merged_arr = [0] * elements # Your code here i = 0 a = 0 b = 0 while i < elements: if a >= len(arrA): merged_arr[i] = arrB[b] b += 1 ...
true
c0fdd5f8b40a8bce1db3e6808c3a9341789b6292
mazoko/python
/14_もっとオブジェクト指向/test14-1.py
1,222
4.1875
4
# 図形クラス class Shape: def __init__(self): pass def what_am_i(self): print("I am a shape!!") # 正方形クラス(図形クラスを継承) class Square(Shape): # 作成済み正方形リスト square_list = [] def __init__(self, s): self.side = s # リストにインスタンスを追加 self.square_list.append(self) # 外周計算メ...
false
a6079ca9dd18ad71ea9a3aee7159e14985c90d63
serereg/homework-repository
/homeworks/homework7/hw2.py
2,154
4.3125
4
""" Given two strings. Return if they are equal when both are typed into empty text editors. # means a backspace character. Note that after backspacing an empty text, the text will continue empty. Examples: Input: s = "ab#c", t = "ad#c" Output: True # Both s and t become "ac". Input: s = "a##c", t = ...
true
e10d7fa1b2457d129396d35cc6885d03f4dee095
serereg/homework-repository
/homeworks/homework4/task_1_read_file.py
1,784
4.1875
4
""" Write a function that gets file path as an argument. Read the first line of the file. If first line is a number return true if number in an interval [1, 3)* and false otherwise. In case of any error, a ValueError should be thrown. Write a test for that function using pytest library. You should create files require...
true
c91cea964cc5f6b8931497a93c6ac1b37cf8ca62
serereg/homework-repository
/homeworks/homework2/hw5.py
1,611
4.15625
4
""" Some of the functions have a bit cumbersome behavior when we deal with positional and keyword arguments. Write a function that accept any iterable of unique values and then it behaves as range function: import string assert = custom_range(string.ascii_lowercase, 'g') == ['a', 'b', 'c', 'd', 'e', 'f'] assert = c...
true
c312bb50572e8260c13796c143961aa68d2cb8f8
serereg/homework-repository
/homeworks/homework2/hw3.py
752
4.125
4
""" Write a function that takes K lists as arguments and returns all possible lists of K items where the first element is from the first list, the second is from the second and so one. You may assume that that every list contain at least one element Example: assert combinations([1, 2], [3, 4]) == [ [1, 3], [...
true
764e06c119d1690a26a80ed11f51c517bf2fc6de
MohitSojitra/PythonExcersise
/Forloop.py
402
4.1875
4
# here i will show ypu a how we use a for loop list1 = ["mohit" , "parth" ,"manoj " , "mamu" , "kinjal" , 34, 54, 456] dictionary1 = {"mohit" : "moylo" , "parth" : "vando" , "manoj" : "bahubally"} for i, j in dictionary1.items(): print(i,j) list2 = ["mohit" , "mamu" , 45 ,54 , 23, 234, 2, 1, 3, 4, 5,6] for ite...
false
d9085475d79d664153e73818e7a07fe628910a06
DonCastillo/learning-python
/0060_sets_intro.py
2,661
4.25
4
farm_animals = {"sheep", "cow", "hen"} # sets are unordered, can set the order randomly every time the code is ran print(farm_animals) # sets only contains one copy of each element for animal in farm_animals: print(animal) print("=" * 40) wild_animals = set(["lion", "tiger", "panther", "elepha...
true
c67e8738b515c6f514123d1b27e57bdbee27a628
mnovak17/wojf
/lab01/secondconverter.py
497
4.125
4
#secondconverter.py #Translates seconds into hours, minutes, and seconds #Mitch Novak def main(): print("Welcome to my Second Converter! \n") print("This program will properly calculate the number of \n minutes and seconds under 60 from a given number of seconds") n = eval(input("How many seconds have you...
true
5c8c994d67629eec2aade0b86e8b4a1ad3d807ae
mnovak17/wojf
/lab02/fibonacci.py
370
4.25
4
#fibonacci.py #prints the fibonacci number at a given index #Mitch Novak #1/7/13 def main(): print("My incredible Fibonacci number generator!") n = eval(input("Plaese enter an integer:")) f0 = 1 f1 = 1 for i in range(3, n+1): temp = f0 + f1 f0 = f1 f1 = temp print("The",...
false
4a0738f39e7d517d81903dd7a63f76b7f6b8d7a5
RinkuAkash/Python-libraries-for-ML
/Numpy/23_scalar_multiplication.py
426
4.1875
4
''' Created on 21/01/2020 @author: B Akash ''' ''' problem statement: Write a Python program to create an array of (3, 4) shape, multiply every element value by 3 and display the new array. Expected Output: Original array elements: [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] New array elements: [[ 0 3 6 9] [12 15 18 21]...
true
0ac549f8f324ddc0246cc9a6227ed0ddb715ffde
sabgul/python-mini-projects
/guess_the_number/main.py
1,110
4.28125
4
import random def guess(x): random_number = random.randint(1, x) guess = 0 while guess != random_number: guess = input(f'Guess a number between 1 and {x}: ') guess = int(guess) if guess < random_number: print('Guess was too low. Try again.') elif guess > ran...
true
5f215b292c15000d73a2007e8ed8e81d32e536a5
OmarKimo/100DaysOfPython
/Day 001/BandNameGenerator.py
465
4.5
4
# 1. Create a greeting for your program. print("Welcome to My Band Name Generator. ^_^") # 2. Ask the user for the city that they grow up in. city = input("What's the name of the city you grow up in?\n") # 3. Ask the user for the name of a pet. pet = input("Enter a name of a pet.\n") # 4. Combine the name of their c...
true
ebca9d6de69c7539774b2a57852d492ab0d7295d
Nicodona/Your-First-Contribution
/Python/miniATM.py
2,703
4.25
4
# import date library import datetime currentDate = datetime.date.today() # get name from user name = input("enter name : ") # create a list of existing name and password and account balance nameDatabase = ['paul', 'peter', 'emile', 'nico'] passwordDatabase = ['paulpass', 'peterpass','emilepass', 'nicopass'] accountB...
true
6614083932d6659190d7eb0dc5ba9693d2faa44e
jeremyosborne/python
/iters_lab/solution/itools.py
816
4.28125
4
""" Lab --- Using the iterutils, figure out the number of permutations possible when rolling two 6-sided dice. (Hint: Think cartesian product, not the permutations function.) Print the total number of permutations. Make a simple ascii chart that displays the count of permutat...
true
edc84c8a30911e7bd2d8c82fbdcac975cd3a1f40
Deathcalling/Data-Analysis
/pythonData/pythonPandas/pandasBasics1.py
1,529
4.125
4
import pandas as pd #Here we import all necessary modules for us to use. import datetime import matplotlib.pyplot as plt import numpy as np from matplotlib import style #This simply tells python that we want to make matplotlib look a bit nicer. style.use('ggplot') #Here we tell python what kind of style we would l...
true
ef5ad01f85285601321ec6fa246a16e6f07b775b
siddharth456/python_scripts
/python/add_elements_to_a_list.py
251
4.34375
4
# add elements to an empty list testlist=[] x=int(input("enter number of elements to be added to the list:")) for i in range(x): e=input("enter element:") testlist.insert(i,e) print() # adds an empty line print("Your list is",testlist)
true
911040a477c107f353b3faace1d688dafde3064d
siddharth456/python_scripts
/python/create_user_input_list.py
209
4.375
4
# We will create a list using user input userlist = [] # this is how you initialize a list for i in range(5): a=input("Enter element:") userlist.append(a) print ("your created list is:",userlist)
true
b32a498930d2701520f45965a56d65fa09e533ad
SergioG84/Python
/weight_converter.py
1,113
4.15625
4
from tkinter import * window = Tk() # define function for conversion def convert_from_kg(): grams = float(entry_value.get()) * 1000 pounds = float(entry_value.get()) * 2.20462 ounces = float(entry_value.get()) * 35.274 text1.insert(END, grams) text2.insert(END, pounds) text3.inser...
true
04b9e2a82aa79e2aaba97531d8cb36e21ccc1983
MHSalehi/Programming
/Lecture1Repeat_Strings.py
2,130
4.28125
4
#Introduction, Printing Strings print ("Hello, Python!") spch = "Greetings!" print (spch + " What is your name?") #Class Task 1 print ("\n") g = 14 t = 0.12 tg = g+g*t print ("£ " + str(tg)) #Class Task 2 print ("\n") fg = 20 s = 0.4 #Calculate sale price to 2 d.p. sg = '{:.2f}'.format(fg-fg*s) print ("£ " + str(sg)...
false
02b0d355297a05752f11a1f18b81e542b849ed01
Zyjqlzy/PythonStudyNotes
/Algorithm/select_sort.py
808
4.25
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ 选择排序 """ def create_list(): user_input = input("请输入数据,逗号分隔:\n").strip() user_list = [int(n) for n in user_input.split(',')] print(user_list) return user_list def find_smallest_item(lst): smallest_item = lst[0] smallest_index = 0 for i in ...
false
8aece43ba3fef62e3bd9b1f2cead27608995c2c4
SHASHANKPAL301/Rock-Paper-and-Scissor-game
/game.py
1,311
4.25
4
import random print(''' Welcome to the Rock,Paper and Scissor game. THe rule of the game is shown below:- 1. rock vs scissor---> rock win 2. scissor vs paper---> scissor win 3. paper vs rock---> paper win''') def game(computer, player): if computer == player: return None #tie elif comput...
true
a43a0d590b70294442e9d92916cad822be961d3e
ohlemacher/pychallenge
/3_equality/equality.py
2,339
4.34375
4
#!/usr/bin/env python ''' Find lower case characters surrounded by exactly three upper case characters on each side. ''' import pprint import re import unittest def file_to_string(): '''Read the file into a string.''' strg = '' with open('equality.txt', 'r') as infile: for line in infile: ...
true
ee05faf9992dcd4041a0cacc10844f0e8f7ba000
fhossain75/CS103-UAB
/lab/lab08/lab08_19fa103.py
2,296
4.40625
4
# 19fa103; john k johnstone; jkj at uab dot edu; mit license # lab08 on recursion # ------------------------------------------------------------------------------ def sum (n): """Compute the sum of the first n positive integers, recursively. >>> sum (10) 55 Params: n (int) n >= 1 Returns: (i...
false
3fbe28eaf7e972df0dc5c38e6adcc6857769fccd
fhossain75/CS103-UAB
/lab/lab07/reverse_stubbed.py
441
4.375
4
# 19fa103; john k johnstone; jkj at uab dot edu; mit license # reverse1 iterates over the element; # this is the one to remember, since it is the most natural and clear; # so this is the one to practice def reverse1 (s): """Reverse a string, iteratively using a for loop (by element). >>> reverse1 ('garden') ...
true
d347240883041f719822fcbf4fed052a3741829d
ParrishJ/cs-module-project-recursive-sorting
/src/sorting/sorting.py
2,239
4.1875
4
# TO-DO: complete the helper function below to merge 2 sorted arrays #test_arr = [1, 5, 3, 2] #test_arr_b = [5, 6] def merge(arrA, arrB): elements = len(arrA) + len(arrB) merged_arr = [0] * elements count = 0 while arrA or arrB: if len(arrA) != 0 and len(arrB) == 0: merged_arr[coun...
false
8393ddf1ce183849578b732960aab84cd2f36d86
A-FLY/pyton8
/反恐精英.py
2,229
4.15625
4
""" 演示反恐精英案例 对一个匪徒 分析: 1.定义人类,描述公共属性 life:100 name:姓名要传参 2.定义出英雄与恐怖分子类 3.定义主函数描述枪战过程 main,创建两个对象 4.定义开枪方法,分成两个方法,Hero Is都有 定义的方法要传入被射击的对象 被射击对象的生命值要进行减少 5.主程序中调用开枪操作 6.开枪操作后,要在主程序中显示每个人的状态信息 7.定义Person类的__str__方法,用于显示每个人的状态 8.设置开枪操作为反复操作 再设置停止条件:一方生命值<=0 停止循环使用break -----------------------修复版------...
false
c18382f6f82bd6d98f293d08ac885a5d78fad773
sqhl/review
/坑向/range的加深理解.py
264
4.15625
4
x = 4 # for i in range(x): # print(i, x) # x = 2 # print(x) # print("------------") for i in range(x): for j in range(x): print(j, x) x = 2 # range(2) 返回一个对象 当每次range完了之后 会重新创建对象
false
4c278680c7c2edd60a3435a9aa424a0a1ac1de6d
diksha16017/fcs_assignment1
/assignment/CipherToPlain.py
1,523
4.28125
4
cipher1 = "slnpzshabylzohssthrluvshdylzwljapunhulzahispzotluavmylspnpvuvywyvopipapunaolmylllelyjpzlaolylvmvyh" cipher2 = "iypknpunaolmyllkvtvmzwlljovyvmaolwylzzvyaolypnoavmaolwlvwslwlhjlhisfavhzzltislhukavwlapapvuaolnvcl" cipher3 = "yutluamvyhylkylzzvmnyplchujlz" alphabets_frequency = dict() def find_frequency(text1...
false
8385b7cca4d9d2e2a7d25209233d5462ab8af24c
ErenBtrk/Python-Exercises
/Exercise21.py
723
4.15625
4
''' Take the code from the How To Decode A Website exercise (if you didn’t do it or just want to play with some different code, use the code from the solution), and instead of printing the results to a screen, write the results to a txt file. In your code, just make up a name for the file you are saving to. Extras: ...
true
f99df6b2eabb591210ef8a18b648deaf198a9ef8
ErenBtrk/Python-Exercises
/Exercise5.py
1,280
4.25
4
''' Take two lists, say for example these two: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] and write a program that returns a list that contains only the elements that are common between the lists (without duplicates). Make sure your program works on two lists o...
true
8b53226541e87eaee9b5ad490c425a35d84e3ab6
Dinesh-Sivanandam/LeetCode
/53-maximum-subarray.py
1,083
4.25
4
#Program to find the maximum sum of the array def maxSubArray(A): """ :type nums: List[int] :rtype: int """ #length of the variable is stored in len_A len_A = len(A) #if the length of the variable is 1 then returning the same value if 1 == len_A: return A[0] """ ...
true
71929d852440e9767bed7adf6cb2d1deb9ed93b3
ul-masters2020/CS6502-BigData
/lab_week2/intersection_v1.py
349
4.1875
4
def intersection_v1(L1, L2): '''This function finds the intersection between L1 and L2 list using in-built methods ''' s1 = set(L1) s2 = set(L2) result = list(s1 & s2) return result if __name__ == "__main__": L1 = [1,3,6,78,35,55] L2 = [12,24,35,24,88,120,155] result = intersection_v1(L1, L2) print(f"Inter...
true
e22b8b0118602f46eeb6d10ece21836a7878a806
Olishevko/home_work2
/day_of_week.py
427
4.25
4
day_of_week = int(input('enter the serial number of the day of the week: ')) if day_of_week == 1: print('monday') elif day_of_week == 2: print('tuesday') elif day_of_week == 3: print('wednesday') elif day_of_week == 4: print('thursday') elif day_of_week == 5: print('friday') elif day_of_week == 6: p...
false
8b2ec04aef80d96e472eaf2592d180f41c0b06a2
ABDULMOHSEEN-AlAli/Guess-The-Number
/Guess-The-Number.py
2,895
4.25
4
from random import randint # imports the random integer function from the random module computer_guess = randint(1, 50) # stores the unknown number in a variable chances = 5 # sets the chances available to the user to 5 def mainMenu(): # defines the main menu function, which will be prompted to the user every now an...
true
7906bb35b5f7c0c0acb8730ff7ccc6423fdd1623
LesroyW/General-Work
/Python-Work/Loops.py
470
4.4375
4
#Looping over a set of numbers # For number in numbers: # print(number) examples of for loop # For loops can also loop of a range #e.g for x in range(5): # print(x) #While loops can also be used within it #Break and continue statements can be used to skip the current block or return to the for/whil statement # el...
true
9b3267d9488f10a980a2935d77bf906c4468f281
adityagith/pythonprograms
/prime number.py
278
4.15625
4
a = int(input("Enter a number to check its prime or not\n")) if(a<=0): print("No") elif(a==2): print("Yes") elif(a>2): for i in range(2,a): if(a%i==0): print("Not a prime") break else: print("Prime")
true
3fe6eb252a60edfa06b9c96e8bdc4728bb0537a7
zhenningtan/DataStructure_Algorithms
/mergesort_inversion.py
1,462
4.15625
4
############################################################ # Count inversion # merge sort function def merge_inversion(arr1, arr2, inversion): n1 = len(arr1) n2 = len(arr2) n = n1 + n2 marray = [0] * n k = 0 i = 0 j = 0 #compare arr1 and arr2 and add the smaller number to the sorted ...
false
379a96400b033254a0ddd01c9a477882d16adfd0
odecay/CS112-Spring2012
/hw04/sect1_if.py
992
4.25
4
#!/usr/bin/env python from hwtools import * print "Section 1: If Statements" print "-----------------------------" # 1. Is n even or odd? n = raw_input("Enter a number: ") n = int(n) x = n % 2 if x == 0: print "1.", n, "is even" else: print "1.", n, "is odd" # 2. If n is odd, double it if x > 0: ...
false
2584097aff364d6aeb60030eda2117628cbceda9
siva4646/DataStructure_and_algorithms
/python/string/longest_word_indictioary_through_deleting.py
986
4.15625
4
""" Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string....
true
9b90a92ae8019fb0f7b7ea91381269abc8df48dc
brahmaniraj/Python_BM
/Datatypes/Strings/capitalize.py
428
4.6875
5
#!/usr/bin/python # 1. capitalize() Method : # Note: string with only its first character capitalized. a01 = "welcome to python world" a02 = "python world" a03 = "to python world" print ("a01.capitalize() : ", a01.capitalize(),id(a01),type(a01),len(a01)) print("") print ("a02.capitalize() : ", a02.capitalize(),id(a...
false
2e274a24f93f81017686ad4c5ceabfaece95d419
sebasbeleno/ST0245-001
/laboratorios/lab02/codigo/laboratorio2.py
1,610
4.15625
4
import random import sys import time sys.setrecursionlimit(1000000) # Function to do insertion sort def insertionSort(arr): # Traverse through 1 to len(arr) for i in range(1, len(arr)): key = arr[i] # Move elements of arr[0..i-1], that are # greater than key, to one posi...
true
38bd89e50954a7421eee5662d019fc303fa1b172
nerincon/Python-Exercises
/week2/Thurs/phonebook_app/phonebook_json.py
2,283
4.15625
4
import json while True: print("Electronic Phone Book") print("=====================") print("1. Look up an entry") print("2. Set an entry") print("3. Delete an entry") print("4. List all entries") print("5. Save entries") print("6. Restore saved entries") print("7. Quit") ...
false
afd31e371feaed5fdf84e4372460b931416b3284
karankrw/LeetCode-Challenge-June-20
/Week 3/Dungeon_Game.py
1,918
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jun 22 01:25:32 2020 @author: karanwaghela """ """ The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially po...
true
65c2f70ca2dae1538060ac49c894702961d52e91
Python-lab-cycle/Swathisha6
/2.fibopnnaci.py
214
4.15625
4
n =int(input("enter the number of terms:")) f1,f2=0,1 f3=f2+f1 print("fibonacci series of first" , n, "terms") print(f1) print(f2) for i in range (3, n+1): print(f3) f1=f2 f2=f3 f3=f1+f2
true
899cccdd60ddcb83f56c18966562d82d0f77703e
LowerDeez/grasp-gof-patterns
/abstract-factory/main.py
1,864
4.3125
4
from abc import ABC, abstractmethod from typing import List class TraditionalDish(ABC): """Base class for traditional dish""" name = "traditional dish" class Lunch(ABC): """Base class for lunch""" name = "lunch" class Cafe(ABC): """Abstract Factory. Base class for specific country food""" ...
false
c40bb2fd8c2d832b63fc1cd49c3718f6d8b96a87
ipcoo43/pythonone
/lesson145.py
758
4.21875
4
print(''' [ 범위 만들기 ] range(<숫자1>) : 0부터 (<숫자1>-1)까지의 정수 범위 range(<숫자1>,<숫자2>) : <숫자1>부터 (<숫자2>-1)까지의 정수의 범위 ringe(<숫자1>,<숫자2>,<숫자3>) : <숫자1>부터 <숫자3> 만큼의 차이를 가진 (<숫자2>-1)까지 범위 [ 범위와 반복문 ] for <범위 내부의 숫자를 담을 변수> in <범위>: <코드> ''') print(range(5)) print(list(range(5))) for i in range(5): print('{}번째 반복문입니다.'.format(i))...
false
6fca883d665e990214b2d41c54de0a598dbff80b
kruart/coding_challenges
/hackerRank/python3_/string-formatting.py
337
4.125
4
# https://www.hackerrank.com/challenges/python-string-formatting/problem def print_formatted(num): maxWidth = len(format(num, 'b')) for i in range(1, num+1): print("{0:>{width}} {0:>{width}o} {0:>{width}X} {0:>{width}b}".format(i, width=maxWidth)) if __name__ == '__main__': n = int(input()) pr...
false
ee934da6f5e0eee00050b8ed0845a2a9f70dd3e7
katherfrain/Py101
/tipcalculator2.py
810
4.125
4
bill_amount = float(input("What was the bill amount? Please don't include the dollar sign! ")) service_sort = input("What was the level of service, from poor to fair to excellent? ") people_amount = int(input("And how many ways would you like to split that? ")) service_sort = service_sort.upper() if service_sort == "P...
true
2efd2878071e1534f85d45a7c3f36badb42c7a96
katherfrain/Py101
/grocerylist.py
447
4.125
4
def want_another(): do_you_want_another = input("Would you like to add to your list, yes/no? ") if do_you_want_another == "yes": grocery = input("What would you like to add to your list? ") grocery_list.append(grocery) print("You have added ", grocery, "to the list") prin...
true
15cba18ee92d82bf0f612e96ece1dc4a2911d9fc
ghimire007/jsonparser1
/jsonparser.py
1,111
4.1875
4
# json parsor import csv import json file_path = input("path to your csv file(add the name of your csv file as well):") # takes file path base_new = "\\".join(file_path.split("\\")[:-1]) file_name = input( "name of th file that you want to save as after conversion(no extension required):") # takes nam...
true
84e0a3ba3678e6e5bc8618871e8d7a2eb6cebfe1
himala76/Codding_Lesson_1
/Lectures_Note_Day_1/Cancat.py
352
4.4375
4
# This is the result we want to have in the console #print "Hello, world! My name is Josh." # Create a variable to represent the name and introduction statement to print name = "Josh" # Comment out this line for the moment # intro_statement = "Hello, world! My name is " # print the concatenated string print "Hello, ...
true
4b02cf096cd437659968330d1e2fed228fd2036f
asenath247/COM404
/1-basics/4-repetition/3-ascii/bot.py
212
4.15625
4
print("How many bars should be charged.") bars = int(input()) chargedBars = 0 while chargedBars < bars: print("Charging "+"█" * chargedBars) chargedBars += 1 print("The battery is fully charged.")
true
4b3fd151726e2692179e72be9fb71e4b3fb632a3
vishal-B-52/Documentation_of_Python
/GuessTheNumberModified.py
1,693
4.25
4
# Guess the number :- print("This is a 'Guess the Number Game'. You have 10 Life(s) to guess the hidden number. You have to win in 10 Life(s) " "else You lose!!! ") Life = 10 while True: N = int(input("Enter the number:- ")) Life -= 1 if 0 <= N < 18: if Life == 0: pr...
true
b15d153e861eeed43c8b9c77c6a4f00198580892
Kaiquenakao/Python
/Coleções Python/Exercicio58.py
1,433
4.125
4
""" 58. Faça um programa que leia uma matriz de 4 linhas e 4 colunas contendo as seguintes informações sobre alunos de uma disciplina, sendo todas as informações do tipo inteiro: º Primeira coluna: Número de matrícula (use um inteiro) º Segunda coluna: Média das prova º Terceira coluna: Média dos trabalhos º Qu...
false
ac95c2666c923119653f31376e715f7d2b233d59
Kaiquenakao/Python
/Coleções Python/Exercicio57.py
762
4.375
4
""" 57. Faça um programa que permita ao usuário entrar com uma matriz de 3 x 3 números inteiros. Em seguida, gere um array unidimensional pela soma dos números de cada coluna da matriz e mostrar na tela esse array. Por exemplo, a matriz: [5 -8 10] [1 2 15] [25 10 7] [31 4 3] """ matriz = [[0, 0, 0], [0, 0...
false
b907811cd06f03f55b3df9afc7fbc9309cb1f96e
Kaiquenakao/Python
/Estruturas Logicas e Condicionais/Exercicio2.py
358
4.21875
4
""" 2. Leia um número fornecido pelo usuário. Se esse número for positivo, calcule a raiz quadrada do número Se o número for negativo, mostre uma mensagem dizendo que o número é inválido. """ import math num = int(input('Insira um número:')) if num >= 0: print(f'A raiz do número:{math.sqrt(num)}') else: ...
false
4a72a5656a63fbd3a14ec2bfe8b7656dbd69a76d
Kaiquenakao/Python
/Coleções Python/Exercicio30.py
594
4.125
4
""" 30. Faça um programa que leia dois vetores de 10 elementos. Crie um vetor que seja a intersecção entre 2 vetores anteriores, ou seja, que contém apenas os números que estão em ambos vetores. """ conjuntoA = [] conjuntoB = [] print('Conjunto A') for i in range(0, 9+1): n = float(input(f'Conjunto : {i...
false
7dbbdacbfd8ce304a0de43a175ec23f5088e7470
Kaiquenakao/Python
/Coleções Python/Exercicio51.py
719
4.21875
4
""" 51. Leia uma matriz de 3 x 3 elementos. Calcule e imprima a sua transporta """ matriz = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] matrizt = [[0, 0, 0], [0, 0, 0], [0, 0, 0]] for i in range(0, 3): for j in range(0, 3): matriz[i][j] = float(input(f'[[{i}] [{j}]] digite um valor: ')) print('----------...
false
f3bc9942cf77b94e4e8c4f9136f1189699fc39bc
Kaiquenakao/Python
/Estruturas Logicas e Condicionais/Exercicio4.py
371
4.34375
4
""" 4. Faça um programa que leia um número e, caso ele seja positivo, calcule e mostre: * O número digitado ao quadrado * A raiz quadrada do número digitado. """ import math num = float(input('Insira o seu valor:')) if num > 0: print(f'O número digitado ao quadrado:{num ** 2}') print(f'A raiz q...
false
c740260a42fd2ecda2ccf6fc33e4c709160d8957
Kaiquenakao/Python
/Coleções Python/Exercicio1.py
1,023
4.3125
4
""" 1. Faça um programa que possua um vetor denominado A que armazene 6 números inteiros. O Programa deve executar os seguintes passos (a) Atribua os seguintes valores a esses vetor:1,0,5,-2 ,-5,7; (b) Armazene em uma variável inteira(simples) a soma entre os valores da posições A[0], A[1] e A[5] do vetor e mostre...
false
bbaa640f05c59ee9347ae2e708de6171d8c16c95
Kaiquenakao/Python
/Variáveis e Tipos de Dados em Python/Exercicio35.py
543
4.125
4
""" 35. Sejam a e b os catetos de um triangulo, onde a hipotenusa é obtida pela equação hip = √a² + b². Faça um programa que receba os valores de a e b e calcule o valor da hipotenusa através da equação. Imprima o resultado dessa operação. """ import math try: a = float(input('Insira o valor de a: ')) ...
false
9790f37381a1455af2fbb10777525caa9b8d0ab0
innovatorved/BasicPython
/x80 - Tuples.py
541
4.3125
4
#turple #turple is immutable #once u defined turple u cannot change its elements bmi_cat = ('Underweight' , 'Normal', 'Overweight' ,'very Overweight') #type print('Type: ',type(bmi_cat)) #access element of turple print(bmi_cat[1]) #we use positive value print(bmi_cat[-2]) #and we also use negative value print(b...
true
43fd97252b25c653bfdbe8a1349cd89475d40e60
HananeKheirandish/Assignment-8
/Rock-Paper-Scissor.py
876
4.125
4
import random options = ['rock' , 'paper' , 'scissor'] scores = {'user' : 0 , 'computer' : 0} def check_winner(): if scores['user'] > scores['computer']: print('Play End. User Win!! ') elif scores['user'] < scores['computer']: print('Play End. Computer Win!! ') else: pri...
true
e2a0c342c90cd07b387b7739b9869aee46df4090
luroto/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
761
4.15625
4
#!/usr/bin/python3 """ Function handbook: text_identation("Testing this. Do you see the newlines? It's rare if you don't: all are in the code." Testing this. Do you see the newlines? It's rare if you dont: all are in the code. """ def text_indentation(text): """ This function splits texts adding newlines when...
true
3b0fe27b3dc3448de0bdcdd034ff6220af9bad2d
mtocco/ca_solve
/Python/CA041.py
2,774
4.28125
4
## Code Abbey ## Website: http://www.codeabbey.com/index/task_view/median-of-three ## Problem #41 ## Student: Michael Tocco ## ## ## ## Median of Three ## ## ## You probably already solved the problem Minimum of Three - and it was ## not great puzzle for you? Since programmers should improve their logic ## (and not o...
true
fbec208c8dae08742e23d199f4a4debc8d125430
unknownpgr/algorithm-study
/code-snippets/02. permutation.py
724
4.15625
4
''' Recursive function may not be recommanded because of stack overflow. However, permutation can be implemented with recursive function without warring about overflow. That is because n! grows so fast that it will reach at time limit before it overflows. ''' def permutation(array): ''' This function returns ...
true
af800a84a2887a6cc0561a74b3a44215ac9e8457
jhglick/comp120-sp21-lab09
/longest_increasing_subsequence.py
467
4.125
4
""" File: longest_increasing_subsequence.py Author: COMP 120 class Date: March 23, 2021 Description: Has function for longest_increasing_subsequence. """ def longest_increasing_subsequence(s): """ Returns the longest substring in s. In case of ties, returns the first longest substring. """ pass i...
true
0ead192ad5b4d5d7d2200c26a78eaed348933274
rachit-mishra/Hackerrank
/String 10 formatting.py
793
4.21875
4
''' def print_formatted(number): for i in range(1,number+1): binlen = len(bin(i)[2:]) print(str(i).rjust(binlen,' '),end=" "), print(str(oct(i)[2:]).rjust(binlen,' '),end=" ") print(str(hex(i)[2:].upper()).rjust(binlen,' '),end=" ") print(str(bin(i)[2:]).rjust(binlen,' '), s...
false
5b17d6216a339ee9642c7d826ff468a2bdd99139
rachit-mishra/Hackerrank
/Sets 1 intro.py
681
4.25
4
# Set is an unordered collection of elements without duplicate entries # when printed, iterated or converted into a sequence, its elements appear in an arbitrary order # print set() # print set('HackerRank') # sets basically used for membership testing and eliminating duplicate entries array = int(input()) sumlist = ...
true
a5daff0eccc74862ba2f2cd962971a27f2ec7099
tinybeauts/LPTHW
/ex15_mac.py
1,197
4.375
4
from sys import argv script, filename = argv txt = open(filename) print "Here's your file %r:" % filename print txt.read() print "Type the filename again:" file_again = raw_input("> ") txt_again = open(file_again) print txt_again.read() # Extra Credit 4 # from sys import argv # # script, filename = argv # # t...
true