blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
0137946f7a9ea9bbdae58fc8d79266575689cf32
dhrvdwvd/practice
/python_programs/50b_genrators.py
1,590
4.78125
5
""" Iterables are those objects for which __iter__() and __getitem__() methods are defined. These methods are used to generate an iterator. Iterators are those objects for __next__() method is defined. Iterations are process through which the above are accessed. If I wish to traverse in a python object (string, lis...
true
6769020adb8b369e75113cf4f75cc06060dc5214
ma-henderson/python_projects
/05_rock_paper_scissors.py
2,297
4.34375
4
import random message_welcome = "Welcome to the Rock Paper Scissors Game!" message_name = "Please input your name!" message_choice = "Select one of the following:\n- R or Rock\n- P or Paper\n- S or Scissors" message_win = "You WON!" message_loss = "You LOST :(" message_end = "If you'd like to quit, enter 'q' or 'quit'"...
true
e63f137ab97124caba74419a6de8f7d8c6f7aa5e
tarunbhatiaind/Pyhtonbasicprogs
/exercise_2.py
759
4.125
4
""""" print("A","\nB") """ print("Enter the operation you want to do :") print("type 1 for addition") print("type 2 for subtraction") print("type 3 for multiplication") print("Type 4 for division") op=int(input()) if op == 1 or op == 2 or op == 3 or op == 4: print("Enter the 2 numbers for the operations :") a=int(i...
false
f58299529ddb80c5ab80ee9a7254570f74372306
Oscarpingping/Python_code
/01-Python基础阶段代码/01-基本语法/Python循环-while-练习.py
1,182
4.15625
4
# 打印10遍"社会我顺哥, 人狠话不多" # print("社会我顺哥, 人狠话不多") # print("社会我顺哥, 人狠话不多") # print("社会我顺哥, 人狠话不多") # print("社会我顺哥, 人狠话不多") # print("社会我顺哥, 人狠话不多") # print("社会我顺哥, 人狠话不多") # print("社会我顺哥, 人狠话不多") # print("社会我顺哥, 人狠话不多") # print("社会我顺哥, 人狠话不多") # print("社会我顺哥, 人狠话不多") # print("社会我顺哥, 人狠话不多\n" * 10) # while # 一定要注意, 以后, ...
false
1184cff6fc360e4a0bfd5754ed1312be4cf624f1
ivanjankovic16/pajton-vjezbe
/Exercise 9.py
885
4.125
4
import random def Guessing_Game_One(): try: userInput = int(input('Guess the number between 1 and 9: ')) random_number = random.randint(1, 9) if userInput == random_number: print('Congratulations! You guessed correct!') elif userInput < random_number: print(f'You guessed to low! The correct answer is...
true
4b3d8f8ce9432d488a4ee4ebdc2bec1256939dbe
ivanjankovic16/pajton-vjezbe
/Exercise 16 - Password generator solutions.py
675
4.21875
4
# Exercise 16 - Password generator solutions # Write a password generator in Python. Be creative with how you generate # passwords - strong passwords have a mix of lowercase letters, uppercase # letters, numbers, and symbols. The passwords should be random, generating # a new password every time the user asks for a...
true
4713b2790c09b0f5f98e8f544c0a961ef87c2ea5
ivanjankovic16/pajton-vjezbe
/Exercise 13 - Fibonacci.py
1,204
4.625
5
# Write a program that asks the user how many Fibonnaci numbers # to generate and then generates them. Take this opportunity to # think about how you can use functions. Make sure to ask the user # to enter the number of numbers in the sequence to generate.(Hint: # The Fibonnaci seqence is a sequence of numbers wher...
true
e1d4247baca7c6291bd0fa90b51d920c86adb81b
csdaniel17/python-classwork
/string_split.py
1,387
4.125
4
## String split # Implement the string split function: split(string, delimiter). # Examples: # split('abc,defg,hijk', ',') => ['abc', 'defg', 'hijk'] # split('JavaScript', 'a') => ['J', 'v', 'Script'] # split('JaaScript', 'a') => ['J', '', 'Script'] # split('JaaaScript', 'aa') => ['J', 'aScript'] def str_split(str,...
true
cf6b1e2e097358113767dc766af9ebd853d52933
Audodido/IS211_Assignment1
/assignment1_part2.py
716
4.28125
4
class Book: """ A class to represent a book Attributes: author (string): Name of the author title (string): Title of the book """ def __init__(self, author, title): """ Constructs all the necessary attributes for the Book object. """ sel...
true
c64f463ed6738262fffbe1f859f86012e566168e
kolarganesha/Assignment2
/assignment_2/list_comprehensions/list_comprehension_assignment.py
1,348
4.15625
4
''' 2. Implement List comprehensions to produce the following lists. Write List comprehensions to produce the following Lists ['A', 'C', 'A', 'D', 'G', 'I', ’L’, ‘ D’] ['x', 'xx', 'xxx', 'xxxx', 'y', 'yy', 'yyy', 'yyyy', 'z', 'zz', 'zzz', 'zzzz'] ['x', 'y', 'z', 'xx', 'yy', 'zz', 'xx', 'yy', 'zz', 'xxxx', 'yyyy', '...
false
9f020702dc8684050f12bca0a0610309033c7bc3
saradcd77/python_examples
/abstract_base_class.py
1,120
4.40625
4
# This example shows a simple use case of Abstract base class, Inheritance and Polymorphism # The base class that inherits abstract base class in python needs to override it's method signature # In this case read method is overriden in methods of classes that inherits Electric_Device # Importing in-built abstract base...
true
22e801ed46b26007bbd7880dce3197fbc3e04a7c
simonzahn/Python_Notes
/Useful_Code_Snippets/DirectorySize.py
522
4.375
4
#! python3 import os def dirSize(pth = '.'): ''' Prints the size in bytes of a directory. This function takes the current directory by default, or the path specified and prints the size (in bypes) of the directory. ''' totSize = 0 for filename in os.listdir(pth): totSize += os.pa...
true
1672167ecd1302e8bfff3da2f790d69ff6889be4
KatGoodwin/LearnPython
/python_beginners/sessions/strings-basic/examples/.svn/text-base/string_concatenation.py.svn-base
734
4.125
4
# concatenating strings newstring = "I am a " "concatenated string" print newstring concat = "I am another " + "concatenated string" print concat print "Our string is : " + newstring # The above works, but if doing a lot of processing would be inefficient. # Then a better way would be to use the string join() met...
true
54415d27cdec4ce01ede31c8a87f330bb703ce59
tomgarcia/Blabber
/markov.py
2,284
4.21875
4
#extra libraries used import queue import tools import random """ markov_chain class is a class that creates a(n) markov chain statistical model on an inputted list of objects. The class is then able to generate randomly a new list of objects based on the analysis model of the inputted list. """ class markov_chain: ...
true
e52255d28a1e9c0d55ce5a296e384e1d7746b87d
mediter/Learn-Python-the-Hard-Way-notes-and-practices
/ex7.py
1,138
4.46875
4
# -*- coding: utf-8 -*- # Exercise 7: More Printing print "Mary had a little lamb." print "Its fleece was white as %s." % 'snow' print "And everywhere that Mary went." print "." * 12 # what would that do? end1 = 'C' end2 = 'h' end3 = 'e' end4 = 'e' end5 = 's' end6 = 'e' end7 = 'B' end8 = 'u' end9 = 'r' end10 = 'g' ...
true
660472dd3ec4d4ab685c784ea85dc540e6eb45c9
mediter/Learn-Python-the-Hard-Way-notes-and-practices
/ex9.py
923
4.28125
4
# -*- coding: utf-8 -*- # Exercise 9: Printing, Printing, Printing # Here's some new strange stuff, remember to type it exactly days = "Mon Tue Wed Thu Fri Sat Sun" # \n would make the stuff after it begin on a new line months = "\nJan\nFeb\nMar\nApr\nMay\nJun" # if a comma is added to the above statement, it woul...
true
625c2dfaeb03200f85a61300ee643d06bf9e4a0a
silky09/BeetrootAcademy
/Python_week4/day1.py
844
4.34375
4
"""print a message""" print("Welcome to MyFriends 1.0!") print() """ Homework. Advanced level write a program, which has two print statements to print the following text (capital letters “O” and “H” made out of “#” symbols): ##### # # # # # # ##### # # # # ##### # # # # """ print() for row in range...
false
10dc31cc92bc284cb08fde0fda5cdb312da06025
Sayed-Tasif/my-programming-practice
/math function.py
256
4.34375
4
Num = 10 Num1 = 5 Num2 = 3 print(Num / Num1) # used to divide print(Num % Num2) # used to see remainder print(Num2 ** 2) # indicates something to the power {like ( "number" ** "the power number")} print(Num2 * Num1) # used to multiply the number
true
c781089190d266c5c3649f4ff96736fc1dfe8b1d
YanSongSong/learngit
/Desktop/python-workplace/homework.py
217
4.1875
4
one=int(input('Enter the first number:')) two=int(input('Enter the second number:')) three=int(input('Enter the third number:')) if(one!=two and one!=three and two!=three): a=max(one,two,three) print(a)
true
95cafd3e875061426d39fd673bbf6327c5eb7c14
krwinzer/web-caesar
/caesar.py
489
4.25
4
from helpers import alphabet_position, rotate_character def encrypt(text, rot): code = '' for char in text: if char.isalpha(): char = rotate_character(char, rot) code = code + char else: code = code + char return (code) def main(): text = input(...
true
a337618daafddfb9224eda521e2e03644f204a0e
Seun1609/APWEN-Python
/Lesson2/quadratic.py
1,141
4.21875
4
# Get inputs a, b and c # The coefficients, in general, can be floating-point numbers # Hence cast to floats using the float() function a = float(input("Enter a: ")) b = float(input("Enter b: ")) c = float(input("Enter c: ")) # Compute discriminant D = b*b - 4*a*c if D >= 0: # There are real roots # x1...
true
30115c3de0f19d9878f2b00c1abf998b7b36a9fb
stansibande/Python-Week-Assignments
/Functions.py
2,048
4.25
4
#name and age printing function def nameAge(x,y): print ("My name is {} and i am {} Years old.".format(x,y)) #take two numbers and multiply them def multiply(x,y): result=x*y print("{} X {} = {}.".format(x,y,result)) #take two numbers and check if a number x is a multiple of a number Y def mul...
true
1f07e8a2872c37d2a6a74c0ef5a6e9c997d3d6ea
UCSD-CSE-SPIS-2021/spis21-lab03-Vikram-Marlyn
/lab03Warmup_Vikram.py
928
4.40625
4
# Vikram - A program to draw the first letter of your name import turtle def draw_picture(the_turtle): ''' Draw a simple picture using a turtle ''' the_turtle.speed(1) the_turtle.forward(100) the_turtle.left(90) the_turtle.forward(100) the_turtle.left(90) the_turtle.forward(100) ...
true
9a7ed39510c516c2e7da84be43a8f8c2a488a337
v-stickykeys/bitbit
/python/mining_simplified.py
2,043
4.1875
4
import hashlib # The hash puzzle includes 3 pieces of data: # A nonce, the hash of the previous block, and a set of transactions def concatenate(nonce, prev_hash, transactions): # We have to stringify it in order to get a concatenated value nonce_str = str(nonce) transactions_str = ''.join(transactions) ...
true
63c362549cdfdeeea249d6d31df11e8fca7748e3
herr0092/python-lab3
/exercise8.py
400
4.34375
4
# Write a program that will compute the area of a circle. # Prompt the user to enter the radius and # print a nice message back to the user with the answer. import math print('===================') print(' Area of a Circle ') print('===================') r = int(input('Enter radius: ')) area = math.pi * ( r * r) ...
true
02096c3d2fcff25f2a680e34586a56d8d7ca1f89
evb-gh/exercism
/python/guidos-gorgeous-lasagna/lasagna.py
1,299
4.1875
4
"""Functions used in preparing Guido's gorgeous lasagna. Learn about Guido, the creator of the Python language: https://en.wikipedia.org/wiki/Guido_van_Rossum """ EXPECTED_BAKE_TIME = 40 PREPARATION_TIME = 2 def bake_time_remaining(minutes): """Calculate the bake time remaining. :param elapsed_bake_time: i...
true
80df60b4c750e3e98e1c00c0d083e3582cbd4093
zee7han/algorithms
/sorting/insertion_sort.py
504
4.28125
4
def insertion_sort(arr): for i in range(1,len(arr)): position = i current_value = arr[i] print("position and current_value before", position, current_value) while position > 0 and arr[position-1] > current_value: arr[position] = arr[position-1] position = pos...
true
4585011053584c47520de828717d53f8944292fc
ivaszka/etwas
/square.py
1,049
4.28125
4
"""Реализуйте рекурсивную функцию нарезания прямоугольника с заданными пользователем сторонами a и b на квадраты с наибольшей возможной на каждом этапе стороной. Выведите длины ребер получаемых квадратов и кол- во полученных квадратов.""" from random import randint def square(a, b, array): if a == b: ...
false
027a6c2e0251e68ff32feef6b1b1710692c7e8f2
Sem31/Data_Science
/2_Numpy-practice/19_sorting_functions.py
1,376
4.125
4
#Sorting Functions import numpy as np #np.sort() --> return sorted values of the input array #np.sort(array,axis,order) print('Array :') a = np.array([[3,7],[9,1]]) print(a) print('\nafter applying sort function : ') print(np.sort(a)) print('\nSorting along axis 0:') print(np.sort(a,0)) #order parameter in sort func...
true
43c6442a8b1b90a1f69392b31c1aef2a26334f6d
Sem31/Data_Science
/3_pandas-practice/1_Create_series.py
950
4.3125
4
#Create a series using pandas #import the pandas library import pandas as pd #pd is a alias name #what the syntax of the series see.. print("Series syntax :\n",pd.Series()) print('create a Series using pandas : ') #pd.Series(array,index) a = pd.Series([1,2,3,4]) #by default index is 0,1,2... so on print(a) print('\...
false
e6c02fe3a07681cc415d9aa0e0257705aca65492
Rishivendra/Turtle_Race_Game
/3.Turtle_race.py
1,281
4.25
4
from turtle import Turtle, Screen import random is_race_on = False screen = Screen() screen.setup(width=500, height=400) # sets the width and height of the main window user_bet = screen.textinput(title="Make your bet", prompt="Which turtle will win the race? Enter color:") # Po...
true
6206eb9dc2cb71a50b5f75a1e9c8ffd11ba8e15c
Polaricicle/practical03
/q3_find_gcd.py
1,231
4.40625
4
#Filename: q3_find_gcd.py #Author: Tan Di Sheng #Created: 20130218 #Modified: 20130218 #Description: This program writes a function that returns the greatest common #divisor between two positive integers print("""This program displays a the greatest common divisor between two positive integers.""") #Creates a loop so...
true
945e12dd76007dba2e48aed8932fc1f01ff4f4d2
Azhar9983/MyCode
/is_palindrome.py
239
4.21875
4
def isPalindrome(str): if(str == "".join(reversed(str))): print("String is Palindrome") else: print("String isn't Palindrome") new = str(input("Enter SomeThing : ")) isPalindrome(new)
false
54b6009927a8c2be078af2e7fdefa94f2df25dae
AndreHBSilva/FIAP-Computational-Thinking
/Checkpoint 2/exercicio1.py
318
4.125
4
n = int(input("Digite a quantidade de números na sequência: ")) qtdSequencia = 0 i = 1 m = 0 while i <= n: numeroAnterior = m m = int(input("Digite o " + str(i) + "° número: ")) if numeroAnterior != m: qtdSequencia = qtdSequencia+1 i = i+1 print("Quantidade de sequências: " + str(qtdSequencia))
false
f4be8a4da4e64e93c42cc9d08966934f8bf49137
satish3366/PES-Assignnment-Set-1
/20_looping_structure.py
458
4.21875
4
print "The numbers from 1 to 100 skipping odd numbers using while loop is below:" i=1 while i<=100: if i%2!=0: i+=1 continue print i i+=1 print "\n\n" print "Breaking the for loop i ==50" i=1 while i<=100: if i==50: break print i i=i+1 print "using continue for the values 10,20...
false
5a734d271228ba71cd34021f260885193bba923d
abbyto/QUALIFIER
/main.py
495
4.125
4
import difflib words= ['i','have','want','a','test','like','am','cheese','coding','sleeping','sandwich','burger'] def word_check(s): for word in s.casefold().split(): if word not in words: suggestion= difflib.get_close_matches(word, words) print(f'Did you mean {",".join(str(x)for x in suggestion)} i...
true
eb8f14bfc5c734800d85b84ba78ad4812876c59c
qufengbin/python3lib
/text/re/re_findall_finditer.py
556
4.15625
4
# 1.3.3 多重匹配 # findall() 函数会返回输入中与模式匹配而且不重叠的所有子串。 import re text = 'abbaaabbbbaaaaa' pattern = 'ab' for match in re.findall(pattern,text): print('Found {!r}'.format(match)) # 输出 # Found 'ab' # Found 'ab' # finditer() 返回一个迭代器,它会生成 Match 实例,而不是返回字符串、 for match in re.finditer(pattern,text): s = match.start() ...
false
7ed458e350f78585fc568c5ad7fc9913077b7890
BethMwangi/DataStructuresAndAlgorithms
/Arrays/operations.py
1,693
4.34375
4
# Accessing an element in an array array = [9,4,5,7,0] print (array[3]) # output = 7 # print (array[9])---> This will print "list index out of range" since the index at 9 is not available. # Insertion operation in an array # One can add one or more element in an array at the end, beginning or any given index #...
true
fae288fd0621c537a2e53d5f5b0a6c97b7f5c21a
rkrishan/Data_structure_program
/Array_rotation.py
383
4.125
4
def reverseArray(arr,start,end): while(start<end): temp = arr[start] arr[start] = arr[end] arr[end] = temp start += 1 end = end-1 def leftRotate(arr,d): n = len(arr) reverseArray(arr,0,d-1) reverseArray(arr,d,n-1) reverseArray(arr,0,n-1) def printArray(arr): for i in range(0,len(arr)): print arr[i...
false
b2ecec901924b48a30b420c2b87c3f9087872bd5
alabiansolution/python-wd1902
/day4/chapter7/mypackage/code1.py
755
4.4375
4
states = { "Imo" : "Owerri", "Lagos" : "Ikeja", "Oyo" : "Ibadan", "Rivers" : "Port Harcourt", "Taraba" : "Yalingo", "Bornu": "Maidugri" } def my_avg(total_avg): ''' This function takes a list of numbers as an argument and returns the average of that list ''' sum = 0 for x in total_avg...
true
d9b7c5980339a47d34694780934f8828440ff379
666176-HEX/codewars_python
/Find_The_Parity_Outlier.py
524
4.5
4
""" You are given an array (which will have a length of at least 3, but could be very large) containing integers. The array is either entirely comprised of odd integers or entirely comprised of even integers except for a single integer N. Write a method that takes the array as an argument and returns this "outlier" ...
true
053d6552e18849fe13c14f0e4d229624f1f19076
mohitsoni7/oops_concepts
/oops5_dunder_methods.py
2,300
4.40625
4
""" Dunder methods / Magic methods / Special methods ================================================ These are special methods which are responsible for the certain types of behaviour of objects of every class. Also, these methods are responsible for the concept of "Operator overloading". O...
true
fdd85c2f7ee6dc32ab562ae51f844720b13b328a
MixFon/ExercisesForPython
/group_b_task24.py
539
4.15625
4
# 24. Заданы М строк слов, которые вводятся с клавиатуры. # Подсчитать количество гласных букв в каждой из заданных строк. m = int(input("Введите колличество строк:\n")) for a in range(m): string = input("Введите строку:\n") count = 0 for c in string: if c in "УЕЭОАЫЯИЮуеэоаыяию": count...
false
98d81c42b0566db41b203261e2c82d56290799b6
MixFon/ExercisesForPython
/group_b_task31.py
621
4.125
4
# 31. Заданы М строк символов, которые вводятся с клавиатуры. # Каждая строка представляет собой последовательность символов, # включающих в себя вопросительные знаки. Заменить в каждой строке # все имеющиеся вопросительные знаки звёздочками. m = int(input("Введите колличество строк :\n")) for a in range(m): strin...
false
a47be7352926ddacb098ca2fd795af56e691c137
mickyaero/Practice
/read.py
951
4.71875
5
""" #It imports the thing argv from the library already in the computer "sys" from sys import argv #Script here means that i will have to type the filename with the python command and passes this argument to the "filename" script, filename = argv #OPen the file and stores it in text variable text = open(filename) #pr...
true
535282c6449efc953b8fc171d0ca08e95fb79ac2
DonalMcGahon/Problems---Python
/Smallest&Largest.Q6/Smallest&Largest.py
515
4.4375
4
# Create an empty list lst = [] # Ask user how many numbers they would like in the list num = int(input('How many numbers: ')) # For the amount of numbers the user wants in the list, ask them to enter a number for each digit in the list for n in range(num): numbers = int(input('Enter number ')) # .append adds ...
true
10781a10fa8cbac266fb58bcd1b87a033d2e842b
DonalMcGahon/Problems---Python
/Palindrome.Q7/Palindrome.py
349
4.59375
5
# Ask user to input a string user_string = str(input('Enter a string to see if it is palindrome or not: ')) # This is used to reverse the string string_rev = reversed(user_string) # Check to see if the string is equal to itself in reverse if list(user_string) == list(string_rev): print("It is palindrome") else: ...
true
df5d470412dbee029d29972f1dc66b8fe4af7912
bernardukiii/Basic-Python-Scripts
/YourPay.py
611
4.28125
4
# Write a program to prompt the user for hours and rate per hour using input to compute gross pay. # Use 35 hours and a rate of 2.75 per hour to test the program (the pay should be 96.25). # You should use input to read a string and float() to convert the string to a number. # Do not worry about error checking or...
true
f1a30c8538d2717acca6a0c4a81b5dc06c2c6516
GitJay37/Python-Guide
/basic_exercises/tuples.py
598
4.46875
4
#tuple = (1,2,3,4,5,6,7,8,9,0) #element = tuple[:9:2] # Recorre la tupla de 2 en 2 desde el prímer índice #print(element) # tuple[2] = 20 #los valores de una tupla no pueden modificarse #tupla = (1,2,3,4,5) #one, two, three, four, five = tupla #print(one, two, three, four, five) array = [1, 2, 3, 4, 5] tuplas = (2, 4...
false
0666f9c6ddb41f8e38a846b8a53530b8aaedfe64
SpenceGuo/py3-learning
/dataType/data_type.py
1,403
4.46875
4
""" 标准数据类型 Python3 中有六个标准的数据类型: Number(数字) String(字符串) List(列表) Tuple(元组) Set(集合) Dictionary(字典) Python3 的六个标准数据类型中: 不可变数据(3 个):Number(数字)、String(字符串)、Tuple(元组); 可变数据(3 个):List(列表)、Dictionary(字典)、Set(集合) """ counter = 100 # 整型变量 miles = 1000.0 # 浮点型变量 name = "runoob" # 字符串 """ 多个变量赋值 Python允许你同时为...
false
d80e637ccb47dfbb56eaedea3cc1549380165edc
asliozn/PatikaVB-PythonFinal
/PythonFinalProject.py
1,215
4.34375
4
""" PROBLEM 1 Bir listeyi düzleştiren (flatten) fonksiyon yazın. Elemanları birden çok katmanlı listtlerden ([[3],2] gibi) oluşabileceği gibi, non-scalar verilerden de oluşabilir. Örnek olarak: input: [[1,'a',['cat'],2],[[[3]],'dog'],4,5] output: [1,'a','cat',2,3,'dog',4,5] """ ex_list = [[1, 'a', ['cat'], 2], ...
false
1f85c84c848524dd0056d74fa6cb6ca3e4bbe3f2
pratikmahajan2/My-Python-Projects
/Guess The Number Game/06 GuessTheNumber.py
536
4.15625
4
import random my_number = random.randint(0,100) print("Please guess my number - between 0 and 100: ") while True: your_number = int(input("")) if your_number > 100 or your_number < 0: print("Ohhoo! You need to enter number between 0 and 100. Try again") elif (your_number > my_number): print("You...
true
9c790eb1bf7fd97ea3d02439d5335f6e09c293ec
Kenkiura/pyintro
/data structures in python.py
914
4.34375
4
#Lists list1=[1,2,3,4,5,6] print(list1[3]) print (list1[0]) print (list1[-2]) days=["mon","tue","wed","thur","fri","sat","sun"] print (days[5:7]) print (days[5:]) print (days[5:6]) print (days[0:3]) print (days[:3]) print (type(list1)) list1.append(7) print (list1) print (list1.index(7)) list1.pop() print (lis...
false
924fde1d0ded0a114f314cfe2560672f7736a629
Theodora17/TileTraveller
/tile_traveller.py
1,911
4.46875
4
# Functions for each movement - North, South, East and West # Function that updates the position # Function that checks if the movement wanted is possible def north(first,second) : if second < 3 : second += 1 return first, second def south(first,second) : if second > 1 : second -= 1 ...
true
58872f4d3554c2849ffeb4c978451bfbf415cfb3
mparker24/EvensAndOdds-Program
/main.py
622
4.25
4
#This asks the user how many numbers they are going to input question = int(input("How many numbers do you need to check? ")) odd_count = 0 even_count = 0 #This asks for a number and outputs whether its even or odd for i in range(question): num = int(input("Enter number: ")) if (num % 2) == 0: print(f"{num} is...
true
50934c184a7b7248bfae0bdcfba6c6a002d38f59
erikseyti/Udemy-Learn-Python-By-Doing
/Section 2 - Python Fundamentals/list_comprehension.py
766
4.46875
4
# create a new list with multiples by 2. numbers = [0,1,2,3,4] doubled_numbers = [] # a more simple way with a for loop # for number in numbers: # doubled_numbers.append(number *2) # print(doubled_numbers) # with list comprehension: doubled_numbers = [number *2 for number in numbers] print(doubled_numbers) # u...
true
f3b0cd25318048ca749c91aecd7ee53e36327221
sloaneluckiewicz/CSCE204
/CSCE204/exercises/mar9/functions3.py
1,190
4.28125
4
def factorial(): num = int(input("Enter number: ")) answer = 1 # error invalid input return = takes you out of the function if num < 1: print("Invalid number") return for i in range(1, num+1): answer *= i print(f"{num}! = {answer}") def power(): base = int(input...
true
67b96044ffc12ef97b3cefb858bbe5fa8aa3a8fd
sloaneluckiewicz/CSCE204
/CSCE204/exercises/feb2/for-loop1.py
888
4.21875
4
""" count from 1 to 10 for i in range (1,11): # add another number to desired end print(i) """ """ loop counting by 2s for i in range (2,21,2): # last parameter will indicate what you will go by called the STEP print(i) """ """ loop from 10 to 1 for i in range (10,0,-1): print(i) """ """ # sum the numb...
false
e8ba520b71bcb4af787d39ad3bca0521c806c433
sloaneluckiewicz/CSCE204
/CSCE204/exercises/feb23/mult_tables.py
449
4.125
4
# multiplication table """ 1 2 3 4 5 1 4 6 8 10 """ tableSize = int(input("Enter size of table: ")) for row in range(1, tableSize+1): # loop through rows for col in range(1, tableSize+1): # for every row loop their cols ans = row * col # if there is just one digit in the number ...
true
a045dbbf26ee8600be9bbd207a535cab0d4b25b7
sloaneluckiewicz/CSCE204
/CSCE204/exercises/mar4/birthdays2.py
926
4.1875
4
# list birthdays and find closest birthday coming up from datetime import date birthdays = { "Sloane": date(2021, 2, 16), "Camille": date(2021, 9, 3), "Jane": date(2021, 7, 10), "Kaden": date(2021, 10, 28), "Treyten": date(2021, 10,9), "Mamacita": date(2021, 5, 6), "Remi": date(2021, ...
false
09c598aa5bfd2a7489b5e30d6723ae6a39cdc04a
ceeblet/OST_PythonCertificationTrack
/Python1/python1/space_finder.py
287
4.15625
4
#!/usr/local/bin/python3 """Program to locate the first space in the input string.""" s = input("Please enter a string: ") pos = 0 for c in s: if c == " ": print("First space occurred at position", pos) break pos += 1 else: print("No spaces in that string.")
true
5bbd0ab39d4112ccac8775b398c37f8f13f42345
ceeblet/OST_PythonCertificationTrack
/Python1/python1/return_value.py
1,259
4.375
4
#!/usr/local/bin/python3 def structure_list(text): """Returns a list of punctuation and the location of the word 'Python' in a text""" punctuation_marks = "!?.,:;" punctuation = [] for mark in punctuation_marks: if mark in text: punctuation.append(mark) return punctuation, text.find('Py...
true
ed5388f3c390d596cd6a2927960cf28e0065d8d2
ceeblet/OST_PythonCertificationTrack
/Python1/python1Homework/caserFirst.py
1,284
4.34375
4
#!/usr/local/bin/python3 """ caser.py """ import sys def capitalize(mystr): """ capitalize(str) - takes a string and returns the string with first letters capitalized. """ print(mystr.capitalize()) def title(mystr): """ title(str) - takes a string and returns the string in title form. ...
true
5598cd6a08c5925a4820f48bd8813d0509d26fcb
idealley/learning.python
/udacity-examples/leap_pythonic.py
258
4.21875
4
def is_leap_baby(year): if ((year % 4 is 0) and (year % 100 is not 0)) or (year % 400 is 0): return "{0}, {1} is a leap year".format(True, year) return "{0} is not a leap year".format(year) print(is_leap_baby(2014)) print(is_leap_baby(2012))
false
4c490de53e3bed60e94a60e4229cffb4181d7ed8
dotnest/pynotes
/Exercises/swapping_elements.py
284
4.21875
4
# Swapping list elements def swap_elements(in_list): """ Return the list after swapping the biggest integer in the list with the one at the last position. >>> swap_elements([3, 4, 2, 2, 43, 7]) >>> [3, 4, 2, 2, 7, 43] """ # your code here
true
15352584fbdce193854661aacf3b73826e716db8
paweldunajski/python_basics
/12_If_Statements.py
462
4.25
4
is_male = True if is_male: print("You are a male") is_male = False is_tall = False if is_male or is_tall: print("You are male or tall or both") else: print("You are not a male nor tall ") if is_male and is_tall: print("You are male and tall") elif is_male and not is_tall: print("You are male bu...
false
d859287b31a1883963543dea6c9f335ade0c0755
Jokekiller/Theory-Programmes
/Program converting ASCII to text and other way.py
956
4.125
4
#Harry Robinson #30-09-2014 #Program converting ASCII to text and other way print("Do you want to convert an ASCII code ? (y/n)") response = input() if response == "y": ASCIINumber = int(input("Give an ASCII number")) ASCIINumberConverted = chr(ASCIINumber) print("The ASCII number is {0} in text c...
true
0f4085b0b240aab78424953c0a66eeb09e6b019e
krouvy/Useless-Python-Programms.-
/18 - Checking the list for parity/pop_break.py
707
4.21875
4
""" This program checks the list items for odd parity. If all elements are even, then the list will be empty. Because the "pop ()" method cuts out the last item from the list. """ List = list(map(int, input("Enter your digit values ").split())) # Entering list items separated by a space while len(List) > 0: # Execut...
true
4e93aec8e1cf56a3fc4610ac438fb50d77a856b8
yding57/CSCI-UA-002
/Lecture 3.py
2,238
4.15625
4
#Data types # "=" is an assignment operator # x=7+"1.0" this is ERROR answer = input("Enter a value: ") print(answer,type(answer)) n1 = input("Number 1: ") n2 = input('Number 2: ') #convert this into an integer n1_int = int(n1) n2_int = int(n2) print(n1_int + n2_int) #different from: print(n1 + n2) #简便convert的方法:ne...
true
607b6d533f1ac9a6ca74f04edcb43f50ad164b4d
AMRobert/Word_Counter
/WordCounter_2ndMethod.py
268
4.1875
4
#WORD COUNTER USING PYTHON #Read the text file file = open(r"file path") Words = [] for i in file: Words.extend(i.split(" ")) print(Words) #Count the Number of Words Word_Count=0 for x in range(len(Words)): Word_Count = Word_Count + 1 print(Word_Count)
true
8f896b4284f1f648ebf70b8d147ab87265a707f6
chudierp/theflowergarden
/flowergarden/idea.py
780
4.1875
4
import turtle as t # draw a simple rectangle car with two wheels. def draw_flower(x,y): t.penup() t.setheading(90) t.goto(x,y) t.pendown() t.pencolor("green") t.pensize(20) t.left(90) t.backward(150) t.forward(150) t.pencolor("orange") t.pensize(15) num_petals = 8 num_degrees = in...
false
b4ad1c25c8d0ecee08a1a48787fb7c116bcba965
igotboredand/python-examples
/loops/basic_for_loop.py
514
4.59375
5
#!/usr/bin/python3 # # Python program to demonstrate for loops. # # The for loop goes through a list, like foreach in # some other languages. A useful construct. for x in ['Steve', 'Alice', 'Joe', 'Sue' ]: print(x, 'is awesome.') # Powers of 2 (for no obvious reason) power = 1 for y in range(0,25): print("...
true
00587653e7706bed6683f00538a9e22f00590cdc
FengdiLi/ComputationalLinguistic
/update automation/menu_update.py
2,857
4.15625
4
#!/usr/bin/env python import argparse import re def main(old_menu, new_menu, category_key, update_key): """This main function will read and create two dictionaries representing the category keys and update keys, then check and update the price according to its multiplier if the item is associated wit...
true
6172e61f25108eec6aee06c155264e74441ee10c
bacizone/python
/ch5-bubble-report.py
2,046
4.3125
4
#Pseudocode for Ch5 2040 excercise #First we have a list with solutions and their scores. We are writing a loop where it iterates until all solution -score pair are output to the screen. #Second: using the len function we display the total number of bubble tests, that is the number of elements in the list. #Then we nee...
true
b3f3acc08c5777696db004a6ccabcb09c1dd3c36
kirankumarcs02/daily-coding
/problems/exe_1.py
581
4.125
4
''' This problem was recently asked by Google. Given a list of numbers and a number k, return whether any two numbers from the list add up to k. For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17. Bonus: Can you do this in one pass? ''' def checkSumPair(input, k): givenNumbers = set(...
true
bc4126d785715c1aebf52f99fbafea90fc21f6fe
kirankumarcs02/daily-coding
/problems/exe_40.py
704
4.1875
4
# This problem was asked by Google. # # Given an array of integers where every integer occurs three # times except for one integer, which only occurs once, # find and return the non-duplicated integer. # # For example, given [6, 1, 3, 3, 3, 6, 6], # return 1. Given [13, 19, 13, 13], return 19. def get_non_duplicate(a...
true
63c881db45cfac236675707f637c29c74f86d257
bhanuxhrma/learn-python-the-hard-way
/ex16.py
882
4.1875
4
from sys import argv script, filename = argv #some important file operations #open - open the file #close - close the file like file -> save ... #readline - read just one line of the text #truncate - Empties the file watch out if you care about file #write('stuff') - write "stuff" to the file print("we are going to er...
true
d0fc479f5b2b320c371912a327272c14266d47d3
lmsullivan18/Election_Analysis
/analysis/Class.py
549
4.15625
4
import random print("Let's Play Rock Paper Scissors!") ​ # Specify the three options options = ["r", "p", "s"] ​ # Computer Selection computer_choice = random.choice(options) ​ # User Selection user_choice = input("Make your Choice: (r)ock, (p)aper, (s)cissors? ") if user_choice = computer_choice: print("Tie!") ...
false
87b94b13d0d6c77a0949ae957847909804dfbc2f
deepakmarathe/whirlwindtourofpython
/operators/bitwise_operators.py
408
4.3125
4
# a & b bitwise and # a | b bitwise or # a ^ b bitwise xor # a << b bitwise leftshift # a >> b bitwise rightshift # ~a bitwise not # bitwise operators make sense on binary numbers, obtained by 'bin' method print "10 in binary : ", bin(10) print "4 in binary : ",bin(4) # find out the number which combines the bi...
false
fd25c5909d3329a11e7eed49c14d08dfbf81ec95
deepakmarathe/whirlwindtourofpython
/string_regex/regex_syntax.py
1,772
4.21875
4
# Basics of regular expression syntax import re # Simple strings are matched directly regex = re.compile('ion') print regex.findall('great expectations') # characters with special meanings # . ^ $ * + ? { } [ ] \ | ( ) # Escaping special characters regex = re.compile('\$') print regex.findall(r"the cost is $100") ...
true
956d7b394457b2fd9526f13206e366a59788cbfd
mbrownlee/Python-Bk1Chp6
/zoo.py
886
4.15625
4
flowers = ("daisy", "rose") print(flowers.index("rose")) # Output is 1 zoo = ("panda", "polar bear", "giraffe", "llama", "monkey", "kangaroo", "cheetah", "tiger", "sloth", "turtle") print(zoo.index("tiger")) print(zoo[7]) if "kangaroo" in zoo: print("Animal is present") (first_animal, second_animal, third_animal,...
false
380cccfd40ee68bf5ffa1a99d145cffcd1fa6d4b
TETSUOOOO/usercheck
/passwordDetect.py
1,058
4.4375
4
#! python3 # passwordDetect.py - Ensures that password is 8 characters in length, at least one lowercase and one uppercase letter, # and at least one digit # saves accepted passwords into a json file import json, re filename = 'passwords.json' def passwordDetector(text): """Uses a regex to parse the user input c...
true
c23b9c26d90994d5aac03bdeb8cf2c038762336c
davekunjan99/PyPractice
/Py6.py
218
4.28125
4
string = str(input("Enter a string: ")) revString = string[::-1] if(string == revString): print("Your string " + string + " is palindrome.") else: print("Your string " + string + " is not palindrome.")
true
659de313db36bb521842ba837228b6fd87d66b52
davekunjan99/PyPractice
/Py11.py
455
4.375
4
num = int(input("Please enter a number: ")) def checkPrime(num): isPrime = "" if num == 1 or num == 2: isPrime = "This number is prime." else: for i in range(2, num): if num % i == 0: isPrime = "This number is not prime." break else: ...
true
f5686d3db18f0f77a679085954f752e648f8e5f4
mjixd/helloworld-sva-2018
/week2/mjstory.py
1,551
4.5
4
# let the user know what's going on print ("Welcome to MJ World!") print ("Answer the questions below to play.") print ("-----------------------------------") # variables containing all of your story info adjective1 = raw_input("Enter an adjective: ") food1 = raw_input("What is your favorite food?: ") location1 = raw...
true
e90ff02843379fd3ff97a9ff61ab7fc351039e03
binthafra/Python
/2-Python Basics 2/6-iterable.py
422
4.1875
4
#iterable -list ,dict,tuple,set,string # iterable ->ono by one check each item in the collection user = { 'name': "afra", 'age': 20, 'can_swim': False } # print only keys for item in user: print(item) for item in user.keys(): print(item) # print key and value for item in user.items(): print(ite...
true
6cc518e1a3e69721374315bcced5aed005cb4d75
jwodder/euler
/digits/euler0055.py
1,808
4.125
4
#!/usr/bin/python """Lychrel numbers If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindromes so quickly. For example, 349 + 943 = 1292, 1292 + 2921 = 4213 4213 + 3124 = 7337 That is, 349 took three iterations to arrive at a palindrome. ...
true
3ade90c1e0cac84869460cd0aa453552002528d5
jwodder/euler
/euler0173.py
1,745
4.15625
4
#!/usr/bin/python """Using up to one million tiles how many different "hollow" square laminae can be formed? We shall define a square lamina to be a square outline with a square "hole" so that the shape possesses vertical and horizontal symmetry. For example, using exactly thirty-two square tiles we can f...
true
d81f15a0dd213f3f16396fbe09213fa0b90a3273
paulknepper/john
/guess_your_number.py
2,836
4.4375
4
#!/usr/local/bin/python3 # guess_your_number.py """ Guess Your Number rules: I, the computer, will attempt to guess your number. This is the exact opposite of the proposition made in guess_my_number.py. You must pick a number between one and ten. I will make a guess. If I am incorrect, tell me if I ...
true
083a743d4d0d0077f417f53312cc9968484d3a14
KinozHao/PythonBasic
/e_oot/polymorphic.py
666
4.1875
4
# 所谓 多态 定义时候类型和运行时的类型不同 此时就是多态 class FAFONE(object): def show(self): print("FAFONE.show") class FAFTWO(FAFONE): def show(self): print("FAFTWO.show") class FAFTHREE(FAFONE): def show(self): print("FAFTHREE.show") def Func(obj): # obj can us object print(obj.show()) FAFON...
false
4258ab9b79c0d20997c84a2d6d4414bc29d953e1
Nathan-Zenga/210CT-Coursework-tasks
/cw q9 - binary search 2 - adapted.py
1,448
4.15625
4
number1 = int(input("1st number: ")) number2 = int(input("2nd number: ")) List = [4, 19, 23, 36, 40, 43, 61, 64, 78, 95] def binarySearch(num1, num2, array): '''performs binary search to identify if there is a number in the List within a given interval''' mid = len(array)//2 try: if...
true
06e6078bb3b5585e95aa3f0f11bb011e6f2723c8
shalu169/lets-be-smart-with-python
/Flatten_Dictionary.py
540
4.15625
4
""" This problem was asked by Stripe. Write a function to flatten a nested dictionary. Namespace the keys with a period. For example, given the following dictionary: { "key": 3, "foo": { "a": 5, "bar": { "baz": 8 }}} it should become: { "key": 3, "foo.a": 5, "foo.bar.baz": 8 } You can assume keys do not contain dots...
true
f8e2832fa04459261dd5d89ec41dbc329f41cee9
shalu169/lets-be-smart-with-python
/object_to_iter.py
2,675
4.40625
4
#The __iter__() function returns an iterator for the given object (array, set, tuple etc. or custom objects). #It creates an object that can be accessed one element at a time using __next__() function, #which generally comes in handy when dealing with loops. #iter(object) #iter(callable, sentinel) # Python code demonst...
true
c1dc30bbfa67313204294ed063b1e3b9f9da93cd
giuspeppe9908/Miei-Esercizi-in-Python
/matrix in python/main.py
905
4.25
4
import numpy as np # Matrix in Python using numpy class #defing fillMAtrix function def fillMatrix(arr, m,n): for i in range(m): c=[] for j in range(n): j = int(input("Enter the number : ")) c.append(j) #out of the inner for loop arr.append(c) def printM...
false
9b0057ebae089905fcecb0c02fccc70c25e13faa
Amir0AFN/pyclass
/s3h1.py
565
4.125
4
#Amir_Abbas_Fattahi-Thursday-14-18-class #BMI h = float(input("Your height(m)? \n")) m = float(input("Your mass(Kg)? \n")) bmi = int(m/(h**2)) print("Your BMI: " + str(bmi)) if bmi < 16: print("You are severe thin.") elif bmi < 17: print("You are moderate thin.") elif bmi < 18.5: print("You are mild thin."...
false
01240ebbeac9cd0dd912097c8249ca7c6654b73f
janedallaway/ThinkStats
/Chapter2/pumpkin.py
1,975
4.25
4
import thinkstats import math '''ThinkStats chapter 2 exercise 1 http://greenteapress.com/thinkstats/html/thinkstats003.html This is a bit of an overkill solution for the exercise, but as I'm using it as an opportunity to learn python it seemed to make sense''' class Pumpkin(): def __init__ (self, ty...
true
254057aa4f45292225fea68a65458c4fb8098bba
gusmendez99/ai-hoppers
/game/state.py
700
4.15625
4
from copy import deepcopy class GameState: """ Class to represent the state of the game. - board = stores board information in a certain state - current_player = stores current_player information in a specified state - opponent = stores opponent information in specified state """ def __in...
true
e618ed89b65c62c5a30486dc6c79a134860efa54
DinakarBijili/Python-Preparation
/Problem Solving/Reverse/Reverse_number.py
263
4.1875
4
"""Reverse Number""" def reverse_num(num): reverse = 0 while num > 0: last_digit = num%10 reverse = reverse*10 + last_digit num = num//10 return reverse num = int(input("Enter Number ")) result = reverse_num(num) print(result)
false
1dfda62b11b9721499dff52d38617d547647198a
DinakarBijili/Python-Preparation
/Data Structures and Algorithms/Algorithms/Sorting_Algorithms/2.Bubble.sort.py
1,042
4.375
4
# Bubble sort is a Simple Sorting algorithm that repeatedly steps through the array, compare adjecent and swaps them if they are in the wrong order. # pass through the array is repeated until the array is sorted #Best O(n^2); Average O(n^2); Worst O(n^2) """ Approach Starting with the first element(index = 0), compare...
true
e88b39744da6626bb46d84c211c9475a0c45ec93
DinakarBijili/Python-Preparation
/Problem Solving/Loops/Remove_Duplication_from_string.py
330
4.125
4
"""Remove Duplication from a String """ def remove_duplication(your_str): result = "" for char in your_str: if char not in result: result += char return result user_input = input("Enter Characters : ") no_duplication = remove_duplication(user_input) print("With out Duplication = ",no_dupl...
true