blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
c02e22d737b5fd6d67359f913faaa23eca061dc8
ebresie/MyGitStuff
/books/OReillyBooks/LearningPython/lists.py
711
4.1875
4
L=[123, 'spam',1.23]; print(L); print('len=',len(L)) # Indexing by position 123 print(L[0]) # Slicing a list returns a new list [123, 'spam'] print(L[:-1]) # Concat/repeat make new lists too [123, 'spam', 1.23, 4, 5, 6] print(L + [4, 5, 6]) print(L * 2) L.append('NI') print(L) # additional list operators L.insert(12...
true
acffad6b2b6e77a9c93642e094345a1bbc1e1c91
abhijeetanand163/Python-Basic
/distance.py
2,774
4.34375
4
import numpy as np class point: def __init__(self, x, y): self.x = x self.y = y class distance(): """ This class contains three different function. 1. Rooks Distance 2. Pandemic Distance 3. Levenshtein Distance """ # 1. Rooks Distance...
true
983505065449a5c2dec5f57c6801aa2ef81cf868
Patrick-Ali/210CT-Programming-Algorithms-Data-Structures
/FinalPrograms/vowelsRecursive.py
885
4.125
4
def check(letter, vowel, count, size): #apple = "This letter is not a vowel" #print(letter) if(count >= size): #print("Count is %d" % count) #print("Hit") return (True) #print("Vowel is: %s" % vowel[count].upper()) if letter == vowel[count] or letter == vowel[count].upper(): ...
true
b26e7f0eb0e4c5b815dfa10022181c3aaa960598
coffeblackpremium/exerciciosPythonBasico
/pythonProject/EstruturaSequenciais/exercicio005/exercicio005.py
205
4.125
4
""" 005)Faça um Programa que converta metros para centímetros. """ metros = float(input('Digite o metro para ser convertido: ')) centimetros = metros * 100 print(f'Esse valor em metros é {centimetros}')
false
a5aa2e1f468b4b4ea9c2ab8ce0957fb3df0c4076
coffeblackpremium/exerciciosPythonBasico
/pythonProject/EstruturaDecisao/exercicio004/exercicio004.py
445
4.1875
4
""" 004)Faça um Programa que verifique se uma letra digitada é vogal ou consoante. """ letra_digitada = input('Digite uma letra para Saber se é vogal ou consoante: ') if letra_digitada.lower() == 'a' or letra_digitada.lower() == 'o' or \ letra_digitada.lower() == 'e' or letra_digitada.lower() == 'i' or letra_d...
false
5643af118ca27ca7d44e48b4217ef85c9b716dd1
coffeblackpremium/exerciciosPythonBasico
/pythonProject/ExerciciosListas/exercicio008/exercicio008.py
401
4.28125
4
""" 008)Faça um Programa que peça a idade e a altura de 5 pessoas, armazene cada informação no seu respectivo vetor. Imprima a idade e a altura na ordem inversa a ordem lida. """ idade_pessoa = [int(input('Digite a sua idade: ')) for nova_idade in range(5)] altura_pessoa = [float(input('Digite a sua altura: ')) for nov...
false
561dd19b8f6fb46448a3287960701d2e844626d0
janina3/Python
/CS 1114/drawRectangle.py
769
4.125
4
import random def drawRectangle(numRows, numColumns): '''Draws a rectangle made up of random digits. Rectangle has length numColumns and height numRows.''' for i in range(numRows): #print string of random digits of length numColumns string = '' for j in range(numColumns): ...
true
7c8041228c70e42f69d00937eaac31e8c5f7a243
trivedimargiv9/My_codes
/Faulty Calc.py
505
4.1875
4
operater = input('Enter the operator: ') num1 = int(input('Enter number 1: ')) num2 = int(input('Enter number 2: ')) if operater == '+': if num1 == 56 and num2 == 9: print('77') else: print(num1+num2) elif operater == '-': print(num1 - num2) elif operater == '*': if n...
false
60f11118fcff0ed3e6258bcc99e4ab4e2d8dad00
Naif18/PythonCourse
/ForthWeek/twentieththree.py
356
4.1875
4
DayList= { "saturday" : 1 , "sunday" : 2, "monday" : 3, "tuesday" : 4, "wedneday" : 5, "Thersday" : 6, "friday":7 } if "friday" in DayList: print("Yes, it's Friday") #Dictionary Lengh print(len(DayList)) #Delete value DayList.pop("monday") print(DayList) #Delete the last value we ad...
true
725fc67e664fbc220885310e18742af8003c27c9
NickBarty/Python-Interactive-Kivy-Project
/song.py
1,433
4.5
4
class Song: """ Song class initialises the attributes every song will have, how they will be printed and the ability to mark a song as required or learned """ def __init__(self, title="", artist="", year=0, required=True): """ initialises the attributes songs will have with default ...
true
3dbed07c2a122a53888c11a18c4da3cf33232614
robertross04/TreeHacks
/keyphrase.py
545
4.28125
4
#Puts the key phrases from the text into a list def generate_keyphrase_list(key_phrases): key_phrases_list = [] for value in key_phrases.values(): for tmp in value: for key in tmp.values(): for phrases in key: if len(phrases) >= 3: #only want words 3 or la...
true
d9cbfc88e0d66835293a10568f4064d12cee136e
xiaolinangela/cracking-the-coding-interview-soln
/Ch10_SortingAndSearching/10.1-sortedmerge.py
586
4.25
4
def sorted_merge(nums1, m, nums2, n): index1 = m - 1 index2 = n - 1 index_merged = m + n - 1 while index2 >= 0: if index1 >= 0 and nums1[index1] > nums2[index2]: nums1[index_merged] = nums1[index1] index1 -= 1 else: nums1[index_merged] = nums2[index2] ...
false
228b5d62e0d5add16ee10e0704cd8ba74f874b7a
xiaolinangela/cracking-the-coding-interview-soln
/Ch2-LinkedLists/2.6-Palindrome.py
884
4.15625
4
from LinkedList import LinkedList from LinkedList import LinkedListNode def is_palindrome(l1_head): def reversed_list(node): head = None while node: n = LinkedListNode(node.val) n.next = head head = n node = node.next return head ...
false
dde6d541bbd7568b9cae9d504a506eb08949da5e
Mak-maak/Python-Fundamentals
/list taking a slice out of them.py
425
4.40625
4
#list: taking slice out of them cities = ["Atlanta", "Baltimore", "Chicago", "Denver", "Los Angeles", "Seattle"] #creating another list by taking a slice of cities smallerListOfCities = cities[2:5] # here we took elements from cities from index 2-5 # it slices the list from first element to 5th smaller_list_of_cit...
false
6113013b9935b8862a5298c340613568329f9080
coltonneil/IT-FDN-100
/Assignment 8/Banking.py
1,294
4.5625
5
#!/usr/bin/env python3 """ requires Python3 Script defines and creates a "bank account" which takes an initial balance and allows users to withdraw, deposit, check balance, and view transaction history. """ # define class Account class Account: # initialize account with balance as initial, create empty transact...
true
6a89874f05bb0c6f201b60f9d682fae6be3b07d5
coltonneil/IT-FDN-100
/Assignment 5/hw5.py
2,557
4.15625
4
import string """ This script reads in a file, parses the lines and creates a list of words from the lines Calculates the word frequency Gets the word with the maximum frequency Gets the minimum frequency and a list of words with that frequency Calculates the percentage of words that are unique in the file and prints ...
true
5dcb6b3a1ae292cd38048b560d0d4c7639aedffd
elliebui/technical_training_class_2020
/data_structures/week_2_assignments/list_without_duplicate.py
595
4.3125
4
""" Write a function that takes a list and returns a new list that contains all the elements of the first list minus all the duplicates. The order should remain the same. """ def get_list_without_duplicate(input_list): new_list = [] for item in input_list: if item not in new_list: new_list...
true
095a73e1207ffba761275a8d58aaa3e12111abf6
elliebui/technical_training_class_2020
/data_structures/arrays_and_linked_lists/strings/reverse_string.py
558
4.5625
5
def string_reverser(our_string): """ Reverse the input strings Args: our_string(string): String to be reversed Returns: string: The reversed strings """ return our_string[::-1] # Test Cases print("Pass" if ('retaw' == string_reverser('water')) else "Fail") print("Pass" if ('...
false
e73a0badae7a610694bae4ef619262523befcdae
Mapashi/Ejercicios-Python
/act_2.2.b.py
299
4.15625
4
'''1.2 Realizar un programa que sea capaz de convertir los grados centígrados em grados Farenheit y viceversa.ºF = 1,8 x ºC + 32''' #print("los grados en farenheit ", farenheit) print("Dime los farenheit") farenheit = float(input()) grado = (farenheit - 32) / 1.8 print("Los grados son ", grado)
false
0dc4b3eecae4758c29efe3ce551efde7ed93475c
vincentnti/vincent_sinclair_TE19C
/Programmering1/Mer Programmering/listor.py
890
4.21875
4
#Create list fruits = ["apple", "pear", "kiwi", "banana", "strawberry", "blueberry"] #Indexing and access operator print(fruits) print(fruits[0]) print(fruits[-1]) print(fruits[3]) print(fruits[::-1]) #Loop for fruit in fruits: print(fruit) #Create new lists greens = ["tomat", "gurka", "majs", "sallad"] fruktsal...
false
d5bce067160ae04d3f173217ac0d3e015e917da4
xushubo/learn-python
/learn46.py
2,004
4.34375
4
#枚举类型定义一个class类型,然后,每个常量都是class的一个唯一实例。Python提供了Enum类来实现这个功能: from enum import Enum, unique Month = Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'sep', 'Oct','Nov', 'Dec')) print(Month.Jan) print(Month.Jan.value) for name, member in Month.__members__.items(): print(name, '=>', member, ',', m...
false
89c5b83a6b8cb4bb8ccb405dbee0511cb1263baf
figengungor/Download-EmAll
/500px.py
816
4.15625
4
#Author: Figen Güngör #Year: 2013 #Python version: 2.7 ################ WHAT DOES THIS CODE DO? ############################## ####################################################################### ###############Download an image from 500px############################ ##############################################...
true
defeadae77a82c2f897efa0d84653ebe0f199d31
wassen1/dbwebb-python
/kmom10/prep/analyze_functions.py
978
4.1875
4
""" Functions for analyzing text """ # text = "manifesto.txt" def read_file(filename): """ Returns the file from given filename """ with open(filename) as fh: return fh.read() def number_of_vowels(filename): """ Calculate how many vowels a string contains """ content = read_file...
true
0fefdd08af95b8b6e671a8507102e34362e83c5c
Octaith/euler
/euler059.py
2,785
4.21875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Each character on a computer is assigned a unique code and the preferred standard is ASCII (American Standard Code for Information Interchange). For example, uppercase A = 65, asterisk (*) = 42, and lowercase k = 107. A modern encryption method is to take a text file, ...
true
012dc26cf8d7b28a0764bc4a3df1cda6c4f772f6
samullrich/crawl_project
/queueADT.py
478
4.125
4
class QueueADT: def __init__(self): self.container = [] self.the_queue = [] #self.visited = [starting_node] def push(self, value): # First item is at front of the list/index 0 self.container.append(value) def pop(self): return self.container.pop(0) # Ho...
true
5636c7334fc22f08ca1963d675e7d4a52b0fca15
Lucass96/Python-Faculdade
/Python-LP/aula06/VerificandoCaracteres.py
359
4.3125
4
s1 = 'Logica de Programacao e Algoritmos' s1.startswith('Logica') s1 = 'Logica de Programacao e Algoritmos' s1.endswith('Algoritmos') s1 = 'Logica de Programacao e Algoritmos' s1.endswith('algoritmos') s1 = 'Logica de Programacao e Algoritmos' s1.lower().endswith('algoritmos') s1 = 'Logica de Programacao e Algoritm...
false
37e893393b4b18703ea2849ee396910eb12950f1
GitError/python-lib
/Learn/Udemy/decorators.py
1,214
4.5625
5
""" Intro to decorators """ # decorator - adding additional functionality on the runtime # commonly used in web frameworks such as flask and django e.g. routing etc. # @ is used to declare decorators # returning a function from within a function def func(): print('upper function') def func2(): print...
true
01b99094424f74626070c04e754c0fc32430ceb7
kaiaiz/python3
/Python 4 高级特性(生成器,迭代器).py
1,985
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #如果列表元素可以按照某种算法推算出来, #那我们是否可以在循环的过程中不断推算出后续的元素呢? #这样就不必创建完整的list,从而节省大量的空间。 #在Python中,这种一边循环一边计算的机制,称为生成器:generator L = [x * x for x in range(10)] print(L) g = (x * x for x in range(10)) print(next(g)) print(next(g)) print(next(g)) print(next(g)) for n in g: print(...
false
0afbfb4deb70181e4ea434f63c3d4968fb3aa332
dikshit22/PathaPadha-Python-DS-P-1
/Assignment-3/1. Making String From String.py
543
4.40625
4
#Program to get a string made of the first 2 and the last 2 chars from a given #string. If the string length is less than 2, print 'empty string'. string = input("Enter a string:\t") if(len(string) >= 2): newstr = string[:2]+string[-2:] print("\tThe new string is:", newstr) else: print("\tEmpty strin...
true
a170005cece2a46858802ec6ecbef9c4e2fdf8e8
dikshit22/PathaPadha-Python-DS-P-1
/Assignment-4/1. Highest In List.py
311
4.40625
4
#Program to find the highest element in a list l = eval(input('Enter the list: ')) h = l[0] for i in l: if(i > h): h = i print('\tThe highest element in the list is:', h) ''' OUTPUT Enter the list: [1, 4, 2, 6, 3, 5, 9, 7, 8] The highest element in the list is: 9 '''
true
d689b639f06393b670f5b1e4b08bd0eeaa534efd
dikshit22/PathaPadha-Python-DS-P-1
/Assignment-3/2. Adding 'ing' Or 'ly'.py
670
4.5
4
#Program to add 'ing' at the end of a given string (length should be at least 3). #If the given string already ends with 'ing' then add 'ly' instead. If the #string length of the given string is less than 3, leave it unchanged.  string = input("Enter a string:\t") if(len(string) >= 3): if(string[-3:] != 'ing')...
true
8244082d74426f04bcd25d8f0013cf8d4f7a94fb
ramkishor-hosamane/Coding-Practice
/Optum Company/11.py
469
4.21875
4
''' In a given String return the most frequent vowel coming. ''' def most_frequent_vowel(string): string = string.lower() hashmap = {'a':0,'e':0,'i':0,"o":0,"u":0} for letter in string: if hashmap.get(letter)!=None: hashmap[letter]+=1 max_freq = 0 max_freq_vowel = None for letter in hashmap: if hashmap[l...
true
390cd4a7fe778a936274eea5cad6e0022a61c2a8
ramkishor-hosamane/Coding-Practice
/Optum Company/3.py
620
4.1875
4
''' 3. Find the middle element of the linked lists in a single pass (you can only traverse the list once). ''' class Node: def __init__(self,val=None): self.data = val self.next = None class Linked_List: def __init__(self): self.head = None def insert(self,val): cur = self.head if cur==None: self.he...
true
07c1e3fb46417cbc98eea6db5c3207c35aa3f6a4
FranklinA/CoursesAndSelfStudy
/PythonScript/PythonBasico/clases.py
1,216
4.125
4
#Los atributos describen las caracteristicas de los objetos, las clases es donde declaramos estos atributos,el atributo se utiliza segun las variables o tipos de datos que disponemos en python # Metodos son acciones/funciones # Constructor o inicializador para inicializar los objetos de una forma predeterminada que pod...
false
deac09987b6d4f6ea09c2806efdf36a55fc63729
rookiy/Leetcode
/SymmetricTree_3th.py
1,300
4.125
4
#!/usr/bin/env python # -*- coding:utf-8 -*- class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None # 使用迭代。分别访问对称的节点。 class Solution: # @param {TreeNode} root # @return {boolean} def isSymmetric(self, root): if not root: return...
true
c9f6c5e7e26087552034fe851306c1e43485d163
SabastianMugazambi/Word-Counter
/act_regex3.py
1,271
4.6875
5
# Regular expressions activity III # Learning about regex match iterators. import re def main(): poem = readShel() printRegexMatches(r'.\'.', poem) def readShel(): '''Reads the Shel Silverstein poem and returns a string.''' filename = 'poem.txt' f = open(filename,'r') poem = f.read() f.cl...
true
e1a8dba62fe06205d1dd1cfa8262c45d51449439
yuvrajschn15/Source
/Python/14-for_loop.py
341
4.65625
5
# to print from 1 to 20 we can use print statement for 20 times or use loops # range is used to define the range(kinda like limit) of the for loop print("this will print from 0 to 19") for i in range(20): print(i, end=" ") print("\n") print("this will print from 1 to 20") for j in range(20): print(j + 1, e...
true
7d00cae2fdac22e0ce5c78c67fcc7844cb608c32
vinayakgaur/Algorithm-Problems
/Split a String in Balanced Strings.py
784
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 18 10:32:00 2021 @author: VGaur """ #Balanced strings are those who have equal quantity of 'L' and 'R' characters. #Given a balanced string s split it in the maximum amount of balanced strings. #Return the maximum amount of splitted balanced stri...
true
280804ce0568b0e832b2ed3a530d475d2a919332
martvefun/I-m-Human
/CustomError.py
1,395
4.25
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- class Error(Exception): """Base class for exceptions""" pass class InputError(Error): """Exception raised for errors in the input. Attributes: expr -- input expression in which the error occurred msg -- explanation of the error """ ...
true
39f9d0b9f3d60ce8f55ccb09bfdaa58da9db8166
NileshNehete/Learning_Repo
/Python_Pro/Python_if-else.py
1,048
4.125
4
# Enter tree numbers and print the biggest and lowest number num1 = input("Enter First Number :") num2 = input("Enter Second Number :") num3 = input("Enter Third Number :") if (( num1 > num2 ) and ( num1 > num3 )): print ("First number %d is the biggest number" %num1) if ( num2 > num3 ): print ("Third...
true
b88a5762d830799a96266825de4ebabb7ab2ec65
arensdj/snakes-cafe
/snakes_cafe.py
2,198
4.40625
4
# data structures containing lists of the various menu items and customer name appetizers = ['Wings', 'Cookies', 'Spring Rolls'] entrees = ['Salmon', 'Steak', 'Meat Tornado', 'A Literal Garden'] desserts = ['Ice Cream', 'Cake', 'Pie'] drinks = ['Coffee', 'Tea', 'Unicorn Tears'] customer_name = input("Please enter your...
true
310bf320e2e333e36cda462a8d4dbbd38faf8fe5
bragon9/leetcode
/21MergeTwoSortedListsRecursive.py
1,252
4.125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: if not(l1) and not(l2): return None if not(l1): return l2 ...
true
fb42140b29d698b9c5fee762211ecc934c25be7c
luiz-alt/Python-LP2-git
/Questao_4_aula_4.py
598
4.125
4
''' Quest ̃ao 4: Crie um programa que leia o nome de 5 pessoas e os armazena em uma lista. Em seguida, construa uma fun ̧c ̃ao que recebe como parˆametros essa lista e uma posi ̧c ̃ao ( ́ındice da lista) e devolve o nome contido naquela posi ̧c ̃ao. B Essa fun ̧c ̃ao deve gerar uma exce ̧c ̃ao do tipo IndexError caso o...
false
185f85d5d9a23e9b2eaa2e03f1069e0884823f30
leonhostetler/undergrad-projects
/numerical-analysis/12_matrices_advanced/givens_rotation_matrix.py
1,251
4.21875
4
#! /usr/bin/env python """ Use Givens rotation matrices to selectively zero out the elements of a matrix. Leon Hostetler, Mar. 2017 USAGE: python givens-rotation-matrix.py """ from __future__ import division, print_function import numpy as np n = 3 # Size of matrix A = np.array([(1, 2, 0), (1, 1, 1...
true
f7f22d37ce06b19e8c501540460a956c402d53c4
leonhostetler/undergrad-projects
/computational-physics/04_visual_python/newtons_cradle_damped.py
1,612
4.40625
4
#! /usr/bin/env python """ Shows an animation of a two-pendulum newton's cradle. This program shows only the spheres--think of the pendulum rods as being invisible. Additionally, this program features a damping parameter mu = 0.11 such that the motion decays to zero in approximately 12 collisions. Leon Hostetler, Feb...
true
3cf2c99c7e05ef76b41823e28b68c940753cd1fe
leonhostetler/undergrad-projects
/computational-physics/11_classes/rectangles.py
1,370
4.59375
5
#! /usr/bin/env python """ Defines a Rectangle class with two member variables length and width. Various member functions, such as area and perimeter, are defined, and the addition operator is overloaded to define rectangle addition. Leon Hostetler, Mar. 30, 2017 USAGE: python rectangles.py """ from __future__ impor...
true
226bd859ee5daa32acaec0afe3d6de4539c708e4
leonhostetler/undergrad-projects
/computational-physics/09_integration_modular/hypersphere_volume.py
1,233
4.46875
4
#! /usr/bin/env python """ Compute the volume of an n-dimensional hypersphere using the Monte Carlo mean-value method. The volume is computed for hyperspheres with dimensions from 0 to 12 and plotted. Leon Hostetler, Mar. 7, 2017 USAGE: python hypersphere_volume.py """ from __future__ import division, print_functio...
true
d9b906bd062339dcbf45944dc6c5f6f7f3c3e033
leonhostetler/undergrad-projects
/computational-physics/03_plotting/polar_plot.py
659
4.15625
4
#! /usr/bin/env python """ Plot a polar function by converting to cartesian coordinates. Leon Hostetler, Feb. 3, 2017 USAGE: polar_plot.py """ from __future__ import division, print_function import numpy as np import matplotlib.pyplot as plt # Main body of program theta = np.linspace(0, 10*np.pi, 1000) # The valu...
true
d6be4afe4ab27720853d615d1b0cc2578e753704
jazzlor/LPTHW
/ex4.py
685
4.15625
4
name = 'Jazzy' age = 36 # not a like height = 54 # inches weight = 200 # lbs eyes = 'Blue' teeth = 'White' hair = 'Brown' cm = 2.54 #single cm kg = 0.453592 #singl kg print(f"Let's talk about {name}.") print(f"She's {height} inches tall") print(f"She's {weight} pounds heavy") print(f"Actually that's not too heavy.") ...
true
6faaf0768daada7527f0b0f31abbb7cfa2e8c6f2
d3m0n4l3x/python
/file_io.txt
876
4.21875
4
#!/usr/bin/python #https://www.tutorialspoint.com/python/file_methods.htm #Open a file fo = open("foo.txt", "r+") print "Name of the file: ", fo.name print "Closed or not : ", fo.closed print "Opening mode : ", fo.mode print "Softspace flag : ", fo.softspace ''' Name of the file: foo.txt Closed or not : False Openin...
true
67b837859fd7ab86aa4d246840a207daa326d535
kpbochenek/algorithms
/codingame/easy/skynet-the-chasm.py
514
4.125
4
R = int(input()) # the length of the road before the gap. G = int(input()) # the length of the gap. L = int(input()) # the length of the landing platform. while 1: S = int(input()) # the motorbike's speed. X = int(input()) # the position on the road of the motorbike. if X < R - 1: if G > S - ...
false
07fb525464c530a2d0c4e9a16560e2dc0ab98e29
Amenable-C/software-specialLectureForPython
/ch005.py
202
4.1875
4
num1 = int(input("What is the first number?")) num2 = int(input("What is the second number?")) num3 = int(input("What is the third number?")) answer = (num1 + num2) * num3 print("The answer is", answer)
true
1247bf7c34fc646e011f35d599dc229427980cc2
brianramaswami/NLP
/PROJECT2/proj2.py
2,586
4.375
4
#Brian Ramaswami #bramaswami@zagmail.gonzaga.edu #CPSC475 #Project2 types of substring searches. ''' GO TO MAIN AND SELECT WHICH PROGRAM TO RUN ''' import sys ''' HELPER FUNCTIONS ''' def readInFile(fileName): f = open(fileName, "r") print(f.read()) ''' OPENS FILE TO READ IN CONTENT ''' def my_open(): pri...
true
79c841fcf7f088f02b1f148fb500f1164049623f
Cenibee/PYALG
/python/fromBook/chapter6/sort/bubble.py
271
4.125
4
from typing import List def bubble_sort(arr: List[int]): for i in range(0, len(arr) - 1): for j in range(1, len(arr)): if arr[j - 1] > arr[j]: arr[j - 1], arr[j] = arr[j], arr[j-1] a = [6,4,2,1,7,8,3,9,0,5] bubble_sort(a) print(a)
false
c290eac1e0eb4f0aeb77ebeb2cbc8857bfdae226
becerra2906/jetbrains_academy
/airmile/air_mile_calculator.py
1,901
4.625
5
### By: Alejandro Becerra #done as part of Jet Brains Academy Python learning Path #serves to calculate the number of months required to pay for a #flight with miles generated with customer credit card purchases. #print welcome message print("""Hi! Welcome to your credit card miles calculator. This program will he...
true
ad46457d7f8e3837cb3628d0d703376a34208dd9
rcmoura/aulas
/prg_inverso_absoluto.py
215
4.125
4
# programa inverso absoluto numero = float(input("Digite um numero: ")) if numero > 0: inverso = 1 / numero; print ("Inverso: ", inverso) else: absoluto = numero * -1 print ("Absoluto: ", absoluto)
false
9e914e1d5f56cd6079bad7b3f3c5cbdb148778f9
team31153/test-repo
/Aaryan/Chapter5HW/C5Problem2.py
597
4.15625
4
#!/usr/bin/env python3 def daysOfTheWeek(x): if x == 0: return("Sunday") elif x == 1: return("Monday") elif x == 2: return("Tuesday") elif x == 3: return("Wednesday") elif x == 4: return("Thursday") elif x == 5: return("Friday") elif x == 6: return("Saturday") e...
true
373a78cc034227556576c08d4af934dde44ea391
team31153/test-repo
/Ryan/RyanChapter5HW/10findHypot.py
312
4.125
4
#!/usr/bin/env python3 firstLength = int(input("Enter the length for the first side: ")) secondLength = int(input("Enter the length for the second side: ")) hypot = 0 def findHypo(f, s, h): f2 = f * f s2 = s * s h = f2 + s2 h = h ** 0.5 print(h) findHypo(firstLength, secondLength, hypot)
true
e86b9c57eb5c8577ca8fe42015584dbb9bdef94a
leemiracle/use-python
/taste_python/cook_book/files_io.py
855
4.75
5
# 1. Reading and Writing Text Data # 2. Printing to a File # 3. Printing with a Different Separator or Line Ending # 4. Reading and Writing Binary Data # 5. Writing to a File That Doesn’t Already Exist # 6. Performing I/O Operations on a String # 7. Reading and Writing Compressed Datafiles # 8. Iterating Over Fixed-Siz...
true
9873594ba403b3dea2f0dd65ddbb289e6c5f5ddb
sedychl2/sr-4-5-6-2
/инд задание в питоне.py
441
4.15625
4
V = 3 A = 1 R = 1 H = 2 if V <= A**3 and V <= 3.14 * R**2 * H: print("Жидкость может заполнить обе ёмкости") elif V <= A**3: print("Жидкость может заполнить первую ёмкость") elif V <= 3.14 * R**2 * H: print("Жидкость может заполнить вторую ёмкость") else: print("Слишком большой объём жидкости")
false
ccf258949439b444ead45f58513ba3e91e60b19d
fiolisyafa/CS_ITP
/01-Lists/3.8_SeeingTheWorld.py
477
4.15625
4
places = ["London", "NYC", "Russia", "Japan", "HongKong"] print(places) #temporary alphabetical order print(sorted(places)) print(places) #temporary reverse alphabetical order rev = sorted(places) rev.reverse() print(rev) print(places) #permanently reversed places.reverse() print(places) #back to original places.reve...
true
8c03b0bc52759815166152c93555c912f05482ca
fiolisyafa/CS_ITP
/03-Dictionaries/6.11_Cities.py
733
4.1875
4
cities = { "Canberra": { "country": "Australia", "population": "6573", "fact": "Capital city but nothing interesting happens." }, "London": { "country": "England", "population": "5673", "fact": "Harry Potter grew up here." }, "Jakarta": { ...
true
79268b3094c685df6c9471c733c92f4ac1a059bb
Br111t/pythonIntro
/pythonStrings.py
2,022
4.65625
5
string_1 = "Data Science is future!" string_2 = "Everybody can learn programming!" string_3 = "You will learn how to program with Python" #Do not change code above this line # #prints the length of the string including spaces # print(len(string_2)) # #Output: 32 # #print the index of the first 'o'; the ind...
true
a953212a542bde4920cd0361dc18769538bb4bfb
sridivyapemmaka/PhythonTasks
/dictionaries.py
419
4.15625
4
#dictonaries methods() #clear() "removes all the elements from the list" list1={1:"sri",2:"java",3:"python"} list2=list1.clear() print(list1) output={} #copy() "returns a copy of the list" list1={1,2,3,4} list2=list1.copy() print(list2) output={1,2,3,4} #get() "returns the values of the specified li...
true
bd2aa8788af65e20d7b261860e66a02635de5ff8
zssvaidar/code_py_book_data_structures_and_algo
/chap03_recursion/reverse_list_another_way.py
568
4.21875
4
from typing import List IntList = List[int] def reverse_list(l: IntList) -> IntList: """Reverse a list without making the list physically smaller.""" def reverse_list_helper(index: int): if index == -1: return [] rest_rev: IntList = reverse_list_helper(index - 1) first: ...
true
ecbfb19bb09dd71d1a832dbbf71553cf306cacdd
zssvaidar/code_py_book_data_structures_and_algo
/chap04_sequences/stack.py
1,123
4.21875
4
class Stack: """ Last in, first out. Stack operations: - push push the item on the stack O(1) - pop returns the top item and removes it O(1) - top returns the top item O(1) """ def __init__(self): self.items = [] ...
true
d712835020e89a2909bfaf1c6d8c01be181be89a
Marcus893/algos-collection
/cracking_the_coding_interview/8.1.py
390
4.15625
4
Triple Step: A child is running up a staircase with n steps and can hop either 1 step, 2 steps, or 3 steps at a time. Implement a method to count how many possible ways the child can run up the stairs. def triple_step(n): lst = [0] * (n+1) lst[0] = 1 lst[1] = 1 lst[2] = 2 for i in range(3, n+1):...
true
06c573fce10ea205d810c7d62e86681a29554d7f
Marcus893/algos-collection
/cracking_the_coding_interview/4.6.py
737
4.15625
4
Successor: Write an algorithm to find the "next" node (i.e., in-order successor) of a given node in a binary search tree. You may assume that each node has a link to its parent. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None self.parent = None...
true
8ed0786f818d82c26edc14d46b405b7c602fafc2
Marcus893/algos-collection
/cracking_the_coding_interview/2.4.py
1,080
4.34375
4
Partition: Write code to partition a linked list around a value x, such that all nodes less than x come before all nodes greater than or equal to x . lf x is contained within the list, the values of x only need to be after the elements less than x (see below) . The partition element x can appear anywhere in the "right ...
true
2c00d4fb1a570e9d053eb1e9283ecea2c343e48b
Marcus893/algos-collection
/cracking_the_coding_interview/3.5.py
505
4.125
4
Sort Stack: Write a program to sort a stack such that the smallest items are on the top. You can use an additional temporary stack, but you may not copy the elements into any other data structure (such as an array). The stack supports the following operations: push, pop, peek, and isEmpty. def sortStack(stack): re...
true
023986d7eda3cad02f6a783dd88764eb1a939cf6
s3icc0/Tutorials
/DBTut/Lesson 009 Object Oriented Programming/pytut_009_001.py
1,178
4.34375
4
# OBJECT ORIENTED PROGRAMMING """ Real World Objects : Attribute & Capabilities DOG Attributes (Fields / Variables) : Height, Weight, Favorite Food Capabilities (Methods / Functions): Run, Walk, Eat """ # Object is created for a template called Class # Classes defines Attributes and Capabilities of an Object class...
true
fd7a49e1c672cf48f42228ebf83969de974dbf4c
s3icc0/Tutorials
/DBTut/Lesson 006 Lists/pytut_006_exe_002.py
1,413
4.375
4
# GENERATE THE MULTIPLICATION TABLE # With 2 for loops fill the cells in a multidimensional list with a # multiplication table using values 1-9 ''' This should be the result: 1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 3, 6, 9, 12, 15, 18, 21, 24, 27, 4, 8, 12, 16, 20, 24, 28, 32, 36, 5, 10, 15, 20, 25...
true
9ea520cffdffe7d5a3e69cce58048b6b8a51cbe5
s3icc0/Tutorials
/DBTut/Lesson 008 Reading Writing Files/pytut_008_001.py
1,488
4.40625
4
# READING AND WRITING TEXT TO A FILE # os module help to manipulate files import os # with helps to properly close the file in case of crash # locate the file # mode='w' will override anything already in the file # mode='a' will enable appending to the file only # UTF-8 store text using Unicode # define where to st...
true
7cbb06c3818d3343558ff13e08f4c98825bdb943
s3icc0/Tutorials
/DBTut/Lesson 001 Learn to Program/pytut_001_exe_002.py
871
4.21875
4
# If age is 5 Go to Kindergarten # Ages 6 through 17 goes to grades 1 through 12 # If age is greater then 17 say go to college # Try to complete with 10 or less lines # Input age # Convert age to Integer age = eval(input('Enter age: ')) # Evaluate age and print correct result if age == 5: print('Go to Kindergarte...
true
fe8fa2c1030929f662e9ed24224999a7c1919053
s3icc0/Tutorials
/DBTut/Lesson 009 Object Oriented Programming/pytut_009_002.py
1,542
4.125
4
# GETTERS and SETTERS # protects our objects from assigning bad fields and values # provides improved output class Square: def __init__(self, height='0', width='0'): self.height = height self.width = width # Getter - property will allow us to access the fields internally @property d...
true
301028f45991ec452118fb86b9c4f0fb8c42f2fc
s3icc0/Tutorials
/Sebastiaan Mathôd Tutorial/001 Enumerate.py
452
4.1875
4
# ------------------------------------------------------------------------------ # WALK THROUGH THE LIST citties = ['Marseille', 'Amsterdam', 'New York', 'London'] """ # The bad way i = 0 # create counter variable for city in citties: print(i, city) i += 1 """ # The good way - Pythonic way # enumerate retu...
true
24fb622a60d869b5bfdc639dec4c0de71826dd1c
s3icc0/Tutorials
/Corey Schafer Tutorial/OOP 2 Class Variables.py
1,209
4.15625
4
""" Python Object-Oriented Programming https://www.youtube.com/watch?v=ZDa-Z5JzLYM """ class Employee: num_of_emps = 0 raise_amount = 1.04 # class variable def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = first + '.' + ...
true
70c317bf1feded53134e4df778b22ce1aa0ec127
lundergust/basic
/intro/basic_calulator.py
225
4.34375
4
num1 = input("enter a number") num2 = input("enter another number") # float allows us to read as decimals. For some reason it is not needed # although the tutorial says it is result = float(num1) + float(num2) print(result)
true
c5d6e949aebb669ffa1ef835817c829bc65b76ad
sami-mai/examples
/conditional-flow.py
798
4.28125
4
#example 1 # name ="Bertha" # female = "Bertha" # if name == female: # print "welcome" # else: # print "NO" # #example 2 # name ="Bertha" # female = "Alex" # if name == female: # print "welcome" # else: # print "NO" #example 3 # name = raw_input("what is your favourite car?") # if name == "Range Rover": #...
false
c83b32a848d04303ae3ee36696623f7fb12f73b9
Dzhano/Python-projects
/nested_loops/train_the_trainers.py
452
4.21875
4
n = int(input()) total_average_grade = 0 grades = 0 presentation = input() while presentation != "Finish": average_grade = 0 for i in range(n): grade = float(input()) average_grade += grade total_average_grade += grade grades += 1 print(f"{presentation} - {(average_grade / n)...
true
bb3fda8131f7ab620bd3e00f66286c13bf8d9b1b
SarthakSingh2010/PythonProgramming
/basics/MapFuncAndLamdaExp.py
999
4.4375
4
# Python program to demonstrate working # of map. # Return double of n def addition(n): return n + n # We double all numbers using map() numbers = (1, 2, 3, 4) result = map(addition, numbers) print(list(result)) # Double all numbers using map and lambda numbers = (1, 2, 3, 4) result = map(lambda ...
true
b326edc311b92b85f80ce03bc646a67db167ccc5
Cationiz3r/C4T-Summer
/Session-6 [Absent]/dictionary/lookUp.py
426
4.21875
4
colors = { "RED": "Hex: #FF0000", "GREEN": "Hex: #00FF00", "BLUE": "Hex: #0000FF", "MAGENTA": "Hex: #FF00FF", "CYAN": "Hex: 00FFFF", "YELLOW": "Hex: FFFF00", "ORANGE": "Hex: FF8000", } while True: print() color = input(" Input color: ") if color.upper() in colors: ...
false
146ccde11f165c54bfed745d5109f9f4dbd764f4
IrakliDevelop/python-small-projects
/generateAlphabetDictionary.py
323
4.21875
4
''' the purpose of this program is to generate for you sequence that you can use to create dictionary of alphabetical characters with numeric values of place in alphabet assigned to them ''' char = 'a' i = 1 while char <="z": print("\"" + char + "\" : " + str(i) + ", ", end="") char = chr(ord(char)+1) i +=...
true
1e57af8593237c7663f6c6d7318ba3e58be8a3b9
Zzechen/LearnPython2.7
/container/list_tuple.py
1,091
4.21875
4
# -*- coding:utf-8 -*- # list:一种有序的集合,使用 [] 声明 # 创建一个list classmates = ['A','B','C'] print classmates # 获取长度 print len(classmates) # 根据下标获取元素 正向从0开始 print classmates[1] # 使用负数获取倒数第几个,反向从-1开始 print classmates[-1] # 遍历 for item in classmates: print item # 追加 classmates.append('D') print len(classmates) # 插入 cla...
false
6c8a3860e9ff8dddccffd99b44aaad48524badca
gurpreet00793/jarvis
/string part 2.py
561
4.15625
4
my_string ='hello' print(my_string) my_string="hello" print(my_string) my_string='''hello''' print(my_string) #triple quotes string can be extend multiple lines my_string="""hello,welcome to the world of python""" print(my_string) b="welcometopython" print('b[9:15]=',b[9:15]) b="welcometopython" ...
false
a106f67cd4e5b01ded6754d9c19f869ecc16e572
gurpreet00793/jarvis
/input.py
591
4.125
4
"""math=input("enter your maths") physics=input("enter your physics") chemistry=input("enter your chemistry") val=int(math)+int(physics) print(val)""" name=input("enter name") math=input("enter marks") physics=input("enter marks") chemistry=input("enter marks") english=input("enter marks") val=(((int(math)+int(physi...
false
d28d3be648383b7b2ded438ef25814c31c3a96f5
manjupoo/manjureddy
/max3fun.py
226
4.28125
4
def max(m,n,o): if m>n and n>o: print(m,"is larger then n") elif n>o and o>m: print(n,"is larger then o") else: print(o,"is larger then m and n") print ("enter three values") m=input() n=input() o=input() max(m,n,o)
false
ea2b440a310eead72ebb03def89eeff21b4c60da
afrokoder/csv-merge
/loops.py
393
4.15625
4
outer_loop = 1 while outer_loop < 10: inner_loop = 1 while inner_loop < outer_loop + 1: print (outer_loop, end="") inner_loop = inner_loop + 1 print() outer_loop = outer_loop + 1 #outer_loop = 10 for outer_loop in range (9,0,-1): for inner_loop in range (9,0,-1): if inn...
true
50b22625006adb5db8fc1c57eaa3d0cc6fa97848
afrokoder/csv-merge
/food_list_exercise.py
607
4.25
4
#creating a list of food items for each day of the week mon_menu = ["white_rice", "stir_fry", "sesame_chicken", "beef", "fried_rice"] tue_menu = ["bread", "stir_fry", "sesame_chicken", "beef", "fried_rice", "potatoes"] user_selection = input("Enter Your Order: ") user_selection = user_selection.lower() #for x in m...
true
64e5a24e7b43691b706769be21a938f9db548197
smallest-cock/python3-practice-projects
/End-of-chapter challenges in ATBS/Chapter 03 – Functions/Collatz sequence.py
1,447
4.40625
4
def collatz(number): try: while number != 1: if number % 2 == 0: print(number // 2) number = number // 2 elif number % 2 == 1: print(number * 3 + 1) number = number * 3 + 1 except ValueError: print("Error: Th...
true
abe9db15437d1d72d1b33b6690ebf34c456fc72e
smallest-cock/python3-practice-projects
/End-of-chapter challenges in ATBS/Chapter 08 – Reading and Writing Files/RegexSearch.py
1,921
4.46875
4
#! /usr/bin/python3 # RegexSearch.py - Searches all text files in a given folder using a (user supplied) # regex, and prints the lines with matched regex on the screen import re, os, sys # creates regex object to be used to find text files regexTxt = re.compile(r'.txt$') # checks to see if 2nd argument is a director...
true
651bf3c14990ee438469cc56377f0ea7df00c605
filhomarlon/python
/exercicio-1.py
608
4.125
4
""" Escreva um Programa que imprime dois numeros de sua escolha e que depois imprime a soma, a subtração, a multiplicação, a divisão normal e a divisão inteira, e o resto da divisão do maior pelo menor (coloque na mensagem a palavra resto ao invez do símbolo %) EXEMPLO DE SAÍDA: >>> x = 15 y = 10 15 + 10 ...
false
0b241218404ab2aecf9090d2a939f5ad3de1af91
hcarvente/jtc_class_code
/class_scripts/bootcamp_scripts/nested_data_practice.py
2,164
4.34375
4
# lists inside lists shopping_list = [['mangos', 'apples', 'oranges'], ['carrots,', 'broccoli','lettuce'], ['corn flakes', 'oatmeal']] # print(shopping_list) #access an inner list # print(shopping_list[1]) # ONE MORE LEVEL DOWN # access an ITEM inside an inner list # print(shopping_list[1][0]) shopping_list[1].appe...
true
aedccc4e66cd18e351eccae9fa706c61405dd998
hcarvente/jtc_class_code
/class_scripts/bootcamp_scripts/functions_practice.py
2,300
4.34375
4
#RUNNING EXISTING FUNCTIONS # print is a function # print('hi') # # name of the function comes first, followed by parentheses # # what is inside the parenthese is called 'parameters' or 'argument' # print(int(2.0)) # CREATING A FUNCTION # DEFININF a function def say_hello(): #anything inside as part of the function ...
true
a75e26f1173c782f29c254c092cf40a446154a5c
TrueNought/AdventOfCode2020
/Day3/Day3.py
907
4.125
4
def count_trees(route, right, down): total_trees = 0 index = 0 index_length = len(route[0]) - 1 height = 0 while height < len(route): if route[height][index] == '#': total_trees += 1 index += right height += down if index > index_length: ind...
true
d295238e7d3b549ff31956008f2620fcec5529ba
GiTJiMz/Advanced-programming
/10-09-2020/W37/greeter.py
415
4.15625
4
#!/usr/bin/env python3 import random def simple_greeting(name): return "hello! " + name def time_greeting(name): from datetime import datetime return f"It's {datetime.now()}, {name}" greetings = [ simple_greeting , time_greeting ] greeting = random.choice(greetings) print(greet...
true
f4225c3e3ae3588dbfaa7ab8b0ebb0bb555dbf67
idzia/Advent_of_code
/day_6/day_6.py
1,860
4.4375
4
""" How many redistribution cycles must be completed, to repeat the value For example, imagine a scenario with only four memory banks: The banks start with 0, 2, 7, and 0 blocks. The third bank has the most blocks, so it is chosen for redistribution. Starting with the next bank (the fourth bank) and then continuing ...
true
12d273ecfd2c3b7603d23ab272905f8108af167b
dovewing123/LehighHacksFall2016
/scientist.py
2,315
4.15625
4
__author__ = 'Alexandra' def scientist(scientistCount): if scientistCount == 0: #print("\"Oh no! The parade is going to be ruined! It's supposed to go by the river, but ", #"the river is a mess!\"") input("\"Oh no! The parade is going to be ruined! I'm supposed to make the float...
true
40268822e0159f88ca821c98b72d4318f06c38ef
L0ganhowlett/Python_workbook-Ben_Stephenson
/25 Units of Time ( Again).py
402
4.15625
4
#Units of Time (Again) #asjking the number of seconds. s = float(input("Enter the number ofseconds = ")) #Assigning d for days, h fro hours, m for minutes, s for seconds. d = int(s // (24 * 60 * 60 )) s = (s % ( 24 * 60 * 60 )) h = int(s // (60 * 60)) s = s % ( 60 * 60) m = int(s // 60) s = int(s % 60) print...
false
b70c555b5db3fb86ec842b042ed7439978d0f55b
L0ganhowlett/Python_workbook-Ben_Stephenson
/47 Birth date to Astrological; Sign.py
1,459
4.34375
4
#47 Birth Date to Astrological Sign #Asking user to input day of birth and month. x = int(input("Day of birth : ")) y = input("Enter the name of birth month : ") if y == "January": if x <= 19: z = "Capricorn" elif 19 < x <= 31: z = "Aquarius" if y == "February": if x <= 18: ...
false