blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
1af15c312f75e507b4acb77abc76b25ff8022318
hackettccp/CIS106
/SourceCode/Module5/returning_data1.py
815
4.15625
4
""" Demonstrates returning values from functions """ def main() : #Prompts the user to enter a number. Assigns the user's #input (as an int) to a variable named num1 num1 = int(input("Enter a number: ")) #Prompts the user to enter another number. Assigns the user's #input (as an int) to a variable named num...
true
c359aae7e1cd194eedb023b580f34e42b7663c27
hackettccp/CIS106
/SourceCode/Module2/mixed_number_operations.py
1,699
4.46875
4
""" Demonstrates arithmetic with mixed ints and floats. Uncomment each section to demonstrate different mixed number operations. """ #Example 1 - Adding ints together. #Declares a variable named value1 and assigns it the value 10 value1 = 10 #Declares a variable named value2 and assigns it the value 20 value2 = 20 ...
true
188486bfabc4f36413579d6d1af0aaae3da63681
hackettccp/CIS106
/SourceCode/Module10/entry_demo.py
504
4.125
4
#Imports the tkinter module import tkinter #Main Function def main() : #Creates the window test_window = tkinter.Tk() #Sets the window's title test_window.wm_title("My Window") #Creates an entry field that belongs to test_window test_entry = tkinter.Entry(test_window, width=10) #Packs the entry field o...
true
6e470e6f8219a39ebdb2b862ea9bf85c7710c576
alexbehrens/Bioinformatics
/rosalind-problems-master/alg_heights/FibonacciNumbers .py
372
4.21875
4
def Fibonacci_Loop(number): old = 1 new = 1 for itr in range(number - 1): tmpVal = new new = old old = old + tmpVal return new def Fibonacci_Loop_Pythonic(number): old, new = 1, 1 for itr in range(number - 1): new, old = old, old + new return new print(Fib...
true
5af688c66904d3d6b0ad57fbb008c93d2797ddd8
alexeahn/UNC-comp110
/exercises/ex06/dictionaries.py
1,276
4.25
4
"""Practice with dictionaries.""" __author__ = "730389910" # Define your functions below # Invert function: by giving values, returns a flip of the values def invert(first: dict[str, str]) -> dict[str, str]: """Inverts a dictionary.""" switch: dict[str, str] = {} for key in first: value: str = ...
true
43fff8b5123088e2fa7416157b729b0ddb3542a8
cassjs/practice_python
/practice_mini_scripts/math_quiz_addition.py
1,687
4.25
4
# Program: Math Quiz (Addition) # Description: Program randomly produces a sum of two integers. User can input the answer # and recieve a congrats message or an incorrect message with the correct answer. # Input: # Random Integer + Random Integer = ____ # Enter your answer: # Output: # Correct = Congratulations! # In...
true
0970f57aa338249ee6466c1dadadeee769acf7c6
MurphyStudebaker/intro-to-python
/1-Basics.py
2,086
4.34375
4
""" PYTHON BASICS PRACTICE Author: Murphy Studebaker Week of 09/02/2019 --- Non-Code Content --- WRITING & RUNNING PROGRAMS Python programs are simply text files The .py extension tells the computer to interperet it as Python code Programs are run from the terminal, which is a low level interaction with the c...
true
874769f6eddcea51823c926e4b520e6cc0bbcf89
IfDougelseSa/cursoPython
/exercicios_seccao4/46.py
266
4.125
4
# Digitos invertidos num = int(input('Digite o numero com 3 digitos: ')) primeiro_numero = num % 10 resto = num // 10 segundo_numero = resto % 10 resto = resto //10 terceiro_numero = resto % 10 print(f'{primeiro_numero}{segundo_numero}{terceiro_numero}')
false
7ea222e7fee925a91e1e9cd3781545759e1f44c6
IfDougelseSa/cursoPython
/exercicios_seccao4/47.py
307
4.1875
4
# Numero por linha x = int(input("Digite o numero: ")) quarto_numero = x % 10 resto = x // 10 terceiro_numero = resto % 10 resto = resto // 10 segundo_numero = resto % 10 resto = resto // 10 primeiro_numero = resto % 10 print(f'{primeiro_numero}\n{segundo_numero}\n{terceiro_numero}\n{quarto_numero}')
false
f721cd2800a98b3e5eec010e698bb4e07f0d8de2
sudoabhinav/competitive
/hackerrank/week-of-code-36/acid-naming.py
544
4.15625
4
# https://www.hackerrank.com/contests/w36/challenges/acid-naming def acidNaming(acid_name): first_char = acid_name[:5] last_char = acid_name[(len(acid_name) - 2):] if first_char == "hydro" and last_char == "ic": return "non-metal acid" elif last_char == "ic": return "polyatomic acid" ...
false
a3c3790812f74749f601c0075b115fbe2a296ca1
sudoabhinav/competitive
/hackerrank/algorithms/strings/pangrams.py
232
4.125
4
# https://www.hackerrank.com/challenges/pangrams from string import ascii_lowercase s = raw_input().strip().lower() if len([item for item in ascii_lowercase if item in s]) == 26: print "pangram" else: print "not pangram"
true
dfd5901190b3715f8b3727b9600518bed7b29a36
jdalichau/classlabs
/letter_removal.py
982
4.1875
4
#CNT 336 Spring 2018 #Jaosn Dalichau #jdalichau@gmail.com #help with .replace syntax found it the book 'how to think like a computer scientist' interactive edition #This code is designed to take an input name and remove vowels of any case n = input('Enter your full name: ') #input statement for a persons full ...
false
6ad233abf66a03c2690d6450f9a54f56d83048ed
sripadaraj/pro_programs
/python/starters/biggest_smallest.py
1,015
4.1875
4
print "The program to print smallest and biggest among three numbers" print "_____________________________________________________________" a=input("enter the first number") b=input("enter the second number") c=input("enter the third number") d=input("enter the fourth number") if a==b==c==d : print "all are equ...
false
b6bd22d9d207e9cd75d3f06e4e9e43d3b80af360
Shijie97/python-programing
/ch04/8-function(3).py
685
4.1875
4
# !user/bin/python # -*- coding: UTF-8 -*- def func(a, b = 2, c = "hello"): # 默认参数一定是从最后一个开始往左连续存在的 print(a, b, c) func(2, 100) # 覆盖了b = 2 i =5 def f(arg = i): print(i) i = 6 f() # 6 # 在一段程序中,默认值只被赋值一次,如果参数中存在可变数据结构,会进行迭代 def ff(a, L = []): L.append(a) return L print(ff(1)) # [1] ...
false
01edc69712cc340ab98aab6edef608483102deda
Shijie97/python-programing
/ch05/2-list(2).py
499
4.125
4
# !user/bin/python # -*- coding: UTF-8 -*- from collections import deque lst = [100, 1, 2, 3, 2] # 列表当做stack使用 lst.append(5) # push print(lst) lst.pop() # pop print(lst) # 列表当做queue用 queue = deque(lst) print(queue) queue.append(5) # 入队 deque([0, 1, 2, 3, 2]) print(type(queue)) # <class 'collections.d...
false
78b8f148a5404d3522e7b9944f810095793c4411
aquibjamal/hackerrank_solutions
/write_a_function.py
323
4.25
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Wed Sep 11 21:41:35 2019 @author: aquib """ def is_leap(year): leap = False # Write your logic here if year%4==0: leap=True if year%100==0: leap=False if year%400==0: leap=True return lea...
false
e8cff56a53e29a80d047e999918b43deff019c3e
sauravsapkota/HackerRank
/Practice/Algorithms/Implementation/Beautiful Days at the Movies.py
713
4.15625
4
#!/bin/python3 import os # Python Program to Reverse a Number using While loop def reverse(num): rev = 0 while (num > 0): rem = num % 10 rev = (rev * 10) + rem num = num // 10 return rev # Complete the beautifulDays function below. def beautifulDays(i, j, k): count = 0 ...
true
1ae7cdf0c2e2b51586428e3627ee4244e9650cab
eduardrich/Senai-2.1
/3.py
529
4.1875
4
#Definição da lista Val = [] #Pede para inserir os 20 numeros para a media for c in range(0,20): Val.append ( int(input("Digite aqui os valores para a média: ")) ) #detalhamento da soma e conta dos numeros dentro da lista SomVal = sum(Val) NumVal = len(Val) #Tira a media MedVal = SomVal / NumVal print("Media da...
false
3fa2fe6caf2a0cfda09a745dc8c7fceb7d381e5a
YayraVorsah/PythonWork
/lists.py
1,673
4.4375
4
names = ["John","Kwesi","Ama","Yaw"] print(names[-1]) #colon to select a range of items names = ["John","Kwesi","Ama","Yaw"] print(names[::2]) names = ["John","Kwesi","Ama","Yaw"] names[0] ="Jon" #the list can be appended print(names) numbers = [3,4,9,7,1,3,5,] max ...
false
f2cacc2f354655e601273d4a2946a2b27258624d
YayraVorsah/PythonWork
/conditions.py
1,769
4.1875
4
#Define variable is_hot = False is_cold = True if is_hot: #if true for the first statement then print print("It's a hot day") print("drink plenty of water") elif is_cold: # if the above is false and this is true then print this print("It's a co...
true
881a8e4b1aa1eaed9228782eef2440097c2cb301
siyangli32/World-City-Sorting
/quicksort.py
1,439
4.125
4
#Siyang Li #2.25.2013 #Lab Assignment 4: Quicksort #partition function that takes a list and partitions the list w/ the last item #in list as pivot def partition(the_list, p, r, compare_func): pivot = the_list[r] #sets the last item as pivot i = p-1 #initializes the two indexes i and j to partition with ...
true
150810f760c409533200b7252912130cc72e792b
aiman88/python
/Introduction/case_study1.py
315
4.1875
4
""" Author - Aiman Date : 6/Dec/2019 Write a program which will find factors of given number and find whether the factor is even or odd. """ given_number=9 sum=1 while given_number>0: sum=sum*given_number given_number-=1 print(sum) if sum%10!=0: print("odd number") else: print("Even number")
true
764b1f8af7fee5c6d0d1707ab6462fc1d279be36
dadheech-vartika/Leetcode-June-challenge
/Solutions/ReverseString.py
863
4.28125
4
# Write a function that reverses a string. The input string is given as an array of characters char[]. # Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. # You may assume all the characters consist of printable ascii characters. # Exampl...
true
ca042af11712f32c4b089da67c4a9dcfecd6000d
darkblaro/Python-code-samples
/strangeRoot.py
1,133
4.25
4
import math ''' getRoot gets a number; calculate a square root of the number; separates 3 digits after decimal point and converts them to list of numbers ''' def getRoot(nb): lsr=[] nb=math.floor(((math.sqrt(nb))%1)*1000) #To get 3 digits after decimal point ar=str(nb) for i in ar: ls...
true
c0c9303b5127be01a420a033e2d0b6dcbc9e1f2d
chskof/HelloWorld
/chenhs/object/demo7_Override.py
470
4.21875
4
""" 方法重写(覆盖): 如果你的父类方法的功能不能满足你的需求,你可以在子类重写你父类的方法 """ # 定义父类 class Parent: def myMethod(self): print('调用父类方法') class Child(Parent): def myMethod(self): print('调用子类方法') c = Child() # 创建子类对象 c.myMethod() # 调用子类重写的方法 super(Child, c).myMethod() # 用子类对象调用父类已被覆盖的方法
false
01b8496d29a0a14957447204d655e441254aeb75
worasit/python-learning
/mastering/generators/__init__.py
1,836
4.375
4
""" `A generator` is a specific type of iterator taht generates values through a function. While traditional methods build and return a `list` of iterms, ad generator will simply `yield` every value separately at the moment when they are requested by the caller. Pros: - Generators pause execution completely u...
true
b3c14db3a26d5d6e122e96fc736c8266e907ed97
lfvelascot/Analysis-and-design-of-algorithms
/PYTHON LOG/tuplas.py
1,022
4.125
4
tupla1=("Hola","Mi",25,"nombre",25) print("Elemento en la posicion 2 : ",tupla1[2]) print("///////") #Convertir una tupla a lista lista=list(tupla1) print("Tupla convertirda en lista\n",lista) print("///////") ##Convetir una lista a tupla tuplar=tuple(lista) print("Lista convertida en tupla\n",tuplar) print("...
false
c03dd868f24eec310e537c5c224b9627b469a811
rileyworstell/PythonAlgoExpert
/twoNumSum.py
900
4.21875
4
""" Write a function that takes in a non-empty array of distinct integers and an integer representing a target sum. If any two numbers in the input array sum up to the target sum, the function should return them in an array, in any order. If not two numbers sum up to the target sum, the function should return an empty...
true
c79ba3a6834fbb5a0f8d5c2ebabe0d4f6f790452
mwongeraE/python
/spellcheck-with-inputfile.py
904
4.15625
4
def spellcheck(inputfile): filebeingchecked=open(inputfile,'r') spellcheckfile=open("words.txt",'r') dictionary=spellcheckfile.read().split() checkedwords=filebeingchecked.read().split() for word in checkedwords: low = 0; high=len(dictionary)-1 while low <= high: ...
true
89038721966e0c3974e91a3c58db4c6245ffa354
robwalker2106/100-Days
/day-18-start/main.py
1,677
4.1875
4
from turtle import Turtle, Screen from random import randint, choice don = Turtle() #don.shape('turtle') don.color('purple3') #don.width(10) don.speed('fastest') screen = Screen() screen.colormode(255) def random_color(): """ Returns a random R, G, B color. :return: Three integers. """ r = randi...
true
a3337bde5cf7d0b0712a15f23d2ab63fed289c2f
nickdurbin/iterative-sorting
/src/searching/searching.py
1,860
4.3125
4
def linear_search(arr, target): # Your code here # We simply loop over an array # from 0 to the end or len(arr) for item in range(0, len(arr)): # We simply check if the item is equal # to our target value # If so, then simply return the item if arr[item] == target: ...
true
c346a76f33f96248e4782304636a32c12238c6aa
adilawt/Tutorial_2
/1_simpsons_rule.py
672
4.15625
4
# ## Tutorial2 Question3 ## a) Write a python function to integrate the vector(in question #2) using ## Simpson's Rule # import numpy as np def simpsonsrule(f, x0, xf, n): if n & 1: print ("Error: n is not a even number.") return 0.0 h = float(xf - x0) / n integral = 0.0 x = float...
true
ab1a0c5e0f29e91a4d2c49a662e3176f4aa158f5
salihbaltali/nht
/check_if_power_of_two.py
930
4.1875
4
""" Write a Python program to check if a given positive integer is a power of two """ def isInt(x): x = abs(x) if x > int(x): return False else: return True def check_if_power_of_two(value): if value >= 1: if value == 1 or value == 2: return True el...
true
89994b56da945167c927ad2617a5b9cbfc2d4a6b
rkovrigin/crypto
/week2.py
2,872
4.25
4
""" In this project you will implement two encryption/decryption systems, one using AES in CBC mode and another using AES in counter mode (CTR). In both cases the 16-byte encryption IV is chosen at random and is prepended to the ciphertext. For CBC encryption we use the PKCS5 padding scheme discussed in the lecture (1...
true
0c40f14af82893bc8ccce60259424a98aaf28574
Wintus/MyPythonCodes
/PrimeChecker.py
608
4.15625
4
'''Prime Checker''' def is_prime(n): '''check if interger n is a prime''' n = abs(int(n)) # n is a pesitive integer if n < 2: return False elif n == 2: return True # all even ns aren't primes elif not n & 1: # bit and return False else: # for all odd ns ...
false
1350fcd3baa866a02f5db2c066420eaa77e00892
BrasilP/PythonOop
/CreatingFunctions.py
1,404
4.65625
5
# Creating Functions # In this exercise, we will review functions, as they are key building blocks of object-oriented programs. # Create a function average_numbers(), which takes a list num_list as input and then returns avg as output. # Inside the function, create a variable, avg, that takes the average of all th...
true
566ff9db1680e613ef013e6918d274b1382c2934
codethat-vivek/NPTEL-Programming-Data-Structures-And-Algorithms-Using-Python-2021
/week2/RotateList.py
646
4.28125
4
# Third Problem: ''' A list rotation consists of taking the first element and moving it to the end. For instance, if we rotate the list [1,2,3,4,5], we get [2,3,4,5,1]. If we rotate it again, we get [3,4,5,1,2]. Write a Python function rotatelist(l,k) that takes a list l and a positive integer k and returns the list l...
true
1ff1fadb88d860e4d2b97c5c38668bcc880c607c
morzen/Greenwhich1
/COMP1753/week7/L05 Debugging/02Calculator_ifElifElse.py
1,241
4.40625
4
# this program asks the user for 2 numbers and an operation +, -, *, / # it applies the operation to the numbers and outputs the result def input_and_convert(prompt, conversion_fn): """ this function prompts the user for some input then it converts the input to whatever data-type the programmer ha...
true
c2e8208d3f33abd0ba15b7e1a51a13c54a0b2135
SerenaPaley/WordUp
/venv/lib/python3.8/WordUp.py
1,231
4.28125
4
# Serena Paley # March, 2021 from getpass import getpass def main(): print('Welcome to Word Up') secret_word = getpass('Enter the secret word') current_list = ["_"] * len(secret_word) letter_bank = [] guess = "" while "_" in current_list: print_board(current_list) get_letter(...
false
86f0b87b8e1aa0178656a4d418774926376a23d0
cindy3124/python
/testerhome_pratice/pytest_practice/pytest_bubble.py
376
4.15625
4
#! /usr/bin/env python # coding=utf-8 import random def bubble_sort(nums): for i in range(len(nums)-1): for j in range(len(nums)-i-1): if nums[j] > nums[j+1]: nums[j], nums[j+1] = nums[j+1], nums[j] print(nums) return random.choice([nums, None, 10]) if __name__ == '_...
false
36e7cd8cc96264f50e49f9cd2b778fc642434312
GaryZhang15/a_byte_of_python
/002_var.py
227
4.15625
4
print('\n******Start Line******\n') i =5 print(i) i = i + 1 print(i) s = '''This is a multi-line string. This is the second line.''' print(s) a = 'hello'; print(a) b = \ 5 print(b) print('\n*******End Line*******\n')
true
a09f9fe6aa0663cf8143ca71d01553918d6d35a1
Sana-mohd/fileQuestions
/S_s_4.py
298
4.34375
4
#Write a Python function that takes a list of strings as an argument and displays the strings which # starts with “S” or “s”. Also write a program to invoke this function. def s_S(list): for i in list: if i[0]=="S" or i[0]=="s": print(i) s_S(["sana","ali","Sara"])
true
a32ad588efb25dad5d64dcf2a29be6e697d5cfdd
Andrewlearning/Leetcoding
/leetcode/String/434m. 字符串中的单词数.py
976
4.25
4
""" 统计字符串中的单词个数,这里的单词指的是连续的不是空格的字符。 请注意,你可以假定字符串里不包括任何不可打印的字符。 示例: 输入: "Hello, my name is John" 输出: 5 解释: 这里的单词是指连续的不是空格的字符,所以 "Hello," 算作 1 个单词。 """ class Solution(object): def countSegments(self, s): """ :type s: str :rtype: int """ if not s and len(s) == 0: ...
false
ed28b398a00b09708cd6cadebe4ce5342d16466b
Andrewlearning/Leetcoding
/leetcode/Random/478m. 在圆内随机生成点(拒绝采样).py
1,711
4.25
4
""" 给定圆的半径和圆心的 x、y 坐标,写一个在圆中产生均匀随机点的函数 randPoint 。 说明: 输入值和输出值都将是浮点数。 圆的半径和圆心的 x、y 坐标将作为参数传递给类的构造函数。 圆周上的点也认为是在圆中。 randPoint 返回一个包含随机点的x坐标和y坐标的大小为2的数组。 示例 1: 输入: ["Solution","randPoint","randPoint","randPoint"] [[1,0,0],[],[],[]] 输出: [null,[-0.72939,-0.65505],[-0.78502,-0.28626],[-0.83119,-0.19803]] """ import rando...
false
ddc89b17a98a81a0e4b2141e487c0c2948d0621a
lfr4704/python_practice_problems
/algorithms.py
1,579
4.375
4
import sys; import timeit; # Big-O notation describes how quickly runtime will grow relative to the input as the input gets arbitrarily large. def sum1(n): #take an input of n and return the sume of the numbers from 0 to n final_sum = 0; for x in range(n+1): # this is a O(n) final_sum += x re...
true
edbe86de9667f66d3cdcdcd120ff76986ab4137e
Schuture/Data-structure
/图算法/图搜索.py
2,937
4.125
4
class Node(): # 单向链表节点 def __init__(self): self.color = 'white' self.d = float('Inf') #与中心点的距离 self.pi = None # 图中的父节点 self.next = None # 只能赋值Node() ''' 循环队列,调用方式如下: Q = Queue() Q.enqueue(5) 往队尾加一个元素 Q.dequeue() 删除队头元素''' class Queue(): def __init__(sel...
false
4459792eff08ed45ddf0bec5cb0337a44e6515ae
olexandrvaitovich/homework
/module7.py
232
4.21875
4
def calculate_sqr(n): """ Calculate squre of a positive integer recursively using n^2 = (n-1)^2 + 2(n-1)+ 1 formula """ if n == 1: return 1 else: return calculate_sqr(n - 1) + 2 * (n - 1) + 1
false
350caa2ceff6bd5a7a05be797bd316c736410ffe
richard1230/NLP_summary
/python字符串操作/1清除与替换.py
1,041
4.34375
4
str1 = " hello world, hello, my name is Richard! " print(str1) #去除首尾所有空格 print(str1.strip()) #去除首部所有空格 print(str1.lstrip()) #去除尾部所有空格 print(str1.rstrip()) #也可以去掉一些特殊符号 print(str1.strip().rstrip('!')) #方法可以组合使用 先去掉首尾空格 在去掉尾部! #注意不能直接str.rstrip('!'),因为此时str的尾部是空格,得先去掉空格再去叹号。 #字符串替换 print(str1) print(str1.replace('h...
false
01d9030aa89da902667a6ea05a45bbd9761162ef
DerekHunterIcon/CoffeeAndCode
/Week_1/if_statements.py
239
4.1875
4
x = 5 y = 2 if x < y: print "x is less than y" else print "x is greater than or equal to y" isTrue = True if isTrue: print "It's True" else: print "It's False" isTrue = False if isTrue: print "It's True" else: print "It's False"
true
f2ed037552b3a8fdd37b776d5b9df5709b0e494e
SamWaggoner/125_HW6
/Waggoner_hw6a.py
2,742
4.1875
4
# This is the updated version that I made on 7/2/21 # This program will ask input for a list then determine the mode. def determinemode(): numlist = [] freqlist = [] print("Hello! I will calculate the longest sequence of numbers in a list.") print("Type your list of numbers and then type \"end\"."...
true
35f1a4243a2a56315eee8070401ee4f8dc38bf9c
JordanJLopez/cs373-tkinter
/hello_world_bigger.py
888
4.3125
4
#!/usr/bin/python3 from tkinter import * # Create the main tkinter window window = Tk() ### NEW ### # Set window size with X px by Y px window.geometry("500x500") ### NEW ### # Create a var that will contain the display text text = StringVar() # Create a Message object within our Window window_me...
true
4df8eadf0fe84ff3b194ac562f24a94b778a2588
Zioq/Algorithms-and-Data-Structures-With-Python
/7.Classes and objects/lecture_3.py
2,395
4.46875
4
# Special methods and what they are # Diffrence between __str__ & __repr__ """ str() is used for creating output for end user while repr() is mainly used for debugging and development. repr’s goal is to be unambiguous and str’s is to be readable. if __repr__ is defined, and __str__ is not, the object will behave as...
true
835fff2341216766489b87ac7682ef49a47fb713
Zioq/Algorithms-and-Data-Structures-With-Python
/1.Strings,variables/lecture_2.py
702
4.125
4
# concatenation, indexing, slicing, python console # concatenation: Add strings each other message = "The price of the stock is:" price = "$1110" print(id(message)) #print(message + " " +price) message = message + " " +price print(id(message)) # Indexing name = "interstella" print(name[0]) #print i # Slicing # [0:...
true
9123640f03d71649f31c4a6740ba9d1d3eca5caf
Zioq/Algorithms-and-Data-Structures-With-Python
/17.Hashmap/Mini Project/project_script_generator.py
1,946
4.3125
4
# Application usage ''' - In application you will have to load data from persistent memory to working memory as objects. - Once loaded, you can work with data in these objects and perform operations as necessary Exmaple) 1. In Database or other data source 2. Load data 3. Save it in data structure like `Dictionary` 4...
true
517611d9663ae87acdf5fed32099ec8dcf26ee76
Zioq/Algorithms-and-Data-Structures-With-Python
/20.Stacks and Queues/stack.py
2,544
4.25
4
import time class Node: def __init__(self, data = None): ''' Initialize node with data and next pointer ''' self.data = data self.next = None class Stack: def __init__(self): ''' Initialize stack with stack pointer ''' print("Stack created") # Only add st...
true
0be4e99dbd9d44d1e06064a98e038fae55dec91f
oilbeater/projecteuler
/Multiples_of_3_and_5.py
1,058
4.125
4
''' Created on 2013-10-24 @author: oilbeater Multiples of 3 and 5 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. ''' import timeit def sol1(): return sum((i for i in range(1...
false
0d624fefe156321ad52de0d0c4ae42e9cf04d781
XZZMemory/xpk
/Question13.py
1,007
4.15625
4
'''输入2个正整数lower和upper(lower≤upper≤100),请输出一张取值范围为[lower,upper]、且每次增加2华氏度的华氏-摄氏温度转换表。 温度转换的计算公式:C=5×(F−32)/9,其中:C表示摄氏温度,F表示华氏温度。 输入格式: 在一行中输入2个整数,分别表示lower和upper的值,中间用空格分开。 输出格式: 第一行输出:"fahr celsius" 接着每行输出一个华氏温度fahr(整型)与一个摄氏温度celsius(占据6个字符宽度,靠右对齐,保留1位小数)。只有摄氏温度输出占据6个字符, 若输入的范围不合法,则输出"Invalid."。 ''' lower, upper = inpu...
false
76a3faf2f22c74922f3a9a00b3f2380ad878b633
XZZMemory/xpk
/Question12.py
593
4.15625
4
'''本题要求将输入的任意3个整数从小到大输出。 输入格式: 输入在一行中给出3个整数,其间以空格分隔。 输出格式: 在一行中将3个整数从小到大输出,其间以“->”相连。''' a, b, c = input().split() a, b, c = int(a), int(b), int(c) # 小的赋值给变量a,大的赋值给变量b if a > b: temp = a a = b b = temp if c < a: print(str(c) + "->" + str(a) + "->" + str(b)) else: # c<a if c < b: print(str...
false
002c584b14e9af36fe9db5858c64711ec0421533
PaulSayantan/problem-solving
/CODEWARS/sum_of_digits.py
889
4.25
4
''' 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 the natural numbers. ''' import unittest def digitalRoot(n:int): ...
true
96487cf3863ed2216c6ad83109b16e98c8955b3c
SeesawLiu/py
/abc/func/first_class_functions.py
2,150
4.34375
4
# Functions Are Objects # ===================== def yell(text): return text.upper() + '!' print(yell('hello')) bark = yell print(bark('woof')) # >>> del yell # >>> yell('hello?') # NameError: name 'yell' is not defined # >>> bark('hey') # HEY print(bark.__name__) # Functions Can Be Stored In Data Structures #...
false
f99bcedd6bed96991fb8fdf06eba27708ef867b1
dks1018/CoffeeShopCoding
/2021/Code/Python/DataStructures/dictionary_practice1.py
1,148
4.25
4
myList = ["a", "b", "c", "d"] letters = "abcdefghijklmnopqrstuvwxyz" numbers = "123456789" newString = " Mississippi ".join(numbers) print(newString) fruit = { "Orange":"Orange juicy citrus fruit", "Apple":"Red juicy friend", "Lemon":"Sour citrus fruit", "Lime":"Green sour fruit" } veggies =...
true
1c4e7bf09af67655c22846ecfc1312db04c3bfe1
dks1018/CoffeeShopCoding
/2021/Code/Python/Tutoring/Challenge/main.py
967
4.125
4
import time # You can edit this code and run it right here in the browser! # First we'll import some turtles and shapes: from turtle import * from shapes import * # Create a turtle named Tommy: tommy = Turtle() tommy.shape("turtle") tommy.speed(10) # Draw three circles: draw_circle(tommy, "green", 50, 0, 100) draw...
true
760537b38c1899088736d0f4a3ba3d27fe3a29c5
dks1018/CoffeeShopCoding
/2021/Code/Python/Searches/BinarySearch/BinarySearch.py
1,779
4.15625
4
low = 1 high = 1000 print("Please think of a number between {} and {}".format(low, high)) input("Press ENTER to start") guesses = 1 while low != high: print("\tGuessing in the range of {} and {}".format(low, high)) # Calculate midpoint between low adn high values guess = low + (high - low) // 2 high_...
true
6ebdc47b984d3f9b7b65663b2ba01f9b54fc7edf
dks1018/CoffeeShopCoding
/2021/Code/Python/Exercises/Calculator2.py
1,480
4.1875
4
# Variable statements Number1 = input("Enter your first number: ") Number2 = input("Enter your second number: ") NumberAsk = input("Would you like to add a third number? Y or N: ") if NumberAsk == str("Y"): Number3 = input("Please enter your third number: ") Operation = input("What operation would you like to perfo...
true
7b98a668260b8d5c0b729c6687e6c0a878574c9d
ajanzadeh/python_interview
/games/towers_of_hanoi.py
1,100
4.15625
4
# Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules: # 1) Only one disk can be moved at a time. # 2) Each move consists of taking the upper disk from one of the stacks and placing it on...
true
ca091bae52a3e79cece2324fe946bc6a52ca6c2f
mrmuli/.bin
/scripts/python_datastructures.py
2,019
4.15625
4
# I have decided to version these are functions and operations I have used in various places from mentorship sessions # articles and random examples, makes it easier for me to track on GitHub. # Feel free to use what you want, I'll try to document as much as I can :) def sample(): """ Loop through number ran...
true
356122c10a2bb46ca7078e78e991a08781c46254
KingHammer883/21.Testing-for-a-Substring-with-the-in-operator.py
/21.Testing-for-Substring-With-the-in-operator.py
752
4.40625
4
# -*- coding: utf-8 -*- """ Created on Fri Jan 18, 2019 File: Testing for a Substring with the in operator @author: Byen23 Another problem involves picking out strings that contains known substrings. FOr example you might wnat to pick out filenames with a .txt extension. A slice would work for this but using Pyt...
true
0606ac38799bfe01af2feda28a40d7b863867569
PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch
/12. Downloading data from input/downloading-data.py
260
4.15625
4
print("Program that adds two numbers to each other") a = int(input("First number: ")) b = int(input("Second number: ")) #CASTING allows you to change ONE type of variable to another type of variable print("Sum of a =", a, "+", "b =", b, "is equal to", a + b)
true
9dbcec24d2b156aa7f69a8bf1e65ade631e0eea3
sdelpercio/cs-module-project-recursive-sorting
/src/sorting/sorting.py
2,202
4.1875
4
# TO-DO: complete the helper function below to merge 2 sorted arrays def merge(arrA, arrB): elements = len(arrA) + len(arrB) merged_arr = [None] * elements # Your code here while None in merged_arr: if not arrA: popped = arrB.pop(0) first_instance = merged_arr.index(None...
true
0684f210b036b64b9821110bdb976908deeca8ca
Guilherme758/Python
/Estrutura Básica/Exercício i.py
374
4.375
4
# Faça um Programa que peça a temperatura em graus Fahrenheit, transforme e mostre a temperatura em graus Celsius. # C = 5 * ((F-32) / 9). fahrenheit = float(input("Informe a temperatura em graus fahrenheit: ")) celsius = 5 * (fahrenheit-32)/9 if celsius.is_integer() == True: celsius = int(celsius) prin...
false
d4393db248c28cafa20467c616da8428496550fb
Guilherme758/Python
/Estrutura Básica/Exercício j.py
332
4.25
4
# Faça um Programa que peça a temperatura em graus Celsius, transforme e mostre em graus Fahrenheit. celsius = float(input('Passe a temperatura em celsius: ')) fahrenheit = 9*(celsius/5)+32 if fahrenheit.is_integer() == True: fahrenheit = int(fahrenheit) print("A temperatura em fahrenheit é:", f'{fahrenh...
false
e0f808f1c93b832eeb29f9133a86ce99dbbe678d
NuradinI/simpleCalculator
/calculator.py
2,097
4.40625
4
#since the code is being read from top to bottom you must import at the top import addition import subtraction import multiplication import division # i print these so that the user can see what math operation they will go with print("Select operation.") print("1.Add") print("2.Subtract") print("3.Multiply") print("...
true
8ba9f444797916c33a00ce7d7864b1fa60ae6f24
Bongkot-Kladklaen/Programming_tutorial_code
/Python/Python_basic/Ex24_UserInput.py
271
4.1875
4
#* User Input """ Python 3.6 uses the input() method. Python 2.7 uses the raw_input() method. """ #* Python 3.6 username = input("Enter username:") print("Username is: " + username) #* Python 2.7 username = raw_input("Enter username:") print("Username is: " + username)
true
dc6515bb3acd810a8e1d86aa59033b660a368594
Yibangyu/oldKeyboard1
/1023.py
381
4.1875
4
#!/usr/bin/python import re preg = input() string = input() result_string = '' preg = preg.upper() + preg.lower() if '+' in preg: preg = preg+'ABCDEFGHIJKLMNOPQRSTUVWXYZ' if preg: for char in string: if char in preg: continue else: result_string = result_string + ...
false
fe462e3d26b866c500619db330b4e7c027189f85
Grigorii60/geekbrains_DZ
/task_1.py
730
4.15625
4
name = input('Как твое имя? : ') print(f'Привет {name}, а мое Григорий.') age = int(input('А сколько тебе лет? : ')) my_age = 36 if age == my_age: print('Мы ровестники!') elif age > my_age: print(f'{name} ты старше меня на {age - my_age} лет.') else: print(f'{name} ты младше меня на {my_age - a...
false
d982dbcd9d34ecfd77824b309e688f9e077093d5
gcvalderrama/python_foundations
/DailyCodingProblem/phi_montecarlo.py
1,292
4.28125
4
import unittest # The area of a circle is defined as πr ^ 2. # Estimate π to 3 decimal places using a Monte Carlo method. # Hint: The basic equation of a circle is x2 + y2 = r2. # we will use a basic case with r = 1 , means area = π ^ 2 and x2 + y2 <=1 # pi = The ratio of a circle's circumference ...
true
24cf6864b5eb14d762735a27d79f96227438392f
ramalldf/data_science
/deep_learning/datacamp_cnn/image_classifier.py
1,545
4.28125
4
# Image classifier with Keras from keras.models import Sequential from keras.layers import Dense # Shape of our training data is (50, 28, 28, 1) # which is 50 images (at 28x28) with only one channel/color, black/white print(train_data.shape) model = Sequential() # First layer is connected to all pixels in original im...
true
60b60160f8677cd49552fedcf862238f9128f326
Prash74/ProjectNY
/LeetCode/1.Arrays/Python/reshapematrix.py
1,391
4.65625
5
""" You're given a matrix represented by a two-dimensional array, and two positive integers r and c representing the row number and column number of the wanted reshaped matrix, respectively. The reshaped matrix need to be filled with all the elements of the original matrix in the same row-traversing order as they were...
true
ea57b522f2bd14f19df61477c8141c238401f1b8
DavidCasa/tallerTkinter
/Ejercicio4.py
559
4.125
4
############## EJERCICIOS 4 ################ from tkinter import * root = Tk() v = IntVar() #Es un pequeño menú, en el cual se aplica Radiobuttons para hacer la selección de opciones Label(root, text="""Choose a programming language:""", justify = LEFT, padx = 20).pack() Radiobutton(root, ...
false
3d999f7baa9c6610b5b93ecf59506fefd421ff86
Minglaba/Coursera
/Conditions.py
1,015
4.53125
5
# equal: == # not equal: != # greater than: > # less than: < # greater than or equal to: >= # less than or equal to: <= # Inequality Sign i = 2 i != 6 # this will print true # Use Inequality sign to compare the strings "ACDC" != "Michael Jackson" # Compare characters 'B' > 'A' # If statement example ag...
true
f256746a37c0a050e56aafca1315a517686f96c8
luxorv/statistics
/days_old.py
1,975
4.3125
4
# Define a daysBetweenDates procedure that would produce the # correct output if there was a correct nextDay procedure. # # Note that this will NOT produce correct outputs yet, since # our nextDay procedure assumes all months have 30 days # (hence a year is 360 days, instead of 365). # def isLeapYear(year): if ye...
true
bf6d09ae3d5803425cf95dd4e53fe62dad41fda0
reveriess/TarungLabDDP1
/lab/01/lab01_f.py
618
4.6875
5
''' Using Turtle Graphics to draw a blue polygon with customizable number and length of sides according to user's input. ''' import turtle sides = int(input("Number of sides: ")) distance = int(input("Side's length: ")) turtle.color('blue') # Set the pen's color to blue turtle.pendown() # Start drawing d...
true
7ebc2621de57aba29a68be3d6dacaa16ebf4c4dc
yywecanwin/PythonLearning
/day03/13.猜拳游戏.py
657
4.125
4
# -*- coding: utf-8 -*- # author:yaoyao time:2019/9/28 import random # 写一个死循环 while True: # 1.从键盘录入一个1-3之间的数字表示自己出的拳 self = int(input("请出拳")) # 2.定义一个变量赋值为1,表示电脑出的拳 computer = random.randint(1,3) print(computer) if((self == 1 and computer == 2) or (self == 2 and computer == 3) or (self == 3 an...
false
eb42aaa882346528732e069a8cde5e7ad92155d0
yywecanwin/PythonLearning
/day04/07.字符串常见的方法-查找-统计-分割.py
885
4.25
4
# -*- coding: utf-8 -*- # author:yaoyao time:2019/9/28 s1 = "hello python" # 1.查找"o"在s1中第一次出现的位置:s1.find() print(s1.find("aa")) # -1 print(s1.find("o",6,11)) # 10 print(s1.find("pyt")) # 6 print(s1.rfind("pyt")) # 6 """ index()方法,找不到将会报错 """ # print(s1.index("o", 6, 11)) # print(s1.index("aa")) #统计"o"出现的次数 print(s...
false
95ce77d9c77b94715837162ed9e85dac67f64053
yywecanwin/PythonLearning
/day04/15.元组.py
922
4.15625
4
# -*- coding: utf-8 -*- # author:yaoyao time:2019/10/5 """ 元组: 也是一个容器,可以存储多个元素,每一个元素可以是任何类型 元组是一个不可需改的列表,不能用于 增删改查操作,只能用于查询 定义格式: 定义非空元组 元组名 = (元素1,元素2,,,,,) 元组空元组 元组名 = () 定义只有一个元素的元组 元组名 = (元素1,) 什么时候使用元组村粗一组数据? 当那一组数据不允许修改时,需要使用元组存储 """ tuple1 = ("冬冬", "柳岩", "美娜")...
false
2c2b4f56fc3f3c0c76ba69866da852edcfbf8186
Anshikaverma24/to-do-app
/to do app/app.py
1,500
4.125
4
print(" -📋YOU HAVE TO DO✅- ") options=["edit - add" , "delete"] tasks_for_today=input("enter the asks you want to do today - ") to_do=[] to_do.append(tasks_for_today) print("would you like to do modifications with your tasks? ") edit=input("say yes if you would like edit your tasks - ") if edit=="ye...
true
6fd57771b4a4fdbd130e6d408cd84e02f89f48a4
Jayasuriya007/Sum-of-three-Digits
/addition.py
264
4.25
4
print ("Program To Find Sum of Three Digits") def addition (a,b,c): result=(a+b+c) return result a= int(input("Enter num one: ")) b= int(input("Enter num one: ")) c= int(input("Enter num one: ")) add_result= addition(a,b,c) print(add_result)
true
2da2d69eb8580ba378fac6dd9eff065e2112c778
sk24085/Interview-Questions
/easy/maximum-subarray.py
898
4.15625
4
''' Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. A subarray is a contiguous part of an array. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. Example 2: Input: nums ...
true
daa21099590ab6c4817de8135937e9872d2eb816
sk24085/Interview-Questions
/easy/detect-capital.py
1,464
4.34375
4
''' 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 the first letter in this word is capital, like "Google". Given a string word, return true if the usage of ...
true
bca49786c266839dc0da317a76d6af24b20816e5
mtahaakhan/Intro-in-python
/Python Practice/input_date.py
708
4.28125
4
# ! Here we have imported datetime and timedelta functions from datetime library from datetime import datetime,timedelta # ! Here we are receiving input from user, when is your birthday? birthday = input('When is your birthday (dd/mm/yyyy)? ') # ! Here we are converting input into birthday_date birthday_date = datet...
true
2937f2007681af5aede2a10485491f8d2b5092cf
mtahaakhan/Intro-in-python
/Python Practice/date_function.py
649
4.34375
4
# Here we are asking datetime library to import datetime function in our code :) from datetime import datetime, timedelta # Now the datetime.now() will return current date and time as a datetime object today = datetime.now() # We have done this in last example. print('Today is: ' + str(today)) # Now we will use tim...
true
e797aa24ce9fbd9354c04fbbf853ca63e967c827
xtdoggx2003/CTI110
/P4T2_BugCollector_AnthonyBarnhart.py
657
4.3125
4
# Bug Collector using Loops # 29MAR2020 # CTI-110 P4T2 - Bug Collector # Anthony Barnhart # Initialize the accumlator. total = 0 # Get the number of bugs collected for each day. for day in range (1, 6): # Prompt the user. print("Enter number of bugs collected on day", day) # Input the number...
true
6e7401d2ed0a82b75f1eaec51448f7f20476d46e
xtdoggx2003/CTI110
/P3HW1_ColorMix_AnthonyBarnhart.py
1,039
4.40625
4
# CTI-110 # P3HW1 - Color Mixer # Antony Barnhart # 15MAR2020 # Get user input for primary color 1. Prime1 = input("Enter first primary color of red, yellow or blue:") # Get user input for primary color 2. Prime2 = input("Enter second different primary color of red, yellow or blue:") # Determine secon...
true
c3ffa8b82e2818647adda6c69245bbc9841ffd76
tsuganoki/practice_exercises
/strval.py
951
4.125
4
"""In the first line, print True if has any alphanumeric characters. Otherwise, print False. In the second line, print True if has any alphabetical characters. Otherwise, print False. In the third line, print True if has any digits. Otherwise, print False. In the fourth line, print True if has any lowercase char...
true
4d1605f77acdf29ee15295ba9077d47bc3f62607
zakwan93/python_basic
/python_set/courses.py
1,678
4.125
4
# write a function named covers that accepts a single parameter, a set of topics. # Have the function return a list of courses from COURSES # where the supplied set and the course's value (also a set) overlap. # For example, covers({"Python"}) would return ["Python Basics"]. COURSES = { "Python Basics": {"Pytho...
true
6ce838e30b83b79bd57c65231de2656f63945486
prashant2109/django_login_tas_practice
/python/Python/oops/polymorphism_info.py
2,144
4.40625
4
# Method Overriding # Same method in 2 classes but gives the different output, this is known as polymorphism. class Bank: def rateOfInterest(self): return 0 class ICICI(Bank): def rateOfInterest(self): return 10.5 if __name__ == '__main__': b_Obj = Bank() print(b_Obj.rateOfInterest()...
true
f7b7853e9332ef9fd2a5c16733f1908c00ea2a04
redoctoberbluechristmas/100DaysOfCodePython
/Day03 - Control Flow and Logical Operators/Day3Exercise3_LeapYearCalculator.py
826
4.375
4
#Every year divisible by 4 is a leap year. #Unless it is divisible by 100, and not divisible by 400. #Conditional with multiple branches year = int(input("Which year do you want to check? ")) if(year % 4 == 0): if(year % 100 == 0): if(year % 400 == 0): print("Leap year.") else: print("Not leap...
true
d167ac2865745d4e015ac1c8565dd07fba06ef4d
redoctoberbluechristmas/100DaysOfCodePython
/Day21 - Class Inheritance/main.py
777
4.625
5
# Inheriting and modifying existing classes allows us to modify without reinventing the wheel.add class Animal: def __init__(self): self.num_eyes = 2 def breathe(self): print("Inhale, exhale.") class Fish(Animal): def __init__(self): super().__init__() # The call to super() ...
true
d999a0fd4f5a5516a6b810e76852594257174245
redoctoberbluechristmas/100DaysOfCodePython
/Day08 - Functions with Parameters/cipherfunctions.py
846
4.125
4
alphabet = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ] def caesar(start_text, shift_amount, ...
true
9006fe1d04ceee567b8ced73bddd2562d0239fb8
zhartole/my-first-django-blog
/python_intro.py
1,313
4.21875
4
from time import gmtime, strftime def workWithString(name): upper = name.upper() length = len(name) print("- WORK WITH STRING - " + name * 3) print(upper) print(length) def workWithNumber(numbers): print('- WORK WITH NUMBERS') for number in numbers: print(number) if number...
true