blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
650b2156b592b55355fcd441cdf6a29ba8760226
syurskyi/Python_Topics
/050_iterations_comprehension_generations/006_nested_comprehensions/examples/006_nested_comprehensions.py
1,954
4.75
5
# Nested Comprehensions # Just as with list comprehensions, we can nest generator expressions too: # A multiplication table: # Using a list comprehension approach first: # The equivalent generator expression would be: # We can iterate through mult_list: # But you'll notice that our rows are themselves generators! # o f...
true
f0deed5e91dc4476292f10ac0e544bd0a8290bb1
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/746 Min Cost Climbing Stairs.py
1,291
4.125
4
#!/usr/bin/python3 """ On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of the floor, and you can either start from the step with index 0, or the step with index 1. Exampl...
true
69fb9eab9782d4b53bbd781db80061561795fe8e
syurskyi/Python_Topics
/045_functions/013_switch_simulation/003.py
922
4.125
4
def add(x, to=1): return x + to def divide(x, by=2): return x / by def square(x): return x ** 2 def invalid_op(x): raise Exception("Invalid operation") def perform_operation(x, chosen_operation, operation_args=None): # If operation_args wasn't provided (i.e. it is None), set it to be an empt...
true
be6d3b624bf38e6ed7cf8c93a26d4c6cb6cd7269
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/100_python_Best_practices_for_absolute_beginers/Project+12 How to check if a point belongs to Circle.py
286
4.3125
4
_______ math x float(input("Insert point x: ")) y float(input("Insert point y: ")) r float(input("Insert the radius: ")) hypotenuse math.sqrt(pow(x,2) + pow(y,2)) __ hypotenuse < r: print("The point belongs to circle.") ____: print("The point does not belong to circle.")
false
0aa08a662cb93ae1b78a565535806c5f649c40c2
syurskyi/Python_Topics
/125_algorithms/_examples/Python_Hand-on_Solve_200_Problems/Section 4 Condition and Loop/triangle_types_solution.py
645
4.125
4
# To add a new cell, type '# %%' # To add a new markdown cell, type '# %% [markdown]' # %% # Write a Python program to check a triangle is equilateral, isosceles or scalene. # Note : # An equilateral triangle is a triangle in which all three sides are equal. # A scalene triangle is a triangle that has three unequal sid...
true
9668ed9b59dffd211b71d671e99bff049ca83215
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/232 Implement Queue using Stacks.py
1,349
4.28125
4
""" Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front of queue. peek() -- Get the front element. empty() -- Return whether the queue is empty. Notes: You must use only standard operations of a stack -- which means only...
true
99e0d1b96397498ae343b4eae4e4b23307e59dbe
syurskyi/Python_Topics
/020_sequences/examples/ITVDN Python Essential 2016/12-mutable_sequences_methods.py
365
4.25
4
""" Примеры других общих для изменяемых последовательностей методов. """ sequence = list(range(10)) print(sequence) # Неполное копирование copy = sequence.copy() # copy = sequence[:] print(copy) # Разворот в обратном порядке sequence.reverse() print(sequence)
false
46b95cecb37be01d2c4ced998e143f9f08a7b9b2
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/pybites/intermediate/intermediate-bite-13-convert-dict-to-namedtuple-json.py
2,029
4.1875
4
""" TASK DESCRIPTION: Write a function to convert the given blog dict to a namedtuple. Write a second function to convert the resulting namedtuple to json. Here you probably need to use 2 of the _ methods of namedtuple :) """ ____ c.. _______ n.. ____ c.. _______ O.. ____ d__ _______ d__ _______ j__ # Q: What is the ...
true
1af8cd8a831f0b63b8c77d2ff35f4ec3e6a1b3f8
syurskyi/Python_Topics
/125_algorithms/_examples/Learn_Python_by_solving_100_Coding_Challenges/Coding Challenge No. 60 - MergeSortLists.py
1,158
4.15625
4
# Merge Sorted Lists # Question: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. # Solutions: class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # @param two ListNo...
true
56ff56c9d7977a59184e97c87a15187edbd1a63f
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/520 Detect Capital.py
1,228
4.375
4
#!/usr/bin/python3 """ Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA". All letters in this word are not capitals, like "leetcode". Only t...
true
0e260d563115adc1074d6e6135c4d62085b1f48f
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/100_python_Best_practices_for_absolute_beginers/Project+13 How to create quadratic Equation.py
331
4.34375
4
____ math _______ sqrt x float(input("Insert x = ")) y float(input("Insert y = ")) z float(input("Insert z = ")) a y*y-4*x*z __ a>0: x1 (-y + sqrt(a))/(2*x) x2 (-y - sqrt(a))/(2*x) print("x1 = %.2f; x2 = %.2f" % (x1,x2)) ____ a__0: x1 -y/(2*x) print("x1 = %.2f" % x1) ____: print("No ro...
false
d30652b267569247f9d3c6a1f20ad03f3f902250
syurskyi/Python_Topics
/115_testing/_exercises/_templates/temp/Github/_Level_1/UnitTesting-master/Proj4/ListsAndTuples/listAndTuples.py
2,218
4.375
4
______ ___ ______ timeit # https://www.youtube.com/watch?v=NI26dqhs2Rk # Tuple is a smaller faster alternative to a list # List contains a sequence of data surrounded by brackets # Tuple contains a squence of data surrounded by parenthesis """ Lists can have data added, removed, or changed Tuples cannot change. Tu...
true
c035fcefec027a5b8e1c619b49d09c7c96cbc330
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/pybites/beginner/beginner-bite-169-simple-length-converter.py
1,245
4.34375
4
''' Your task is to complete the convert() function. It's purpose is to convert centimeters to inches and vice versa. As simple as that sounds, there are some caveats: convert(): The function will take value and fmt parameters: value: must be an int or a float otherwise raise a TypeError fmt: string containing either ...
true
4e4ffc46df598ca4b6990664d765f2ee36ca9c63
syurskyi/Python_Topics
/012_lists/examples/Python 3 Most Nessesary/8.1. Listing 8.1. Create a shallow copy of the list.py
1,169
4.375
4
# -*- coding: utf-8 -*- x = [1, 2, 3, 4, 5] # Создали список # Создаем копию списка y = list(x) # или с помощью среза: y = x[:] # или вызовом метода copy(): y = x.copy() print(y) # [1, 2, 3, 4, 5] print(x is y) # Опе...
false
0e1f60a4dd71d99753e8a19d3f767d8d2815615d
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/768 Max Chunks To Make Sorted II.py
1,673
4.40625
4
#!/usr/bin/python3 """ This question is the same as "Max Chunks to Make Sorted" except the integers of the given array are not necessarily distinct, the input array could be up to length 2000, and the elements could be up to 10**8. Given an array arr of integers (not necessarily distinct), we split the array into some...
true
17c9922315777a98beb9a4799bad497699ecd265
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/pybites/intermediate/299/base_converter.py
859
4.5
4
# ___ convert number i.. base i.. 2 __ s.. # """Converts an integer into any base between 2 and 36 inclusive # # Args: # number (int): Integer to convert # base (int, optional): The base to convert the integer to. Defaults to 2. # # Raises: # Exception (ValueError): If base is less t...
false
2a941e251d78633d70caf05e60efa864cc49aba9
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/701 Insert into a Binary Search Tree.py
1,190
4.375
4
#!/usr/bin/python3 """ Given the root node of a binary search tree (BST) and a value to be inserted into the tree, insert the value into the BST. Return the root node of the BST after the insertion. It is guaranteed that the new value does not exist in the original BST. Note that there may exist multiple valid ways fo...
true
f50b7d8beae1763ff2665416301bec37eff8fc53
syurskyi/Python_Topics
/050_iterations_comprehension_generations/009_permutations/examples/009_permutations.py
1,745
4.46875
4
# Permutations # In mathematics, the notion of permutation relates to the act of arranging all the members of a set into some sequence # or order, or if the set is already ordered, rearranging (reordering) its elements, a process called permuting. # These differ from combinations, which are selections of some members o...
true
c3cac517a34075d13cc9839c5aafffab20eefd1d
syurskyi/Python_Topics
/045_functions/007_lambda/examples/The_Modern_Python_3_Bootcamp/Coding Exercise 67 sum_even_values.py
566
4.21875
4
# Sum Even Values Solution # # I define a function called sum_even_values which accepts any number of arguments, thanks to *args # I grab the even numbers using the generator expression (arg for arg in args if arg % 2 == 0) # (could also use a list comp) # I pass the even numbers I extracted into sum()...
true
e68fa28abb8eb130145171dbbaadced13f473c6d
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/LeetCode_with_solution/953 Verifying an Alien Dictionary.py
1,996
4.21875
4
#!/usr/bin/python3 """ In an alien language, surprisingly they also use english lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters. Given a sequence of words written in the alien language, and the order of the alphabet, return true if and only if th...
true
c7fde44dbdbdd8fbf0a8f75bc98819f46a6d2dd2
Nunziatellanicolepalarymzai/Python-104
/mean.py
883
4.375
4
# Python program to print # mean of elements # list of elements to calculate mean import csv with open('./height-weight.csv', newline='') as f: reader = csv.reader(f) #csv.reader method,reads and returns the current row and then moves to the next file_data = list(reader) #list(reader) adds the...
true
34b74af222fda40f35d744e2909cde08df0f3092
ravis3517/i-neuron-assigment-and-project-
/i neuron_python_prog_ Assignment_3.py
1,845
4.34375
4
#!/usr/bin/env python # coding: utf-8 # 1. Write a Python Program to Check if a Number is Positive, Negative or Zero # In[25]: num = float(input("Enter a number: ")) if num >0: print("positive") elif num <0 : print("negative") else: print(" number is zero") # 2. Wri...
true
07540d509c99f96db7fcc7f7362a36f5dc52d36d
bowie2k3/cos205
/COS-205_assignment4b_AJ.py
683
4.5
4
# Write a program that counts the number of words in a text file. # the program should print out [...] the number of words in the file. # Your program should prompt the user for the file name, which # should be stored at the same location as the program. # It should consider anything that is separated by white space o...
true
b6d35f31562d97ec2fe4c6d9a1d349d23a45e7ea
jmmalnar/python_projects
/primes.py
1,896
4.40625
4
import unittest # Find all the prime numbers less than a given integer def is_prime(num): """ Iterate from 2 up to the (number-1). Assume the number is prime, and work through all lower numbers. If the number is divisible by ANY of the lower numbers, then it's not prime """ prime_status = ...
true
69d63e236fd5585208ec5bebab45137c260c3562
lmhavrin/python-crash-course
/chapter-seven/deli.py
536
4.4375
4
# Exercise: 7-8 Deli # A for loop is useful for looping through a list # A while loop is useful for looping through a list AND MODIFYING IT sandwich_orders = ["turkey", "roast beef", "chicken", "BLT", "ham"] finished_sandwiches = [] while sandwich_orders: making_sandwich = sandwich_orders.pop() print("I made...
true
637260eab712b7cca3c5f0f9e058fcd3639ffa96
bqr407/PyIQ
/bubble.py
1,671
4.15625
4
class Bubble(): """Class for bubble objects""" def __init__(self, id, x, y, x2, y2, value): """each bubble object has these values associated with it""" self.x = x self.y = y self.x2 = x2 self.y2 = y2 self.id = id self.value = value def getX(self): ...
true
a72b8412d9b2ca109436ac39d7dc3dcc021a8d75
jsvn91/example_python
/eg/getting_max_from_str_eg.py
350
4.15625
4
# Q.24. In one line, show us how you’ll get the max alphabetical character from a string. # # For this, we’ll simply use the max function. # print (max('flyiNg')) # ‘y’ # # The following are the ASCII values for all the letters of this string- # # f- 102 # # l- 108 # # because y is greater amongst all y- 121 # # i- 105...
true
5935356da274001c362f979a7405c61f71cdef0b
Zhaokun1997/2020T1
/comp9321/labs/week2/activity_2.py
1,596
4.4375
4
import sqlite3 import pandas as pd from pandas.io import sql def read_csv(csv_file): """ :param csv_file: the path of csv file :return: a dataframe out of the csv file """ return pd.read_csv(csv_file) def write_in_sqlite(data_frame, database_file, table_name): """ :param data_frame: the ...
true
b5ef32acae6f59590e4cd373b2368eb4414bf12f
Sharonbosire4/hacker-rank
/Python/Algorithms/Warmup/Staircase/python_staircase/__main__.py
392
4.125
4
from __future__ import print_function import sys def staircase(height): lines = [] for n in range(height): string = '' for i in range(height): string += '#' if i >= n else ' ' lines.append(string) return reversed(lines) def main(): T = int(input()) for line in s...
false
dc903ba5999763753228f8d9c2942718ddd3fe69
magicmitra/obsidian
/discrete.py
1,190
4.46875
4
#---------------------------------------------------------------------------------- # This is a function that will calculate the interest rate in a discrete manner. # Wirh this, interest is compounded k times a year and the bank will only add # interest to the pricipal k times a year. # The balance will then be return...
true
097a63c09d55dc17208b953b948229ccc960c751
Onyiee/DeitelExercisesInPython
/circle_area.py
486
4.4375
4
# 6.20 (Circle Area) Write an application that prompts the user for the radius of a circle and uses # a method called circleArea to calculate the area of the circle. def circle_area(r): pi = 3.142 area_of_circle = pi * r * r return area_of_circle if __name__ == '__main__': try: r = int(input...
true
bccd0d8074473316cc7eb69671929cf14ea5c1ac
Onyiee/DeitelExercisesInPython
/Modified_guess_number.py
1,472
4.1875
4
# 6.31 (Guess the Number Modification) Modify the program of Exercise 6.30 to count the number of guesses # the player makes. If the number is 10 or fewer, display Either you know the secret # or you got lucky! If the player guesses the number in 10 tries, display Aha! You know the secret! # If the player makes more th...
true
3b26b40c9619c6b0eee0a36096688aeb57819f10
Subharanjan-Sahoo/Practice-Questions
/Problem_34.py
810
4.15625
4
''' Single File Programming Question Your little brother has a math assignment to find whether the given number is a power of 2. If it is a power of 2 then he has to find the sum of the digits. If it is not a power of 2, then he has to find the next number which is a power of 2. He asks for your help to validate his w...
true
0bbb5802a3cfb9cd06a9a458bc77403689dad0ca
Subharanjan-Sahoo/Practice-Questions
/Problem_33.py
1,040
4.375
4
''' Write a program to calculate and return the sum of distances between the adjacent numbers in an array of positive integers Note: You are expected to write code in the find TotalDistance function only which will receive the first parameter as the number of items in the array and second parameter as the array itsel...
true
97c1bac183bf1c744eb4d1f05b6e0253b1455f10
Subharanjan-Sahoo/Practice-Questions
/Problem_13.py
733
4.21875
4
''' Write a function to find all the words in a string which are palindrome Note: A string is said to be a palindrome if the reverse of the string is the same as string. For example, "abba" is a palindrome, but "abbe" is not a palindrome. Input Specification: input1: string input2: Length of the String Output Spe...
true
d30504a329fd5bcb59a284b5e28b89b6d21107e3
lada8sztole/Bulochka-s-makom
/1_5_1.py
479
4.1875
4
# Task 1 # # Make a program that has some sentence (a string) on input and returns a dict containing # all unique words as keys and the number of occurrences as values. # a = 'Apple was sweet as apple' # b = a.split() a = input('enter the string ') def word_count(str): counts = dict() words = str.split() ...
true
cdc0c71ee2fd47586fca5c145f2c38905919cff5
lada8sztole/Bulochka-s-makom
/1_6_3.py
613
4.25
4
# Task 3 # # Words combination # # Create a program that reads an input string and then creates and prints 5 random strings from characters of the input string. # # For example, the program obtained the word ‘hello’, so it should print 5 random strings(words) # that combine characters ‘h’, ‘e’, ‘l’, ‘l’, ‘o’ -> ‘hlelo’...
true
5438b1928dc780927363d3d7622ca0d00247a5c2
malay190/Assignment_Solutions
/assignment9/ass9_5.py
599
4.28125
4
# Q.5- Create a class Expenditure and initialize it with expenditure,savings.Make the following methods. # 1. Display expenditure and savings # 2. Calculate total salary # 3. Display salary class expenditure: def __init__(self,expenditure,savings): self.expenditure=expenditure self.savings=savings def total_s...
true
d4c987322a7e4c334bfb78920c52009101a1ba13
malay190/Assignment_Solutions
/assignment6/ass6_4.py
291
4.15625
4
#Q.4- From a list containing ints, strings and floats, make three lists to store them separately l=[1,'a',2,3,3.2,5,8.2] li=[] lf=[] ls=[] for x in l: if type(x)==int: li.append(x) elif type(x)==float: lf.append(x) elif type(x)==str: ls.append(x) print(li) print(lf) print(ls)
false
72a8086b765c8036b7f30853e440550a020d7602
bradger68/daily_coding_problems
/dailycodingprob66.py
1,182
4.375
4
"""Assume you have access to a function toss_biased() which returns 0 or 1 with a probability that's not 50-50 (but also not 0-100 or 100-0). You do not know the bias of the coin. Write a function to simulate an unbiased coin toss. """ import random unknown_ratio_heads = random.randint(1,100) unknown_rati...
true
68c281e253778c4c3640a5c67d2e7948ca8e150a
farahhhag/Python-Projects
/Grade & Attendance Calculator (+Data Validation).py
2,363
4.21875
4
data_valid = False while data_valid == False: grade1 = input("Enter the first grade: ") try: grade1 = float(grade1) except: print("Invalid input. Only numbers are accepted. Decimals should be separated with a dot.") continue if grade1 <0 or grade1 > 10: print("...
true
6e85b53b38083b361d3d6d3a43b2b6fbc9d82ba9
farahhhag/Python-Projects
/Age Comparison.py
226
4.21875
4
my_age = 26 your_age = int( input("Please type your age: ") ) if(my_age > your_age): print("I'm older than you") elif(my_age == your_age): print("We are the same age") else: print("You're older than me")
false
c68084826badc09dd3f037098bfcfbccb712ee15
kayazdan/exercises
/chapter-5.2/ex-5-15.py
2,923
4.40625
4
# Programming Exercise 5-15 # # Program to find the average of five scores and output the scores and average with letter grade equivalents. # This program prompts a user for five numerical scores, # calculates their average, and assigns letter grades to each, # and outputs the list and average as a table on the sc...
true
ed61c43c7ab9b7ea26b890a00a08d2ed52ba3e47
kayazdan/exercises
/chapter-3/exercise-3-1.py
1,209
4.65625
5
# Programming Exercise 3-1 # # Program to display the name of a week day from its number. # This program prompts a user for the number (1 to 7) # and uses it to choose the name of a weekday # to display on the screen. # Variables to hold the day of the week and the name of the day. # Be sure to initialize the ...
true
ebd7d39e55aa5a0200a680629a31442a9795ba72
suman9868/Python-Code
/class.py
863
4.125
4
""" this is simple program in python for oops implementation submitted by : suman kumar date : 1 january 2017 time : 9 pm """ class Employee: emp_count = 0 def __init__(self, name, salary): self.name = name self.salary = salary Employee.emp_count = Employee.em...
false
77f27e01be7161901f28d68801d67c3d1e1e8c83
Nikola011s/portfolio
/work_with_menus.py
2,539
4.6875
5
#User enters n, and then n elements of the list #After entering elements of the list, show him options #1) Print the entire list #2) Add a new one to the list #3) Average odd from the whole list #4) The product of all elements that is divisible by 3 or by 4 #5) The largest element in the list #6) The sum...
true
ba564bd38231baac9bec825f4eaac669c00ff6a5
desingh9/PythonForBeginnersIntoCoding
/Day6_Only_Answers/Answer_Q2_If_Else.py
353
4.21875
4
#1.) Write a program to check whether a entered character is lowercase ( a to z ) or uppercase ( A to Z ). chr=(input("Enter Charactor:")) #A=chr(65,90) #for i in range(65,90) if (ord(chr) >=65) and (ord(chr)<=90): print("its a CAPITAL Letter") elif (ord(chr>=97) and ord(chr<=122)): print ("its a Small charect...
true
dea948a20c0c3e4ad252eb28988f2ae935e79046
desingh9/PythonForBeginnersIntoCoding
/Q4Mix_A1.py
776
4.28125
4
#1) Write a program to find All the missing numbers in a given integer array ? arr = [1, 2,5,,9,3,11,15] occurranceOfDigit=[] # finding max no so that , will create list will index till max no . max=arr[0] for no in arr: if no>max: max=no # adding all zeros [0] at all indexes till the maximum no in arra...
true
152920d0c317bb528f19c39d56dfead8bc0d9952
EvertonAlvesGomes/Curso-Python
/listas.py
1,525
4.5625
5
### listas.py ## Estudando listas em Python moto = ['Rodas','Motor','Relação','Freios'] # lista inicial moto.append('Embreagem') # adicona elemento ao final da lista moto.insert(2, 'Transmissão') # insere o elemento 'Transmissão' na posição 2, # sem substituir o ele...
false
be06a70e1eef93540bb5837ae43220ae29d7d7fa
veetarag/Data-Structures-and-Algorithms-in-Python
/Interview Questions/Rotate Image.py
592
4.125
4
def rotate(matrix): l = len(matrix) for row in matrix: print(row) print() # Transpose the Matrix for i in range(l): for j in range(i, l): matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j] for row in matrix: print(row) print() # Row Reverse ...
true
219d0100864e2e8b1777cb935a9b5e61ca52ef8a
osalpekar/RSA-Encrypter
/rsa.py
620
4.15625
4
''' Main function instantiates the Receiver class Calls encrypt and decrypt on user-inputted message ''' from receiver import Receiver def main(): message = raw_input("Enter a message you would like to encrypt/decrypt: ") receiver = Receiver() encrypted_message = receiver.encrypt(message) decrypted_me...
true
8858083bbd2a1ff2bd63cdde91462bc1efbeb4c7
HenriqueSilva29/infosatc-lp-avaliativo-06
/atividade 1.py
624
4.1875
4
#O método abs () retorna o valor absoluto do número fornecido. # Exemplo : # integer = -20 #print('Absolute value of -20 is:', abs(integer)) numero=0 lista = [2,4,6,8] def rotacionar(lista, numero): numero=int(input("Algum número positivo ou negativo :")) if numero >= 0: for i in range(n...
false
69da6775487c8b27702302afdc60c7ceef53f148
NoroffNIS/Code-2019-Week-5
/16 - Documenting_Practical.py
2,826
4.1875
4
class Car: def __init__(self): self.type = "" self.model = "" self.wheels = 4 self.doors = 3 self.seets = 5 def print_model(self): print("This car is a {model}: {type}, Wow!".format(model=self.model,type= self.type)) def print_space(self): print("The...
false
bd42b81d7d008bab809a365e99c4d410876b453c
rocky-recon/mycode
/farm_challange.py
704
4.5
4
#!/usr/bin/env python3 # Old Macdonald had a farm. Farm. farms = [{"name": "NE Farm", "agriculture": ["sheep", "cows", "pigs", "chickens", "llamas", "cats"]}, {"name": "W Farm", "agriculture": ["pigs", "chickens", "llamas"]}, {"name": "SE Farm", "agriculture": ["chickens", "carrots", "celery"]}] #...
false
c758366a22e1ab6095ada44d366394395b6797bf
MieMieSheep/Learn-Python-By-Example
/python3/2 - 数据类型与变量/1.py
1,684
4.375
4
#encoding:utf-8 #!/user/bin/python ''' 前面两行#encoding:utf-8 #!/user/bin/python 的作用: 第一行:#encoding:utf-8 用于声明当前文件编码,防止程序乱码出现 第二行: #!/user/bin/python 用于声明python文件 养成良好编码习惯,敲代码时习惯添加这两行注释。 ''' ''' 变量:仅仅使用字面意义上的常量很快就会引发烦恼—— 我们需要一种既可以储存信息 又可以对它们进行操作的方法。 这是为什么要引入 变量 。 变量就是我们想要的东西——它们的值可以变化, 即你...
false
db6b22e0d6c051b508dbdff4cab4babcbd867c6e
ua-ants/webacad_python
/lesson01_old/hw/script3.py
485
4.15625
4
while True: print('To quit program enter "q"') val1 = input('Enter a first number: ') if val1 == 'q': break val2 = input('Enter a second number: ') if val2 == 'q': break try: val1 = int(val1) val2 = int(val2) except ValueError: print('one of entere...
true
265a3d593c820ebc354bcd04b15da5489ba51f6d
ua-ants/webacad_python
/lesson02_old/hw/script3.py
336
4.3125
4
# given array: arr = [1, 3, 'a', 5, 5, 3, 'a', 5, 3, 'str01', 6, 3, 'str01', 1] # task 3. Удалить в массиве первый и последний элементы. def remove_last_and_first(arr): del arr[0] del arr[-1] return arr print("Array before: ", arr) print("Array after: ", remove_last_and_first(arr))
false
23b0bf7288672ad81c27e25daec3a6afe4ca707f
ThallesTorres/Curso_Em_Video_Python
/Curso_Em_Video_Python/ex096.py
654
4.25
4
# Ex: 096 - Faça um programa que tenha uma função chamada área(), que receba # as dimensões de um terreno retangular(largura e comprimento) e mostre a # área do terreno. def area(a, b): print("\n--Dados finais:") print(f"Área de um terreno {a}x{b} é de {a * b}m².") print(''' -=-=-=-=-=-=-=-=-=-=-=-=-=-...
false
1814f6fbdbf5a3c28a73efa51323d42a0a3e2fe9
ThallesTorres/Curso_Em_Video_Python
/Curso_Em_Video_Python/ex095.py
2,045
4.1875
4
# Ex: 095 - Aprimore o DESAFIO 093 para que ele funcione com vários jogadores, # incluindo um sistema de visualização de detalhes do aproveitamento de cada jogador. print(''' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- --Seja bem-vindo! --Exercício 095 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ''') jogadores = list() resp = 's'...
false
84d6bfe4e4fe89f4a08d2e8ca73631d950c86fcf
KarthickM89/basicPython
/loops.py
236
4.28125
4
#for i in [0, 1, 2, 3, 4, 5]: # print(i) #for i in range(6): # print(i) # Defining names names = ["karthick", "kaviya", "kavinilaa"] name1 = "kannan" # Looping and Printing for name in names: print(name) for n in name1: print(n)
false
96b4061196c3dc36646c9f3b88a004890db47edf
KostaSav/Tic-Tac-Toe
/console.py
1,231
4.1875
4
########## Imports ########## import config # Initialize the Game Board and print it in console board = [ [" ", "|", " ", "|", " "], ["-", "+", "-", "+", "-"], [" ", "|", " ", "|", " "], ["-", "+", "-", "+", "-"], [" ", "|", " ", "|", " "], ] ## Print the Game Board in console def print_board(): ...
true
c03e3f76b690c87b8939f726faeac5c0d6107b93
Anwar91-TechKnow/PythonPratice-Set2
/Swipe two numbers.py
1,648
4.4375
4
# ANWAR SHAIKH # Python program set2/001 # Title: Swipe two Numbers '''This is python progaramm where i am doing swapping of two number using two approches. 1. with hardcorded values 2. Values taken from user also in this i have added how to use temporary variable as well as without ...
true
e1c4f9c2034a1fa3f8f4535e68f394af0e6f2d7d
paulo-sk/python-crash-course-2019
/c6_dictionaries/loop_dictionaries.py
943
4.3125
4
""" vc pode dar loop em dicionarios de 3 formas: loop nas keys: loop nos values: loop nos key , values: """ favorite_languages = { 'jen': 'python', 'sarah': 'c', 'edward': 'ruby', 'phil': 'python', } # loop nas keys; for name in favorite_languages.keys(): print(name.title()) # l...
false
a5dcfbb508c112b3184f4c65c0425573b4c2c043
paulo-sk/python-crash-course-2019
/c10_files_and_exceptions/exceptions/division_calculator.py
805
4.28125
4
# programa tenta fazer o que vc quer, se nao de, ele manda uma mensagem de erro mais amigavel # e o programa continua rodando try: print(5/0) except ZeroDivisionError: print("You can't divide by zero.") print("\n-------------------------------------------------------") # outro exemplo print("\nGive me 2 numb...
false
87d19ef751bdb5bd5e305d8a18c634ebf08c39a8
VladSquared/SoftUni---Programming-Basics-with-Python
/01. Problem.py
805
4.125
4
email = input() while True: cmd = input() if cmd == "Complete": break elif "Make Upper" in cmd: email = email.upper() print(email) elif "Make Lower" in cmd: email = email.lower() print(email) elif "GetDomain" in cmd: count = int(cmd.split...
false
cb49784d1f95205fb3152e9e3ff05f2bc585ff17
rakeshsingh/my-euler
/euler/utils.py
1,623
4.25
4
#!/usr/bin/python import math from math import gcd def my_gcd(a, b): ''' returns: str gcd for two given numbers ''' if a == b or b == 0: return a elif a > b: return gcd(a-b, b) else: return gcd(b-a, a) def lcm(a, b): '''''' return a * b // gcd(a, b) def ...
false
981c2e7984813e752f26a37f85ca2bec74470b40
mon0theist/Automate-The-Boring-Stuff
/Chapter 04/commaCode2.py
1,183
4.375
4
# Ch 4 Practice Project - Comma Code # second attempt # # Say you have a list value like this: # spam = ['apples', 'bananas', 'tofu', 'cats'] # # Write a function that takes a list value as an argument and returns a string # with all the items separated by a comma and a space, with and inserted before # the last item. ...
true
3c2f7e0a16640fdb7e72795f10824fcce5370199
mon0theist/Automate-The-Boring-Stuff
/Chapter 07/strongPassword.py
1,249
4.375
4
#! /usr/bin/python3 # ATBS Chapter 7 Practice Project # Strong Password Detection # Write a function that uses regular expressions to make sure the password # string it is passed is strong. # A strong password has: # at least 8 chars - .{8,} # both uppercase and lowercase chars - [a-zA-Z] # test that BOTH exist, no...
true
f950540f7fd7e20c033f7b562a41156f5c43a1f2
ZYSLLZYSLL/Python
/代码/code/day06/Demo07_列表常用操作_修改_复制.py
1,104
4.1875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2021/1/11 15:35 # @Author : ZY # @File : Demo07_列表常用操作_修改_复制.py # @Project : code # 修改指定位置的数据 # a = [1, [1, 2, 3], 1.23, 'abc'] # a[1] = '周宇' # print(a) # 逆置:reverse() # a = [1, [1, 2, 3], 1.23, 'abc'] # a.reverse() # print(a) # # print(a[::-1]) # 排序 sort() 默认升序 #...
false
cf1e3aa630ec34233b352168bd4b0818565883cb
sofianguy/skills-dictionaries
/test-find-common-items.py
1,040
4.5
4
def find_common_items(list1, list2): """Produce the set of common items in two lists. Given two lists, return a list of the common items shared between the lists. IMPORTANT: you may not not 'if ___ in ___' or the method 'index'. For example: >>> sorted(find_common_items([1, 2, 3, 4], [1,...
true
bf2a05fff10cf1fa6a2d0e5591da851b22069a78
adamny14/LoadTest
/test/as2/p4.py
219
4.125
4
#------------------------------ # Adam Hussain # print a square of stars for n #------------------------------ n = input("Enter number n: "); counter = 1; while counter <= n: print("*"*counter); counter = counter +1;
false
d00c727795694f3d0386699e15afeb5cb4484f89
VictoriaAlvess/LP-Python
/exercicio5.py
565
4.40625
4
''' 5) Escreva um programa que receba três números quaisquer e apresente: a) a soma dos quadrados dos três números; b) o quadrado da soma dos três números.''' import math print("Digite o primeiro número: ") num1 = float(input()) print("Digite o segundo número: ") num2 = float(input()) print("Digite o terceiro número:...
false
d77e3f0c1b69178d36d43f767e4e12aed8a821da
Laishuxin/python
/2.thread/3.协程/6.create_generator_send启动.py
742
4.3125
4
# 生成器是特殊的迭代器 # 生成器可以让一个函数暂停,想执行的时候执行 def fibonacci(length): """创建一个financci的生成器""" a, b = 0, 1 current_num = 0 while current_num < length: # 函数中由yield 则这个不是简单的函数,而是一个生成器模板 print("111") ret = yield a print("222") print(">>>>ret>>>>", ret) a, ...
false
fbb4ce33a955eec2036211a7421950f027330a0b
l3ouu4n9/LeetCode
/algorithms/7. Reverse Integer.py
860
4.125
4
''' Given a 32-bit signed integer, reverse digits of an integer. E.g. Input: 123 Output: 321 Input: -123 Output: -321 Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpose of t...
true
4f85b8be417d4253520781c0f99e31af282d60b7
sjtrimble/pythonCardGame
/cardgame.py
2,811
4.21875
4
# basic card game for Coding Dojo Python OOP module # San Jose, CA # 2016-12-06 import random # to be used below in the Deck class function # Creating Card Class class Card(object): def __init__(self, value, suit): self.value = value self.suit = suit def show(self): print self.value +...
true
6e2fd2cc56821e6aeb9ac0beb5173a9d57c03f67
ericd9799/PythonPractice
/year100.py
421
4.125
4
#! /usr/bin/python3 import datetime now = datetime.datetime.now() year = now.year name = input("Please enter your name: ") age = int(input("Please enter your age: ")) yearsToHundred = 100 - age turnHundred = int(year) + yearsToHundred message = name + " will turn 100 in the year "+ str(turnHundred) print(message)...
true
1b6d711b5078871fca2de4fcf0a12fc0989f96e4
ericd9799/PythonPractice
/modCheck.py
497
4.125
4
#! /usr/bin/python3 modCheck = int(input("Please enter an integer: ")) if (modCheck % 4) == 0: print(str(modCheck) + " is a multiple of 4") elif (modCheck % 2) == 0: print(str(modCheck) + " is even") elif (modCheck % 2) != 0: print(str(modCheck) + " is odd") num, check = input("Enter 2 numbers:").split() num =...
true
68097abbf240ee911dfd9cf5d8b1cc60dedb6bf8
EraSilv/day2
/day5_6_7/practice.py
2,677
4.3125
4
# calculation_to_seconds = 24 * 60 * 60 calculation_to_hours = 24 # print(calculation_to_seconds) name_of_unit = "hours" #VERSION 1: # print(f"20 days are {20 * 24 * 60 * 60} seconds") # print(f"35 days are {35 * 24 * 60 * 60} seconds") # print(f"50 days are {50 * 24 * 60 * 60} seconds") # print(f"110 days are {110...
false
4e8737d284c7cf01dea8dd82917e1fc787216219
EraSilv/day2
/day5_6_7/day7.py
879
4.125
4
# password = (input('Enter ur password:')) # if len(password) >= 8 and 8 > 0: # print('Correct! ') # print('Next----->:') # else: # print('Password must be more than 8!:') # print('Try again!') # print('Create a new account ') # login = input('login:') # email = input('Your e-mail:') # print('Choos...
true
76f09844a2ee8abc1ebb5d7be2432a9f7b568a93
Aayushi-Mittal/Udayan-Coding-BootCamp
/session3/Programs-s3.py
648
4.3125
4
""" a = int(input("Enter your value of a: ") ) b = int(input("Enter your value of b: ") ) print("Adding a and b") print(a+b) print("Subtract a and b") print(a-b) print("Multiply a and b") print(a*b) print("Divide a and b") print(a/b) print("Remainder left after dividing a and b") print(a%b) # Program 2 name=input("Ent...
false
3253b6843f4edd1047c567edc5a1d1973ead4b00
watson1227/Python-Beginner-Tutorials-YouTube-
/Funtions In Python.py
567
4.21875
4
# Functions In Python # Like in mathematics, where a function takes an argument and produces a result, it # does so in Python as well # The general form of a Python function is: # def function_name(arguments): # {lines telling the function what to do to produce the result} # return result # lets consid...
true
de12c3cb06a024c01510f0cf70e76721a80d506e
ytlty/coding_problems
/fibonacci_modified.py
1,049
4.125
4
''' A series is defined in the following manner: Given the nth and (n+1)th terms, the (n+2)th can be computed by the following relation Tn+2 = (Tn+1)2 + Tn So, if the first two terms of the series are 0 and 1: the third term = 12 + 0 = 1 fourth term = 12 + 1 = 2 fifth term = 22 + 1 = 5 ... And so on. Given thre...
true
f69783e7a620ca692a6b6213f16ef06b491b35e5
lily-liu-17/ICS3U-Assignment-7-Python-Concatenates
/concatenates.py
883
4.3125
4
#!/usr/bin/env python3 # Created by: Lily Liu # Created on: Oct 2021 # This program concatenates def concatenate(first_things, second_things): # this function concatenate two lists concatenated_list = [] # process for element in first_things: concatenated_list.append(element) for elemen...
true
2015152c0424d7b45235cefa678ea2cb90523132
ChiselD/guess-my-number
/app.py
401
4.125
4
import random secret_number = random.randint(1,101) guess = int(input("Guess what number I'm thinking of (between 1 and 100): ")) while guess != secret_number: if guess > secret_number: guess = int(input("Too high! Guess again: ")) if guess < secret_number: guess = int(input("Too low! Guess again: ")) if gues...
true
ae9e8ccfee70ada5d6f60a9e8a16f3c2204078ca
OmarSamehMahmoud/Python_Projects
/Pyramids/pyramids.py
381
4.15625
4
height = input("Please enter pyramid Hieght: ") height = int(height) row = 0 while row < height: NumOfSpace = height - row - 1 NumOfStars = ((row + 1) * 2) - 1 string = "" #Step 1: Get the spaces i = 0 while i < NumOfSpace: string = string + " " i += 1 #step 2: Get the stars i = 0 while i < NumOfStars...
true
b746c7e3d271187b42765b9bf9e748e79ba29eca
fortunesd/PYTHON-TUTORIAL
/loops.py
792
4.40625
4
# A for loop is used for iterating over a sequence (that is either a list, a tuple, a set, or a string). students = ['fortunes', 'abdul', 'obinaka', 'amos', 'ibrahim', 'zaniab'] # simple for loop for student in students: print(f'i am: {student}') #break for student in students: if student == 'odinaka': ...
true
6d3f673aad4128477625d3823e3cf8688fc89f2f
CollinNatterstad/RandomPasswordGenerator
/PasswordGenerator.py
814
4.15625
4
def main(): #importing necessary libraries. import random, string #getting user criteria for password length password_length = int(input("How many characters would you like your password to have? ")) #creating an empty list to store the password inside. password = [] ...
true
2b33a5ed96a8a8c320432581d71f2c46b2a3998a
laufzeitfehlernet/Learning_Python
/math/collatz.py
305
4.21875
4
### To calculate the Collatz conjecture start = int(input("Enter a integer to start the madness: ")) loop = 1 print(start) while start > 1: if (start % 2) == 0: start = int(start / 2) else: start = start * 3 + 1 loop+=1 print(start) print("It was in total", loop, "loops it it ends!")
true
dfa330f673a2b85151b1a06ca63c3c78214c722e
joq0033/ass_3_python
/with_design_pattern/abstract_factory.py
2,239
4.25
4
from abc import ABC, abstractmethod from PickleMaker import * from shelve import * class AbstractSerializerFactory(ABC): """ The Abstract Factory interface declares a set of methods that return different abstract products. These products are called a family and are related by a hi...
true
1af1818dfe2bfb1bab321c87786ab356f7cff2d4
rahulrsr/pythonStringManipulation
/reverse_sentence.py
241
4.25
4
def reverse_sentence(statement): stm=statement.split() rev_stm=stm[::-1] rev_stm=' '.join(rev_stm) return rev_stm if __name__ == '__main__': m=input("Enter the sentence to be reversed: ") print(reverse_sentence(m))
true
590419d3a0fa5cbf2b1d907359a22a0aa7fe92b5
kopelek/pycalc
/pycalc/stack.py
837
4.1875
4
#!/usr/bin/python3 class Stack(object): """ Implementation of the stack structure. """ def __init__(self): self._items = [] def clean(self): """ Removes all items. """ self._items = [] def push(self, item): """ Adds given item at the t...
true
289d459d9e0dda101f443edaa9bf65d2985b4949
YaraBader/python-applecation
/Ryans+Notes+Coding+Exercise+16+Calculate+a+Factorial.py
604
4.1875
4
''' Create a Factorial To solve this problem: 1. Create a function that will find the factorial for a value using a recursive function. Factorials are calculated as such 3! = 3 * 2 * 1 2. Expected Output Factorial of 4 = 24 Factorial at its recursive form is: X! = X * (X-1)! ''' # define the factorial function def fac...
true
84e848c7b3f7cd20142ce6326a8a5131b1ecacad
YaraBader/python-applecation
/Ryans+Notes+Coding+Exercise+8+Print+a+Christmas+Tree.py
1,956
4.34375
4
''' To solve this problem: Don't use the input function in this code 1. Assign a value of 5 to the variable tree_height 2. Print a tree like you saw in the video with 4 rows and a stump on the bottom TIP 1 You should use a while loop and 3 for loops. TIP 2 I know that this is the number of spaces and hashes for the tre...
true
e3c8b5241b67c829edc0b1ff4da04dd6e764a89a
jdurbin/sandbox
/python/basics/scripts/lists.py
738
4.15625
4
#!/usr/bin/env python import numpy as np a = [1,2,3,4] print a print a[2:5] # omitted in a slice assumed to have extreme value print a[:3] # a[:] is just a, the entire list print "a[:-1]",a[:-1] print "a[:-2]",a[:-2] #numpy matrix: # Note that [,] are lists, but (,) are tuples. # Lists are mutable, tuples are ...
false
20d2c16838f90918e89bfcf67d7c1f9210d6d39a
vaishu8747/Practise-Ass1
/1.py
231
4.34375
4
def longestWordLength(string): length=0 for word in string.split(): if(len(word)>length): length=len(word) return length string="I am an intern at geeksforgeeks" print(longestWordLength(string))
true
7462b7bb66c8da8ec90645eb00a654c316707b28
matheus-hoy/jogoForca
/jogo_da_forca.py
1,154
4.1875
4
print('Bem Vindo ao JOGO DA FORCA XD') print('Você tem 6 chances') print() palavra_secreta = 'perfume' digitado = [] chances = 6 while True: if chances <= 0: print('YOU LOSE') break letra = input('Digite uma letra: ') if len(letra) > 1: print('Digite apenas uma letra Mal...
false
894abe59b869794b4a35903f04a750b1f9ee5788
brianbrake/Python
/ComputePay.py
834
4.3125
4
# Write a program to prompt the user for hours and rate per hour using raw_input to compute gross pay # Award time-and-a-half for the hourly rate for all hours worked above 40 hours # Put the logic to do the computation of time-and-a-half in a function called computepay() # Use 45 hours and a rate of 10.50 per hour to ...
true
74c1a177115b9dd2e3b519e0581e1605814ef499
oschre7741/my-first-python-programs
/geometry.py
1,285
4.1875
4
# This program contains functions that evaluate formulas used in geometry. # # Olivia Schreiner # August 30, 2017 import math def triangle_area(b,h): a = (1/2) * b * h return a def circle_area(r): a = math.pi * r**2 return a def parallelogram_area(b,h): a = b * h return a ...
false
6168ffa995d236e3882954d9057582a5c130763a
ghinks/epl-py-data-wrangler
/src/parsers/reader/reader.py
2,129
4.15625
4
import re import datetime class Reader: fileName = "" def __init__(self, fileName): self.fileName = fileName def convertTeamName(self, name): """convert string to upper case and strip spaces Take the given team name remove whitespace and convert to uppercase """ ...
true
3e0567d81aa20bf04a43d2959ae3fff8b71501ec
biam05/FPRO_MIEIC
/exercicios/RE05 Functions/sumNumbers.py
955
4.34375
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 24 11:47:09 2018 @author: biam05 """ # # DESCRIPTION of exercise 2: # # Write a Python function sum_numbers(n) that returns the sum of all positive # integers up to and including n. # # For example: sum_numbers(10) returns the value 55 (1+2+3+. . . +10) # # Do N...
true