blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
0d56aa5047f1f172ffdc73425b26d25c9706dee7
ShashikantBhargav/Bubble_sort-
/bubble_shor_using_list(user input).py
446
4.1875
4
print("program in assending order by user input:") list1=[] num=int(input('how many number you want to enter:-')) print("enter values do you wants:") for k in range(num): list1.append(int(input("enter element:-"))) print("user entered list:",list1) for j in range(len(list1)-1): for i in range(len(list...
false
93f1ec4e576c4d805a26e8e0a8b9adef0e021aca
rockchar/CODE_PYTHON
/Sets.py
598
4.28125
4
# sets are unordered collections of unique objects. They contain only one # unique object # Lets create a set my_set = set() my_set.add(1) my_set.add(2) my_set.add(3) print(my_set) # lets try to add a duplicate element to the set my_set.add(3) print(my_set) #lets declare a list with duplicate objects my_list =...
true
1bdd5f43e2f869c0c42681b8ade249c89e9258a0
jao11/curso-em-video
/mundo01/aula006/Aula006.py
1,280
4.1875
4
# AULA 006 # n1=input('digite um número') # n2=input('digite mais um número') # s=n1+n2 # print('A soma vale',s) # Infelizmente o algoritmo não vai funcionar se for escrito dessa forma. # Para dar certo temos que escrever assim... n1 = int(input('digite um número')) n2 = int(input('digite mais um número')) s =...
false
27e7c9c2bc894a1b298afa9c6b8b869d880d9c76
MiroVatov/Python-SoftUni
/Python Advanced 2021/TUPLES AND SETS/Lab 02.py
701
4.21875
4
num_of_grades = int(input()) students_dict = {} for _ in range(num_of_grades): student_info = input().split() student_name = student_info[0] grade = float(student_info[1]) if student_name not in students_dict: students_dict[student_name] = [grade] else: students_dict[stu...
false
c0c7854471f06aec35a86a9d09b5549773a22a6a
MiroVatov/Python-SoftUni
/PYTHON OOP/INHERITANCE/Labs/stack_of_strings/stack.py
610
4.15625
4
class Stack: def __init__(self): self.data = [] def push(self, item): self.data.append(item) def pop(self): return self.data.pop() # peek()method will show us the top value in the Stack def peek(self): return self.data[-1] def is_empty(self...
false
aa7a877fb5450c27b78fbf7f026991d1e9289c7e
MiroVatov/Python-SoftUni
/Python Advanced 2021/EXAMS_PREPARATION/Exam 27 June 2020/02 snake.py
2,730
4.125
4
field_size = int(input()) snake_field = [list(input()) for _ in range(field_size)] def check_starting_position(field, start): for row in range(len(field)): if start in field[row]: return row, field[row].index(start) def is_outside(cur_row, cur_col, size): if 0 <= cur_row < size and 0 <= ...
false
d4eb863d441ae9a67d333784662b3aa35f4cc745
xd-lpc/sharemylove
/ex39.py
1,060
4.125
4
#create a mapping of status to abbreviation states = { 'Oregon':'OR', 'Florida': 'FL', 'California':'NY', 'Michigan':'MI' } #create a basic set of status and some cities in them cities = { 'CA':'San Francisco', 'MI':'Detroit', 'FL':'Jacksonville' } #add more cities cities['NY'] = 'New Yo...
false
6bcdb23587171691e25cd375ea30f5356487dcc9
vensder/codeacademy_python
/shout.py
289
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- def shout(phrase): if phrase == phrase.upper(): return "YOU'RE SHOUTING!" print phrase else: return "Can you speak up?" print "Hello!" phrase = raw_input("Enter yours phrase:\n") print shout(phrase)
true
2bb4c43c58c24f07a6b0a2e30ae5e3a1593e1ef6
sipakhti/code-with-mosh-python
/Data Structure/Dictionaries.py
1,002
4.25
4
point = {"x": 1, "y": 2} point = dict(x=1, y=2) point["x"] = 10 # index are names of key point["z"] = 20 print(point) # to make sure the program doesnt crash due to invalid dict key if "a" in point: print(point["a"]) # Alternative approach using .get function and it makes the code cleaner print(point.get("a", 0...
true
b5fc18297b318ff88610adf0cb3d3448de671d31
sipakhti/code-with-mosh-python
/Data Structure/Unpacking Operator.py
440
4.21875
4
numbers = [1, 2, 3] print(*numbers) print(1, 2, 3) values = list(range(5)) print(values) print(*range(5), *"Hello") values = [*range(5), * "Hello"] first = [1, 2] second = [3] values = [*first, *second] print(*values) first = dict(x=1) second = dict(x=10, y=2) # incase of multiple values with similar keys, the last...
true
307eccd04d95e8e169f1b1cf743b10fb42686268
sipakhti/code-with-mosh-python
/Control Flow/Ternary_Operator.py
240
4.15625
4
age = 22 if (age >= 18): message = "Eligible" else: message = "Not Eligible" print(message) # more clearner way to do the same thing age = 17 message = "Eligible" if age >= 18 else "Not Eligible" # ternary Operator print(message)
true
64fef01dcc207fc7e1d965d319f03433672f2429
EarthCodeOrg/earthcode-curriculum
/modules/recursive_to_iterative.py
544
4.15625
4
# Recursive to Iterative # Approach 1: Simulate the stack def factorial(n): if n < 2: return 1 return n * factorial(n - 1) def factorial_iter(n): original_n = n results = {} inputs_to_resolve = [n] while inputs_to_resolve: n = inputs_to_resolve.pop() if n < 2: results[n] = 1 else: ...
true
f2a9b7ec51fa931682743a4957d34a9a80441679
ModellingWebLab/chaste-codegen
/chaste_codegen/_script_utils.py
676
4.15625
4
import os def write_file(file_name, file_contents): """ Write a file into the given file name :param file_name: file name including path :param file_contents: a str with the contents of the file to be written """ assert isinstance(file_name, str) and len(file_name) > 0, "Expecting a fi...
true
d0bf5cbec6cc10cecfd3a5e556851908df86110e
pliz/PDF-guard
/pdf-encryptor.py
651
4.15625
4
from PyPDF2 import PdfFileWriter, PdfFileReader pdfWriter = PdfFileWriter() # Read the pdf file which will be encrypted pdf = PdfFileReader("example.pdf") for page_num in range(pdf.numPages): pdfWriter.addPage(pdf.getPage(page_num)) # Encryption process goes here passw = input('Enter your password: ') pdfWriter...
true
2a185cc736922ae8baff835e5d0b9b3727dc7fc3
MLgeek96/Interview-Preparation-Kit
/Python_Interview_Questions/leetcode/problem_sets/Q139_word_break.py
1,980
4.28125
4
import re from typing import List def wordBreak(s: str, wordDict: List[str]) -> bool: """ Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary may be reused multip...
true
0c822fefe2815bf1f401a6ae0e5ca175fd252ee8
MLgeek96/Interview-Preparation-Kit
/Python_Interview_Questions/leetcode/problem_sets/Q46_permutations.py
1,137
4.125
4
from typing import List def permute(nums: List[int]) -> List[List[int]]: """ Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. Example 1: Input: nums = [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] Examp...
true
6b91e70df04c6feb54be4da4c340b151951f0a4e
MLgeek96/Interview-Preparation-Kit
/Python_Interview_Questions/leetcode/problem_sets/Q169_majority_element.py
1,126
4.28125
4
from typing import List def majorityElement(nums: List[int]) -> int: """ Given an array nums of size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. Example 1: Input: num...
true
cd2d86cd6a9e91412e5e4eaac9d33716291177e2
MLgeek96/Interview-Preparation-Kit
/Python_Interview_Questions/CSES_Problem_Set/Q2_missing_number.py
1,248
4.125
4
""" You are given all numbers between 1,2,…,n except one. Your task is to find the missing number. Input The first input line contains an integer n. The second line contains n−1 numbers. Each number is distinct and between 1 and n (inclusive). Output Print the missing number. Constraints 2 ≤ n ≤ 2*10^5 Example ...
true
856d259f74a1016e5cc43bfe2bc9bb714108ed2c
MLgeek96/Interview-Preparation-Kit
/Python_Interview_Questions/leetcode/problem_sets/Q20_valid_parenthesis.py
1,243
4.28125
4
def isValid(s: str) -> bool: """ Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 1. Open brackets must be closed by the same type of brackets. 2. Open brackets must be closed in the correct order....
true
6ad68ea092a6435db680bd485a1279b2de19292d
MLgeek96/Interview-Preparation-Kit
/Python_Interview_Questions/leetcode/problem_sets/Q11_container_with_most_water.py
1,501
4.25
4
from typing import List def container_with_most_water(height: List[int]) -> int : """" Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines...
true
2be28d3c7f1d27878116b489ddf78409f4fe1a2c
bheinks/2018-sp-a-puzzle_4-bhbn8
/priorityqueue.py
1,194
4.21875
4
class PriorityQueue: """Represents a custom priority queue instance. While Python has a PriorityQueue library available, this is more efficient because it sorts on dequeue, rather than enqueue.""" def __init__(self, key, items=[]): """Initializes a PriorityQueue instance. Args: ...
true
ec9ab3c13b26dfbfbf5edf2225ae6870f59a7e80
lucguittard/DS-Unit-3-Sprint-2-SQL-and-Databases
/module2-sql-for-analysis/practice.py
946
4.21875
4
# Working with sqlite # insert a table # import the needed modules import sqlite3 import pandas as pd # connect to a database connection = sqlite3.connect("myTable.db") # make a cursor curs = connection.cursor() # SQL command to create a table in the database sql_command = """CREATE TABLE emp (staff_number INT...
true
23b32a35acc060b021706f17754c0e1479259025
saranaweera/dsp
/python/q8_parsing.py
701
4.3125
4
# The football.csv file contains the results from the English Premier League. # The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program to r...
true
656a32a3781605c1f68539cfcdc3e8de98bf4181
sivaneshl/real_python
/implementin_linked_list/implementing_a_own_linked_list.py
1,765
4.46875
4
from linked_list import LinkedList, Node # using the above class create a linked list llist = LinkedList() print(llist) # add the first node first_node = Node('a') llist.head = first_node print(llist) # add subsequent nodes second_node = Node('b') third_node = Node('c') first_node.next = second_node secon...
true
37898e1d98f7a08c52d2dc6fc80779c54ba60685
nnamon/ctf101-systems-2016
/lessonfiles/offensivepython/11-stringencodings.py
864
4.125
4
#!/usr/bin/python def main(): sample_number = 65 # We can get binary representations for a number print bin(sample_number) # Results in 0b1000001 # We can also get hex representations for a number: print hex(sample_number) # Results in 0x41 # Also, octal: print oct(sample_number) # Re...
true
a5ad8c8a3e2c0a6ac172e08129f092bb638768a5
ZhangJiaQ/LintCode_and_other_homework
/LintCode/字符串处理/LintCode415.py
935
4.25
4
# 有效回文串 # 给定一个字符串,判断其是否为一个回文串。只包含字母和数字,忽略大小写。 # 样例 # "A man, a plan, a canal: Panama" 是一个回文。 # "race a car" 不是一个回文。 # 解题思路:由于需要忽略标点与空格,只对字母和数字进行回文判定,所以我们需要先对字符串进行处理,遍历字符串并使用 # isalpha()方法与isnumeric()方法取得字母与数字,然后将字母全变为小写,进行回文判定。 class Solution: # @param {string} s A string # @return {boolean} Whether the ...
false
d57e662d520f5ff40408d2d410584cb32942d4aa
elrapha/Lab_Python_01
/zellers.py
1,672
4.75
5
""" Zeller’s algorithm computes the day of the week on which a given date will fall (or fell). In this exercise, you will write a program to run Zeller’s algorithm on a specific date. You will need to create a new file for this program, zellers.py. The program should use the algorithm outlined below to compute the day ...
true
1faf7950718cd67c1bd3dc182059763b1c784c5c
JosephLiu04/Wave3
/PythagTheorem.py
317
4.53125
5
from math import sqrt Side1 = float(input("Input the length of the shorter first side:")) Side2 = float(input("Input the length of the shorter second side: ")) def Pythag_theorem(): Side3 = sqrt((Side1 * Side1) + (Side2 * Side2)) return Side3 print("The length of the hypotenuse is", str(Pythag_theorem()))
true
9902409c31c852fd0878827aaa3b025099f997af
mrfabroa/ICS3U
/Archives/2_ControlFlow/conditional_loops.py
1,611
4.34375
4
__author__ = 'eric' def example1(): # initialize the total and number total = 0 number = input("Enter a number: ") # the loop condition while number != -1: # the loop statements total = total + number number = input("Enter a number: ") print "The sum is", total def...
true
c2e42318e56cf09abd5c1a456a4e3222a80e5226
mrfabroa/ICS3U
/Archives/3_Lists/3_1_practice.py
1,341
4.1875
4
__author__ = 'eric' def middleway(list_a, list_b): """ Given 2 int lists, list_a and list_b, each length 3, write a function middle_way(list_a,list_b) that returns a new list length 2 containing their middle elements. :param list_a: int[] :param list_b: int[] :return: int[] """ li...
true
51c4f09686dfc3e7b2cf59a1a549ba5ac1fb7806
shijietopkek/cpy5p1
/q1_fahrenheit_to_celsius.py
268
4.25
4
# q1_fahrenheit_to_celsius.py # Fahrenheit to Celsius converter # get input Fahrenheit = float(input("Enter Fahrenheit temperature: ")) # convert temperature celsius = (5/9) * (Fahrenheit - 32) # output result print("temperature in celsius is", celsius)
false
8b505676a08ba224903433f7546e35ae8f441edb
manhtruong594/vumanhtruong-fundamental-c4e24
/Fundamental/Session04/homework/SeriousEx1.py
1,313
4.125
4
items = ["T-Shirt", "Sweater"] print("Here is my items: ", sep=" ") print(*items, sep=", ") loop = True while loop: cmd = input("Welcome to our shop, what do u want (C, R, U, D or exit)? ").upper() if cmd == "R": print("Our items: ", *items, sep=", ") elif cmd == "C": new = input("Enter new...
true
24979e4b645fd55c678190b244fd9ee3436232d7
sbolla27/python-examples
/class2/calculator_class.py
748
4.125
4
class Calculator(object): def __init__(self, num1, num2, num3=0): self.x = num1 self.__y = num2 self.z = num3 def add(self): return self.x + self.__y + self.z def sub(self): return self.x - self.__y def multi(self): return self.x * self.__y def di...
false
7d34ce21348e849a06da1b04a3c40c611587261a
fabiangothman/Python
/fundamentals/4_strings.py
811
4.21875
4
myStr = "hello_all_world" #Properties of an object: command "dir" #print(dir(myStr)) print(myStr.upper()) print(myStr.lower()) print(myStr.swapcase()) print(myStr.capitalize()) print(myStr.replace("hello", "bye").upper()) #Method chaining (Métodos encadenados) print(myStr.count("l")) print(type(myStr.count("l"))) ...
false
99ec192ac77df5906950a92b131e73665a76a06a
Cole-Hayson/L1-Python-Tasks
/Names List.py
1,136
4.25
4
names = ["Evi", "Madeleine", "Dan", "Kelsey", "Cayden", "Hayley", "Darian"] user_name = input("Enter a name") if user_name in names: print("That name is already on the list!") else: print("The name you chose is not on the list.") if user_name != names: replace = input("Would you like to replace one of the n...
true
bd64fadca3071891ce36d42ddfdd8b1ddc96901b
PuneetPowar5/Small-Python-Projects
/fibonacciSequence.py
323
4.21875
4
print("Welcome to the Fibonacci Sequence Generator\n") maxNum = int(input("How many numbers of the sequence do you want to see? \n")) maxNum = int(maxNum) a = 0 b = 1 c = 0 print("\n") for num in range(0, maxNum): if(num <= 1): c = num else: c = a + b a = b b = c print...
true
34adf55b11a6b6c45f7b9d25d49b385a3e7cd8c7
karendi/python
/excercise39.py
1,737
4.21875
4
counties = { 'nairobi' :"NRB" , 'Thika':"Tka" , 'Githurai':"GRI" , 'Kakamega':"KKGA", 'Webuye':"WBE", 'Kisumu':"KSM" } #adding towns to the different counties we have towns ={ 'NRB':"Westlands", 'Tka':"Gatundu", ...
false
aa960deeb474ab57d4ef72d675a8fd4742104014
egonnelli/algorithms
/sorting_algorithms/01_bubblesort.py
544
4.34375
4
#Bubblesort algorithm in python #Time complexity - O(N^2) def bubble_sort(array): """ This functions implements the bubble sort algorithm """ is_sorted = False counter = 0 while not is_sorted: is_sorted = True for i in range(len(array) - 1 - counter) if array[i] > array[i+1]: swap(i, i+1, array) i...
true
4d5b37c3bef7ed5a71b12b3ba30b895af39b6b12
Dushyanttara/Competitive-Programing
/deli.py
730
4.34375
4
#Dushyant Tara(19-06-2020): This program will help you understand while loop through exercises sandwich_orders = ['aloo tikki','bbq chicken','ceasers','pastrami', 'tuna','cheese','pastrami','paneer tikka','ham','pastrami'] finished_sandwiches = [] print("The Deli has run out of Pastrami") while 'pastrami' in sa...
false
2af5b432ac298bebe3343f9ee18ae79e5f368b3e
Dushyanttara/Competitive-Programing
/aliens.py
2,312
4.15625
4
"""#Dushyant Tara(19-06-2020): This program will help you understand dictionary as a data strucutre alien_0 = {'color': 'green', 'points': 5} #print(alien_0['color']) #print(alien_0['points']) #new_points = alien_0['points'] #print("You just earned " + str(new_points) + " points.") #Adding new...
true
6b6c88029116d4f5de407c8c8640345bdadb10bb
PajamaProgrammer/Python_MIT-6.00_Problem-Set-Solutions
/Problem Set 2/ps2b.py
2,303
4.15625
4
# Problem Set 2 (Part 4) # Name: Pajama Programmer # Date: 28-Oct-2015 # """ Problem4. Assume that the variable packages is bound to a tuple of length 3, the values of which specify the sizes of the packages, ordered from smallest to largest. Write a program that uses exhaustive search to find the largest number (less ...
true
2352cc95d3464d4a7f6a7f01781d9de1278b0113
UddeshJain/Master-Computer-Science
/Data_Structure/Python/Stack.py
1,262
4.34375
4
class Stack(object): ''' class to represent a stack Implemented with an array ''' def __init__(self): ''' Constructor ''' self.datas = [] def __str__(self): return " ".join(str(e) for e in reversed(self.datas)) def size(self): ...
true
e8faa90b2c9b3ee9a1d694bb6a236e80cbd27733
missystem/math-crypto
/mathfxn.py
790
4.53125
5
""" Authors: Missy Shi Date: 05/22/2020 Python Version: 3.8.1 Functions: - largest_prime_factor Find the largest prime factor of a number - prime_factors Given a integer, return a set of factors of the number """ import math def largest_prime_factor(n: int) -> int: """ Return largest prime factor of num...
true
682d25a675d2b58c48c7359774378ae921405b24
missystem/math-crypto
/prime.py
1,155
4.21875
4
""" Author: Missy Shi Course: math 458 Date: 04/23/2020 Project: A3 - 1 Description: Write a Python function which, given n, returns a list of all the primes less than n. There should be 25 primes less than 100, for instance. Task: How many prime numbers are there which are less than 367400? """ i...
true
cea5559f924ca0ec895074ca5898c96fc003bc74
sahilkumar4all/HMRTraining
/Day-5/calc_final.py
380
4.125
4
def calc(operator): z = eval(x+operator+y) print(z) print(''' Press 1 for addition press 2 for substraction press 3 for multiplication press 4 for division''') x = input("enter first no") y = input("enter second no") choice = input("enter operation you wanna perform") dict = {"1":"+", "2":"-", ...
true
cc669352fa7f30b87d40343ab529635289a35884
Miguelmargar/file-io
/writefile.py
698
4.125
4
f = open("newfile.txt", "a") # opens and creates file called newfile.txt to write on it with "w" - if using "a" it means append not create new or re-write f.write("\nHello World\n") # writes Hello on the file opened above - depending on where you use the \n the lines will brake accor...
true
5bfd768ba34df709af7e5c425510b44dc8a63cb0
cheeseaddict/think-python
/chapter-5/ex-5.3.py
419
4.15625
4
def check_fermat(a, b, c, n): if a**n + b**n == c**n and n > 2: print("Holy smokes, Fermat was wrong!") else: print("No that does not work") def input_test_values(): a = int(input("Enter a value for a: ")) b = int(input("Enter a value for b: ")) c = int(input("Enter a value for c: ...
false
a153c0f74861ec3c8c786b7b5d9b379331904612
cheeseaddict/think-python
/chapter-6/exercise-6.2.py
667
4.25
4
import math def distance(x1, y1, x2, y2): dx = x2 - x1 dy = y2 - y1 dsquared = dx**2 + dy**2 result = math.sqrt(dsquared) return result print(distance(1,2,4,6)) """ As an exercise, use incremental development to write a function called hypotenuse that returns the length of the hypotenuse of a r...
true
3d045213ec7cc8711783ec2e6be8eeedf4ebf6c2
FrankchingKang/phrasehunter
/phrasehunter/character.py
1,774
4.125
4
# Create your Character class logic in here. class Character(object): """The class should include an initializer or def __init__ that receives a char parameter, which should be a single character string.""" def __init__(self,char): """An instance attribute to store the single char string character so...
true
898ed9b37e512dca37848a040ff175ce57b65e08
mverleg/bardeen
/bardeen/inout.py
2,011
4.15625
4
""" Routines related to text input/output """ import sys, os def clear_stdout(lines = 1, stream = sys.stdout, flush = True): """ Uses escape characters to move back number of lines and empty them To write something on the empty lines, use :func:sys.stdout.write() and :func:sys.stdout.flush() :param lines: the...
true
c824029a5d1ef7317bb98bd39f623292fd392d71
ms-shakil/Some_problems_with_solve
/Extra_Long_Factorial.py.py
401
4.125
4
""" The factorial of the integer n , written n! , is defined as: n! = n * (n-1)*(n-2)*... *2*1 Calculate and print the factorial of a given integer. For example Inp =25 we calculate 25* 24* 23*....*2*1 and we get 15511210043330985984000000 . """ def Factorial(inp): val = 1 for i in range(1,inp): val +...
true
12b784aecca1d4276228b7b7ad13d3cc1d679208
lenncb/safe_password
/main.py
1,319
4.125
4
# This programm will show you how strong your password is # If your password is weak, program will generate new and strong password. # Just write your password import re, password_generator password = input(str('Enter your password: ')) #good password is if it has minimum 8 signs, inculde small and big letters and h...
true
37693a5b038c83a5eae1f13d6bd0540c4852b9ad
navinduJay/interview
/python/sort/insertionSort.py
635
4.34375
4
#INSERTION SORT array = [] #array declaration for everyValue in range(10): array.append(input("Enter number ")) #adding values to the array print('Unsorted array') print(array) def insertionSort(array): #function declaration for j in range(1 , len(array)): # starting index is 1(2nd position) to array lengt...
true
c574d55303bce0e3e99b39777be42153f3c47a7d
minkyaw17/CECS-328
/Lab 5/lab5.py
2,656
4.15625
4
import random import time def swap(arr, a, b): # swap function to be used in the heap sort and selection sort temp = arr[a] arr[a] = arr[b] arr[b] = temp def max_heapify(arr, i, n): # parameter n for length of array max_element = i left = (2 * i) + 1 right = (2 * i) + 2 max_element = ...
true
589aada2ad71b067e9602780edd62c7e540169db
carlosmertens/Python-Masterclass
/challenge_control_flow.py
1,456
4.34375
4
# Complete Python MasterClass Course # # This challenge is intended to practise for loops and if/else statements, # so although you could use other techniques (such as splitting the string up), # that's not the approach we're looking for here. # # Create a program that takes an IP address entered at the keyboard and pr...
true
ee6e9248a17fc4ec2426cebf57ec9404dea28955
ardaunal4/My_Python_Lessons
/ClassPython/example_of_properties_of_classes.py
1,459
4.21875
4
# -*- coding: utf-8 -*- """ Created on Wed May 27 02:35:30 2020 @author: ardau """ from abc import ABC, abstractmethod from cmath import pi class shape(ABC): """ Parent class / abstract class example """ # abstract methods @abstractmethod def area(self): pass @...
true
33c1feb36398f075fc0b1d205803ad901e7366d6
ardaunal4/My_Python_Lessons
/ALGORITHMS/Fundemantals of_Python_Questions/questions3.py
723
4.25
4
# How you can convert a sorted list to random from random import shuffle my_list = [0, 1, 2, 3, 4, 5, 6, 7] print("Sorted list : ", my_list) shuffle(my_list) print("Shuffled list : ", my_list) # How you can make sorted list from random list my_list.sort() print("Sorted list : ", my_list) # What are funct...
true
5e2eba80e377a1eb7d2fadfe8c52999605fe8e06
ardaunal4/My_Python_Lessons
/ClassPython/abstract_class.py
488
4.28125
4
from abc import ABC, abstractmethod # abc -> abstract base class class Animal(ABC): #super class @abstractmethod # this makes the class abstract def walk(self): pass def run(self): pass # this abstract class is a kind of template for other sub classes class Bird(A...
true
6421bd469e371aa256b634c344f81c71072ff336
dailycodemode/dailyprogrammer
/Python/034_squareTwoLargest.py
984
4.15625
4
# https://www.reddit.com/r/dailyprogrammer/comments/rmmn8/3312012_challenge_34_easy/ # DAILY CODE MODE def square_two_largest(list): list.sort(reverse=True) return list[0] ** 2 + list[1] ** 2 print(square_two_largest([3,1,2])) # ANSWER BY Should_I_say_this def sumsq(a,b,c): l=[a,b,c] del l[l.index(mi...
true
575ce16017a9ace610e155825511410519cc0a9c
Bacbia3696/rsa-key-gen
/src/helper.py
1,937
4.21875
4
from random import randrange, getrandbits, seed def is_prime(n, k=128): """ Test if a number is a prime use Miller-Rabin algorithm Args: n int: number to test k int: number of test to do return True if n is prime """ if n == 2 or n == 3: return True if n...
false
bdbd2c226ad2c18abcaa9c781d7951357cd1cb0c
Vasilii-Redinskii/ps-pb-hw4
/collections.py
490
4.125
4
from collections import namedtuple # Создаем описание (т.е. некую структуру) для объекта student = namedtuple('student','first_name last_name age') # Создаем сам объект, используя описание student1 = student(first_name='Иван', last_name='Иванов', age=18) # Обращаемся к полям объекта через точку print(student1.first...
false
4a977849536b8afc9d7cce8f715d1359009d14da
rnekadi/CSEE5590_PYTHON_DEEPLEARNING_FALL2018
/ICP3/Source/codon.py
522
4.21875
4
# Program to read DNA Codon Sequence and Split into individual Codon # Fixed Codon Sequence codonseq = 'AAAGGGTTTAAA' # Define List to hold individual Codon codon = [] # Defining function to to fill Codon list def codonlist(seq): if len(seq) % 3 == 0: for i in range(0, len(seq), 3): codo...
true
2d7a2d740143a19d38e290c3dc81e00cafcdeaff
smailmedjadi/jenkins_blueocean
/src/new_functions.py
570
4.1875
4
def bubbleSort(list): for passnum in range(len(list)-1,0,-1): for i in range(passnum): if list[i]>list[i+1]: temp = list[i] list[i] = list[i+1] list[i+1] = temp def insertionSort(list): for index in range(1,len(list)): currentv...
true
c9c0ac3f7b507c15f40170980db8b16ed03f2601
EhODavi/curso-python
/exercicios-secao06/exercicio08.py
362
4.25
4
numero = float(input('Informe um número: ')) maior_numero = numero menor_numero = numero for i in range(9): numero = float(input('Informe um número: ')) if numero < menor_numero: menor_numero = numero if numero > maior_numero: maior_numero = numero print(f'Maior número: {maior_numero}') p...
false
926276604ff778d85b0ef490eb4155277d8660b0
EhODavi/curso-python
/exercicios-secao06/exercicio45.py
447
4.125
4
while True: print('1 - Converter de km/h para m/s') print('2 - Converter de m/s para km/s') print('3 - Finalizar') opcao = int(input('\nInforme a opção: ')) if opcao == 3: break velocidade = float(input('\nInforme a velocidade: ')) if opcao == 1: print(f'\n{velocidade} km/...
false
55d0933225917746cf734f4ae38b7ab9b9362828
ravi4all/PythonOnlineJan_2021
/backup/code_3.py
485
4.15625
4
''' for(int i = 0; i <= 10; i++) { Logic... } ''' ''' start = 0 stop = 10 - 1 = 9 step = +1 ''' for i in range(10): print(i, end=',') print("Inside Loop") print("Bye") ''' start = 2 stop = 10 - 1 = 9 step = +1 ''' for i in range(2,10): print(i, end=',') print("Inside Loop") ...
false
0ec2e9f2fcb36f32ae4220b6f35fa96529a2af30
Sandeep8447/interview_puzzles
/src/main/python/com/skalicky/python/interviewpuzzles/sum_2_binary_numbers_without_converting_to_integer.py
1,784
4.21875
4
# Task: # # Given two binary numbers represented as strings, return the sum of the two binary numbers as a new binary represented # as a string. Do this without converting the whole binary string into an integer. # # Here's an example and some starter code. # # def sum_binary(bin1, bin2): # # Fill this in. # # print(...
true
480dd41bb1dfde38741970333c6442df17dd944a
Sandeep8447/interview_puzzles
/src/main/python/com/skalicky/python/interviewpuzzles/sort_array_with_three_values_in_place.py
2,376
4.25
4
# Task: # # Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are # adjacent, with the colors in the order red, white and blue. # # Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. # # Note: You are not supp...
true
96002e94186bdfef6a04951c5b99d55e21bb9d00
Sandeep8447/interview_puzzles
/src/main/python/com/skalicky/python/interviewpuzzles/find_first_recurring_character.py
1,231
4.125
4
# Task: # # Given a string, return the first recurring letter that appears. If there are no recurring letters, return None. # # Example: # # Input: qwertty # Output: t # # Input: qwerty # Output: None # # Here's some starter code: # # def first_recurring_char(s): # # Fill this in. # # print(first_recurring_char('qwer...
true
04269da9800ce546e8c89a5d9cba8b74b102e05d
Sandeep8447/interview_puzzles
/src/main/python/com/skalicky/python/interviewpuzzles/swap_every_two_nodes_in_linked_list.py
1,632
4.15625
4
# Task: # # Given a linked list, swap the position of the 1st and 2nd node, then swap the position of the 3rd and 4th node etc. # # Here's some starter code: # # class Node: # def __init__(self, value, next=None): # self.value = value # self.next = next # # def __repr__(self): # return f"{self.value}, (...
true
cc2d33ae78495714b158947820c819a25734ed64
Sandeep8447/interview_puzzles
/src/main/python/com/skalicky/python/interviewpuzzles/find_shortest_distance_of_characters_to_given_character.py
1,560
4.15625
4
# Task: # # Given a string s and a character c, find the distance for all characters in the string to the character c in # the string s. You can assume that the character c will appear at least once in the string. # # Here's an example and some starter code: # # def shortest_dist(s, c): # # Fill this in. # # print(sh...
true
1dc29418a4324e658afdddbabd372c2dbe9ae97c
Sandeep8447/interview_puzzles
/src/main/python/com/skalicky/python/interviewpuzzles/find_characters_appearing_in_all_strings.py
862
4.15625
4
# Task: # # Given a list of strings, find the list of characters that appear in all strings. # # Here's an example and some starter code: # # def common_characters(strs): # # Fill this in. # # print(common_characters(['google', 'facebook', 'youtube'])) # # ['e', 'o'] from typing import List, Set def find_characters...
true
9e6ca28b0657297cd3223daef3a3fb6eee2e0ec9
Sandeep8447/interview_puzzles
/src/main/python/com/skalicky/python/interviewpuzzles/reverse_integer_without_converting_it_to_string.py
677
4.3125
4
# Task: # # Given an integer, reverse the digits. Do not convert the integer into a string and reverse it. # # Here's some examples and some starter code. # # def reverse_integer(num): # # Fill this in. # # print(reverse_integer(135)) # # 531 # # print(reverse_integer(-321)) # # -123 from math import floor def reve...
true
d720bec8f8a39a08d7eba61fb7006042e54394e8
Sandeep8447/interview_puzzles
/src/main/python/com/skalicky/python/interviewpuzzles/reverse_binary_representation_of_integer.py
980
4.15625
4
# Task: # # Given a 32 bit integer, reverse the bits and return that number. # # Example: # # Input: 1234 # # In bits this would be 0000 0000 0000 0000 0000 0100 1101 0010 # Output: 1260388352 # # Reversed bits is 0100 1011 0010 0000 0000 0000 0000 0000 # # Here's some starter code: # # def to_bits(n): # return '{0:0...
true
9e1f8ae86d4092c5105f8ab43ff0356c00777fea
Sandeep8447/interview_puzzles
/src/main/python/com/skalicky/python/interviewpuzzles/search_in_matrix_with_sorted_elements.py
2,075
4.25
4
# Task: # # Given a matrix that is organized such that the numbers will always be sorted left to right, and the first number of # each row will always be greater than the last element of the last row (mat[i][0] > mat[i - 1][-1]), search for # a specific value in the matrix and return whether it exists. # # Here's an ex...
true
8a5fcc17e24a57d5783b8f91a7a41f480171d9c3
ksu-is/Hotel-Python
/hotelpython2.py
1,949
4.125
4
print("Welcome to Hotel Python!") print("\t\t 1 Booking") print("\t\t 2 Payment") print("\t\t 3 Guest Requests") print("\t\t 4 Exit") reservation=" " payment=" " payment_method=" " requests=" " def guest_info(reservation="A"): print("Please collect guest information such as name, phone number, and dates of stay")...
true
ce09f1c9ebded1b1b2716f017583dea3d4cf5a23
rfaroul/Activities
/Week03/3/lists.py
1,601
4.28125
4
prices = ["24","13","16000","1400"] price_nums = [int(price) for price in prices] print(prices) print(price_nums) dog = "poodle" letters = [letter for letter in dog] print(letters) print(f"We iterate over a string into a list: {letters}") capital_letters = [letter.upper() for letter in letters] print(capital_letters)...
true
a9a126c09ea31fd436771775cee74a487a2cd528
keyasu/30DaysOfPython
/30DaysOfPython/06_days_ Tuples.py
2,705
4.34375
4
print('days-06-Tuples') """ 元组是有序且不可更改(不可变)的不同数据类型的集合。 元组用圆括号 () 书写。 一旦创建了一个元组,我们就不能改变它的值。 我们不能在元组中使用 add、insert、remove 方法,因为它不可修改(可变)。 与列表不同,元组的方法很少。 与元组相关的方法: tuple(): 创建一个空元组 count():计算元组中指定项的个数 index():在元组中查找指定项的索引 运算符:连接两个或多个元组并创建一个新元组 """ # syntax """ tpl = ('item1', 'item2','item3') pr...
false
8c3e51f656c307af2f1167dc1fa0d0f907b27d2c
guillempuigcomerma/Exercise.github.io
/goldenspear-backend/caesarEncrypt.py
711
4.375
4
import sys def caesarEncrypt(text,s): 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'] result = "" text = text.lower() # transverse the plain text for i in range(len(text)): char = text[i] # Encrypt ...
false
821f9a0d094f177d3a7b2c2cbf8ed3fee0967e3e
Jayden-Liang/mypractice
/Algorithem/栈和队列/stack.py
568
4.28125
4
# 因为Stack是存和取最后位置的数据 # 非常简单,就是利用list的append, remove, 和索引查询, class Stack(object): def __init__(self): self.data = [] self.size = 0 def add(self, data): self.data.append(data) self.size +=1 def pop(self): self.data.remove(self.data[-1]) self.size -=1 de...
false
131f1147267852294f9674c7b6883c1f5f580d7d
minhazalam/py
/data_collectn_and_processing/week_1/nested_iteration.py
443
4.5
4
# In this program we'll implement the nested iteration concepts using # * two for loops # * one loop and a square bracket(indexing) # * indexing(square bracket) and a for loop # nested list nested1 = [1, 2, ['a', 'b', 'c'],['d', 'e'],['f', 'g', 'h']] # iterate for x in nested1: # outer loop print("level1: ")...
true
4448b46aeb6c9ba1ea874f52aa7a0a8a10c761d7
minhazalam/py
/class_inheritance/inheritance/inheritance.py
827
4.28125
4
# Intro : Inheritance in python 3 # current year CURRENT_YEAR = 2020 # base class class Person: # constructor def __init__(self, name, year_born): self.name= name self.year_born = year_born # def methods def get_age(self): return CURRENT_YEAR - self.year_born # def _...
true
328931edeb4128727316cc80b135935d06434f6a
minhazalam/py
/py dict fun and files/programs/csv_writing.py
713
4.1875
4
# ABOUT : This program deals with the writing of the .csv files using # python 3 code as shown olympians = [("John Aalberg", 31, "Cross Country Skiing"), ("Minna Maarit Aalto", 30, "Sailing"), ("Win Valdemar Aaltonen", 54, "Art Competitions"), ("Wakako Abe", 18, "Cycling"...
false
b2677a1cee82e3f2a851f604804f276131f63d75
minhazalam/py
/class_inheritance/exceptions/try_exception.py
554
4.15625
4
# we'll see how this try and exception works in the python 3 programming language # syntax : # try: # <try clause code block> # except <ErrorType>: # <exception handler code block> # def square(num): # return num * num # # assertion testingg # assert square(3) == 9 # try and except block of statement a_...
true
eff579a5e13bd543666069b222ade3a0d386ba8c
XanderCalvert/learning_python
/bmielse.py
502
4.375
4
height = float(input("enter your height in m: ")) weight = float(input("enter your weight in kg: ")) _bmi = weight / (height * height) bmi = round(_bmi, 1) if bmi <= 18.5: print(f"Your BMI is {bmi} you are underweight") elif bmi <= 25: print(f"Your BMI is {bmi} you are a normal weight") elif bmi <= 30: ...
false
8c44c1692f9091b3290f50c23ee3529888b606db
adam-worley/com404
/1-basics/5-functions/4-loop/bot.py
271
4.125
4
def cross_bridge (steps): x = 0 while (steps>0): print("Crossed step") steps = (steps-1) x = x+1 if (x>=5): print("The bridge is collapsing!") else: print("we must keep going") cross_bridge(3) cross_bridge(6)
true
0a7343306387e4f6c326a8bec187da13dc2c45ed
adam-worley/com404
/1-basics/6-mocktca/1-minimumtca/Q2.py
255
4.125
4
print("Where is Forky?") forky_location=str(input()) if (forky_location=="With Bonnie"): print("Phew! Bonnie will be happy.") elif(forky_location=="Running away"): print ("Oh no! Bonnie will be upset!") else: print("Ah! I better look for him")
true
637abb15832ba8ebafa8e90d958df4ea05d3b236
keshavkummari/KT_PYTHON_6AM_June19
/Functions/Overview_Of_Functions.py
1,347
4.25
4
# Functions in Python # 1. def # 2. Function Name # 3. Open & Close Paranthesis and Parameters # 4. Colon : Suit # 5. Indented # 6. return statement - Exits a Function """ def function_name(parameters): function_suite return [expression] def sum(var1,var2): total = var1 + var2 print(total) retu...
true
cfbba32a8f869a1f9afaba9381382611f70c789a
MompuPupu/ProjectEuler
/Problems 1 - 10/Problem 1.py
516
4.5
4
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. def determine_if_multiple_of_3_or_5(number): """Return whether the number is a multiple of 3 or 5. """ if number % 3 == 0 or n...
true
ffd4583fc2f7498e36d5f9bd8fa7162c08295439
MompuPupu/ProjectEuler
/Problems 1 - 10/Problem 4.py
1,154
4.34375
4
# A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers # is 9009 = 91 × 99. # Find the largest palindrome made from the product of two 3-digit numbers. import math def check_for_palindrome(num): # loads the number into an array of characters digit_list...
true
ee164fea12b17eb34cf532481c77e93bd91a2313
nda11/CS0008-f2016
/ch5/ch5,ex3.py
1,064
4.375
4
# name : Nabil Alhassani # email : nda11@pitt.edu # date :septemper/11th # class : CS0008-f2016 # instructor : Max Novelli (man8@pitt.edu) # Description:Starting with Python, Chapter 2, # Notes: # any notes to the instructor and/or TA goes here # ...and now let's program with Python # exercise 3 # Many financial exper...
true
81d1b25c60fd7043a49fb43f2cb4c808c4d21a86
nda11/CS0008-f2016
/ch2.py/ch2-ex3 bis.py
442
4.25
4
# Exercise : ch2-ex3 #This program asks the user to enter the total square meters of land and calculates the number of #acres in the tract. #set one_acre value and one_acre= 4,046.8564224**2 one_square_meter= 0.000247105 #input square_meter square_meter=float(input('enter the total square meters:',)) # calculation th...
true
935e0d1a4a7f85d3aa7a44c03171faa99c491d6f
marcoahansen/Python-Estudos
/exercicios/semana3/fizz.py
210
4.125
4
def main(): numero= float(input("Digite um número para saber se é divisível por 3:")) resto3 = numero % 3 if(resto3 == 0): print("Fizz") else: print(int(numero)) main()
false
2f3cf52da18ad63dcd6a9cec6710b3b1b15f1e9f
Victor-Bonnin/git-tutorial-rattrapages
/guessing_game.py
1,300
4.375
4
#! /usr/bin/python3 # The random package is needed to choose a random number import random # Define the game in a function def guess_loop(): # This is the number the user will have to guess, chosen randomly in between 1 and 100 number_to_guess = random.randint(1, 100) name = input("Write your name:...
true
3759e1450a801809bb2b00bcbf17d8ab474054a4
nagalr/algo_practice
/src/main/Python/Sort/insertion_sort.py
565
4.15625
4
def insertion_sort(l): """ Insertion Sort Implementation. Time O(n^2) run. O(1) space complexity. :param l: List :return: None, orders in place. """ # finds the next item to insert for i in range(1, len(l)): if l[i] < l[i - 1]: item = l[i] # moves the...
true
15e3ed05dc5919e6a86fe26cd62e6fff05e65209
wulfebw/algorithms
/scripts/probability_statistics/biased_random.py
2,057
4.25
4
""" :keywords: probability, biased, random """ import random def biased_random(p=.1): """ :description: returns 1 with p probability and 0 o/w """ if random.random() < p: return 1 return 0 def unbiased_random(): """ :description: uses a biased random sampling with unknown bias to ...
true
914c9007a4dbf898d7d84bcdf477dc00b5a43d89
JingYiTeo/Python-Practical-2
/Q08_top2_scores.py
567
4.15625
4
NStudents = int(input("Please Enter Number of Students: ")) Names = [] Scores = [] for i in range(NStudents): Name = str(input("Please enter Name: ")) Score = int(input("Please enter Score: ")) Names.append(Name) Scores.append(Score) Scores, Names = (list(t) for t in zip(*sorted(zip(Scor...
true
ab7a5601210b13fd049b859d96aa0e25c1f6df0e
Soreasan/Python
/MoreList.py
1,135
4.4375
4
#!/usr/bin/env python3 #We can create a list from a string using the split() method w = "the quick brown fox jumps over the lazy dog".split() print(w) #We can search for a value like this which returns the index it's at i = w.index('fox') print(i) print(w[i]) #w.index('unicorn') #Error #You can check for membership wi...
true
e6b4587b69e39a7e1bdbeb7befc1cd064ef1cb35
Ankitpahuja/LearnPython3.6
/Lab Assignments/Lab06 - Comprehensions,Zip/Q1.py
886
4.75
5
# Create a text file containing lot of numbers in float form. The numbers may be on separate lines and there may be several numbers on same line as well. We have to read this file, and generate a list by comprehension that contains all the float values as elements. After the data has been loaded, display the total numb...
true
6486f929c5adccc0980dc26db652e9358c001754
Ankitpahuja/LearnPython3.6
/Lab Assignments/Lab05 - RegEX/ppt_assignment.py
673
4.3125
4
''' Write a function that would validate an enrolment number. valid=validateEnrolment(eno ) Example enrolment number U101113FCS498 U-1011-13-F-CS-498 13 – is the year of registration, can be between 00 to 99 CS, EC or BT Last 3 are digits ''' import re pattern = re.compile("U1011[0-9][0-9]F(CS|BT)\d\d\d")...
true