blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
e82894a863e7bc24cd1a17432b99630d9cfc604c
Oboze1/UCI_homework
/04-Python2/create_notes_drs.py
1,446
4.25
4
import os #imports os #defines the function main to create the folder directory system def main(): # #checks to see if the 'CyberSecurity-Notes' directory already exits # if os.path.isdir("CyberSecurity-Notes") == False: #uses 'os.mkdir' to make a directory 'CyberSecurity-Notes' # ...
true
7b39b19ccd500ec83103a1e07e89e55b108079df
timtingwei/prac
/py/corePy/13.1_object_intrudce.py
2,251
4.15625
4
#13.1_object_intrudce.py #/// instance and class class MyData(object): """" def __init__(self): self.x = 10 self.y = 20 """ pass mathObj = MyData() mathObj.x = 4 #/// x是实例特有的属性,不是类的属性,是动态的 mathObj.y = 5 print (mathObj.x + mathObj.y) #9 print (mathObj.x * mathObj.y) #20 #/// method cla...
false
55d6f682df04071d77456fefaa8e89e00e6eede9
SpartaKushK/First
/coin_flip_simulator.py
816
4.1875
4
''' #Coin Flip Simulation - Write some code that simulates flipping a single coin however many times the user decides. # The code should record the outcomes and count the number of tails and heads. ''' import random def flip_coin(): flip_results = [] total_heads = 0 total_tails = 0 num_of_flips = int(i...
true
26041107893579444099238b735b5a2f59f550fa
Garric81/Python
/old_files/lessons2.py
817
4.125
4
#speed = int(input()) print("Система расчёта штрафов") car_speed = 85 is_town = True fine_for_20_to_40 = 500 fine_for_40_to_60 = 1000 fine_for_60_to_80 = 2000 fine_for_80_and_more = 5000 town_speed = 60 country_speed = 90 if is_town: over_speed = car_speed - town_speed else: over_speed = car_speed - country_speed ...
false
322ea317e128b82eb03ffb98a1501a7b0ddbbd4c
payalbhatia/Machine_Learning
/*Python_Basics/Command_Line_Argument/command_line_argument.py
478
4.125
4
import sys # check if it has any arguments print() arg_num = len(sys.argv) if arg_num == 1: print('there are no arguments') elif arg_num > 1: # subtract 1 because one of the arguments is the file name print('there are %d arguments ' % (arg_num-1)) print(sys.argv) print('first argument is:', sys.argv[1]) ...
true
d851d6a26beedfdd9217f92a9d31052d8bcd02e8
Travis-ugo/pythonTutorial
/Class.py
801
4.3125
4
# A Class in python is like an object constuctor or a blueprint for creating object. # all classes have function called __init__(), which always executes when the class # is being initiated. # use the __init__() function to assign values to object properties, or other operationns # that are nessesary to do when th obj...
true
e51665d1d889fc309ec96cb7a3357dcdc6b27f90
devesh37/HackerRankProblems
/Datastructure_HackerRank/Linked List/MergeTwoSortedLlinkedLists.py
1,620
4.1875
4
#!/bin/python3 #Problem Link: https://www.hackerrank.com/challenges/merge-two-sorted-linked-lists/problem import math import os import random import re import sys class SinglyLinkedListNode: def __init__(self, node_data): self.data = node_data self.next = None class SinglyLinkedList: def __ini...
true
5cb576a8f9e9891f8046e0f8e0f188f5d98241bd
zepedac6581/cti110
/P3WH1_ColorMixer_Zepeda.py
1,563
4.34375
4
# A program that allows users to input primary colors as a mix and ouputs # a secondary color. # CTI-110-0003 # P3HW1 - Color Mixer # Clayton Zepeda # 2-14-2019 # def main(): # User inputs two primary colors # Primary colors are red, blue and yellow. print("The primary colors are red, blue, and yellow...
true
182bb72bf884e6f1678e7fcf5f408c7b521a1900
alvinwang922/Data-Structures-and-Algorithms
/Strings/Compare-Version-Numbers.py
1,904
4.125
4
""" Given two version numbers, version1 and version2, compare them. Version numbers consist of one or more revisions joined by a dot '.'. Each revision consists of digits and may contain leading zeros. Every revision contains at least one character. Revisions are 0-indexed from left to right, with the leftmost revi...
true
3adb0122c6c2190389ffa9c91e2e3013f08310fa
alvinwang922/Data-Structures-and-Algorithms
/Trees/Tree-To-LinkedList.py
1,529
4.21875
4
""" Convert a Binary Search Tree to a sorted Circular Doubly-Linked List in place. You can think of the left and right pointers as synonymous to the predecessor and successor pointers in a doubly-linked list. For a circular doubly linked list, the predecessor of the first element is the last element, and the succes...
true
e9c31922276c7e2e860cd5716b72e9a7ff0a613b
alvinwang922/Data-Structures-and-Algorithms
/LinkedList/Odd-Even-LinkedList.py
1,001
4.125
4
""" Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity. """ # Definition for singly-...
true
63a2c6bd1837d4d68b58bb0b4e7d6767c9e6a6ab
alvinwang922/Data-Structures-and-Algorithms
/DFS/Reconstruct-Itinerary.py
1,476
4.375
4
""" Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the itinerary must begin with JFK. Note: If there are multiple valid itineraries, you should return the itinerary ...
true
760df47c1a3a8a7cdb8b3353e3ac4b2ff5f34f45
alvinwang922/Data-Structures-and-Algorithms
/Strings/ZigZag-Conversion.py
971
4.25
4
""" The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: P A H N A P L S I I G Y I R Write the code that will take a string and make this conversion given a number of rows """ class Solution: def convert(self, s: str, numRows: int) -> str: if numRows == ...
true
3d937fce84d5cb59a5424014b4d0a42942fb3661
alvinwang922/Data-Structures-and-Algorithms
/Matrices/Flood-Fill.py
1,521
4.21875
4
""" An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a coordinate (sr, sc) representing the starting pixel (row and column) of the flood fill, and a pixel value newColor, "flood fill" the image. To perform a "flood fill", consider the ...
true
3531a16c7b8ee9a8ed2ee798cbac3c2f49cc759e
I201821180/ALGO
/merge_sort.py
708
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Python implementation for merge sort, complexity O(NlogN) def merge(A, p, q, r): L = A[p: q+1] R = A[q+1: r+1] L.append(float('inf')) R.append(float('inf')) i, j = 0, 0 for k in range(p, r+1): if L[i] <= R[j]: A[k] = L[i] ...
false
7cbab018f0905dadf19ee3b27ede26839cb27aab
alltej/kb-python
/data_structures/tuples.py
782
4.65625
5
##TUPLES - A tuple is a one dimensional, fixed-length, immutable sequence. tup = (1, 2, 3) print(tup) #convert to tuple list_1 = [1,2,3] tup_1 = type(tuple(list_1)) #create a nested tuple nested_tup = ([1,2,3],(4,5)) print(nested_tup) print(nested_tup[0]) # Although tuples are immutable, their contents can conta...
true
1206dbd776ea188e499d301fcb655040e5d6d434
Jhon112/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
649
4.15625
4
#!/usr/bin/python3 """prints a text with 2 new lines after each of these characters: ., ? and :""" def text_indentation(text): """replace the characters ., ? and : for a 2 blank_lines Args: text (str): str that will be modified Returns: prints the new text Raises: TypeError:...
true
2e2d6a28de15808f95b8c848338905b202764ec9
Jhon112/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/tests/6-max_integer_test.py
1,350
4.375
4
#!/usr/bin/python3 """Test max_integer function""" import unittest max_integer = __import__('6-max_integer').max_integer class TestMaxInteger(unittest.TestCase): """class to test max_integer function No attributes are needed but different methods for differents test cases are. """ def test_empty_li...
true
e6e4a29ab2520be59425f9651c40d6e49866d720
ik2y/recode-beginner-python
/materials/week-4/src/solveTogether-bmi.py
649
4.28125
4
# The formula is BMI = weight(kg) / height (m) ^ 2 # - Underweight: < 18.5 # - Normal: 18.5 - 24.9 # - Overweight: 25 - 29.9 # - Obese: > 30 userWeight = input("Insert your weight in KG: ") userWeight = float(userWeight) userHeight = input("Insert your height in meters: ") userHeight = float(userHeight) bmiValue = u...
true
e01a7b6001470bf28970a96664e8a212033d22d6
ik2y/recode-beginner-python
/materials/week-7/src/takeHomeChallenge-wordCounter/app.py
1,101
4.15625
4
############################################################### # do not modify the code in here ############################## from helper.TxtReader import TxtReader import helper.Utility import clearScreen DATA_PATH = "text.txt" # load data txtReader = TxtReader(DATA_PATH) rawSentence = txtReader.load() # do not d...
true
57e5e4ff4c6ed09c3c4902bdd182b373c4686422
srisivan/python
/divisibility.py
396
4.3125
4
# To find divisible numbers for 3. divisors = [] my_num = int(input("Enter the desired number : ")) for i in range (1, (my_num + 1)): if my_num % i == 0: divisors.append(i) length = len(divisors) if length == 2: print("%s is a prime number" % my_num) else: print("%s is a composite number...
true
57b2759986521a7435beed8922aafc8a19b25f75
nikolaosmparoutis/Algorithms_and_Data_Structures_Python
/breadth_first_search.py
920
4.3125
4
# Implementation of breadth first search using queue. Add children then BFS the tree # from left to right. Input an empty array where the return from the BFS will fill it with the nodes. # T=O(V+E) traverse the nodes + for each node traverse its edges(children), # space O(V) class Node: def __init__(self, name): ...
true
1495c305585fd90afb2967e3a753e7bfd89e69d0
Stanislav144/python
/rekord.py
1,411
4.15625
4
# Programm record # scores = [] choice = None while choice != "0": try: print( """ 0- Exit 1- View record 2- Add record 3- Delete record 4- Sorted list """ ) choice = input('Enter position: ') print() # Exit if choice == '0': print("Good...
true
d9b99b09041ae56608107cf6993b6cc1665120ff
jc98924/Metis-Data-Science-Prework
/lessons/python_intro/calc_row_value.py
837
4.59375
5
#!/usr/bin/python import os import sys def calc_row_value(input_string): """ This function takes a string input, converts it to an integer value and then outputs a "new value". --- args: input_string(str): input string returns: calc_value (int): output value """ if type...
true
95cf841c5a27979c0b573a29f32dae17b6ddc562
olegpolivin/AlgorithmsSpecializationStanford
/01_Divide_and_Conquer/Week01/RecIntMult.py
1,214
4.34375
4
print('Welcome to exercise 1: Stanford Algorithms') print('Input: two n-digit positive integers x and y') print('Assumption: n is a power of 2') from math import ceil x = input('Enter first integer: ') y = input('Enter second integer: ') n = max(len(x), len(y)) n1, n2 = len(x), len(y) assert n1 % 2 == 0, 'Number of...
false
8fef04cee7bd39d7a23c2e9f74b5e741f424bf61
serre-lab/smart-playroom-kalpit
/kinectpath/source/utils/misc.py
1,385
4.21875
4
"""Miscellaneous helper functions required for calculations """ import numpy as np def calc_line_point_distance(line, point): """Function to calculate the distance of a point from a line Parameters ---------- line : list (x1, y1, z1, x2, y2, z2) - the endpoints of the line segment point :...
true
4e27bf1d7ec0a4f8d87c8f01e47577029413c4fe
mndimitrov92/Python3_deep_dive
/Functional_Closure_decorators/decorators_with_attributes.py
1,063
4.25
4
""" Decorators which can contain additional attributes that can be accessed. """ from functools import wraps def my_decorator(fn): my_var = {} @wraps(fn) def wrapper(*args, **kwargs): print("Decorating...") result = fn(*args, **kwargs) print("Finished") return result def my_helper_func(): print("Help ...
true
9e3a4323ce922225209ba8eb326ce434a9c6e77c
Somesh1501/Codes
/sort_method.py
229
4.3125
4
#sort method is used for sorting element in a list #sorted function animals = ['dog','fox','cow','cat'] animals.sort(reverse = True) print(animals) ''' print(sorted(animals)) x=(sorted(animals)) x.reverse() print(x)'''
true
e5701d4e69fba20f6478ec1ab94a57e567d2a82d
peninah-odhiambo/andela-day4
/missing_number.py
401
4.125
4
def find_missing (list1, list2): """ The lists represent two different lists""" # list1 = set (list1) # list2 = set (list2) if len(list1) > len(list2): for number in list1: if number not in list2: return number else: for number in list2: if number not in list1: return number """set gets rids of...
true
072c2b2b60dc5e4e056742228f14a85902a2b83e
ninarobbins/astr-119-session-2
/dictionaries.py
376
4.125
4
# dictionaries have key:value for elements example_dict = { 'class' : 'Astr 119', 'prof' : 'Brant', 'awesomeness' : 10 } print(type(example_dict)) #get value with key course = example_dict['class'] print(course) #change a value via key example_dict['awesomeness'] += 1 #increase awesomeness print(example_dict) f...
true
b83bb0e5c7c7c284c9b5d7dce366b3b626856f9a
VINEETHREDDYSHERI/Python-Deep-Learning
/ICPLab2/src/Question1.py
879
4.1875
4
studentCount = int(input("Enter No.of Students: ")) # Asking the User to provide count of students studentHeightsInFeet = [] studentHeightsInCM = [] for i in range(studentCount): height = float(input("Enter the Student-{} height in Feet ".format(i))) # Accepting Height of the each student # from user and conv...
true
0951e9e5237eed56918ae45dafeac20298d25c11
grumm1728/SFcubestepdown
/Dandy.Candies.py
749
4.125
4
import math while 1==1: #input n = input("How many candies? n=") n = int(n) s1_0 = int(math.floor(n ** (1 / 3.0))) print("s1_0 = ", s1_0) s1 = s1_0 while n % s1 > 0: s1 = s1 - 1 print(s1) print("Side 1 = ",s1) s1quot = int(n/s1) # quo...
false
eb7c7f0fc65acc343f1867aa1606d4b0e3caf3f0
isabellabvo/Design-de-Software
/Listando todos os sufixos de uma string.py
417
4.125
4
#---------ENUNCIADO---------# ''' Escreva uma função que recebe uma string e devolve uma lista com todos os seus sufixos. Um sufixo é qualquer substring que se encontra no final da string original. O nome da sua função deve ser lista_sufixos. ''' #----------CÓDIGO-----------# def lista_sufixos(palavra): a = [] ...
false
2c53a2ebfa484658215e3a119ac8c82436feb2a2
isabellabvo/Design-de-Software
/Lista caracteres.py
415
4.28125
4
#---------ENUNCIADO---------# ''' Faça uma função que recebe uma string e devolve uma lista contendo os caracteres dessa string, sem repetição. Ex: 'abacate' deve devolver ['a', 'b', 'c', 't', 'e']. O nome da sua função deve ser lista_caracteres. ''' #----------CÓDIGO-----------# def lista_caracteres(string): j...
false
4017d35f2bf0dc692fd02770510ca0aeba71ccbd
isabellabvo/Design-de-Software
/Diferença de listas.py
698
4.34375
4
#---------ENUNCIADO---------# ''' Faça uma função que recebe 2 listas e retorna uma nova lista com os elementos da primeira lista que não estão na segunda lista. Exemplo: para a entrada lista1 = [2, 7, 3.1, 'banana'] e lista2 = [2, 'banana', 'carro'] sua função deve devolver a lista [7, 3.1]. Atenção, esse é só u...
false
647a55a85639fb849c9feb2e2086a31fa4777fc8
isabellabvo/Design-de-Software
/Jogo da roleta simplificado.py
1,816
4.3125
4
#---------ENUNCIADO---------# ''' Faça um programa em Python que implementa o jogo da roleta simplificado, o usuário começa com 100 dinheiros, e o programa fica em loop até que o dinheiro acabe: O programa mostra a quantidade de dinheiro disponível (obrigatório o uso de print) O usuário aposta um valor (se o ...
false
811d5e93df6669d787ddd75713785ec4d9d6f006
livsmith77/Reading-text-files
/MAP_REDUCE_FILTER.py
1,751
4.15625
4
1. Temperature conversions def fahrenheit(t): return ((float(9)/5)*t + 32) def celsius(t): return (float(5)/9*(t - 32)) def to_fahrenheit(values): return map(fahrenheit, values) def to_celsius(values): return map(celsius, values) 2. Return maximum value from list def max(values): r...
true
c54ee7da573fab0b4fe1f9c8b93d90cfb0b7d17f
arnab0000/StartUps
/CaseStudy/solution1.py
2,762
4.34375
4
# 1. Your Friend has developed the Product and he wants to establish the product startup and he is searching for a perfect location where # getting the investment has a high chance. But due to its financial restriction, he can choose only between three locations - Bangalore, # Mumbai, and NCR. As a friend, you...
true
414bb0784c697fde373f95670fcb9ff2abfb98f3
belarminobrunoz/BYUI-CSE-110
/week 07/w08_loops.py
588
4.46875
4
# #Aqui estou criando umma variavel chamada 'name' e fazendo o loop em cima desse array # for name in ['bruno', 'fran']: # print(name) # #Aqui estou criando um range onde coloco o numero inicial, neste caso 0 e a quantidade de numeros neste range, que no caso é 3 # for index in range(0,3): # print(index) # ...
false
ebef709fb875dbccc987fb7fc94ac1474bbd9f56
AwsafAlam/Python_Problems
/Basics/List_Pract.py
2,395
4.53125
5
courses = ['Datastructures' , 'AI' , 'Micro' , 'Assembly'] print(courses) print(courses[0]) print(courses[len(courses) - 1]) # or, we can use negative indexes print(courses[-1]) ## So, we can traverse in reverse as well print(courses[0:3]) ## starting at 0 , and upto but not including 3 (ie, < 3 ) print(courses[:2]...
true
49c8c5504bf0d1932ef3f7b3a294e7577fd1be7b
antoni-g/programming-dump
/vgg/manhattan.py
875
4.25
4
# The following method get the manhatten distance betwen two points (x1,y1) and (x2,y2) def manhattan_distance(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) def convert(l): try: l[0] = float(l[0]) l[1] = float(l[1]) except ValueError: print("An input character was not a number.") exit() # Enter yo...
true
93e74790f44f6720f7778dd243943bd3115289d7
andersondev96/Curso-em-Video-Python
/Ex014.py
228
4.21875
4
# Escreva um programa que converta uma temperatura digitada em ºC para ºF celsius = float(input('Digite uma temperatura em ºC: ')) fareheit = 9 * celsius/5 + 32 print('{}ºC equivale a {:.1f}ºF.' .format(celsius, fareheit))
false
8f028989552dda6b9bd311d060593842a0ff2a59
andersondev96/Curso-em-Video-Python
/Ex031.py
572
4.125
4
""" Desenvolva um programa que pergunte a distância de uma viagem em Km. Calcule o preço da passagem, cobrando R$0,50 por Km para viagens de até 200Km e R$0,45 parta viagens mais longas. """ distancia = float(input('Digite a distancia da viagem: ')) print('Você está prestes a começar uma viagem de {}Km.'.format(dis...
false
657a00ade5ec77aa9c1941825188b32b10eb8146
choroba/perlweeklychallenge-club
/challenge-200/sgreen/python/ch-2.py
1,017
4.1875
4
#!/usr/bin/env python3 import sys def print_row(line, numbers): row = [] for n in numbers: if type(line) == str: # We want to show a solid line if line in n: row.append('-------') else: row.append(' ') else: ...
false
2b609dccec107322e639da52fcaa496e1be3200f
choroba/perlweeklychallenge-club
/challenge-228/pokgopun/python/ch-1.py
698
4.125
4
### Task 1: Unique Sum ### Submitted by: Mohammad S Anwar ### You are given an array of integers. ### ### Write a script to find out the sum of unique elements in the given array. ### ### Example 1 ### Input: @int = (2, 1, 3, 2) ### Output: 4 ### ### In the given array we have 2 unique elements (1, 3). ### Example 2...
true
0410ee45731cc27f26fd509d21b5e8c37e7fcd0f
choroba/perlweeklychallenge-club
/challenge-025/lubos-kolouch/python/ch-2.py
2,635
4.59375
5
def chaocipher_encrypt(message: str) -> str: """ Encrypts a message using the Chaocipher algorithm. Chaocipher is a symmetric encryption algorithm that uses two mixed alphabets to perform a double substitution on each letter of the plaintext. The two alphabets are predetermined and fixed. Args...
true
8c7d82cd01beb8066fb38276e41783c950a5027d
choroba/perlweeklychallenge-club
/challenge-208/lubos-kolouch/python/ch-2.py
1,435
4.40625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from typing import List, Tuple, Union def find_missing_and_duplicate(nums: List[int]) -> Union[Tuple[int, int], int]: """ Finds the duplicate and missing integer in a given sequence of integers. Args: nums (List[int]): A list of integers with one mis...
true
67e59949be5273b74bd40126657c52ad8022feec
choroba/perlweeklychallenge-club
/challenge-212/manfredi/python/ch-1.py
1,080
4.125
4
#!/usr/bin/env python3 # Python 3.9.2 on Debian GNU/Linux 11 (bullseye) print('challenge-212-task1') # Task 1: Jumping Letters # You are given a word having alphabetic characters only, and a list of positive integers of the same length # Write a script to print the new word generated after jumping forward each letter...
true
e0fc6f2aaee11b9eb1cf92e1db5a0030d047aec9
choroba/perlweeklychallenge-club
/challenge-206/spadacciniweb/python/ch-1.py
1,732
4.25
4
# Task 1: Shortest Time # Submitted by: Mohammad S Anwar # # You are given a list of time points, at least 2, in the 24-hour clock format HH:MM. # Write a script to find out the shortest time in minutes between any two time points. # # Example 1 # Input: @time = ("00:00", "23:55", "20:00") # Output: 5 # # Since the d...
true
c8ca87012b85e47b31c3de061e2f614fc3c0b936
choroba/perlweeklychallenge-club
/challenge-034/lubos-kolouch/python/ch-2.py
1,111
4.40625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Define a function to add two numbers def add(a, b): return a + b # Define a function to subtract two numbers def subtract(a, b): return a - b # Define a function to multiply two numbers def multiply(a, b): return a * b # Define a function to divide two...
true
0d747cbd92407a75a2bc104bf5dbe0968dc9e372
choroba/perlweeklychallenge-club
/challenge-023/lubos-kolouch/python/ch-2.py
1,466
4.21875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys from typing import List def prime_decomposition(n: int) -> List[int]: """ Compute the prime factors of a number. Args: n: An integer greater than or equal to 2. Returns: A list of prime factors of the input number. Raises...
true
9f5bef0b4d288b4f35fa4f7dd3e300ea5cdf95e2
choroba/perlweeklychallenge-club
/challenge-228/spadacciniweb/python/ch-1.py
868
4.125
4
# Task 1: Unique Sum # Submitted by: Mohammad S Anwar # # You are given an array of integers. # Write a script to find out the sum of unique elements in the given array. # # Example 1 # Input: @int = (2, 1, 3, 2) # Output: 4 # # In the given array we have 2 unique elements (1, 3). # # Example 2 # Input: @int = (1, 1...
true
3a5da53de265165f484f3df00a716bd2f67b2577
HelmuthMN/python-studies
/begginer_projects/acronym.py
227
4.25
4
print("Enter the full meaning and we provide the acronym.") acronym = " " meaning = input("Full Meaning: ") phrase = (meaning.replace('of', '')).split() for word in phrase: acronym = acronym + word[0].upper() print(acronym)
true
5386874a6d1a078920d9f974deef7ad565d4e9f7
ssoto/five-programming-problems-1hour
/00_first/00-for-loop.py
962
4.3125
4
#!/bin/python # -*- coding: utf-8 -*- # starts at 20:28 sun 10 may # end at 21:12 sun 10 may # DO IT FOR-EACH WAY: #  METHOD=0 # WHILE WAY: # METHOD=1 # RECURSIVE WAY: # METHOD=2 METHOD=2 def for_loop (array): for element in array: print "element " , array.index(element) , " => " , str(element) de...
false
f13d007eea6e94814615fc1c33abd4eb5f3df379
JoseSerrano22/basic-calculator-recursion
/main.py
1,473
4.1875
4
import art print(art.logo) def add(n1,n2): result = n1+n2 return result def substract(n1,n2): result = n1-n2 return result def mult(n1,n2): result = n1*n2 return result def div(n1,n2): result = n1/n2 return result operations = { #dictionary of funcions "+": add, "-": substract, "*": mult, ...
true
45e80eb9a45952dc622f98a4fc1afd5c20d49a4b
z875759270/Learning-Python-100-Days
/day6/day6.py
1,786
4.125
4
# %% """ 定义一个函数 def add(a,b): return a+b print(add(1,5)) """ # %% """ 重载的另一种实现(指定参数的默认值) def two(a=1,b=2): return a+b print(two()) print(two(2,3)) """ # %% """ 不确定参数个数时可以使用可变参数 (在参数名前面添加 ‘ * ’) def three(*args): sum=0 for x in args: sum+=x return sum print(three()) print(three(1,3,5,8))...
false
a699bb554458b43e6a6418f8e1eff32feb139eaa
maxthemouse/myhpsc
/homework/homework2/hw2a.py
1,143
4.125
4
""" Demonstration script for quadratic interpolation. Update this docstring to describe your code. Modified by: M. Adam Webb """ import numpy as np import matplotlib.pyplot as plt from numpy.linalg import solve # Set up linear system to interpolate through data points: # Data points: xi = np.array([-1., 1., 2]) yi =...
true
62f7db3c1ef8193c9ab4a786f20e9ee36090d51a
broccoli-farm/master
/01/08.py
1,024
4.15625
4
""" 与えられた文字列の各文字を,以下の仕様で変換する関数cipherを実装せよ. 英小文字ならば(219 - 文字コード)の文字に置換 その他の文字はそのまま出力 この関数を用い,英語のメッセージを暗号化・復号化せよ. """ #ord()関数で英小文字をUnicodeコードポイントに変換 #chr()関数に219-(取得した数値)で暗号処理を行う。 def cipher(text): ans = "" for i in text: if i.islower(): #すべての文字が小文字かどうか判定 ※文字列型じゃ無いと無理? ans += chr(219 - or...
false
15304d525c86ddae9436c54cabd2c0360d0cddab
AlyoshaS/codes
/startingPoint/01-EstruturasCondicionais/exercicios_resolvidos/00.py
539
4.125
4
""" **00** - Faça um programa que receba quatro notas de um aluno, calcule e mostre a média aritmética das notas e a mensagem de aprovado ou reprovado, considerando para aprovação média 7. """ nota1 = int(input("Digite a primeira nota: ")) nota2 = int(input("Digite a segunda nota: ")) nota3 = int(input("Digite ...
false
095b75f2c665593faf6c469773742a99b02bf2b5
AlyoshaS/codes
/startingPoint/02-EstruturaSequencial/Exercicios_Propostos/21.py
442
4.1875
4
#!/usr/bin/python # coding: latin-1 """21 - Faça um programa que receba um número real, calcule e mostre: - a parte inteira desse número; - a parte fracionária desse número; - o arredondamento desse número""" num = float(input("Digite o numero: ")) i = int(num) f = num - i a = round(num) print("A parte ...
false
c07fba06c649594cee345c31c1a69a387ef8ea6e
AlyoshaS/codes
/Python/PORRA DE EXERCÍCIO/exerciciofb.py
2,281
4.28125
4
""" Faça um programa para uma loja de tintas: O programa deverá pedir o tamanho em metros quadrados da área a ser pintada. Considere que a cobertuta da tinta é de 1 litro para cada 6 metros quadrados e que a tinda é vendida em: latas de 18 litros, que custam R$ 80,00 ou em galões da 4 litros, que custam R$ 25,00. ...
false
d54a3e576cc0b2990fb41f48d436d26842acda20
AlyoshaS/codes
/startingPoint/01-EstruturasCondicionais/exercicios_resolvidos/18.py
638
4.125
4
""" 18 - Faça um programa que receba a altura e o sexo de uma pessoa; calcule e mostre seu peso ideal, utilizando as seguintes fórmulas (onde h é a altura): * para homens: (72.7 * h) - 58. * para mulheres: (62.1 * h) - 44.7. """ height = float(input("Digite a sua altura: ")) sex = input("Digite o seu sexo(M ...
false
ab070412a6de8c1479c984d904b2a387e21f0dec
AlyoshaS/codes
/startingPoint/01-EstruturasCondicionais/exercicios_propostos/04.py
848
4.1875
4
""" 4. Faça um programa que receba três números obrigatoriamente em ordem crescente e um quarto número que não siga essa regra, Mostre, em seguida, os quatro números em ordem decrescente. Suponha que o usuário digitará quatro números diferentes. """ n1, n2, n3 = [int(x) for x in input("Digite três números em ordem ...
false
0bdf7f0dca7a10df9aa02dacd85424532380af57
AlyoshaS/codes
/startingPoint/01-EstruturasCondicionais/exercicios_resolvidos/13.py
1,504
4.1875
4
""" **13** - Faça um programa que receba o salário de um funcionário e, usando a tabela a seguir, calcule e mostre o novo salário. | FAIXA SALARIAL | % DE AUMENTO | |----------------------------------------|--------------------------------------| | Até R$ 300,00 ...
false
40f93e67e8d94aee7f80fdbe458d237f5cbac464
AlyoshaS/codes
/startingPoint/02-EstruturaSequencial/Exercicios_Resolvidos/02.py
403
4.125
4
# 3. Faça um programa que receba dois números, calcule e mostre a divisão do primeiro número pelo segundo. Sabe-se que o segundo # número não pode ser zero, portanto, não é necessário se preocupar com validações. n1 = int(input("Digite o primeiro número: ")) n2 = int(input("Digite o segundo número diferente de 0...
false
962115d2a0262c8911c90a2461a8c3b26888aead
AlyoshaS/codes
/startingPoint/02-EstruturaSequencial/Exercicios_Resolvidos/11.py
676
4.15625
4
""" 12. Faça um programa que receba o ano de nascimento de uma pessoa e o ano atual, calcule e mostre: a idade dessa pessoa em anos; a idade dessa pessoa em meses; a idade dessa pessoa em dias; a idade dessa pessoa em semanas. """ ano_nasc, ano_atual = [int(x) for x in input("Digite seu ano de nascimento e o a...
false
b895d5454fc57a6796174a3fdd135ed64ec9bd84
Cyb3rKn1gh7/Python
/HCF-LCM.py
307
4.125
4
#HCF and LCM calculator python n = float(input("Enter the First Number : ")) n1 = float(input("Enter the Second Number : ")) a,b=n,n1 while(n1 != 0): t = n1 n1 = n % n1 n = t lcm=(a*b)/n print("HCF of {0} and {1} = {2}".format(a, b, n)) print("LCM of {0} and {1} = {2}".format(a, b, lcm))
false
536c642ab2156d9eb572b0d2123c6828cd6d4ae6
Marist-CMPT120-FA19/-Gabi-Gervasi--Lab-3
/tree.py
329
4.21875
4
def tree(): print("How many branches in the tree") print() height = input("Number of Branches : ") length = int(height)*2-1 space = (length-1)/2 x=1 while x <= int(height): print (" "* (int(space)- x +1 ), "#"*(2*x-1)) x=x+1 print(" "*(int(height) -1), "#") tree() ...
true
3302367ec4353353bb979e91bef07b02b8749dcf
FarkasAlex170/siw
/siw-fibonacci.py
206
4.1875
4
how_many = int(input("How many numbers would you like to see?: ")) a = 0 b = 1 fib = 0 for i in range(how_many): print("#", i + 1, "a=", a, "b=", b, "fib=", a + b) fib = a + b a = b b = fib
false
b5268fb1ecee82958548337949e83a396dc63a3a
nguyendatvn/DATACAMPPYTHON
/Intermediate Python for Data Science/Dictionaries & Pandas/ex2.py
800
4.5
4
# Definition of countries and capital countries = ['spain', 'france', 'germany', 'norway'] capitals = ['madrid', 'paris', 'berlin', 'oslo'] # Get index of 'germany': ind_ger ind_ger = countries.index("germany") # # Use ind_ger to print out capital of Germany # print(capitals[ind_ger]) # From string in countries and ...
false
49eb017ae455509a32fda6f5073bf032b79334e2
kawing13328/Basics
/My Homework/Ex_9-3.py
1,634
4.84375
5
"""9-3: Users 1. Make a class called User. Create two attributes called first_name and last_name, and then 2. create several other attributes that are typically stored in a user profile. 3. Make a method called describe_user() that prints a summary of the user’s information. 4. Make another method called greet_user() ...
true
9fb1a32d7c0817bca54b6c4caa894821950f70f0
kawing13328/Basics
/My Homework/Ex_6-7.py
2,226
4.46875
4
countries = ['usa', 'russia', 'spain'] cities = ['new york', 'moscow', 'barceloca'] companies = ['level up', 'abc company', 'ola company'] customers =[companies, cities, countries] # 6-7. People: Start with the program you wrote for Exercise 6-1 (page 102). first_name, last_name, age, city they live # Make two new di...
false
3e7903b6dec9f72cf5e9f88ec4abcdc9499fc5c6
rraj29/ProgramFlow
/searching2.py
1,004
4.25
4
shopping_list = ["milk", "pazzta", "eggs","spam", "bread", "rice"] item_to_find = "albatross" #The next initialization is important if the item is not found in the list. Otherwise we'll get error. found_at = None #we are searching for something, we need to find the index at which it is located #for index in range(6)...
true
b0784098e30c43588a5dcd5535006eb7f8b44ef1
kajili/interview-prep
/src/cracking_the_coding_interview/ch_01_arrays_and_strings/Q1_04_PalindromePermutation.py
1,178
4.25
4
# CTCI Question 1.4 Palindrome Permutation # Given a string, write a function to check if it is a permutation of a palindrome. # A palindrome is a word or phrase that is the same forwards and backwards. # A permutation is a rearrangement of letters. # The palindrome does not need to be limited to just dictionary words...
true
6e223b5094b02006b3c9e7275b414e114bd4130b
mouday/SomeCodeForPython
/test_from_myself/测试练习/面向对象/1.创建类.py
2,055
4.21875
4
# 创建类 class Employee(object): """所有员工的基类""" empCount = 0 # 类变量 def __init__(self, name, salary): self.name = name self.salary = salary Employee.empCount += 1 def displayCount(self): print("Total Employee %d" % Employee.empCount) def displayEmployee(self): ...
false
9f102c93e36f09140eb08ab9954101c59a229de9
mouday/SomeCodeForPython
/test_from_myself/leetcode/760. Find Anagram Mappings.py
1,178
4.125
4
""" 760. Find Anagram Mappings Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the order of the elements in A. We want to find an index mapping P, from A to B. A mapping P[i] = j means the ith element in A appears in B at index j. These lists A and B may contain d...
true
a3547b570eda2bc5890118e8813abac1104dedd6
mouday/SomeCodeForPython
/test_from_myself/测试练习/dict简单数据库.py
564
4.125
4
#dict简单数据库.py #使用人名作为字典的键,每个人又用另一个字典表示 people={ "Alice":{ "phone":"2341", "addr":"foot drive 23" }, "Beth":{ "phone":"9012", "addr":"bar street 42" }, "Cecil":{ "phone":"3154", "addr":"Baz avenue 90" } } #描述性标签 labels={ "phone":"phone number", "addr":"address" } name=input("Name:") request=input("查找...
false
8669143fd6031d8032ee958845f5623f5e473974
mouday/SomeCodeForPython
/test_from_myself/设计模式/2.简单工厂模式.py
1,193
4.625
5
# 设计模式之简单工厂模式 # http://mp.weixin.qq.com/s/3J0hq3I95iKnbT5YjniZVQ """ 简单工厂模式: 专门定义一个 工厂类 来负责创建 产品类 的实例,被创建的产品通常都具有共同的父类。 三个角色: 简单工厂(SimpleProductFactory)角色 抽象产品(Product)角色 具体产品(Concrete Product)角色 """ # 抽象产品 class Fruit(object): def produce(self): print("Fruit is prodeced") # 具体产品 class Apple(Fruit): ...
false
d4a618dbff9c023f636126babb245f533da50a08
abmish/pyprograms
/100Py/Ex37.py
282
4.125
4
""" Define a function which can generate and print a list where the values are square of numbers between 1 and 20 (both included). """ def num_square_list(num): sq_list = list() for i in range(1, num+1): sq_list.append(i ** 2) print sq_list num_square_list(20)
true
be8d6f2cc44daeca5e03c98ff560e8eccb351f5c
abmish/pyprograms
/100Py/Ex2.py
556
4.1875
4
""" Write a program which can compute the factorial of a given list of comma-separated numbers. The results should be printed in a comma-separated sequence on a single line. Suppose the following input is supplied to the program: 8,5 Then, the output should be: 40320,120 """ def factorial(num): if num ==0: ...
true
4026f1f3ceba0ae5ac94b3af49de6529209c4222
abmish/pyprograms
/intermediate/I5.py
1,870
4.21875
4
""" PALPRIM - Palindromic Primes A Palindromic number is a number without leading zeros that remains the same when its digits are reversed. For instance 5, 22, 12321, 101101 are Palindromic numbers where as 10, 34, 566, 123421 are not. A Prime number is a positive integer greater than 1 that has no positive divisors ot...
true
5c74dc0f564824fd35817728941b6c82381f952a
abmish/pyprograms
/100Py/Ex86.py
252
4.1875
4
""" By using list comprehension, please write a program to print the list after removing numbers which are divisible by 5 and 7 in [12,24,35,70,88,120,155] """ tlist = [12,24,35,70,88,120,155] print [num for num in tlist if num%5 == 0 and num%7 == 0]
true
1b3ddb739a4cbd02e853f3312fa0b08c3bd0cd18
abmish/pyprograms
/100Py/Ex44.py
280
4.53125
5
""" Write a program which accepts a string as input to print "Yes" if the string is "yes" or "YES" or "Yes", otherwise print "No". """ input_str = raw_input("input yes variation:") if input_str=="yes" or input_str=="YES" or input_str=="Yes": print "Yes" else: print "No"
true
c49a758c98c06b5f3d4d631310a59e1fcadd5169
abmish/pyprograms
/100Py/Ex71.py
310
4.25
4
""" Please write a program which accepts basic mathematical expression from console and print the evaluation result. If the following string is given as input to the program: 35+3 Then, the output of the program should be: 38 """ user_exp = raw_input("Input a mathematical expression :") print eval(user_exp)
true
e11fd9c5ef073e8e0636346f15adb29c87d9562d
abmish/pyprograms
/euler/e30.py
659
4.125
4
""" Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: 1634 = 1^4 + 6^4 + 3^4 + 4^4 8208 = 8^4 + 2^4 + 0^4 + 8^4 9474 = 9^4 + 4^4 + 7^4 + 4^4 As 1 = 1^4 is not a sum it is not included. The sum of these numbers is 1634 + 8208 + 9474 = 19316. Find the ...
true
632395e421c68037fa58d4876a541be446d4428a
abmish/pyprograms
/100Py/Ex24.py
663
4.3125
4
""" Python has many built-in functions, and if you do not know how to use it, you can read document online or find some books. But Python has a built-in document function for every built-in functions. Please write a program to print some Python built-in functions documents, such as abs(), int(), raw_input() And add doc...
true
f7a07ea2f7fb455ea2afddea71e9405f23a70d5b
google/google-ctf
/third_party/edk2/AppPkg/Applications/Python/Python-2.7.2/Demo/scripts/fact.py
1,182
4.4375
4
#! /usr/bin/env python # Factorize numbers. # The algorithm is not efficient, but easy to understand. # If there are large factors, it will take forever to find them, # because we try all odd numbers between 3 and sqrt(n)... import sys from math import sqrt def fact(n): if n < 1: raise ValueE...
true
2cd2be0282ef81f0cec9624f819b0edb1fc6d79c
StoneRiverPRG/Python_Study
/22 continue-break.py
1,822
4.125
4
# break # continue # まずはbreakの使い方 i = 0 while True: # 無限ループ print(i, end=" ") if i == 5: print("i==5なのでwhileループをbreakします") break # breakがあると無限ループから抜ける i += 1 print("whileループ終了しました") # 0 1 2 3 4 5 i==5なのでwhileループをbreakします # whileループ終了しました  # continue for j in range(5): prin...
false
b7855277caad219b7e696201229ca46c036d84ff
sufairahmed/Udacity-Introduction-to-Python-Practice
/sum_of_series.py
520
4.21875
4
def sum_of_series(num_series): total = 0 for i in range(0, num_series): total = total + i print("The sum of the series {} = {}".format(num_series, total)) def sum_of_square_series(num_series): total = 0 total = (num_series * (num_series + 1) * (2 * num_series + 1 )) / 6 p...
true
a8a8e8c4a092e9712c897f670590a74e27adffc6
sufairahmed/Udacity-Introduction-to-Python-Practice
/list.py
323
4.25
4
# my_list = [23, 43, 'sufair','ahmed',90, 100, 'taslima',13] # print(my_list) # print(my_list[ :-1]) #month = 8 month =int (input('enter a month no: ')) days_in_month = [31,28,31,30,31,30,31,31,30,31,30,31] # use list indexing to determine the number of days in month num_days = days_in_month[month - 1] print(num_day...
false
2794354be8ee3d2752b336ac79eee4b5c6be5f11
lxyshuai/Algorithm-primary-class-python
/1/bubble_sort.py
732
4.1875
4
# coding=utf-8 def bubble_sort(array): # type: (list[int]) -> None """ 冒泡排序 时间复杂度:O(N^2) 额外空间复杂度:O(1) 第一轮把最大的数冒泡到最后 第二轮把第二大的数冒泡到最后 ... 最后一轮把最小的数放到第一 @param array: @return: """ if not array: return for i in reversed(range(0, len(array) - 1)): for j...
false
4d047a7ac0be12375caece8284ebaae753043612
lxyshuai/Algorithm-primary-class-python
/4/zig_zag_print_matrix.py
1,857
4.25
4
# coding=utf8 """ “之”字形打印矩阵 【题目】 给定一个矩阵matrix,按照“之”字形的方式打印这个矩阵,例如: 1 2 3 4 5 6 7 8 9 10 11 12 “之”字形打印的结果为:1,2,5,9,6,3,4,7,10,11,8,12 【要求】 额外空间复杂度为O(1)。 """ def print_diagonal(matrix, top_row, top_column, down_row, down_column, direction): """ 打印对角线 @param matrix: @type matrix: @param top_row: ...
false
385df9987fa2baa4709aa28d27c190371b134f3a
DavidBlazek18/Python-Projects
/python_Polymorphism_Assignment_P193.py
2,891
4.15625
4
#Parent class class Airline_Passenger: name = "Chuck Yeager" email = "Yeager@gmail.com" password = "1234abcd" def getLoginInfo(self): entry_name = input("Enter your name: ") entry_email = input("Enter your email: ") entry_password = input("Enter your password: ") if ent...
true
0286c74096a35d30aebee609727ca21e66bada45
ICS3U-Programming-JonathanK/Unit5-01-Python
/temp_convert.py
838
4.28125
4
#!/usr/bin/env python3 # Created by: Jonathan Kene # Created on: June 1, 2021 # The program will use one for loop and one if statement, # outputting five integers per line with each separated by a space. def fahrenheit(): user_string = input("Enter the Temperature (°C): ") print("") # make sure if the u...
true
c5524e0f95241287a34536f24fefa49a60136e53
uniquearya70/Python_Practice_Code
/q15_odd.py
464
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jun 15 16:49:35 2018 @author: arpitansh """ ''' Use a list comprehension to square each odd number in a list. The list is input by a sequence of comma-separated numbers. Suppose the following input is supplied to the program: 1,2,3,4,5,6,7,8,9 Then, t...
true
8e1b506f8b585879cfe91b215aa660c75598e03e
uniquearya70/Python_Practice_Code
/q42_lambda.py
429
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jun 18 00:40:29 2018 @author: arpitansh """ ''' Write a program which can filter even numbers in a list by using filter function. The list is: [1,2,3,4,5,6,7,8,9,10]. ''' ''' li = [1,2,3,4,5,6,7,8,9,10] evenNumber = filter(lambda x: x%2==0, li) print...
true
da2116af1f80d95c24399be57ebf10219e9cba51
uniquearya70/Python_Practice_Code
/q61.py
747
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jun 18 13:54:37 2018 @author: arpitansh """ ''' The Fibonacci Sequence is computed based on the following formula: f(n)=0 if n=0 f(n)=1 if n=1 f(n)=f(n-1)+f(n-2) if n>1 Please write a program using list comprehension to print the Fibonacci Sequence ...
true
fe4c37e3083ffd64145d3177ac205dc94a719164
uniquearya70/Python_Practice_Code
/q40.py
362
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jun 18 00:08:41 2018 @author: arpitansh """ ''' Write a program to generate and print another tuple whose values are even numbers in the given tuple (1,2,3,4,5,6,7,8,9,10). ''' tp=(1,2,3,4,5,6,7,8,9,10) lst=list() for i in tp: if tp[i]%2==0: lst...
true
c1805d558362add81db3e79c33335eb8b537b100
uniquearya70/Python_Practice_Code
/q21_leftrigtupdn.py
1,052
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Jun 17 13:57:52 2018 @author: arpitansh """ ''' A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following: UP 5 DOWN 3...
true
af2e45c06a6b024e20d8da0d8887c45f4cf1aec5
shubhamsahu02/cspp1-assignments
/M22/assignment1/read_input.py
288
4.28125
4
''' Write a python program to read multiple lines of text input and store the input into a string. ''' STR_ING = "" S_1 = int(input()) for i in range(S_1): STR_ING += input() +'\n' i += 1 print(STR_ING) def main(): '''main function''' if __name__ == '__main__': main()
true