blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
40c7b0f8fe9101a9227cac07d0c9f6cbd5ef7fcc
AaronChelvan/adventOfCode
/2016/day6part1.py
1,079
4.15625
4
#!/usr/bin/python3 #Converts a letter to the corresponding number #a->0, b->1, ..., z->25 def charToNumber(char): return ord(char) - 97 #Converts a number to the corresponding letter #0->a, 1->b, ..., 25->z def numberToChar(number): return chr(number + 97) with open('day6_input.txt') as f: lines = f.readlines() ...
true
3b56fdb3d884695176207f5748a3c111d53cba06
gudmundurgh/Forritun
/dæmatímar/python_basic_excercises.py
253
4.25
4
low = int(input("Enter an integer: ")) high = int(input("Enter another integer: ")) sum_of_integers = 0 for i in range(low, high+1): if i % 3 == 0 or i % 5 == 0: sum_of_integers = sum_of_integers + i print(i) print(sum_of_integers)
false
afd6126ccad94f42620bd7c33233666f0c71e3a2
k08puntambekar/IMCC_Python
/Practical3/Program7.py
591
4.28125
4
# 7.Write a program to implement composition. class Company: def __init__(self, company_name, company_address): self.company_name = company_name self.company_address = company_address def m1(self): print("You are in", self.company_name, "company based in ", self.company_address) cla...
false
92f59612b2697db155da1bdc625fdabc115867b0
k08puntambekar/IMCC_Python
/Practical3/Program5.py
589
4.375
4
# 5. Write a program to implement polymorphism. class Honda: def __init__(self, name, color): self.name = name self.color = color def display(self): print("Honda car name is : ", self.name, " and color is : ", self.color) class Audi: def __init__(self, name, color): sel...
true
f6e52e7cc61e9176624dcb96c899034e8ab011ea
jennyfothergill/project_euler
/problems/p9.py
712
4.28125
4
# A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, # a^2 + b^2 = c^2 # For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. # There exists exactly one Pythagorean triplet for which a + b + c = 1000. # Find the product abc. from math import sqrt n = 1000 def is_triplet(a, b, c): if a**2 + b...
true
e75b4ae01cdd3c69351143331b14b526c68b660e
Michael-Zagon/ICS3U-Unit4-07-Python
/1_2_number_printer.py
485
4.375
4
#!/usr/bin/env python3 # Created by: Michael Zagon # Created on: Oct 2021 # This program lists every number from 1000 to 2000 def main(): # This function lists every number from 1000 to 2000 counter = 0 # Process and Output for counter in range(1000, 2001): if counter % 5 == 0: ...
true
15025d260c7794e1a19a129429e2991d8a705ada
devilhtc/leetcode-solutions
/0x01e9_489.Robot_Room_Cleaner/solution.py
2,537
4.125
4
# """ # This is the robot's control interface. # You should not implement it, or speculate about its implementation # """ # class Robot: # def move(self): # """ # Returns true if the cell in front is open and robot moves into the cell. # Returns false if the cell in front is blocked and robot st...
true
f1b5efe9da688ec3db58dac8a9bb293ef095ae5a
gwccu/day3-Maya-1000
/problemSetDay3.py
728
4.21875
4
integer = int(input("Tell me a number.")) if integer % 2 == 0: print("That is even.") else: print("Why did you put in an odd number? I don't like them.") a = int(input("Tell me another number.")) if a % 2 == 0: print("That is even.") else: print("Why did you put in an odd number? I don't like them.")...
true
a182e54029a511e2475e56f3de533a1685fc9c97
Fanz11/homework3
/main.py
1,177
4.28125
4
# первое number1 = [1, 2, 3] #числа number2 = [i * 2 for i in number1] #умножение на 2 print(number2) #ответ # второе number1 = [1, 2, 3] #числа number2 = [i ** 2 for i in number1] ...
false
be98c59ba48044650c0e0a990b1cdd831d1b1d0f
gflorianom/Programacion
/Practica5/Ejercicio3.py
404
4.25
4
"""Biel Floriano Morey - 1 DAW - PRACTICA5 - EJERCICIO 3 Escriu un programa que demani notes i les guardi en una llista. Per a terminar d'introduir notes, escriu una nota que no estigui entre 0 i 10. El programa termina escrivint la llista de notes. """ print "Escribe una nota" n=float(raw_input()) notas=[] while (n<...
false
7ab1de683ab9a0a12d0b7e7d78378244412f3fd3
gflorianom/Programacion
/Practica5/Ejercicio10.py
922
4.28125
4
"""Biel Floriano Morey - 1 DAW - PRACTICA5 - EJERCICIO 10 Escriu un programa que et demani els noms i notes d'alumnes. Si escrius una nota fora de l'interval de 0 a 10, el programa entendr que no vols introduir ms notes d'aquest alumne. Si no escrius el nom, el programa entendr que no vols introduir ms alumnes. Nota...
false
7124ec44628cab139bbfb750fd872c95623ce33f
keerthikapopuri/Python
/lab2_8.py
205
4.1875
4
def factorial(n): if n==0: return 1 else: recurse=factorial(n-1) result=n*recurse return result n=int(input("enter a number: ")) res=factorial(n) print(res)
false
d301a77da333fee20a0792a4aa2e21e3230913a9
sherry-fig/CEBD1100_Work
/function2.py
336
4.125
4
def isnumbernegative(n): if n<0: return True return False print(isnumbernegative(4)) my_value=-2 #print number is negative OR number is positive if isnumbernegative(my_value): print("number is negative") else: print("number is positive") def isnumbernegative(n): return n<0 print(isnumb...
false
313e68bb71568fe1e8709fd03ecb4e999bc29ac5
lisali72159/leetcode
/easy/1200_min_abs_diff.py
1,088
4.15625
4
# Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements. # Return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows # a, b are from arr # a < b # b - a equals to the minimum absolute difference of any two element...
true
e29ba721cad2cf58d8c8c2e41b6b69347a96a677
jzohdi/practice
/SimpleSymbols.py
1,138
4.125
4
# Have the function SimpleSymbols(str) take the str parameter being passed and determine if it is an acceptable sequence # by either returning the string true or false. The str parameter will be composed of + and = symbols with several letters between them # (ie. ++d+===+c++==a) and for the string to be true each let...
true
2c570dd2659fa744d2234d7e70062979008c9fe3
nsky80/competitive_programming
/Hackerrank/Archive 2019/Python Evaluation(built_ins).py
412
4.375
4
# The eval() expression is a very powerful built-in function of Python. It helps in evaluating an expression. # The expression can be a Python statement, or a code object. # >>> x = 3 # >>> eval('x+3') # 6 # >>> a = 'x**2 + x**1 + 1' # >>> eval(a) # 13 # >>> type(eval("len")) # <class 'builtin_function_or_method'> #...
true
e0ceeb1da7502b6db937c7cf7da90f4c8adb1eb4
BrichtaICS3U/assignment-2-logo-and-action-NAKO41
/logo.py
2,391
4.34375
4
# ICS3U # Assignment 2: Logo # <NICK SPROTT> # adapted from http://www.101computing.net/getting-started-with-pygame/ # Import the pygame library and initialise the game engine import pygame pygame.init() import math # Define some colours # Colours are defined using RGB values BLACK = (0, 0, 0) WHITE = (255, 255, 255...
true
0f0f464b3c550ec5397d59392aa038993d3521a1
ankurtechtips/att
/circularqueue.py
1,159
4.15625
4
# This is the CircularQueue class class CircularQueue: # taking input for the size of the Circular queue def __init__(self, maxSize): self.queue = list() # user input value for maxSize self.maxSize = maxSize self.head = 0 self.tail = 0 # add element to the queue def enqueue(self, dat...
true
7e4a9f3cd3ebc8aa92284b5b2c62a1256b51f401
rastislp/pands-problem
/weekday.py
1,677
4.46875
4
#Rastislav Petras #12 Feb 2020 #Excercise 5 #Write a program that outputs whether or not today is a weekday. # An example of running this program on a Thursday is given below. print() print("Welcome in day teller.") print() import datetime #import librarys with time functions. import calendar #import libr...
true
04a05dfedb19b73cb631555d9ea17d8c79f00b26
rastislp/pands-problem
/primenum.py
542
4.125
4
# Ian McLoughlin # Computing the primes. # My list of primes - TBD. P = [] # Loop through all of the numbers we're checking for primality. for i in range(2, 1000): # Assume that i is a prime. isprime = True # Loop through all values j from 2 up to but not including i. for j in P: # See if j divides i. ...
true
5d807153dd64a43c86d4db233d3cc20b9a62fc5c
williamSouza21/exercicios-em-python
/Calculadora_1.0_.py
1,122
4.3125
4
valor1 = float(input("Digite o 1° valor: ")) valor2 = float(input("Digite o 2° valor: ")) print("Operações matemáticas da calculadora: ") print("1- Adição") print("2- Subtração") print("3- Multiplicação") print("4- Divisão") print("5- Potenciação") print("6- Radiciação") operação = int(input("Escolha a operação: ")) i...
false
93b119123f07094a993e4420dd6e56be1918d59b
ZyryanovAV/lb8
/Общее 1.py
693
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Решите задачу: создайте словарь, где ключами являются числа, а значениями – строки. # Примените к нему метод items(), c с помощью полученного объекта dict_items создайте # новый словарь, "обратный" исходному, т. е. ключами являются строки, а значениями – # числа. if __...
false
9d5dd4c12b1186a88ad6379c9a4a058d63d3bfde
ishleigh/PythonProjects
/BulletsAdder.py
805
4.21875
4
""" 1. Paste text from the clipboard -pyperclip.paste() 2. Do something to it- add bullets * 3. Copy the new text to the clipboard -pyperclip.copy() """ #! python3 # bulletPointAdder.py - Adds Wikipedia bullet points to the start # of each line of text on the clipboard. import pyperclip text = pyperclip.past...
true
7363fe66b7718058f37b9dcb90dc140b3b569fec
r426/python_basics
/10_special_numbers_no_sum.py
782
4.28125
4
# Find out if it is a special number: # composed of only odd prime digits and # the sum of its digits is an even number. # Implementation based on the number of digits # (not their sum). def number(): while True: userInput = input('Please enter a non-negative integer number: ') if userInput.isnum...
true
b5a9de5c17145944f5e182c5a947aafa642e2146
r426/python_basics
/03_reverse_number.py
468
4.3125
4
# Generate the reverse of a given number N. def number(): while True: userInput = input('Please enter a big non-negative integer number: ') if userInput.isnumeric(): return int(userInput) else: print("Input error.") def reverse(number): reverseNumber = 0 wh...
true
74b0ef4a5944da5c9e586712e0b28630abcf1f38
richardOlson/cs-module-project-recursive-sorting
/src/searching/searching.py
2,520
4.34375
4
# TO-DO: Implement a recursive implementation of binary search def binary_search(arr, target, start, end): # the base case if start > end: return -1 # pick the middle point = start + ((end - start)//2) if arr[point] == target: return point if arr[point] > target: # need ...
true
ff295d4749a6c22db1c54b07c127d7debb27e1f3
raju7572/learning_python
/chapter7,8&9.py
2,485
4.1875
4
def sequence(n): while n != 1: print(n), if n % 2 == 0: # n is even n = n / 2 else: # n is odd n = n * 3 + 1 while True : line=raw_input('>') if line == 'done': break print(line) print('done!') import matheval var = (...
false
492d7bf144f95fe083013ca38e4e94ed849c4a79
a123aaa/python_know
/Python知识清单/字符串(str)的查询.py
491
4.3125
4
arr='hello,hello' print(arr.index('lo')) #3 print(arr.find('lo')) #3 print(arr.rindex('lo')) #9 print(arr.rfind('lo')) #9 #字符串的查询 #index() 查找子串第一次出现的位置,如果找不到就报错 #rindex() 查找子串最后一次出现的位置,如果找不到就报错 #find() 查找子串第一次出现的位置,如果找不到就返回-1 #rfind() 查找子串最后一次出现的位置,如果找不到就返回-1
false
ec65536007e903b26e133bb7319a8ae70af247e5
a123aaa/python_know
/Python知识清单/字符串(str)大小写变换.py
781
4.21875
4
arr='aBcDe' app=arr.swapcase() print(app) #AbCdE app=arr.upper() print(app) #ABCDE app=arr.lower() print(app) #abcde arr='I LOVE YOU' print(arr.title()) #I Love You arr='I LOVE YOU' print(arr.capitalize()) #I love you #新字符串=字符串 .u...
false
5c1433f1a874101aed6c6da3edff753181d8b785
a123aaa/python_know
/Python知识清单/内置函数range.py
1,160
4.21875
4
for i in range(3): print(i) #0 1 2 for i in range(-3): print(i) #无 for i in range(1,5): print(i) #1 2 3 4 for i in range(-3,5): print(i) #-3 -2 -1 0 1 2 3 4 for i in range(-3,-5): print(i) #无 for i in range(2,...
false
d7d14f7f96abc194328ef5700d56ca7a73cbe97b
a123aaa/python_know
/Python知识清单/列表(list)排序.py
1,218
4.28125
4
#列表名 . sort() 达到升序效果,且地址不变 #列表名 . sort( reverse = False ) 达到升序效果,且地址不变 #列表名 . sort( reverse = True ) 达到降序效果,且地址不变 #新列表名 = sorted(列表名) 达到升序效果,地址改变 #新列表名 = sorted(列表名 ,reverse = False ) 达到升序效果,地址改变 #新列表名 = sorted(列表名 ,reverse = ...
false
b810f69f0cbbd72a740385f8e954cc7524769ab8
MannyP31/CompetitiveProgrammingQuestionBank
/Arrays/Maximum_Difference.py
1,177
4.28125
4
''' From all the positive integers entered in a list, the aim of the program is to subtract any two integers such that the result/output is the maximum possible difference. ''' # class to compute the difference class Difference: def __init__(self, a): # getting all elements from the entered li...
true
3203f96749773440ba87ed366bd845ea5a43a2c9
MannyP31/CompetitiveProgrammingQuestionBank
/DSA 450 GFG/reverse_linked_list_iterative.py
960
4.125
4
#https://leetcode.com/problems/reverse-linked-list/ # Iterative method #Approach : # Store the head in a temp variable called current . # curr = head , prev = null # Now for a normal linked list , the current will point to the next node and so on till null # For reverse linked list, the current node should po...
true
5c3d15047bcfc2d2d43b0063c428effa2b6c88d1
MannyP31/CompetitiveProgrammingQuestionBank
/Data Structures/Graphs/WarshallAlgorithm.py
1,567
4.25
4
''' A program for warshall algorithm.It is a shortest path algorithm which is used to find the distance from source node,which is the first node,to all the other nodes. If there is no direct distance between two vertices then it is considered as -1 ''' def warshall(g,ver): dist = list(map(lambda i: list(map(lamb...
false
942a3dd1c36e73edb02447e99929d8025b0814cd
MannyP31/CompetitiveProgrammingQuestionBank
/Data Structures/Stacks/balanced_parentheses.py
792
4.21875
4
## Python code to Check for # balanced parentheses in an expression #Function to check parentheses def validparentheses(s): open_brace=["{","[","("] closed_brace=["}","]",")"] stack=[] for i in s: if i in open_brace: stack.append(i) elif i in closed_brace: p=cl...
true
7979d5e0293630e4b6934b5cf35600e720028bd2
MannyP31/CompetitiveProgrammingQuestionBank
/General Questions/Longest_Common_Prefix.py
868
4.28125
4
#Longest Common Prefix in python #Implementation of python program to find the longest common prefix amongst the given list of strings. #If there is no common prefix then returning 0. #define the function to evaluate the longest common prefix def longestCommonPrefix(s): p = '' #declare an empty s...
true
791bf0a4ddf889ce2cccfaf1837e9e6dd8b103f6
MannyP31/CompetitiveProgrammingQuestionBank
/Arrays/Array Reversal.py
225
4.3125
4
'''This is a Program to reverse an array i.e. Input: 1,2,3,4,5 Output:5,4,3,2,1''' # Taking array input l=input().split() #Creating reverse array r=[] for i in range(0,len(l)): r.append(int(l[len(l)-i-1])) print(r)
false
84c655acc227222e4f6e141c97949be2aac1e22a
mori-c/cs106a
/sandbox/sandcastles.py
1,495
4.3125
4
""" File: sandcastles.py ------------------------- Practice of control flow, variable and function concepts using the following files: 1 - subtract_numbers.py 2 - random_numbers.py 3 - liftoff.py """ import random import array def main(): """ Part 1 - user inputs numbers, py separates numbers with substract...
true
ff56ce66a59f499b792bd149fe299703dc332a71
JokerJudge/py111_lab
/Tasks/a2_priority_queue.py
1,622
4.28125
4
""" Priority Queue Queue priorities are from 0 to 5 """ from typing import Any queue = [] MIN_QUEUE_PRIORITY = 5 def enqueue(elem: Any, priority: int = 0) -> None: """ Operation that add element to the end of the queue :param elem: element to be added :return: Nothing """ global queue queue.append((priority,...
false
cfeb93211aa0377e330ddde26d4eed63766f790f
vinaym97/Simple-Tic-Tac-Toe
/Topics/Split and join/Spellchecker/main.py
906
4.1875
4
"""Write a spellchecker that tells you which words in the sentence are spelled incorrectly. Use the dictionary in the code below. The input format: A sentence. All words are in the lowercase. The output format: All incorrectly spelled words in the order of their appearance in the sentence. If all words are spelled co...
true
8979055b59283c406fc719d073cecbb72c327f06
mchughj/AirQualitySensor
/storage/create_sqlite_db.py
1,666
4.46875
4
#!/usr/bin/python3 # This program will create the table structure within the # sqlite3 database instance. It destroys existing data # but only if you allow it. import sqlite3 import os.path def create_connection(db_file): """ create a database connection to a SQLite database """ conn = None try: ...
true
dfd958a2a422e5a3cabc1c3a41e9a32a2dbb8242
Nelcyberth86/IntroProgramacion
/practico_1/9.2.py
578
4.15625
4
num1 = int(input("ingrese numero: ")) num2 = int(input("ingrese, numero: ")) suma = "suma" or "+" resta = "resta" or "-" multiplicacion = "multiplicacion" or "*" division= "division" or "/" operacion = str(input("operacion, que decea realizar: ")) if operacion== suma or "+": resultado= num2 + num1 print(resulta...
false
31a805a8387d66f06ecf741aaec458dc413f27f6
jm9176/Data_structures_practice
/If_Tree_is_BST.py
734
4.40625
4
''' To check if the given tree is a BST tree or not ''' # creating a class for the node class Node: def __init__(self, node = None): self.node = node self.left = None self.right = None # Function running a chek on the given tree def chk_tree(temp): if not temp: return ...
true
a80a73379941066b0356763a25be654d7786db9a
jm9176/Data_structures_practice
/Finding_max_of_sub_arrays.py
503
4.3125
4
''' Finding the maximum value in each of the sub array of size k. If the given array is [10,5,2,7,8,7] then the resulting output should be [10,7,8,8]. ''' # this fnction will return the list of # max element of the sub array def max_sub(arr, k): max_sub_arr = [] for i in range(len(arr)-k+1): m...
true
d2d6b6221c9f0b6ce00befa87966ba9c55a9425c
jm9176/Data_structures_practice
/Finding_pair_with_given_sum.py
571
4.125
4
# finding a pair with a given sum def pair_check(arr, var_sum): for var in arr: if var_sum - var in arr: print "Match found" return var, var_sum - var else: print "Match not found" arr = [] try: for i in range(int(input("Enter the le...
true
02d59a4c2fad30f306482a63ffa5966511543f88
jm9176/Data_structures_practice
/Finding_the_lowest_positive_missing_element.py
645
4.375
4
''' Find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well. For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3. ''' # Function to find and add the lowest positive element # to the defined input def input_elem(...
true
c32b529aab468b5b36632d52080c9f0663d27f6c
saikiranshiva/assignmentwork2
/calculator.py
820
4.125
4
def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): return x / y print("Select operation.") print("1.Add") print("2.Subtract") print("3.Multiply") print("4.Divide") while True: choice = input("Enter choice(1/2/3/4): ") if choice in ...
false
1b240c41de5a51243305a8d33f694fa835d2aba6
Merkasi/rpsls.
/rpsls.py
2,996
4.1875
4
""" 第一个小项目:Rock-paper-scissors-lizard-Spock 作者:杨敬升 日期:2020/11/15 """ import random def name_to_number(name): if name=='石头' : name=0 if name=='史波克' : name=1 if name=='纸' : name=2 if name=='蜥蜴' : name=3 if name=='剪刀' : name=4 return name def number_to_name(n...
false
69163cc318847e1c18b91c7c7c6203aee9e7365b
QUSEIT/django-drf-skel
/libs/utils.py
701
4.125
4
from decimal import Decimal import random import string def convert_weight_unit(from_, to, weight): """单位转换""" units = ['lb', 'oz', 'kg', 'g'] kg_2_dict = { 'oz': Decimal('35.2739619'), 'lb': Decimal('2.2046226'), 'g': Decimal(1000), 'kg': Decimal(1), } if from_ no...
true
987b4ab8d7c7a262ece34dabdbdd182c087adc2c
kelseyoo14/oo-melons
/melons.py
2,009
4.28125
4
"""This file should have our order classes in it.""" class AbstractMelonOrder(object): """A melon order at UberMelon.""" # initializing class attributes that are default for all melons order shipped = False def __init__(self, species, qty, order_type, tax, country_code): """Initialize melon o...
true
1c1a06d62faada3fbb4992a94b6fa909e07ae4fc
Thraegwaster/my-pi-projects
/old-rpi-files/test_count.py
327
4.125
4
# This is just a test def testcount(): myCount = raw_input("Enter your count: ") if myCount == '3': print("The number of thy counting") elif myCount == '4': print("Four shalt thou not count") elif myCount == '5': print("Five is right out") else: print("Thou shalt count to three, no more, no less.") testc...
true
9efee6b49cc9b260986d5dbe7db8df7c48d7a1ea
Thraegwaster/my-pi-projects
/python3/chris/primefactorizor/divider.py
662
4.25
4
# Divider # Takes a number and a divisor as input, then counts how many times # the number goes into the divisor before a remainder is enocuntered. def divider(dividend, divisor): index = 0 # we don't want dividend to be changed by the subsequent calculation. quotient = dividend while quotient % divisor == 0: ...
true
3cc7c35b40fef068a4cc6c697d0016c03a522807
endurance11/number-game
/gtn.py
659
4.25
4
print(''' Welcome If you want to beat the Computer, guess the right number between 0 and 9 Remember you have only 3 guesses ''') name=input("What's your name? ") import random number=random.randint(0,9) guess_count=0 guess_limit=3 while guess_count<guess_limit: guess=int(input("@@@@>>> GUESS : ")) guess_count+=1...
true
c7d4837df914029e8595e16fdab3589c2bbc2a5f
furkanbakkal/Machine-Learning-with-Tensorflow
/draw.py
1,064
4.1875
4
# draw square in Python Turtle from os import name import turtle import time def boxing(start_point_x, start_point_y,length,label): t = turtle.Turtle() turtle.title("Squid Game Challange") wn = turtle.Screen() wn.setup(1200, 800) wn.bgpic("test.gif") t.hideturtle() t.penup() ...
false
aba13551e40c413eff1db924393773a94a607eeb
giangtranml/Project-Euler
/P1-10/p4.py
884
4.21875
4
""" Name: Largest palindrome product. 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. ---------------------------...
true
83300e85e3fad296133b01f26bd276208f18cc06
modibhargav/python11amweek
/nummax.py
241
4.125
4
x=int(input("Enter Num1 :")) y=int(input("Enter Num2 :")) z=int(input("Enter Num3 :")) if x>y: if x>z: print("%d is max"%x) else: print("%d is max"%z) elif y>z: print("%d is max"%y) else: print("%d is max"%z)
false
09b9bdaecc3aecd8a4562096bc262df90135ca1c
hi-yee/MyPython
/py_14 字符串.py
1,427
4.1875
4
""" 字符串 1、 字符串和元组一样,一旦定下来就不能更改,如果需要更改只能 str = 'i love my family' str =str[:6] + '插入的字符串' + str[6:] 比较操作符,逻辑操作符,成员关系操作符的操作与列表/元组是一样的 """ # 2、 通过拼接就字符串的各部分得到新的字符串,并不是真正意义上的改变了原字符串,原来的那个‘家伙’ # 还在,只是将变量指向了新的字符串(旧的字符串一旦失去了变量的引用,就是会Python的垃圾回收机制释放掉) str = 'i love my family' str = str[:6] print(str) # 3、当需要访问字符串的其中一个字符...
false
31132c770344013588f88d6178ebca95df3d869c
viltsu123/basic_python_practice
/data_analysis_learning/MatplotlibExample.py
1,653
4.28125
4
import numpy as np import matplotlib.pyplot as plt print("** Import matplotlib.pyplot as plt and set %matplotlib inline if you are using the jupyter notebook. What command do you use if you aren't using the jupyter notebook?**") print("plt.show()") print() x = np.arange(0, 100) y = x*2 z = x**2 ''' ## Exercise 1 ** ...
true
94ee5e375cb64e6b6786a95f1e62148b1e45b0ef
Nishi216/PYTHON-CODES
/NUMPY/numpy8.py
1,107
4.34375
4
''' Numpy sorting ''' #Different ways of sorting import numpy as np array = np.array([[10,2,4],[5,9,1],[3,2,8]]) print('The array is : \n',array) print('The sorted array is : \n',np.sort(array,axis=None)) print('Sorting array along the rows : \n',np.sort(array,axis=1)) print('Sorting array along the columns : ...
true
99d11a07744936b5fc9f64e07c2237d23c45236e
Nishi216/PYTHON-CODES
/NUMPY/numpy10.py
614
4.25
4
''' Creating your own data type and using it to create the array ''' import numpy as np dt = np.dtype(np.int64) print('The data type is: ',dt) print() dt = np.dtype([('age',np.int32)]) print('The data type defined is: ',dt) print('The data type of age is: ',dt['age']) print() dt = np.dtype([('name','S20'...
true
7760126769cbf27c81971da7354bc33c57fd3085
Nishi216/PYTHON-CODES
/DICTIONARY/dict1.py
1,527
4.34375
4
#for creating a dictionary dict = {'prog_lang1':'python','prog_lang2':'java','prog_lang3':'c++','prog_lang4':'javascript'} print('The dictionary created is: ') print(dict) print() #to get only the keys from dictionary print('The keys are: ',dict.keys()) #this will give in list form for val in dict....
true
42b3891d2911ea5f8f42f74f223f6120ee4c255a
caglagul/example-prime-1
/isprimex.py
555
4.1875
4
def isprime(x): counter = 0 for i in range(2, x): if x % i == 0: counter = counter + 1 if counter == 0: print("True! It is a prime number.") else: print("False! It is not a prime number.") while True: x = int(input("Enter a number:")) if x>0: if x %...
true
05d25aedab2b5f0916042557f2635ba79a9d9257
ShunKaiZhang/LeetCode
/search_insert_position.py
776
4.1875
4
# python3 # Given a sorted array and a target value, return the index if the target is found. # If not, return the index where it would be if it were inserted in order. # You may assume no duplicates in the array. # Here are few examples. # [1,3,5,6], 5 → 2 # [1,3,5,6], 2 → 1 # [1,3,5,6], 7 → 4 # [1,3,5,6],...
true
8a2027785914b52545d65b1332d2502ced8e3b5d
ShunKaiZhang/LeetCode
/flatten_binary_tree_to_linked_list.py
1,491
4.40625
4
# python3 # Given a binary tree, flatten it to a linked list in-place. # For example, # Given # 1 # / \ # 2 5 # / \ \ # 3 4 6 # The flattened tree should look like: # 1 # \ # 2 # \ # 3 # \ # 4 # \ # ...
true
900d468157c948c32bc959f9462e861e765a9d85
ShunKaiZhang/LeetCode
/reverse_words_in_a_string_III.py
484
4.21875
4
# python3 # Given a string, you need to reverse the order of # characters in each word within a sentence while still preserving whitespace and initial word order. # Example: # Input: "Let's take LeetCode contest" # Output: "s'teL ekat edoCteeL tsetnoc" # My solution class Solution(object): def reverseWo...
true
72fa161b02264138f4c7ec6b2e12f31413c23baa
ShunKaiZhang/LeetCode
/binary_search_tree_iterator.py
1,317
4.1875
4
# python3 # Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. # Calling next() will return the next smallest number in the BST. # Note: next() and hasNext() should run in average O(1) time and uses O(h) memory, where h is the height of the tree....
true
36574b984807772900de46bab6121a6932936d7c
MaxDol8888/CodeClubProjects
/quizshowGame.py
736
4.125
4
print('======= WELCOME TO GABY''S QUIZSHOW! =======') score = 0 #ask first question print("What city is this years Olympics in?") answer = input() if answer == "Rio" or answer == "rio": print("Correct!") score += 1 print("Your current score is:", score) else: print("Your current score is:", score) ...
true
410308838ec85af96605487ecbcb139688446a83
christos-dimizas/Python-for-Data-Science-and-Machine-Learning
/pythonDataVisualization/Seaborn/regressionPlot.py
2,810
4.1875
4
# ------------------------------------------------------------ # # ------- Regression Plots ------- # # Seaborn has many built-in capabilities for regression plots, # however we won't really discuss regression until the machine # learning section of the course, so we will only cover the # lmplot() function...
true
bf25de63b2eab4bc13a97a2ebcc8f61232c3bbe1
jaugustomachado/Curso-Next-Python
/Aula 2 - operadores lógicos e estrutura condicional/bhaskara.py
1,175
4.1875
4
#Faça um programa que calcule as raízes de uma equação do segundo grau, na forma ax2 + bx + c. # O programa deverá pedir os valores de a, b e c e fazer as consistências, # informando ao usuário nas seguintes situações: # a- Se o usuário informar o valor de A igual a zero, a equação não é do segundo grau # e o progr...
false
a0878140048d20558fa8917718542a0ee465c567
TerryLun/Code-Playground
/generate_magic_squares.py
727
4.125
4
import copy import magic_square import rotate_matrix import flip_matrix def generate_magic_squares_three_by_three(): magic_squares = [] m = magic_square.solve(3) magic_squares.append(copy.deepcopy(m)) for _ in range(3): rotate_matrix.rotate_matrix(m) magic_squares.append(copy.deepco...
false
bbf8b5718568d7b9ef2974b393b8ce361eeefe1f
TerryLun/Code-Playground
/Leetcode Problems/lc1389e.py
680
4.28125
4
""" 1389. Create Target Array in the Given Order Given two arrays of integers nums and index. Your task is to create target array under the following rules: Initially target array is empty. From left to right read nums[i] and index[i], insert at index index[i] the value nums[i] in target array. Repeat the previous st...
true
9313918ae338b6950bc3df26b30b83962403e82a
syvwlch/MIT-OpenCourseWare---6.00
/ps1b.py
1,291
4.34375
4
# Problem Set 1 # Name: Mathieu Glachant # Collaborators: None # Time Spent: 0:30 # # Gathering user inputs initial_balance=float(raw_input('Enter the outstanding balance' ' on your credit card: ')) annual_interest_rate=float(raw_input('Enter the annual credit card interest rate' ...
true
185a14e652863682964e15764408405f45459dc9
harshilvadsara/Getting-started-with-python-Coursera
/Assignment 5.2.py
391
4.15625
4
largest = None smallest = None while True: num = input("Enter a number: ") if num == "done" : break try : numb = int(num) except : print('Invalid input') if smallest is None : smallest = numb elif numb < smallest : smallest = numb elif numb > largest : largest = numb print("Maximum is", largest) print("Minimum is", sma...
true
ce952e7599a131cf66e9079a68505a09438b2b77
MarcBanuls/Freecodecamp_Projects
/Data_Analysis_With_Python_Projects/Mean_Variance_Standard_Deviation_Calculator/mean_var_std.py
1,431
4.1875
4
# Import Numpy import numpy as np def calculate(lst): # In case the list has the expected length, it will be reshaped to a 3x3 matrix if len(lst) == 9: reshaped = np.reshape(lst, (3,3)) # In case the list has a different length, a ValueError is raised else: raise ValueError("List must c...
true
62e00457178016c2402e9e6413b2a6c83505d33d
mohammedvaghjipurwala/Learning-Python-
/Palindrome.py
414
4.625
5
################################################# # #Ask the user for a string and print out whether this string is a palindrome or not. # ################################################# Str = input("Enter a string: ").lower() ### Reverse the string Rev_str = Str[::-1] #condition if palindrome if Str == Rev_str...
true
f6847b87e545e85958b4b887a495a89394863a25
mohammedvaghjipurwala/Learning-Python-
/DrawBoard.py
1,094
4.5
4
####################################################################### ''' 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, t...
true
594fbb3446570ebd9253162ee6a1f89828a8a49d
Srajan-Jaiswal/Python-Programming
/amstrong_number.py
213
4.1875
4
a=int(input("Enter the number: ")) num=a ans=0 while(num>0): d = num%10 ans+=pow(d,3) num = int(num/10) if(ans==a): print("It's an amstrong number.") else: print("It's not an amstrong number")
true
bf27462cadd90e8001922e3fdf5ef602671f2aba
Jcvita/CS1
/Week1/hexes.py
1,201
4.125
4
""" Joseph Vita 8/26/19 CS-141 Herring hexes.py uses turtle to draw 2 large hexagons that are comprised of smaller hexagons. The second hexagon is offset by the same distance as one side of a hexagon. """ import turtle def makeHex(): """generates a hexagon by moving forward 50 pixels 6 times with a...
false
95d45a6991967fecc5356eefce42740706d50514
Jcvita/CS1
/Week7/biggiesort.py
1,608
4.25
4
""" Joseph Vita CSCI-141 Herring 10/9/19 biggiesort.py reads numbers from a file, puts them in a list and sorts them using the BiggieSort algorithm """ def main(): # file = open(input("Sort which file? ")) file = open('C:\\Users\\jcvit\\Documents\\CS1\\Week7\\nums') lines = file.readlines() tempstr =...
true
8141a45c20d0dc7cc3cb51f2faf361bfbeb7e1b1
Jcvita/CS1
/Week4/zigzag.py
1,728
4.3125
4
""" Joseph Vita Program creates a colored zig zag stair shape using recursion """ import turtle def main(): turtle.speed(0) depth = int(input("How many layers do you want? ")) zigzag(100, depth, 0) turtle.done() def draw_l(size, back, count): """ param: size precondition: turtle facing...
true
086243d392736aeb25fec6784922fde63c5b0873
anushalihala/SOC2018
/hackathons/week2/trienode.py
1,703
4.375
4
#!/usr/bin/env python3 class TrieNode(object): """ This class represents a node in a trie """ def __init__(self, text: str): """ Constructor: initialize a trie node with a given text string :param text: text string at this trie node """ self.__text = text ...
true
bb3e5d77d477bc3f690b548406bacab3e31ac902
Zumh/PythonUdemyLessons
/PythonLessons/FibonnaciNumber.py
2,962
4.28125
4
# This is Naive algorithm for calculating nth term of Fibonnaci Sequence # This is the big-O notation formula, T(n) = 3 + T (n-1) + T(n-2). # Here we create the program to caclulate fibonnaci number # First we assign two number in dynamic array or datastructer which is 0 and 1 # Then we add the number using recursive f...
true
642fe00d7ebcade604de37a6c2e67c80e0773ff4
ss2576/Interview
/Lesson_2/task_1.py
1,191
4.1875
4
""" Проверить механизм наследования в Python. Для этого создать два класса. Первый — родительский (ItemDiscount), должен содержать статическую информацию о товаре: название и цену. Второй — дочерний (ItemDiscountReport), должен содержать функцию (get_parent_data), отвечающую за отображение информации о товаре в одной...
false
8db434a7005d40751cdf84db5a06917fe8e8b305
ss2576/Interview
/Lesson_1/task_3.py
1,944
4.25
4
""" Задание 3. Разработать генератор случайных чисел. В функцию передавать начальное и конечное число генерации (нуль необходимо исключить). Заполнить этими данными список и словарь. Ключи словаря должны создаваться по шаблону: “elem_<номер_элемента>”. Вывести содержимое созданных списка и словаря. Пример: ( [18, 22, ...
false
cfd2cc81cc9e04c64b16f0a01c17c9c01da54143
quanlidavid/top50pythoninterviewquestions
/Q49.py
386
4.15625
4
# 49. What is the output of following code in Python? # >>>name = 'John Smith' # print name[:5]+name[5:] """ John Smith This is an example of Slicing. Since we are slicing at the same index, the first name[:5] gives the substring name upto 5th location excluding 5th location. The name[:5] gives the rest of the substr...
true
b3ae13465e597c61dc648a0d91bfb527fdd10ba1
Daymond-Blair/picking-up-python
/55_oo_inheritance_basics_overriding methods_and_str_special_method_default_values_for_methods.py
1,995
4.125
4
# 55 56 57 OO Inheritance Basics, Overriding Methods, Overriding __str__ special_method_default_values_for_methods # Python conventions: # 2. Class names should use CapWords convention. # 3. Variables should use thisStyle convention. # 4. Always use self for the first argument to instance methods. # 5. When writing me...
true
237598368af3a1fb9f7ef1058419b1ff5cbc8e71
Daymond-Blair/picking-up-python
/48_49_tkinter_gui.py
1,098
4.125
4
# 48 49 tkinter gui from tkinter import * # MODULE/PACKAGE that contains many many classes - * means import ALL OF THESE CLASSES FOR USE root = Tk() # instance of Class Tk() from MODULE TKINTER aka OBJECT!!! pythonCourseLogo = PhotoImage(file="giphy-downsized.gif") # photo image function grabs image file rightLab...
true
146fc2c4c3f535a6dc977ba40f0bd6110b582f1e
SuperCXW/byte_of_python_demos
/return.py
534
4.21875
4
# def maxium(x, y): # # return # # if x > y: # # x == 1 # # elif x == y: # # x == 1 # # # return 'The numbers are equal' # # else: # # x == 1 # # # return y # '''ghfvjhgjhk # ''' # print(1) # # # # print(maxium(3, 1)) # print(maxium(3, 4).__doc__) de...
false
ced51dfc8fe013921040fb178e64d9edae42ee3e
dvishnu/py_basics
/classes.py
1,851
4.59375
5
# basics on python classes # __init_() is always executed when a class is being initiated class student: def __init__(self,name,age): self.name = name # self reference self.age = age print("Hi My name is {} and i am {} years old".format(name,age)) s1 = student("Vishnu", 28) print("My age ...
true
3e8922eb850931e0ef6b64ca092e497e11f2d668
NCPlayz/screen
/screen/utils/math.py
792
4.125
4
import math def distance(*pairs): """ Calculates euclidean distance. Parameters ---------- *pairs: Tuple[:class:`int`, :class:`int`] An iterable of pairs to compare. Returns ------- :class:`float` The euclidean distance. """ return math.sqrt(sum((p[0] - p[1])...
true
2dea1231a318718f498a34f7515905ac2ea10241
Cryafonic/ConsoleCalculator
/Calculator.py
707
4.125
4
def subtract(): return num1 - num2 def multiply(): return num1 * num2 def devide(): return num1 / num2 def add(): return num1 + num2 stop = "quit" stop += input("Type quit to exit:") for x in stop: if x == stop: break else: num1 = int(input('Choose a number: ')) nu...
false
312a93a4d26a775412c1be13455ec503f6fc1f16
dbhoite/LearnPython
/DataStructures.py
2,199
4.25
4
def findFirstDuplicate(numlist): """Returns the first duplicate number in a given list, None if no duplicate Arguments: numlist {list[integer]} -- input list of integers Returns: integer -- first duplicate number """ # set operations numset = set() for num in numlist: ...
true
d1962c1a9a3a1bbb97a7ab9bd7567f4638230674
dsabalete/binutils
/lpthw/ex15.py
617
4.15625
4
# -*- coding: utf-8 -*- # http://learnpythonthehardway.org/book/ex15.html # import feature argv from package sys from sys import argv # extract values packed in argv script, filename = argv # open file which name is in filename var txt = open(filename) # Nice output print "Here's your file %r:" % filename # File co...
true
0b374c001ff08647d818d6f3f3f7b88719b0384a
scumroe/aws-dump
/03DataTypes/pythag.py
1,416
4.28125
4
import math def get_sides(a=0, b=0, c=0, o=1): if o == 1: c = round(math.sqrt(a**2+b**2), 2) print("The hypotenuse (side c )is:\nThe square root of: %s^2 + %s^2 = %s" % (a , b, c)) elif o == 2: a = round(math.sqrt(c**2-b**2), 2) print("Side a is:\n The square root of %s^...
false
29ea7e14f93cd6270cdc8d491d11f5c23f93d6cb
temaari/PyCode
/Ch2/variables.py
203
4.125
4
f = 0 # print(f) # f = "abc" # print(f) # print("this is a string" + str(123)) def someFunction(): global f f="def" print(f) someFunction() print(f) del f print(f) # Global name 'f' is not defined
false
f1d72706672bca03e29324ee53d0218eaaabe5aa
likendero/SGE
/python/ejercicios3JavierGonzalezRives/calculos.py
1,936
4.15625
4
from math import log10 # metodo que sirver para introducir dos numeros def introducir_numeros(): # bloque try que controla los posibles errores que hallan sucedido try: numero1 = int(input("introduzca el primer numero: ")) numero2 = int(input("introduzca el segundo numero: ")) except ValueEr...
false
cf7cab61cb8c1c793f29736da9cf655d086fe804
Ziaulhaq11/pythontim
/overloading.py
562
4.125
4
class Point(): def __init__(self, x =0, y=0): self.x = x self.y = y self.coords = (self.x, self.y) def move(self,x,y): self.x += x self.y += y return x,y def __add__(self, p): return Point(self.x+ p.x,self.y + p.y) def __sub__(self,p): return Point(self.x - p.x,self.y - p.y) def __mul__(self,p)...
false
85a41b62ec3f79d1243a852f3f88fa1a0900d328
pbchandra/cryptography
/cryptography/Python/caesar_crack.py
869
4.3125
4
#we need the alphabet because we convert letters into numerical values to be able to use #mathematical operations (note we encrypt the spaces as well) ALPHABET = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ' #cracking the caesar encryption algorithm with brute-force def caesar_crack(cipher_text): #we try all the possible key...
true
a43ebcb53a12fcd8d75c04cbea2197586d5660c7
suchismitarout/tt
/pallin.py
247
4.125
4
def pallindrome_num(num): num2 = "" for i in str(num): num2 = i + num2 if int(num2) == int(num): print("it is a pallindrome number") else: print("it is not a pallindrome number") n = 150 pallindrome_num(n)
false
c6130096fc3a581323001dcea1f2c9fb696adab7
piyushPathak309/100-Days-of-Python-Coding
/Area of a Circle.py
489
4.46875
4
# Write a Python program that finds the area of a circle from the value of the diameter d. # # The value of d should be provided by the user. # # The area of a circle is equal to pi*(radius)^2. The radius is the value of the diameter divided by 2. # # Round the value of the area to two decimal places. # # You m...
true