blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
bc17e2a5436a35f6c2036c929bbe1ca4d1706839
colinbazzano/learning-python
/src/regex/main.py
604
4.28125
4
import re string = 'search inside of this text, please!' print('search' in string) # we are looking for the word 'this' in the variable string a = re.search('this', string) # will show you where it began counted via index print(a.start()) # returns what you wanted if available print(a.group()) """NoneType if you...
true
01a1deaacd22b9a1bb7664748887a7abb2db59aa
colinbazzano/learning-python
/src/fileio/inputoutput.py
499
4.15625
4
# File I/O or, File Input/Output # Below, we are assigning a variable to the path of the txt file we want to read. my_file = open('src/fileio/write.txt') # here we are just using the read method and printing it print(my_file.read()) # .seek(0) is another way to move the cursor # .readline() you can continue to call t...
true
81e58f79d8e6c77e374487444531d9e98e3c2e4c
mike006322/ProjectEuler
/Solutions/PE002_even_fibonacci_numbers/python/even_fibonacci_numbers.py
1,124
4.15625
4
#!/bin/python3 # https://www.hackerrank.com/contests/projecteuler/challenges/euler002 from functools import lru_cache @lru_cache(maxsize=None) def fib(n): """ returns the nth fibonacci number """ if n == 1: return 1 if n == 2: return 2 if n > 2: return fib(n - 1) + fi...
false
07cd1b50d39d25a2cb18c2b4f36110c80b192691
rishabhgautam/LPTHW_mynotes
/ex13-studydrills3.py
303
4.21875
4
# ex13: Parameters, Unpacking, Variables # Combine input with argv to make a script that gets more input from a user. from sys import argv script, first_name, last_name = argv middle_name = input("What's your middle name?") print("Your full name is %s %s %s." % (first_name, middle_name, last_name))
true
da50855b9c02c62100ae1870849b03c545afc8e1
rishabhgautam/LPTHW_mynotes
/ex20-studydrills.py
1,962
4.28125
4
# ex20: Functions and Files # Import argv variables from the sys module from sys import argv # Assign the first and the second arguments to the two variables script, input_file = argv # Define a function called print_call to print the whole contents of a # file, with one file object as formal parameter def print_all...
true
bd5993726157d5b616c171c1bd1c3527996b5ed7
ramanancp/python-test
/mytimedelta.py
826
4.125
4
from datetime import date from datetime import time from datetime import timedelta from datetime import datetime print(timedelta(days=365, hours=5, minutes=1)) now = datetime.now() print("Today is " + str(now)) #print today's date one year from now print("Today's date 1 year from now " + str(now + timedelta(days=365...
false
d8e39d1e7c7561253203f68afcc1f4dfa7d7f5e7
xiemingzhi/pythonproject
/lang/arrays.py
1,365
4.375
4
#List is a collection which is ordered and changeable. Allows duplicate members. # in python they are called lists a = [1, 2, 3, 4, 5] def printArr(arr): for x in arr: print(x) printArr(a) #Dictionary is a collection which is unordered, changeable and indexed. No duplicate members. # in python t...
true
477ed45fd0d6d278a87f33209ad99b30e7732c65
AbhinavUtkarsh/Cracking-The-Coding-Interview
/Solutions to Arrays and Strings/rotate matrix.py
1,787
4.34375
4
def rotate(matrix): N=len(matrix) for layer in range(N//2): first , last = layer, N - layer - 1 for i in range(first, last): top = matrix[layer][i] matrix[layer][i] = matrix[-i-1][layer] matrix[-i-1][layer] = matrix[-layer-1][-i-1] matrix[-l...
true
f98cdb5ef5a5a9af2a5f6304b85a81750c5a0be6
MojoZZ/Python
/pwork/11.循环.py
924
4.25
4
# 循环语句 while和for # while 条件表达式 : # 代码块 # else : # i = 0 # while i < 5 : # print('i=', i) # i += 1 # else : # # 在条件表达式为False时执行 # print('结束循环') #循环的嵌套 # i = 0 # while i < 5 : # j = 0 # while j < 5 : # print('*', end='') # j += 1 # print() # i += 1 # i = 0 # while i < 5 : # j = 0 # while j < i + 1 :...
false
817b9baccfd33d2e7c06126fbd97244545fdf29d
MojoZZ/Python
/pwork/07.类型检查.py
1,132
4.21875
4
#通过类型检查,可以检查数值(变量)的类型 #type() 函数,用来检查值得类型 a = 123 b = '123' print(type(a)) #<class 'int'> print(type(b)) #<class 'str'> print(type(0.152)) #<class 'float'> print(type(True)) #<class 'bool'> print(type(None)) #<class 'NoneType'> #类型转换 将一个类型的对象转换为其他对象 #类型转换不是改变对象本身的类型,而是根据当前对象的值创建一个新对象 #int() float() str() bool()...
false
410d4d42ae44f344665057493173c13ad2fac4be
panchaldhruvin99/forsk2019
/Day_09/database1.py
1,193
4.15625
4
""" Code Challenge 1 Write a python code to insert records to a mongo/sqlite/MySQL database named db_University for 10 students with fields like Student_Name, Student_Age, Student_Roll_no, Student_Branch. """ import sqlite3 from pandas import DataFrame conn = sqlite3.connect("db_university.db") c=conn.cursor() c...
false
a365034c83e81045f609c720c145b23fcca28489
angeldeng/LearnPython
/LearnPython/data structure/using_tuple.py
2,068
4.28125
4
zoo=('python','elephant','penguin') #小括号可选 print('Number of cages in the new zoo is',len(zoo)) new_zoo=('monkey','camel',zoo) print('Number of cages in the new zoo is',len(new_zoo)) print('All animals in new zoo are', new_zoo) print('Animals brought from old zoo are', new_zoo[2]) print('Last animal brought from old...
false
ba2fe09108179858452060b08d2eba2bd3b485c6
dem27va/Dp-P026
/Homework 2020-06-23/HW06-23_Task_4.py
1,363
4.28125
4
#Пользователь вводит целое число. #Определить является ли чесло однозначным, двузначным, трехзначным или содержит больше символов inputNumber = input('Введите целое число: ') #Проверяем положительно или отрицательное введено число if inputNumber[0] == '-': digitsCount = len(inputNumber) - 1 sign = 'от...
false
a64c82bd01eac0b1114b23a9a3a88d0fe593e26e
Birdboy821/python
/natural.py
399
4.1875
4
#natural.py #christopher amell 1/3/19 #find the sum and sum of the cubed of the natural #numbers up to one that is imputed by the user def sumN(n): summ = 0 while(n>0): summ=summ+n n=n-1 print(summ) def sumNCubes(n): summ = 0 while(n>0): summ=summ+n**3 n=n-1 print(summ) def ...
true
384061158790da10d7eb6975a80044e9bfb89a0b
Birdboy821/python
/sphere.py
325
4.25
4
#sphere.py #christopher amell 1/3/19 #a program that calculate a spheres area and volume def sphereArea(radius): a = 4 * 3.14 * radius ** 2 print(a) def sphereVolume(radius): v = 4 / 3 * 3.14 * radius ** 3 print(v) def main(): r = eval(input('what is your radius: ')) sphereArea(r) sphereVolum...
false
337b757021637c1ea01c47410999d9f0d4ff125c
Shiv2157k/leet_code
/math_and_srings/square_root_x.py
1,738
4.125
4
class SquareRoot: def get_square_root_(self, val: int) -> int: """ Approach: Pocket Calculator input: val, output: res Formulae: left-------------right res^2 <= val < (res + 1) :param val: :return: """ from math import e, log ...
false
b7aaa56c625d4c68ce805e97b891a600313e56c3
Shiv2157k/leet_code
/revisited__2021/arrays/container_with_most_water.py
759
4.125
4
from typing import List class WaterContainer: def with_most_water(self, height: List[int]) -> int: """ Approach: Two Pointers Time Complexity: O(N) Space Complexity: O(1) :param height: :return: """ left, right = 0, len(height) - 1 area = 0 ...
true
1d77a643e819600c1b626c78b53d8bc489f0ffa6
Shiv2157k/leet_code
/revisited/math_and_strings/math/plaindrome_number.py
759
4.1875
4
class Number: def is_palindrome(self, num: int) -> bool: """ Approach: Revert the half Time Complexity: O(log base 10 N) Space Complexity: O(1) :param num: :return: """ # base case if num < 0 or (num % 10 == 0 and num != 0): retur...
false
46780f22b185fa8b881a63bb12a4c78e9e993e7b
Shiv2157k/leet_code
/revisited/trees/same_tree.py
1,537
4.125
4
from collections import deque class TreeNode: def __init__(self, val: int, left: int=None, right: int=None): self.val = val self.left = left self.right = right class BinaryTree: def is_same_tree_(self, t1: "TreeNode", t2: "TreeNode") -> bool: """ Approach: Recursion ...
false
5882a8db15e46c6cfcb1e523e8f111e698b16789
Shiv2157k/leet_code
/revisited__2021/linked_list/swap_nodes_in_pairs.py
1,811
4.21875
4
class ListNode: def __init__(self, val: int, next: int = None): self.val = val self.next = next class LinkedList: def swap_nodes_in_pairs_(self, head: "ListNode"): """ Approach: Iterative Time Complexity: O(N) Space Complexity: O(1) :param head: ...
true
79d35a93969f21c3087a68c0a5326d6f7055b346
Shiv2157k/leet_code
/goldman_sachs/implement_trie_prefix_tree.py
1,549
4.21875
4
class TrieNode: def __init__(self): self.child_nodes = {} self.end = False class Trie: def __init__(self): self.root = TrieNode() def insert(self, word: str): """ Time Complexity: O(M) Space Complexity: O(M) :param word: :return: "...
false
df117ff3f1c3411a5f9a6bc55d364c40727fb8cc
Shiv2157k/leet_code
/expedia/merge_two_sorted_list.py
764
4.125
4
class ListNode: def __init__(self, val: int, next: int = None): self.val = val self.next = next class LinkedList: def merge_two_sorted_list(self, l1: "ListNode", l2: "ListNode") -> "ListNode": """ Approach: Iterative Time Complexity: O(M + N) Space Complexity...
false
442f234a5a5e4a0fedf9bb5a8c89fcafcefab587
Shiv2157k/leet_code
/amazon/greedy_or_two_pointers/queue_reconstruction_by_height.py
656
4.25
4
from typing import List class People: def queue_reconstruction_by_height(self, people: List[List[int]]) -> List[int]: """ Approach: Greedy Time Complexity: O(N^2) - O(N log N) Sorting O(K) for inserting Space Complexity: O(N) :param people: :return: """ ...
false
074c11ad90d77eb8641b6251f4065bc2c87c2855
Shiv2157k/leet_code
/goldman_sachs/shortest_word_distance.py
994
4.125
4
from typing import List class Words: def shortest_word_distance(self, words: List[str], word1: str, word2: str) -> int: """ Approach: One Pass Time Complexity: O(N * M) Space Complexity: O(1) :param words: :param word1: :param word2: :return: ...
true
1ed7487081e736f8b4732b114799d1b37bf59dee
obedansah/Smart_Game
/Smart_Game.py
1,315
4.1875
4
#Welcoming the Users name = input("Enter your name") print("Hello " +name,"Let's Play SmartGame") print("So what's your first guess") #Guess word word = "Entertainment" #creates an variable with an empty value guesses = " " #determine the number of runs runs = 15 while runs>0: # Create a while...
true
cba91cabb82130749a4ca5026a76a949e0cd63b9
mastansberry/LeftOvers
/lotteryAK.py
1,573
4.125
4
''' matches(ticket, winners) reports how well a lottery ticket did test_matches(matches) reports whether a matches() function works as assigned. ''' def matches(ticket, winner): ''' returns the number of numbers that are in both ticket and winner ticket and winner are each a list of five unique in...
true
07a9daea73195e3c57c8f793a15fe10a80eb561c
Setubal18/Introducao-as-AGs
/funcao1.py
547
4.15625
4
def converteBinarioReal(string): if(len(string)==8): return float(f'{int(string[:2], 2)}.{int(string[3::], 2)}') else: raise Exception('Número menor ou maior que o permitido') #recebe uma string com oito valores 'zero' ou 'um' sendo os dois primeiros #equivalentes à parte inteira e os s...
false
c239d4aedead6d00d326929403ba5ef36b5edbab
Varshitha019/Daily-Online-Coding
/25-06-2020/Program1.py
207
4.125
4
1. Write a python program for cube sum of first n natural numbers. def sumOfSeries(n): sum = 0 for i in range(1, n+1): sum +=i*i*i return sum n = int(input("Enter number:")) print(sumOfSeries(n))
true
b4685f71740233957125bbcf285279612d6e7669
Varshitha019/Daily-Online-Coding
/28-5-2020/Program2.py
611
4.28125
4
2. .Write a python program to find digital root of a number. Description: A digital root is the recursive sum of all the digits in a number. Given n, take the sum of the digits of n. If that value has more than one digit, continue reducing in this way until a single-digit number is produced. This is only applicable to...
true
e77acb53bf3bc9c86e18dc2b72ac6c86187b0ed0
gislig/hr2018algorithmAssignment1
/project2.py
1,166
4.28125
4
# 1. Checks if the first three numbers are entered # 2. If the numbers are above 3 then start sequencing # 3. Sums up the first, second and third number into a variable next_num # 4. Each step sets the last number to the next bellow # 5. Finally it prints out the next_num n = int(input("Enter the length of the sequen...
true
c99cf490702d49b88dfd18cdb8592546a46d17d0
Nate-Rod/PythonLearning
/Problem_003.py
1,319
4.4375
4
''' Problem text: Time for some fake graphics! Let’s say we want to draw game boards that look like this: --- --- --- | | | | --- --- --- | | | | --- --- --- | | | | --- --- --- This one is 3x3 (like in tic tac toe). Obviously, they come in many other sizes (8x8 for chess, 19x19 for Go,...
true
a18192ce83389931a90328b9b2b7fa21c282fe27
BravoCiao/PY103_Bravo
/ex11.py
1,921
4.375
4
print "How old are you?", age = raw_input("24") # i've tried to delete the comma and run the programme, # then the age shows,on the second line, the comma # is a prompt for data to show on the same line. # based on official handbook, raw_input() is written to standard output # without a trailing newline. The func...
true
db546942befa0cb9745931a986ff2f75ee008c53
linusqzdeng/python-snippets
/exercises/string_lists.py
867
4.34375
4
'''Thsi program asks the user for a string and print out whether this string is a palindrome or not (a palindrome is a string that reads the same forwards and backwards) ''' # ask for a word something = input('Give me a word: ') # convert the given word into a list original_list = list(something) print(orig...
true
8d085b8f331fad09583bc0e31e40e961ea03e833
linusqzdeng/python-snippets
/exercises/guessing_game1.py
1,102
4.3125
4
''' This program generates a random number between 1 to 9 (including 1 and 9) and asks the user to guess the number, then tell them whether they guessed too low, too high, or exactly right. ''' from random import randint num = randint(1, 9) attempt = 1 while True: guess = int(input('Guess what number ...
true
4501b4ba1f9e9b31875c063f1c21e36ac58475e2
zerynth/core-zerynth-stdlib
/examples/Interrupts/main.py
1,442
4.40625
4
################################################################################ # Interrupt Basics # # Created by Zerynth Team 2015 CC # Authors: G. Baldi, D. Mazzei ################################################################################ import streams # create a serial port stream with default parameters s...
true
981052ef2e22904af49c578dc06edab1df4834ea
SiddharthSampath/LeetCodeMayChallenge
/problem16.py
1,707
4.25
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. Example 1: Input: 1->2->3->4->...
true
20f31fa81f7e3ac014987d042e32ac4f0d9e2cc9
tonycmooz/Pythonic
/nested_function.py
277
4.15625
4
# An example of a nested function def outer(): x = 1 def inner(): print x # Python looks for a local variable in the inner inner() # then looks in the enclosing, outer outer() # Python looks in the scope of outer first # and finds a local variable named inner
true
94086d952013023c802590a289e042bcdaedc44f
iffishells/Regular-Expression-python
/Split-with-regular-expressions.py
908
4.71875
5
####################################### #### Split with regular expressions ### ###################################### import re # Let's see how we can split with the re syntax. This should look similar to how # you used the split() method with strings. split_term="@" phrase = "what is the domain name of someone d...
true
743956f40ff4a5139d5fb2a6ce64688642238d39
ai230/Python
/draw_shape.py
504
4.125
4
import turtle def draw_square(): # Create window window = turtle.Screen() window.bgcolor("red") #Create object fig = turtle.Turtle() fig.shape("circle") fig.color("white") fig.speed(5) fig.forward(200) fig.right(90) fig.forward(200) fig.right(90) fig.forward(200) ...
true
6263594794ac44dd19a4a81f202f5cc1fb63049b
1devops/fun
/project 1.py
318
4.40625
4
"""If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.""" def proj1(num): j = 0 for i in range(0, num): if i % 3 == 0 or i % 5 == 0: j = i + j print "final", j proj1(1000)
true
376ff13289b1b622db69e6591494d2d59a3256a8
bensoho/Python
/Basic_Python/Chapter03/01_data_structure.py
2,679
4.15625
4
#Python 数据结构 # 列表 # Python中列表是可变的,这是它区别于字符串和元组的最重要的特点,一句话概括即:列表可以修改,而字符串和元组不能。 # 以下是 Python 中列表的方法: # 方法 描述 # list.append(x) 把一个元素添加到列表的结尾,相当于 a[len(a):] = [x]。 # list.extend(L) 通过添加指定列表的所有元素来扩充列表,相当于 a[len(a):] = L。 # list.insert(i, x) 在指定位置插入一个元素。第一个参数是准备插入到其前面的那个元素的索引,例如 a.insert(0, x) 会插入到整个列表之前,而...
false
d7197fb18c63b4718cd3f24687925d0cf8e44029
rishav-ish/MyCertificates
/reverseStack_recu.py
398
4.125
4
#Reverse Stack using recursion def insert(stack,temp): if not stack: stack.append(temp) return temp2 = stack.pop() insert(stack,temp) stack.append(temp2) def reverse(stack): if not stack: return temp = stack.pop() reverse(stack) in...
true
5480ea016f829075ef8d69d2905ff2ba8966189d
kostpasha/Homework-SP
/lab1/Zadanie_6.py
421
4.15625
4
import math R1=float(input('Ввести значение R1: ')) R2=float(input('Ввести значение R2: ')) R3=float(input('Ввести значение R3: ')) v1=(4/3)*math.pi*R1**3 v2=(4/3)*math.pi*R2**3 v3=(4/3)*math.pi*R3**3 Z=(v1+v2+v3)/3 print('Значение v1: ', v1) print('Значение v2: ', v2) print('Значение v3: ', v3) print(...
false
cc8605be2016f8acf8c4a29029ed2d4b5bf80e2b
thirihsumyataung/Python_Tutorials
/Fizz_Buzz_Python.py
748
4.125
4
#Fizz Buzz #if a number is divisilbe by 3 and 5 --> FIZZ BUZZ #elif a number is divisible by 3 --> FIZZ #elif a number is divisible by 5 --> BUZZ #else just a number ( user input ) myFizzBuzzList = [] aString = '' number = int(input('How many numbers user want to type ? ')) for i in range(number): userInput = int...
false
6676dffc286556c70577090f37d2a7f94d1eb652
thirihsumyataung/Python_Tutorials
/function_CentigradeToFahrenheit_Converter_Python.py
801
4.3125
4
#Temperture converting from Centigrade to Fahrenheit is : # F = 9/5 * C + 32 #Question : F = Fahrenheit temperature # C = the centigrade temperature #Write a function named fahrenheit that accepts a centigrade temperature as an argument # function should return the temperature the temperature , converted to Fahrenheit ...
true
c2778ff17feadc65e78715ec67b201d09d9adbfe
thirihsumyataung/Python_Tutorials
/function_kineticEnergyCalculation_Python.py
779
4.375
4
#Write a function named kineticEnergy that accepts an object’s mass (in kilograms) and velocity (in meters per second) as arguments. # The function should return the amount of kinetic energy that the object has. # Demonstrate the function by calling it in a program that asks the user to enter values for mass and veloci...
true
25761d97611f8acc56c87bbae58d07600d5054a5
sppess/Homeworks
/homework-13/hw-13-task-1.py
676
4.3125
4
from functools import wraps # Write a decorator that prints a function with arguments passed to it. # NOTE! It should print the function, not the result of its execution! # For example: # "add called with 4, 5" def logger(func): def wripper(*args, **kwargs): arguments = '' for arg in args: ...
true
abc589ba9207eac5da8ebad5db193fe0e7909b2f
hzhao22/ryanpython
/venv/hailstone.py
533
4.375
4
print ("Hail Stone") #Starting with any positive whole number $n$ form a sequence in the following way: #If $n$ is even, divide it by $2$ to give $n^\prime = n/2$. #If $n$ is odd, multiply it by $3$ and add $1$ to give $n^\prime = 3n + 1.$ def hailStone(n): numbers = [] while ( 1 not in numbers): if n...
true
97c9933472f1f2fab1c37d13c22fc91fa943dace
gstoel/adventofcode2016
/day3_DK.py
1,106
4.1875
4
# http://adventofcode.com/2016/day/3 from itertools import combinations from pandas import read_fwf # all combinations of 2 sides of a triangle tri = [list(n) for n in combinations(range(3), 2)] for n in range(3): tri[n].append(list(reversed(range(3)))[n]) def check_tri(sides): """checks whether the sum of a...
true
4def4f4e7119ff665c9279a80916c60a64ce1af9
awsk1994/DailyCodingProblems
/Problems/day23.py
2,273
4.1875
4
''' This problem was asked by Google. You are given an M by N matrix consisting of booleans that represents a board. Each True boolean represents a wall. Each False boolean represents a tile you can walk on. Given this matrix, a start coordinate, and an end coordinate, return the minimum number of steps required to r...
true
bbe885cb3e51c0c7b083a7a42d634dfc143e3d6a
Kapral26/solutions_from_checkio.org
/elem_list.py
249
4.125
4
''' returns a tuple with 3 elements - first, third and second to the last ''' def easy_unpack2(elements: tuple) -> tuple: return(elements[0],elements[2], elements[-2]) print(easy_unpack2((1, 2, 3, 4, 5, 6, 7, 9))) print(easy_unpack2((6, 3, 7)))
true
dc19208a3b7aa093a1588f3abb635f7c67c427b2
bnitin92/coding_practice
/Interview1_1/9_30.py
1,436
4.125
4
# finding the depth of a binary tree """ input : root Binary tree : not balanced ouput: the height of the tree 5 / \ 4 7 / \ \ 12 15 15 \ 19 use Breadth first searc...
true
6432a0c3992552346b7bff30f72c4980422c513e
bnitin92/coding_practice
/Recursion_DP/8.1 Triple Step.py
491
4.3125
4
""" 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 tripleStep(n): if n < 0: return 0 if n == 0: return 1 else: return tripleStep(n-3...
true
8c6d32b839e851b019b2a8936e8809b97e28a361
MarineKing5248/MLPython
/chapter4/gradient_descent.py
1,000
4.21875
4
# 1) An Empty Network weight = 0.1 alpha = 0.01 def neural_network(input, weight): prediction = input * weight return prediction # 2) PREDICT: Making A Prediction And Evaluating Error number_of_toes = [8.5] win_or_lose_binary = [1] # (won!!!) input = number_of_toes[0] goal_pred = win_or_lose_binary[0] pred...
true
b08fc4ba6f9053b9ffbae0c391bdaa10f7df906d
giacomocallegari/spatial-databases-project
/src/main.py
1,394
4.125
4
from src.geometry import Point, Segment from src.structures import Subdivision def main(): """Main function. After providing a sample subdivision, its trapezoidal map and search structure are built. Then, points can be queried to find which faces contain them. """ example = 2 # Number of the ex...
true
83e1cae23a573214248dadb3d9ed670330319555
ruppdj/Curriculum
/Beginner_Level/Unit1/Practice_what_you_learned/variables.py
308
4.15625
4
"""Variables""" # To set the value 3 to the variable distance we code distance = 3 # 1. Set the variable speed to the value 5. speed = # 2. Set the variable fast_speed to the value True. # 3. Change the value in the variable below to 1.23 # What will be printed now? a_variable = 3.4 print(a_variable)
true
cfd13f7dd2db899ebba36c992cefc0580c04a2dd
sdg000/git
/lowerANDupperlimit_code.py
1,849
4.46875
4
#Write a script to take in a lower limit and an upper limit. #And based on the users selection, provide all the even or odd #numbers within that range. #enter a new range: then display odd or even values following that. #if not , then exit. ''' VARIABLES TO DECLARE LowerL UpperL odd_range even_range ''' LowerL=in...
true
18a85925742b90cc3618d42435ba3684caaf7614
fr0z3n2/Python-Crash-Course-Examples
/ch2_variables_and_strings/print_message.py
494
4.53125
5
''' This is how to print a message in python 3 ''' # Storing the message in a variable. message = "This is a message ;)" print(message) message = 'Holy crap "Look at these quotes"' print(message) message = "holy cRaP 'look again'" print(message) # The title method puts the characters in upper case. print(message.tit...
true
c4dfc75f401eeddfd21b968c9ba149e204640089
Niaksis/Example
/python/колво четных и нечетных.py
923
4.34375
4
'''Посчитать четные и нечетные цифры введенного натурального числа. Например, если введено число 34560, то у него 3 четные цифры (4, 6 и 0) и 2 нечетные (3 и 5).''' print("Эта программа посчитает из вашего числа количество четных и нечетных цифр") even = 0 odd = 0 list_even = [] list_odd = [] list_num = [] number =...
false
62a5324ffbf462e7c2003314afe70526edead42c
MalithaDilshan/Data-Structures-and-Algorithms
/Sorting/Selection Sort/selectionsort.py
1,301
4.34375
4
''' This is the code for the selection sort algorithm This code will handle the execution time using the time.time() method in python and here use the random arrays (using the random()) as the input to the algorithm to sorting to ascending order ''' import time import random random.seed() #test cas...
true
0dc4cb22e911d581c47016f3214c5e1e0846d823
Sam-Power/Trials
/Exercises/Statistics/Assignment-3.py
1,547
4.28125
4
"""EXERCISE 1. The following data represent responses from 20 students who were asked “How many hours are you studying in a week?” 16 15 12 15 10 16 16 15 15 15 12 18 12 14 10 18 15 14 15 15 What is the value of the mode? The median? The mean? EXERCISE 2. Use the data below to calculate the mean, variance, and standard...
true
4044b4aa2dd63741b06f7632f462d1df05c26669
nickvarner/automate-the-boring-stuff
/04-first-complete-program/numberGuessing.py
610
4.125
4
#This is a guess the number game. import random print('Hello! What is your name?') userName = input() print('Well ' + userName + ", I'm thinking of a number between 1-20.") secretNum = random.randint(1,20) for guessesTaken in range(1, 7): print('Take a guess!') guess = int(input()) if guess < secretNum:...
true
7a5d9234b3d407ed4e1adc22f8bd5e4e845fec8d
ShijieLiu-PR/Python_Learning
/month01/python base/day04/code03.py
611
4.1875
4
""" 字符串操作 """ # 1.数学运算 str01 = "wukong" str02 = "bajie" #创建新对象 str03 = str01 + str02 print(str03) #容器可以与数字相乘 str04 = str01 * 3 print(str04) print(str01 > str02) for item in str01: print(ord(item)) # 2.成员运算 str03 = "猥琐发育,别浪!" print("猥琐" in str03) # 3.索引 str04 = "abcdef" print(str04[0]) print(str04[len(str04) ...
false
e61039ada9393964301b2363ca6f090faeb2757f
ShijieLiu-PR/Python_Learning
/month01/python base/day05/code02.py
414
4.125
4
""" 列表推导式 """ list01 = [3,5,6,7,9] # 需求:创建新列表,每个元素是list01中的元素的平方 list02 = [] for item in list01: list02.append(item **2) print(list02) list03 = [item ** 2 for item in list01] print(list03) # 需求:创建新列表,如果元素是偶数,则将该元素的平方存入新列表 list04 = [item ** 2 for item in list01 if item % 2 != 0] print(list04)
false
a414e7ab54f84b7bc6157155f73d914c5fca7a27
ShijieLiu-PR/Python_Learning
/month01/python base/day16/code02.py
438
4.3125
4
""" 生成器表达式 """ list01 = [2,3,4,6] result = [ x**2 for x in list01] print(result) result = (x**2 for x in list01) for item in result: print(item) list02 = [2,3,4,6] # 练习:使用列表推导式与生成器表达式,获取列表list02中大于3的数据。 result01 = [item for item in list02 if item > 3] print(result01) result02 = (item for item in list02 if i...
false
c857cc2eb199b41ab3e029618ac73dd7894120c5
ShijieLiu-PR/Python_Learning
/month01/python base/day04/exercise01.py
231
4.3125
4
# 练习1:在控制台中获取一个字符串,打印每个字符的编码值。 str_input = input("Please input string:") for item in str_input: print(ord(item)) else: print("Complete!") print(ord("a")) print(bin(11))
false
e9a42970ce63c9f9e0c7ea825c3fa03a0a9fdc09
ShijieLiu-PR/Python_Learning
/month01/python base/day02/review.py
775
4.59375
5
""" day01复习 1. python定义:免费的,开源的,跨平台的,动态的,面向对象的编程语言 2. 执行方式:交互式和文件式 3. 执行过程:源代码-编译->字节码-解释->机器码 4. 函数:功能,做功能的人--函数定义者 使用功能的人--函数调用者 print("需要显示的信息") 将括号中的内容显示到控制台中 变量=input("需要显示的信息") 从控制台中获取信息 5. 变量:存储对象低着的标识符, 见名知义 """ # 练习:在控制台中获取一个变量 # 再获取一个变量 #...
false
0716cd827ea6026471f6e1d28483cab1a2c33b06
Tanmay-Shinde/Python
/Arithmetic operators.py
308
4.1875
4
#Arithmetic Operators print(3+5) # Addition print(3-5) # Subtraction print(3*5) # Multiplication print(6**2) # Exponentiation print(6/2) # Division (returns Quotient as floating value) print(6//2) # Division (returns Quotient as integer value) print(6%2) # Modulo Operator - returns the remainder
true
dd0eb1fd68a35a32d4a63c16df74367a4c6a4a21
aryanmotgi/python-training
/training-day-9.py
747
4.15625
4
class MyClass: # atrribute or methods go here pass myObj = MyClass() class Person: def __init__(self, name, age): """ This methods is executed every time we created a new `person` instance `self` is the object instanve being created.""" self.name = name self.name = age ...
true
132f53ace51e422b8506cae237fbb30ba673fb22
dfrantzsmart/metis-datascience
/Pair-Programming/01-12-reverser.py
661
4.28125
4
""" ## Pair Programming 1/12/2016 ## Reverser of string ## Ozzie with Bryan Pair Problem You may be asked to write code that reads from standard input and/or writes to standard output. For example, you will be asked to do that now. Write a program that reads from standard input and writes each line reversed to standa...
true
bbb8676999f0fefc1ece885fb1929ede01415a22
antymijaljevic/google_python_course
/seconds_of_iteration.py
668
4.15625
4
#!/home/amijaljevic/anaconda3/bin/python3 print("ITERATION TIME CALCULATOR\n") numOfElements = float(input("Number of elements to iterate through loop? > ")); loopNum = float(input("How many loops you have? > ")); milisec = 1000; minAndHour = 60; numOfElements = numOfElements ** loopNum; resultInMili = numOfElement...
false
ab837ad96b076533c9f146e58d7af43ad2358389
sebadp/LeetCode---Python
/sortArrayByParity.py
1,167
4.25
4
def sortArrayByParity(A): """ Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A. You may return any answer array that satisfies this condition. Example 1: Input: [3,1,2,4] Output: [2,4,3,1] The outputs...
true
dbeab0c45b25f8651e4f53bf4079be1e9da143b9
dssheldon/pands-programs-sds
/es.py
1,691
4.1875
4
# Sheldon D'Souza # G00387857 # Weekly task 7 # The objective of the task is to write a program that reads a text file and outputs the number of 'e's it contains # I amended the program slightly to take in a user input search character but the default remaining as e # As instructed the program will take the filename on...
true
35a9fc3839f5c8f0c0e81e68f1a9655bacbb2417
rohyat/EXCEL_AUTOMATION_WITH_PYTHON
/write.py
2,333
4.40625
4
def column_edit(s, row, column, wb): coln = int(input("ENTER THE COLUMN NUMBER\n")) if(coln > column): print("U HAVE ENTERED WRONG COLUMN NUMBER\n") else: f = int(input('''PRESS THE RIGHT OPTION THIS WILL DONE TO ALL CELLS OF COLUMN EXCEPT FIRST\n'1'--FOR ADD(+)\n'2'--FOR SUBTRACT(-)\n'3'--F...
false
377d4dfa97ff594717d6973bc512132c26f28e30
Dhanya-bhat/MachineLearning_Programs
/3-9-2020/HighestOf3values-p5.py
354
4.5625
5
5.Write a Python program to find the highest 3 values in a dictionary. from collections import Counter my_dict = {'elston': 30, 'winston': 40, 'alsten': 60, 'royston': 50, 'joyston': 20} k = Counter(my_dict) high = k.most_common(3) print("Dictionary with 3 highest values are :") print("Keys: Values") for i in h...
false
a3d99c04c8e39bb909ff2d0088a1b85cb00e3de5
Zhou-jinhui/Python-Crash-Course-Exercise
/Chepter4Slice.py
2,422
4.5
4
# Chepter 4 Working with part of a list # Slice players = ["charles", "martina", "michael", "florence", "eli"] print(players[0:3]) # !!! It's a colon in the square bracket, not commas. print(players[1:4]) print(players[:4]) print(players[2:]) print(players[-3:]) # Looping through a slice playe...
true
00069a2c8dcc8fbf17458c148b7f02be35cf7678
alsgk0221/Java_Project
/src/chap4/추상메소드구현.py
2,002
4.15625
4
import math class Shape: def __init__(self): self.name = "모양" def area(self): raise NotImplementedError("이것은 추상메소드입니다. ") def perimeter(self): raise NotImplementedError("이것은 추상메소드입니다. ") class Rectangle(Shape): def __init__(self, w, h): super().__ini...
false
2c9d0340d2ea59cf566a7c60360b766a6f1a0209
karinnecristina/Curso_Python
/Programacao_Procedural/zip.py
433
4.34375
4
''' Considerando duas listas de inteiros ou floats (lista A e lista B) Some os valores nas listas retornando uma nova lista com os valores somados: Se uma lista for maior que a outra, a soma só vai considerar o tamanho da menor. Exemplo: lista_a = [1,2,3,4,5,6,7] lista_b = [1,2,3,4] Resultado: [2,4,6,8] ''' lista_...
false
03682e34db14e13d8d458b185a7d11d2489a7506
karinnecristina/Curso_Python
/Logica_de_Programacao/Tamanho_da_string.py
543
4.15625
4
''' Faça um programa que peça o primeiro nome do usuário. Se o nome tiver 4 letras ou menos escreva "Seu nome é curto"; se tiver entre 5 e 6 letras, escreva "Seu nome é normal"; maior que 6 letras escreva "Seu nome é muito grande". ''' nome = input('Qual o seu nome?: ') tamanho = len(nome) if tamanho <= 4: print(f...
false
ca5af8027fc67847c56a641fb996d7a0f8c3e517
AchWheesht/python_koans
/python3/koans/triangle.py
1,064
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Triangle Project Code. # Triangle analyzes the lengths of the sides of a triangle # (represented by a, b and c) and returns the type of triangle. # # It returns: # 'equilateral' if all sides are equal # 'isosceles' if exactly 2 sides are equal # 'scalene' ...
true
de61b7fcb0b2521097f41b1a8e140764dea0158e
meghavijendra/K_means_model
/elbow_method.py
1,857
4.28125
4
#!/usr/bin/env python # coding: utf-8 # ## Finding optimum value for number of clusters for k-means clustering # <p> Here we are trying to find the optimum value of k which needs to be used for the k-means algorithm in order to get the more accurate results</p> # <p> We can either use this method to get the optimum k...
true
4d73b7bfe97a3fd817181536eb6a97e8fa9a0cf1
licheeee/PythonProject
/is_odd.py
219
4.25
4
# -*- coding: UTF-8 -*- # 判断数字是否是奇数 num = int(input("Please input a number :")) if (num % 2) == 0: print("{0} is an even number".format(num)) else: print("{0} is an odd number".format(num))
false
5e6b40a9df523d901c02b7f9323e96b8cc05ea01
chinmaybhoir/project-euler
/euler4.py
707
4.25
4
""" A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. """ import time start_t = time.time() def is_palindrome(num): num_string = str(num) if num_str...
true
662ecea8a000da7eacebedf9381f7c06ec627e90
DipeshBuffon/python_assignment
/DT16.py
269
4.125
4
#Write a Python program to sum all the items in a list. list=[] n=int(input("Enter length of list:- ")) for i in range(n): a=int(input("Enter numeric value for list:- ")) list.append(a) sum=0 for i in range(len(list)): sum+=list[i] print(sum)
true
1ddd0ef3ae72a9de31920d1413b2795aee5b18b2
DipeshBuffon/python_assignment
/DT18.py
229
4.34375
4
#Write a Python program to largest item in a list. n=int(input("Enter length of list:- ")) list=[] for i in range(n): a=int(input("Enter numeric value for list:- ")) list.append(a) list.sort() print(list[-1])
true
eff9439139901b66bb066e932c4ff9326662c111
DipeshBuffon/python_assignment
/f6.py
280
4.15625
4
#WAP in python function to check whether the given number is in range or not. n=int(input("Enter a number:- ")) r=int(input("enter the end of range:- ")) def check(n,r): if n in range(r+1): print('found') else: print("not found") check(n,r)
true
06e581477069f64f865aa01ddf93c433761b94c3
deepakdas777/anandology
/functional_programming/tree_reverse.py
255
4.125
4
#Write a function tree_reverse to reverse elements of a nested-list recursively. def tree_reverse(lis): lis.reverse() for i in lis: if isinstance(i,list): tree_reverse(i) return lis print tree_reverse([[1, 2], [3, [4, 5]], 6])
true
162c03918391f131d1f4c8741094da50238f0e9a
anudeepthota/Python
/checkingIn.py
206
4.1875
4
parrot = "Norwegian Blue" letter = input("Enter a character:") if(letter in parrot): print("{} is present in {}".format(letter,parrot)) else: print("{} is not present in {}".format(letter,parrot))
true
75c93b591147c4f1cf0e2788a46a0e4cf700d14d
anudeepthota/Python
/instance_start.py
1,109
4.46875
4
# Python Object Oriented Programming by Joe Marini course example # Using instance methods and attributes class Book: # the "init" function is called when the instance is # created and ready to be initialized def __init__(self, title, author, pages, price): self.title = title self.author =...
true
e1a7cde7429b806310907f77fd32b95af3b466a8
anudeepthota/Python
/holidaychallenge.py
235
4.21875
4
name = input("Please enter your name: ") age = int(input("Please enter your age: ")) if age > 18 and age < 31: print("Hi {}, Welcome to the Holiday!!".format(name)) else: print("Hi {}, Sorry you are not eligible".format(name))
true
ee1c1f40b7e3cf42cfc8a0851d834d8fd9cc1cdc
edubu2/OOP-Tutorials
/2_oop_class_variables.py
1,566
4.4375
4
# Object-Oriented Programming tutorials from Corey Schafer's OOP YouTube Series. class Employee: num_of_emps = 0 # will increment each time an employee is added raise_amount = 1.04 def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay ...
true
e5a3e18b2c9d28d763d47f72157bbe0a7f977f1d
ciriusblb/python
/bucles.py
2,346
4.15625
4
# for i in ["pildoras", "informaticas", 3]: # print("Hola", end= " ") #para quitar el salto de linea # -----------------ejercicio------------------- # email = False # for i in "ciriusblb@gmail.com": #iterar i tantas veces caracteres tenga el string # if i == "@": # email = True # if email: # prin...
false
6f816aa39a46097c3bcbad42f6a262e12ab5aba7
bana513/advent-of-code-2020
/day2/part1.py
1,145
4.125
4
""" Task: Each line gives the password policy and then the password. The password policy indicates the lowest and highest number of times a given letter must appear for the password to be valid. For example, 1-3 a means that the password must contain a at least 1 time and at most 3 times. In the above example, 2 pas...
true
c04bb30ce006e2b0f4fc816daaf6c664aa8fb147
hasrakib/Python-Practice-Projects
/Basic/days-between.py
293
4.375
4
# Write a Python program to calculate number of days between two dates. # Sample dates : (2014, 7, 2), (2014, 7, 11) # Expected output : 9 days from datetime import date first_date = date(2014, 7, 2) last_date = date(2014, 7, 11) difference = last_date - first_date print(difference.days)
true
220827b7f76f736120e24d9855bc3d1a1b66b0f5
friver6/Programming-Projects
/Python Exercises/ex16-DriveAge.py
314
4.3125
4
#Program to determine if user can drive according to his or her age. drivAge = 16 userAge = int(input("What is your age? ")) if userAge <= 0: print("Please enter a valid age.") elif userAge > 0 and userAge < drivAge: print("You are not old enough to legally drive.") else: print("You are allowed to drive.")
true
c1918e556d13f357889d5f2196abfbd9811a758c
friver6/Programming-Projects
/Python Exercises/ex28-AddingNums.py
263
4.125
4
#Prompts for five numbers and computes the total. total = 0 numInput = 0 usrInput = "" for i in range(0,5): usrInput = input("Enter a number: ") if usrInput.isdecimal(): numInput = int(usrInput) total += numInput print("The total is {}.".format(total))
true
cdea4e4f0c0489edba630b95b4467efd84ae8a1f
friver6/Programming-Projects
/Python Exercises/ex18-TempConv.py
678
4.34375
4
#Converts between Fahrenheit and Celsius and vice-versa. print("Press C to convert from Fahrenheit to Celsius.\nPress F to convert from Celsius to Fahrenheit.\n") usrChoice = input("Your choice: ") if usrChoice == "C" or usrChoice == "c": usrTemp = float(input("Please enter the temperature in Fahrenheit: ")) convTe...
true
206bf39105de0fa5388ec4635523c0e1378becf4
rishavsharma47/ENC2020P1
/Session10G.py
2,477
4.21875
4
""" OOPS : Object Oriented Programming Structure How we design Software Its a Methodology 1. Object 2. Class Real World Object : Anything which exists in Reality Class : Represents how an object will look like Drawing of an Object Princ...
true
e9ac0a9133baf8a519d7a00d7ae4955a5d48ef8d
rishavsharma47/ENC2020P1
/Session20C.py
1,025
4.15625
4
# Function with Input to Reference of Function def hello(fun): print(">> Hello...") fun() def bye(): print(">> Bye...") def show(num=10): print(">> showing", num) # Passing Function as Argument hello(fun=bye) print("~~~~~~~~~") hello(fun=show) # Factory Design Pattern # Create with help of Con...
false
98a87be0f2fe544c1db9d42800763be8a086562a
BurnsCommaLucas/Sorts
/python/bubble.py
618
4.125
4
#!/usr/bin/env python """bubble.py: Sorts an array of integers using bubble sort""" __author__ = "Lucas Burns" __version__ = "2017-9-28" import process def sort(items): swapped = True while (swapped): swapped = False for i in range(0, len(items) - 1): process.comparisons += 1 if items[i] > items[i + 1]:...
true