blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
09f793ed475b80515b440709e16eeb92d06be6ac
FGG100y/myleetcode
/hwtt/lpalindrome.py
1,536
4.3125
4
#!/usr/bin/env python # # recursive is_pal to help identify the palindrome # def is_palindrome(s): # def is_pal(s): # if len(s) <= 1: # return True # else: # answer = (s[0]) == s[-1] and is_pal(s[1:-1]) # return answer # # return is_pal(s) # # # def...
false
8a9f2bb818704eadf12c8838672b63b6259e1b25
FGG100y/myleetcode
/leetcode/reverse_words.py
828
4.28125
4
#!/usr/bin/env python def rwords(s): """reverse the words in string rtype: None """ s = s[::-1] rws = [w[::-1] for w in s.split()] print("".join(rws)) def rwords_1space(s): """reverse the words in string, seperate by only one space between words """ # replace all non-alphabetic ...
false
62ab746c5779f2deb2c4dd5a813fa34795b09978
jleyva82/Resources
/file_creation.py
762
4.125
4
''' Author = Jesus Leyva Last Update: 01/28/2019 Purpose: Sample of how to use python to create a new file sample resources as described via stack skills python lessons ''' newfile = open("newfile.txt", "w+") #newfile variable is like a class. ...
true
19c4a3143ccb88b7c58e1bd27f380fd739d5958a
Programmer-X31/PythonProjects
/Project Basic/Datetime_Module.py
742
4.25
4
import datetime as dt birth_day = int(input("Enter your birthdate \n")) birth_month = int(input("Enter your birthmonth \n")) birth_year = int(input("Enter your birthyear \n")) today = dt.date.today() print("Today is " + str(today)) birthday = dt.date(birth_year, birth_month, birth_day) print("Your birthday...
false
8633f7141389e8fbfabff287cf97602ff3a65533
BoHyeonPark/BI_test
/bioinformatics_1_4.py
391
4.1875
4
#!/usr/bin/python num1 = raw_input("Enter a integer: ") num2 = raw_input("Enter another: ") try: num1 = int(num1) num2 = int(num2) except: print "Enter only number!" else: if num1 > num2: print "%d is greater than %d" % (num1, num2) elif num1 < num2: print "%d is less than %d" % (...
true
93886ea9807f467a784600cbf3be7d2e60522a11
klprabu/myprojects
/Python/HackerRank/DesignerMat.py
1,581
4.21875
4
# Set the design as per the input #Mr. Vincent works in a door mat manufacturing company. One day, he designed a new door mat with the following specifications: #Mat size must be X. ( is an odd natural number, and is times .) #The design should have 'WELCOME' written in the center. #The design pattern should on...
true
cb3f2a2ba89d10eeb06bc7bdb3a1e205ade8ddeb
kiennd13/NguyenDucKien-Fundamentals-C4E30
/Session 5/function_7,8.py
352
4.125
4
def remove_dollar_sign(s): return s.replace("$","") m = str(input("Nhập chuỗi : ")) t=remove_dollar_sign(m) print(t) string_with_no_dollars = remove_dollar_sign("$80% percent of $life is to show $up") if string_with_no_dollars == "80% percent of life is to show up": print("Your function is correct") else: ...
true
825f18874a543fe5162d409085f17def0aed29e9
kiennd13/NguyenDucKien-Fundamentals-C4E30
/Session 5/function_5,6.py
481
4.21875
4
from turtle import * def draw_star(x,y,length): up() setposition(x,y) down() for _ in range(5): left(144) forward(length) mainloop() length = int(input("Length = ")) x = int(input("Position 1: ")) y = int(input("Position 2: ")) draw_star(x,y,length) speed(0.3) color('blue') for i in ...
true
e2d0c4546380e8e7e6a2268b69893dc78732266e
rsdarji/CEGEP-sem-2-Algorithm
/examples.py
2,490
4.28125
4
# ====================================================================================================================== # Printing # ====================================================================================================================== """ Basic user output in Python is done with 'print'. Although we...
true
3f30f28b8f3a8db8e53cab846a248d4b8c8f11ff
jeffrlynn/Codecademy-Python
/removeVowels.py
250
4.3125
4
#Remove all vowels from a string def anti_vowel(text): phrase = "" for letter in text: for vowel in "aeiouAEIOU": if letter == vowel: letter = "" else: letter = letter phrase = phrase + letter return phrase
true
f37185b847d2d868082ab9db5cca9a318f0632bb
GeertenRijsdijk/Theorie
/main.py
2,649
4.15625
4
''' main.py Authors: - Wisse Bemelman - Michael de Jong - Geerten Rijsdijk This file implements the front end for the algorithms and visualisation. usage: python main.py <datafile> <amount of houses> <algorithm> example: python main.py ./data/wijk_2.csv 60 r The algorithm choices are located in th...
true
9c13585b3241bdd8f0d5b538afee7044567cfe32
TanyaMozoleva/python_practice
/Lectures/Lec11/p15.py
736
4.1875
4
''' Using and if ... elif statement complete the compare_nums2() function which is passed two integers and returns a string. The function compares the first number to the second number and returns one of the following three strings (i.e., the string which is applicable): "equal to" OR "less than" OR "greater than" ''' ...
true
759f3b296db18e6557f46ffa8bd99d48a713c247
TanyaMozoleva/python_practice
/Lectures/Lec12/p13.py
1,040
4.15625
4
''' A perfect number is an integer that is equal to the sum of its divisors (including 1, excluding the number itself), e.g., the sum of the divisors of 28 is 28 (1 + 2 + 4 + 7 + 14). Complete the check_perfection() function which checks for perfection and prints either '#is a perfect number' or '#is NOT a perfect numb...
true
9f3dda1df5bfb23fbc90698d6db2e62c37d0c37c
TanyaMozoleva/python_practice
/Weeks/week2/w2t2.py
506
4.625
5
''' Complete the programm that prompts the user to enter a floatibg point value and an unteger value and calculates and displays the value obtained when the floating point value is raised to the power of the integer value. The result will be rounded to the nearist 3 decimal places. ''' number = float(input('Enter a fl...
true
713b95248bac2b24e652bd1437ccc055598783c5
TanyaMozoleva/python_practice
/Lectures/Lec4/p24.py
315
4.28125
4
''' Complete the following program so that it prints the name between two rows of stars. The output has three spaces on each side of the name ''' name = 'Philomena Evangeline' extras = 3 symbol = '*' lots_of_symbols = symbol * 26 print(lots_of_symbols) print(' ' * extras, name, ' ' * extras, sep = '') print(lots_of_...
true
06d0a2da145a8c679ffc0c12bf9730233f8ec553
TanyaMozoleva/python_practice
/Weeks/week2/w2t5.py
387
4.28125
4
''' Write a program that prompts the user to enter a word. In then prints a new word where the first and last characters of the word entered by the user are swapped. ''' word = input('Enter a word: ') first_character = word[0] last_character = word[-1] middle_slice = word[1:-1] new_word = last_character + middle_slic...
true
00bdd1f1d9b9f76752edd0f65ea483a6fa039089
cvhs-ap-2018/python-practice-exam-Alvarezchris23
/graphics.py
813
4.53125
5
""" 1. Write the lines of code that would import and create a turtle named 'Pong'. """ import turtle Pong = turtle.Turtle('turtle') Pong.pd() """ 2. Draw a square with Pong of length 100 """ import turtle Pong = turtle.Turtle('turtle') for i in range(4): Pong.fd(100) Pong.rt(90) """ 3. W...
true
e229e096226f4e2cca03bc1250f079d122406250
ZR-Huang/AlgorithmsPractices
/Leetcode/Basic/Dynamic_Programming/53_Maximum_Subarray.py
662
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. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. Follow up: If you have figured out the O(n) solution, try coding another solu...
true
30fd79047b91178674d44118792ab65aedc59a66
ZR-Huang/AlgorithmsPractices
/Divide and Conquer Algorithm/Week1_MergeSort.py
1,062
4.125
4
""" @function: the implement of Merge Sort """ def Merge(A,B): i = 0 j = 0 result = [] for k in range(len(A)+len(B)): if i < len(A) and j < len(B): if A[i] < B[j]: result.append(A[i]) i += 1 elif B[j] < A[i]: result.app...
false
460e74a392f8586e88a120885f7cfe6c1400c525
ZR-Huang/AlgorithmsPractices
/Leetcode/Intermediate/Array_and_string/73_Set_Matrix_Zeroes.py
2,957
4.3125
4
''' Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: Input: [   [1,1,1],   [1,0,1],   [1,1,1] ] Output: [   [1,0,1],   [0,0,0],   [1,0,1] ] Example 2: Input: [   [0,1,2,0],   [3,4,5,2],   [1,3,1,5] ] Output: [   [0,0,0,0],   [0,4,5,0],   [0,3,1,0] ] Follow ...
true
17e86d07b7f438a8365650253f65130b0eebde87
ZR-Huang/AlgorithmsPractices
/Leetcode/Basic/Math/326_Power_of_Three.py
1,530
4.46875
4
''' Given an integer, write a function to determine if it is a power of three. Example 1: Input: 27 Output: true Example 2: Input: 0 Output: false Example 3: Input: 9 Output: true Example 4: Input: 45 Output: false Follow up: Could you do it without using any loop / recursion? ''' class Solution: def isPowerO...
true
4b53b20061ab23c8e8f84ef083f0980dd482675f
ZR-Huang/AlgorithmsPractices
/Leetcode/Intermediate/Backtracking/78_Subsets.py
611
4.46875
4
class Solution: ''' Computing the subset of the array can be considered as the selection of every element of the array. Thus, the DFS algorithm is used to search all the possible combinations. This method also called backtrack algorithm. ''' def subsets(self, nums): result = [] ...
true
83cc10463f51848197a05dadf1be6a16bc96de01
dziarkachqa/example_pytest
/src/src.py
734
4.125
4
def join_list(some_list: list) -> str: """Function joins list elements and strings""" if not isinstance(some_list, list): return "I need list!" return "".join([str(el) for el in some_list]) def split_list(some_list: list, sep=None) -> tuple: """Function for splitting list by separator""" if...
true
7d1ed39f4b34b009182e04e7a4b6f62b4329357a
JeffreyAsuncion/SQLite_Databases_with_Python
/db001.py
593
4.21875
4
import sqlite3 # conn = sqlite.connect(':memory:') # to create a database in memory that disappear after done conn = sqlite3.connect('customer.db') # before create table need a cursor # Create a cursor cursor = conn.cursor() # if we recreate a table we get an error # # Create a table # cursor.execute("""CREATE TA...
true
03de7319b70da0d4bbbabcd4df51886b767857f9
geniousisme/CodingInterview
/leetCode/Python/281-zigzagIterator.py
946
4.21875
4
# Given two 1d vectors, # implement an iterator to return their elements alternately. # For example, given two 1d vectors: # v1 = [1, 2] # v2 = [3, 4, 5, 6] # By calling next repeatedly until hasNext returns false, # the order of elements returned by next should be: [1, 3, 2, 4, 5, 6]. # Follow up: What if you are gi...
true
b67be5db60f242b0a586cac963668509304f2521
geniousisme/CodingInterview
/leetCode/Python/147-insertionSortList.py
1,567
4.125
4
# Time: O(n ^ 2) # Space: O(1) # # Sort a linked list using insertion sort. # # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: # @param {ListNode} head # @return {ListNode} def insertionSortList(self, head): ...
false
f6225982288731faa7c4d02b279789b75796ff39
jdmorrone01/Triangle567
/TestTriangle.py
2,140
4.125
4
# -*- coding: utf-8 -*- """ Updated Jan 21, 2018 The primary goal of this file is to demonstrate a simple unittest implementation @author: jrr @author: rk """ import unittest from Triangle import classifyTriangle # This code implements the unit test functionality # https://docs.python.org/3/library/unittest.html ha...
true
8f425d726835670b203d4f636d41f7157c7592d2
biglocalnews/covid-world-scraper
/covid_world_scraper/utils.py
529
4.1875
4
from datetime import datetime def relative_year(month, day): """Given a month and day, determine the correct year on New Year's Day """ t = today() # If incoming date is Jan 1st if month == 1 and day == 1: # and current UTC is Dec 31st, # then increment the current year ...
false
c46fbcd48b0dae0d7a5c8e6b1b852c7baeb91fb4
mz09code/brutal-algorithm-class
/2019 首期/Chapter 1/4/stack.py
690
4.21875
4
class Stack: # 抽象数据结构 def __init__(self): self.data = [] def length(self): return len(self.data) def peek(self): # 窥, 返回顶上的数据 return self.data[-1] # self.data[len(self.data)-1] def push(self, ele): self.data.append(ele) def pop(self): # return self.d...
false
105907e46fd1d42a49ce22765393ef5a88b39102
anshul-musing/basic_cs_algorithms
/test_heap.py
935
4.21875
4
from src.heap import MaxHeap def testHeap(): ''' Here we test algorithms for a max heap The heap class takes a balanced binary tree as an input and converts it into a max heap We test a) building a max heap b) heapify operation Each node of the max heap is an object of the...
true
cc3a38c69c3105c5b40b7d2f968013f695454f8a
anshul-musing/basic_cs_algorithms
/test_graph.py
1,284
4.34375
4
from src.graph import Graph def testGraph(): ''' Here we test algorithms for graphs We test a) breadth first search b) depth first search c) minimum spanning tree using Prim's algorithm d) shortest distance using Dijkstra's algorithm Graph's vertices are specified as a list ...
true
0ffd265548c8bda235ed4ad28c81fef877dc48aa
ironxmind/SkillBox
/3.6 homework/task5.py
1,041
4.21875
4
print('Задача 5. Вход в систему') # Что нужно сделать # Исправьте программу и допишите необходимые команды для получения нужного результата. # Будьте внимательны при исправлении и помните о правилах названия переменных. # Программа: first_name = input('Введите имя пользователя: ') greeting = 'Утро доброе' print(gree...
false
11e7d3d78785ed89f7734d05608121ef8d58dd8e
betteridiot/biocomp_bootcamp
/basic_script.py
413
4.75
5
"""Write a Python 'Hello, World' program. A 'Hello, World' program is a program that prints out 'Hello, World' on the screen. In addition to doing 'Hello, World', I want you to go a little further. 1. Print out 'Hello, World' 1. Save your partner's name as a variable 2. Print out 'Hello, <your partner's name>' by pa...
true
55ae3800c673d4a662d51d3e272a25a8186458d1
acm-kccitm/Python
/Class/Person.py
2,885
4.3125
4
class Person: ''' The class Person describes a person''' count = 0 def __init__(self, name, DOB, Address): ''' Objective: To initialize object of class Person Input Parameters: self (implicit parameter) - object of type Person name - string DOB - ...
true
b3430f9aa7d8b084ea5f8f44a1af6723f12e98a4
jsore/notes
/v2/python-crash-course/python_work/loops.py
818
4.5625
5
items = ['val1', 'val2', 'val3'] # basic syntax for item in items: print(item) # don't forget Python loves whitespace print('this is outside the loop') # ranges for value in range(1, 5): print(value) # 1 # 2 # 3 # 4 # list from ranges numbers = list(range(1, 6)) # [1, 2, 3, 4, 5] # set step size for s...
true
e3c3ff38d924f380917f5d5b48a755d1e708a06e
Sravya12379/walk2zero
/googlemaps.py
2,089
4.3125
4
import requests def input_locations(): """ This allows the user to input the locations of the origin and destination, assigns them to variables and returns these variables. :return: inputted origins and destination """ origin = input("Your location: ") destination = input("Your destinatio...
true
382c5bc9518497e6d3d972912c33c7cb93ef75d8
HarrisonMS/JsChallenges
/Python/hackerrank/staircase.py
301
4.125
4
#!/bin/python3 import math import os import random import re import sys # Complete the staircase function below. def staircase(n): spaces = n-1 stairs = 1 while n: print(" "*spaces + '#'*stairs) n -= 1 spaces -= 1 stairs += 1 print(staircase(6))
true
7271c2f2f3f3c02b743f365b3d203c9b2fc0085a
shinjita-das/python-learning
/prac.py
848
4.125
4
def calc(input1, input2, operator): value = None # Start here # if else # math operators # how to compare strings in python if operator == "+": value = input1 + input2 elif operator == "-": value = input1 - input2 elif operator == "*": value = input1 * input2 ...
true
96627c0924c2a27c74ad4e6eef0bfe0ba369027c
sarahmarie1976/cs-guided-project-python-basics
/src/demonstration_03.py
803
4.53125
5
""" Challenge #3: Create a function that takes a string and returns it as an integer. how would we cast string to integer We would instantiate an int object from the string data example --- int("10") then it will return an integer -- 10 if we check the type(int("10")) <class 'int'> We can use the int() ...
true
6b884ea45e91503820623d0344ba2983c022cdb1
xiaochuanjiejie/python_exercise
/Exercise/15-18/exercise_13.6.py
1,213
4.1875
4
#-*- coding: utf-8 -*- from math import sqrt class Line(object): def __init__(self,x1=0,y1=0,x2=0,y2=0): self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 self.length = 0 self.slope = 0 def getlength(self): if (self.x1 == self.x2) and (self.y1 == self....
false
ed72de3aa6354a0e194df8e3ffeead2c69e5f379
diminako/100-days-of-python
/day-03-conditionals/day-03.py
2,425
4.25
4
# conditionals # If / Else statement print('Welcome to the Roller Coaster!') height = int(input("What is your height?\n")) if height >= 100: print('You may ride the roller coaster!') else: print('Grow up kid!') print('Neat!') print('----------------------') # Code Challenge Odd or even check num = int(input(...
true
6d9a4335b26fbea1049b8e593beadc0fb09cf10f
ZrcLeibniz/PythonTest
/mypro01/mypy10.py
277
4.375
4
# 测试zip()并行迭代 for i in [1, 2, 3]: print(i) names = ('rich', 'rich2', 'rich3', 'rich4') ages = (18, 16, 21, 43) jobs = ('老师', '程序员', '公务员') for names, ages, jobs in zip(names, ages, jobs): print("{0}---{1}---{2}".format(names, ages, jobs))
false
3d7ed338c44c8b0bd2bae45b1ee10274995dae07
ZrcLeibniz/PythonTest
/mypro01/mypy04.py
488
4.125
4
# 选择结构的嵌套 score = int(input("请输入学生的分数:")) grade = '' if score > 100 or score < 0: print("请认真输入学生的分数") score = int(input("请输入学生的分数:")) else: if 0 <= score < 60: grade = "不及格" elif 60 <= score < 80: grade = "及格" elif 80 <= score < 90: grade = "良好" elif 90 <= score <= 100: ...
false
943faf287b532ae4846c8960feb62e7d79a1214a
ZrcLeibniz/PythonTest
/mypro01/mypy08.py
1,020
4.1875
4
# break的学习 # break可用于while和for循环,用来结束整个循环。当有嵌套循环时,break语句只能跳出最近一层循环 # continue的学习 # continue语句用于结束本次循环,继续下一次循环。多个循环嵌套时,continue也是应用于最近一层循环 while True: a = input("请输入一个字符:") if a == 'q' or a == 'Q': print('循环结束,退出') break print('&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&')...
false
449c36aa7b4d056abb31ea4623d7d3d29ec3d14c
TheGrateSalmon/Side-Projects
/Collatz Conjecture.py
1,048
4.1875
4
# Collatz Conjecture (3n+1) # performs the 3n+1 algorithm for any positive integer from time import * def main(): number = int(input('Input any positive integer or "0" to quit: ')) while number < 0: number = int(input('That is not a valid input. Please input any positive integer or "0" t...
true
a43bf45cbc1d6a88280ed77efabc85d471978f6f
uisandeep/ML-Journey
/python/variablescope.py
1,923
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun May 31 14:57:34 2020 @author: sandeepthakur """ # Example 1 # Although x and y are two different variables, it will have same memory addess x=20 y=20 print(id(x)) print(id(y)) print("-----------------------------------------------------") # Exampl...
true
265c8b5a4d091d1c9ee4066dc4ecf06270eb7205
jjliun/Python
/Interactive/project1.py
2,495
4.3125
4
#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- # Filename : project1.py # Author : Yang Leo (JeremyRobturtle@gmail.com) # Last Modified : 2014-04-01 '''Demo of rock-paper-scissors-lizard-Spock ''' # The key idea of this program is to equate the strings # "rock", "paper", "scissors", "lizard", "Spock" to n...
true
f15e22655fc5e6225dd18018e07cba2b0089aa93
Vansh-Arora/InteractWithOS
/diff-file-operations/workingOnFiles/last_modification_date.py
525
4.125
4
#!/usr/bin/env python import os import datetime def file_date(filename): # Create the file in the current directory file = open(filename,"w") file.close() timestamp = os.path.getmtime(filename) # Convert the timestamp into a readable format, then into a string date = str(datetime.datetime.fromtimestamp(ti...
true
8c74e8c55d53a970b46fde0f4305fe7da4988c07
cddas/python27-practice
/exercise-6.py
427
4.34375
4
user_string = raw_input("Enter a name for Palindrome check : ") list_string = [] reverse_list_string = [] for letter in user_string: list_string.append(letter) reverse_list_string = list_string[:] reverse_list_string.reverse() if (list_string == reverse_list_string): print("The entered string " + user_strin...
true
76fb884a8571e0cc23d7c1a122f78e3cc386d6c2
Simrang19/sort_n_search
/searching/bisect_library.py
553
4.125
4
# bisect : python library to use binary search # bisect left : find the leftmost possible index to insert in the list such that list is still sorted. # bisect right : find the rightmost possible index to insert in the list such that list is still sorted. import bisect li = list(map(int, input().split())) while True:...
true
df93e0dfc98976e5101dcf53d6cdad6044d643ea
596050/DSA-Udacity
/practice/data-structures/stacks/reverse-stack.py
347
4.125
4
from stack import * def reverse_stack(stack): """ Reverse a given input stack Args: stack(stack): Input stack to be reversed Returns: stack: Reversed Stack """ reversed_stack = Stack() for i in range(stack.size()): item = stack.pop() reversed_stack.push(item) ...
true
2eb8ef40c03c083f60841c7e63e6043792a2fdc1
596050/DSA-Udacity
/practice/data-structures/recursion/string-permutations.py
1,148
4.1875
4
def permutations(string): """ :param: input string Return - list of all permutations of the input string TODO: complete this function to return a list of all permutations of the string """ return _permutations(string, 0) def _permutations(string, index): if index >= len(string): ret...
true
ac702a3e7956293a0f38a414a3b45a22348de3e5
Aditya7256/Demo
/join sets.py
1,348
4.53125
5
# The union() method returns a new set with all items from both sets: set1 = {"a" "b", "c"} set2 = {1, 2, 3} set3 = set1.union(set2) print(set3) # The update() method inserts the items in set2 into set1: set1 = {"a", "b", "c"} set2 = {1, 2, 3} set1.update(set2) print(set1) # The intersection_update() me...
true
61e42234117d666ae39fe3783e82a85ffcb07813
Aditya7256/Demo
/join List.py
431
4.1875
4
# Join two list list1 = ["Apple", "banana", "mango"] list2 = [4, 7, 3] list3 = list1 + list2 print(list3) # append to list2 into list1 list1 = ["mango", "orange", "pineapple"] list2 = [3, 4, 25, 6] for x in list2: list1.append(x) print(list1) # use the extend() method to add list2 at end of list1 ...
true
78b733b769bdba9af2c2676c6ec564442c608fb5
jmvbxx/happiness
/happiness_words.py
823
4.25
4
# This this program does two things: # # 1. Create a dictionary based on the happiness word list (AFINN-111.txt) # 2. Prompts the user to choose a word and returns the value of that word import re words_dict = {} # Generate dictionary from word list with open("AFINN-111.txt") as words: for line in words: ...
true
a3cc9d25bd458d2c080c60a4b15aa10d5cb4563b
SamanthaCorner/100daysPython-DAY-5
/adding_evens.py
618
4.25
4
""" 100 days of Python course DAY 5 """ # calculate the sum of all the even numbers from 1 to 100, # including 2 and 100: using the for ... in range loop # approach using range 2, 101 and stepping by 2 even_sum = 0 for number in range(2, 101, 2): even_sum += number print(even_sum) # a different appro...
true
303698b606fe853364454dc666a8414eb803b920
UCD-pbio-rclub/Pithon_Michelle.T
/pithon_07112018/0711_ex3.py
1,178
4.125
4
#3. Demonstrate inheritance by importing your class "Organism" from problem 2. #Use it to create a new class called "LongOrganism" which inherits "Organism" and #modifies it by adding any other attributes that may be significant about an organism #(ie ploidy, genome size, region). Write new methods which allow a use...
true
713737d145b1f751736a35aa7556e1482bf68e63
yashshah4/Data-Science-Projects
/Miscellaneous/charactercount.py
630
4.21875
4
#The following module helps prettify the printout of a dictionary #This module includes pprint() & pformat() to improve what print() generally offers import pprint #Asking for a text input from the user and saving it as a string message = str(raw_input("Enter a text : ")) #Declaring a dictionary to count characters cou...
true
e4fe8c8df4a778d3c73c3193df5e5995cf80029c
jovannovarian1117/stephanusjovan
/drivingsimulatorstephj.py
1,255
4.3125
4
# declare data for inputs # initial velocity set to 0 u = 0 time = 0 velocity_data = 0 # user have to input the time below t_input = int(input("Input time spent on the road")) # user have to input their acceleration below a = int(input("Input acceleration")) # user have to input distance travel below ...
true
68017376126391b4e4a4dae814825fdc903209ad
nconstable2/constable_n_python
/conditions.py
800
4.34375
4
# print a message to the terminal window print("Rules that govern the state of water") # set up a variable to hold the temp we input current_temp = False while current_temp is False: # MAKE THIS A NUMBER!! x = current_temp current_temp = x # see what current temp is print("you input:", x) # if...
true
32560b22b72e04fd4c5d74538331c5101701df96
sridhar29k/interview-task
/Task_2_virtusa.py
706
4.15625
4
##Seating Arrangement. You have n students and n chairs in an exam hall. n/3 students are writing ##Maths, n/3 are writing physics and n/3 are writing chemistry. The n chairs are arranged in two ##rows, with n/2 in each row. Write an algorithm to make sure no two maths students sit either ##next/in front/behind of a...
true
0ac4c535cf8c69463dcb5527747842510ae2318e
emerick23/python-control-flow-lab
/exercise-6.py
1,536
4.53125
5
# exercise-06 What's the Season? # Write the code that: # 1. Prompts the user to enter the month (as three characters): # Enter the month of the season (Jan - Dec): # 2. Then propts the user to enter the day of the month: # Enter the day of the month: # 3. Calculate what season it is based upon this chart:...
true
9fe75a4cd0e11f1266cb257deaf339ac3575e24a
Sam40901/Variables
/assignment development exercise 1.py
556
4.25
4
print("hello, this program will ask you for two numbers, divide one by the other, give you the integer and the variable.") number_1 = int(input("please enter your first number: ")) number_2 = int(input("please enter your second number: ")) number_integer = number_1 // number_2 number_remainder = number_1 % n...
true
61d764d8419883b424ddedacee128a00621d22cf
pamelot/poem-word-count
/calculator.py
1,461
4.375
4
""" calculator.py Using our arithmetic.py file from Exercise02, create the calculator program yourself in this file. """ from arithmetic import * def main(): # This is where the user can input the calculation. # This will be a series of if statements for determining which function to call. cond = T...
true
5d1f55b305b0929036b1baf302bd6195eac2beb7
AdriAriasAlonso/Python
/Practica6/E3P6.py
502
4.15625
4
#Ejercicio 3 Practica 6: Adrián Arias """Escribe un programa que pida notas y los guarde en una lista. Para terminar de introducir notas, escribe una nota que no esté entre 0 y 10. El programa termina escribiendo la lista de notas.""" notas=[] entrada=float(input("Escribe un número\n")) while entrada>=0 and entrada<=...
false
9cf59ca6e5ef627197a86a2bb92140e88d0242ff
derekforesman/CMPSC-131
/Python/apr_calculator.py
630
4.1875
4
#!/usr/bin/env python3 deposit = float(input("What is the amount you will be depositing?\n")) # get the amount to be deposited apr = float(input("Please enter the APR for the account. For example (2) will be read as 2% or 0.02\n")) # get the percent APR years = int(input("How many years will it gain interest?\n")) # g...
true
45120d9c4d2adcbe72d170ec14a1908e512cd132
aallooss/CSquared-2021
/2_Whats_your_name.py
217
4.125
4
# authored by >Haden Sangree< for >Coding with Character Camp< # Lesson 2 # CHALLENGE: Try changing the question and what your print. name = input("Whats your name? ") print("Your name is " + name) #challenge
true
22d44e8410c0f7f7cc3696f2ae60b39c43bddccb
hudaquresh/pythonDSRune
/sortingAndSearching/sorting/insertion.py
461
4.1875
4
'''Implementing an insertion sort algorithm.''' def insertionSort(aList): # insertion sort for index in range(1, len(aList)): currentValue = aList[index] position = index while position > 0 and aList[position-1] > currentValue: aList[position] = aList[position-1] position = position-1 aList[positio...
true
9f4225b7fbaf84b3d97360f38a12d72fb4c1d4b2
arleybri18/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/1-last_digit.py
607
4.125
4
#!/usr/bin/python3 import random number = random.randint(-10000, 10000) if number < 0: print("Last digit of {0} is {1} and is less than 6 and not 0".format (number, -(-number % 10))) else: if (number % 10) > 5: print("Last digit of {0} is {1} and is greater than 5".format (number...
true
9808fd61460fd7caf2657561f8b172590def8396
arleybri18/holbertonschool-higher_level_programming
/0x06-python-classes/5-square.py
1,357
4.4375
4
#!/usr/bin/python3 class Square: """Class with a instance private attribute, with optional value 0 validate type and value > to 0, send a message Error using raised and define a method to calculate area of square """ def __init__(self, size=0): """init method Args: si...
true
35e4f85e35f97e1427b77f5c57632cc425eb18ac
IonesioJunior/Data-Structures
/Python/LinkedList/SingleLinkedList/RecursiveSingleLinkedList.py
2,998
4.25
4
#coding: utf-8 __author__ = "Ionesio Junior" class RecursiveLinkedList(object): ''' Single Linked List in recursive implementation Attributes: data(optional) : data stored in this object nextNode(RecursiveLinkedList) : next Recursive Node ''' __data = None; __nextNode = None; def __init__(self,...
true
f2fa0f0eb5bfcfbff341ee268ed6652d1f589ee7
IonesioJunior/Data-Structures
/Python/Stack/Stack.py
2,027
4.125
4
#coding:utf-8 __author__ = "Ionésio Junior" class Stack(): """ Stack Structure Implementation Attributes: stackList[] = list of elements in stack size(int) = size of stack top(int) = index of top """ __stackList = None; __size = None; __top = None; def __init__(self,size = 10): '''' Stack Con...
true
020210178bbd278da6d41b09c26ea74d5bca0c84
IonesioJunior/Data-Structures
/Python/Queue/SimpleQueue.py
2,244
4.4375
4
#coding: utf-8 __author__ = "Ionésio Junior" class SimpleQueue(): ''' Implementation of simple queue data structure Attributes: queueList[] : list of elements in queue size(int) : size of list tail(int) : index of queue tail ''' def __init__(self,size = 10): ''' Constructor of Simple Queue initi...
true
d3659a72ef9816bee8d3c05c1c15f73fb2fb89e8
khemasree/CSEE5590_Lab
/Lab1/Source/Lab1/lab2a.py
994
4.21875
4
input = input("Please enter the sentence") # Initialize all the variables with default values individualwords=input.split() wordset=individualwords longestword = '' reversesen = '' print(wordset) # For even number of words print the middle two words if len(wordset) % 2 == 0 : print("Middle Words are: ["+individua...
true
5677689f850e6b426c4a88976b4bd1e9e6c07aa2
SillAndrey/training
/next_factorial.py
876
4.25
4
def next_factorial(n): ''' find all Prime Factors (if there are any) and display them. program find prime numbers until the user chooses to stop asking for the next one. ''' Ans = [] d = 2 while d * d <= n: if n % d == 0: Ans.append(d) n //= d else: ...
true
6ffe61b87d42a3734848c0cf33a315be33da25d4
jan-nemec/ATBSWP
/03_exception_zero_divide.py
1,008
4.28125
4
# Errors can be handled with try and except statements. # The code that could potentially have an error is put in a try clause. # The program execution moves to the start of a following except clause if an error happens. # You can put the previous divide-by-zero code in a try clause # and have an except clause contain...
true
9a97f2525c57bb9d575b24669f5686b4c78cf198
Zahidsqldba07/competitive-programming-1
/Leetcode/Problems/p987.py
2,364
4.125
4
# 987. Vertical Order Traversal of a Binary Tree ''' Print a Binary Tree in Vertical Order Given a binary tree, return the vertical order traversal of its nodes values. For each node at position (X, Y), its left and right children respectively will be at positions (X-1, Y-1) and (X+1, Y-1). Return a list of lists o...
true
41731edbe4168ead2b1a686ada6cc9bdde370677
Zahidsqldba07/competitive-programming-1
/Leetcode/June Leetcooding Challenge/sort_colors.py
1,322
4.3125
4
# Sort Colors ''' 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 suppo...
true
018d052ffdbc192e36c18097ecee981143d66a21
aviidlee/backend-coding-challenge
/tools/scoringmethods/scoringmethod.py
967
4.28125
4
from abc import abstractmethod class ScoringMethod(object): ''' Abstract base class for a scoring method and its associated parameters. Given two strings, return a number in range [0, 1] representing how closely the strings match, where the higher the number, the closer the match. Methods: ...
true
c13891e853f055cae779f3dea7a797090595f7f4
vijaycs20/Python_Projects
/Vote age.py
371
4.25
4
# -*- coding: utf-8 -*- month=int(input("Enter your month of birth : ")) year=int(input("Enter your year of birth : ")) age=2020-year mon=9-month vote="You are eligible for voting! Just use your power!" if age>=18 else "you are just ",age,"years And",mon,"months Old!.\n S0 you're not eligible for voting.\n S0, just cal...
true
86006b7f09c6ed179b076b85e9052a265e969d77
zaliubovskiy/webacademy
/HomeWork_06/03_Sort_array_by_element_frequency.py
678
4.375
4
# Sort the given iterable so that its elements end up in the decreasing frequency order, that is, the number # of times they appear in elements. If two elements have the same frequency, they should end up in the same # order as the first appearance in the iterable. def frequency_sort(items): # Sorting by index fir...
true
fd8e289bd82fcc379ee150f9f7a10eea70296385
EradicDagger/Coding-Questions
/Python/Task1.py
1,209
4.25
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 1: How many different telephone nu...
true
856b9487bd2e8cdeda776566d80d8a4e5f10aac9
kewy76/ICP4
/One.py
2,237
4.1875
4
# Kate Williams # 6/14/2018 class Employee: # Employee class """A class representing an employee""" empNum = 2 def increment(self): self.__class__.empNum += 1 def __init__(self, n, f, s, d): self.name = n self.family = f self.salary = s self.de...
false
0115be8b2cb5a2fad67d50f042fe3dcf2d7661ab
Igor-Suchilin/Python
/LESSON1/lesson1.6.py
758
4.125
4
def choose_plural(num, choice): if (num // 10) % 10 == 1 or num % 10 == 0: return str(num) + ' ' + choice[2] elif num % 10 == 1: return str(num) + ' ' + choice[0] elif num % 10 <= 4: return str(num) + ' ' + choice[1] else: return str(num) + ' ' + choice[2] choice = 'день...
false
d67807edc76b47cfcf8aaed6ed71d9e8c33b4752
alamine42/coursera_computing_spec
/coursera-computing-01/Week2/user40_1Frzg4VuPq_5.py
2,375
4.21875
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import simplegui, random, math secret_number = 1000 secret_range = 100 remaining_guesses = 1 # helper function to start and restart the game def new_game(): # i...
true
1da645660ab64d0951d894634b5d143e16d2ab77
smiledt/Full-Stack-Web-Developer-Bootcamp
/python_lesson1/dictionaries.py
256
4.375
4
# Dictionary examples my_dict = {"key1": 123, "key2": "value2", 'key3': {"123": [1, 2, 'grabme']}} print(my_dict['key3']['123'][2].upper()) dict2 = {'lunch': 'pizza', 'bfast': 'eggs'} print(dict2['lunch']) dict2['lunch'] = 'burger' print(dict2['lunch'])
false
9a8d5de84f8877cf39d1bd52027f157c432bbee2
ikaros274556330/my_code
/python_1000phone/语言基础/day16-面向对象2/code/03-getter和setter.py
2,224
4.15625
4
"""__author__=吴佩隆""" import time """ 时间戳:当前时间距离1970年1月1日0时0分0秒的时间差,单位是秒 """ print(time.time()) # 获取当前时间的时间戳 time1 = time.time() # localtime(时间戳) - 将时间戳转化为当地时间 time2 = time.localtime(time1) print(time2) '2019-11-26 14:15:00' # 1.getter 和 setter """ 1)什么时候用 如果希望在对象属性赋值前做点别的什么事情就给这个属性添加setter 如果希望在获取属性值之前做点别的什么事情就给这个...
false
7a1ddb808e3b92d08f8a86db50680e0a09fc4957
ikaros274556330/my_code
/python_1000phone/语言基础-老师代码/day4-分支和循环/day4-分支和循环/02-分支结构.py
1,629
4.3125
4
"""__author__=余婷""" # 1. if-elif-else结构 """ 1)语法: if 条件语句1: 代码段1 elif 条件语句2: 代码段2 elif 条件语句3: 代码段3 ... else: 代码段N 其他语句 2) 执行过程: 先判断条件语句1是否为True,为True就执行代码段1,然后整个if-elif-else结构结束; 如果为False,就判断条件语句2是否为True, 为True就执行代码段2,然后整个if-elif-else结构结束; 如果是False,就判断条件语句3是否为True, 为True就执行代码段3,然后整个if-elif-else结构结束; 以...
false
7737ac629d4f74c7b3bd8194a59bbbd2e2965496
ikaros274556330/my_code
/python_1000phone/语言基础-老师代码/day6-列表元组和数字/code/05-元组.py
1,856
4.25
4
"""__author__=余婷""" # 1.什么是元祖(tuple) """ 元组就是不可变的列表 元组是容器型数据类型,将()作为容器的标志,里面多个元素用逗号隔开: (元素1,元素2,元素3,...) 元祖不可变(不支持增删改操作), 有序(支持下标操作) 元素可以是任何类型的数据 """ tuple1 = (1, 2, 3) print(type(tuple1)) # 2.和列表一样的操作 # 1)获取元素 # 列表获取元素的操作元组都支持 tuple2 = (10, 30, 21, 70) print(tuple2[-1]) print(tuple2[1]) print(tuple2[2:]) # (21, ...
false
03552a1e563ac606495fb7e9c767697919f944b9
ikaros274556330/my_code
/python_1000phone/语言基础-老师代码/day15-面向对象1/06-类中的属性.py
1,834
4.5
4
"""__author__=余婷""" # 1.类中的属性 - 就是类中保存数据的变量 """ 类中的属性分为2种:字段、对象属性 """ # 2.字段 """ 1)怎么声明: 直接声明在类里面函数外面的变量就是字段 2)怎么使用: 通过类使用; 以'类.字段'的形式去使用 3)什么时候用:不会因为对象不同而不一样的属性就声明成对象属性 """ # 3.对象属性 """ 1)怎么声明:声明在__init__方法中;以'self.属性名=值'的形式来声明 2)怎么使用: 通过对象来使用; 以'对象.属性'的形式来使用 3)什么时候用: 会因为对象不同而不一样的属性就声明成对象属性 """ class Person: ...
false
e923a39be0eeda5287d947d85f1c06ea88afbae3
reyesmi/Automate-the-Boring-Stuff-Codes
/2_guessTheNumber.py
1,236
4.3125
4
# This is a guess the number game. import random # imports random module secretNumber = random.randint(1,20) #sets a variable named secretNumber, which is equal to a random number generated between 1 to 20. print("I am thinking of a number between 1 and 20.") # informs user of the range of numbers. # Ask the player t...
true
35cef219cf6ae91d509d6fad385e59d03447f138
hzuluag56268/pycharm
/PycharmProjects/DeepLearning/Introduction to Deep Learning with PyTorch.py
1,567
4.5
4
'''1 Introduction to PyTorch ''' ......Introduction to PyTorch import torch # Create random tensor of size 3 by 3 your_first_tensor = torch.rand(3, 3) # Create a matrix of ones with shape 3 by 3 tensor_of_ones = torch.ones(3, 3) # Create an identity matrix with shape 3 by 3 identity_tensor = torch.eye(3) # Do ...
true
c59edea7dbf2eebdb2d1e7c12241915eb2ab4bb1
apbaca06/Python_100Days
/day-27/main.py
816
4.15625
4
from tkinter import * # document: http://tcl.tk/man/tcl8.6/TkCmd/entry.html window = Tk() window.title("GUI Program") window.minsize(500, 600) window.config(padx=100,pady=200) my_label = Label(text="I'm a label.", font=("Arial", 24, "italic")) # Pack the label on to the screen my_label.pack(side="top") my_label.pac...
true
b87072210ca5537a154dd3852a508cf374652bcd
ostapalfavitskyi/Lv-609.PythonCore
/HW5/Anton/1.py
247
4.21875
4
even = [] odd = [] not_div = [] for i in range(1,11): if i%2 == 0 : even.append(i) elif i%2 and i%3 != 0: not_div.append(i) else: odd.append(i) print(f'\nEven: {even}\nOdd: {odd}\nNot divisible: {not_div}\n')
false
ee171bbf10d81ee2bca71d7e354cc47614530dff
cesarschool/cesar-school-fp-2018-2-lista1-EduardoBBGusmao
/questoes/questao_1.py
904
4.125
4
## QUESTÃO 1 ## # Faça um programa que calcule o aumento de um salário. Ele deve solicitar o # valor do salário e a porcentagem do aumento. Exiba o valor do aumento e do # novo salário. ## ## # A sua resposta da questão deve ser desenvolvida dentro da função main()!!! # Deve-se substituir o comado print existente...
false
b874e8fbf6c9bd36ecff0b75e4780133517d1971
sapphire008/Python
/python_tutorials/ThinkPython/practice_notes_2.py
2,403
4.28125
4
# Python 3.3.0 Practice Notes # Day 2: November 24, 2012 import math; # Conditional statements x=1; y=2; z=3; if x<y and z<y: #again, don't forget the colon print("Y is teh biggest!"); elif x<y or z<y: print("Let's do nothing!"); else: print("Okay, I am wrong"); ...
true
1fca96cffc6a1fe5e1dfd942f592e900fddc39e0
sapphire008/Python
/PySynapse/archive/flow_chart_basic.py
2,642
4.28125
4
# -*- coding: utf-8 -*- """ This example demonstrates a very basic use of flowcharts: filter data, displaying both the input and output of the filter. The behavior of he filter can be reprogrammed by the user. Basic steps are: - create a flowchart and two plots - input noisy data to the flowchart - flow...
true
9adee9b38a36060bc32fb1ab396ecb4304fc66fa
albertkowalski/100-days-of-code
/day_7/day-7.py
1,013
4.125
4
# Hangman Game # Made using strings instead of lists import random import hangman_words import art print(art.logo) word = random.choice(hangman_words.word_list) word_underscored = "" for letter in word: word_underscored += "_" print(f"Hidden word is: {word}") print(word_underscored) lives = 6 game_won = False wh...
true
19b203d6daeb61c8ba6dc64c0a778c868659e06c
redline-collab/Python-Basic-Programs
/Prime_interval.py
400
4.25
4
# Made by Vinay on 08 Sept 2021 print("Enter Range in Which you want to Find Prime Numbers!") start = int(input("Start:")) end = int(input("End:")) print("Prime Numbers in Given Range are:") for num in range(start, end+1): # as 1 is neither prime or composite if num > 1: for d in range(2,num): ...
true
fb28c4236c8fdd8df0ec9acaca71b6e294ed13b7
pcaa3000/CodingChallenge
/6_calculadora.py
1,142
4.125
4
def sum(val1,val2): return val1+val2 def substraccion(val1,val2): return val1-val2 def multiplication (val1,val2): return val1*val2 def division (val1,val2): return val1/val2 operators={ '/': division, '*': multiplication, '-': substraccion, '+': sum } def math_operation(operator, ...
false