blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ef28f1eb265cb90c47a2c1fec8c714d3542f7d8c
Toruitas/Python
/Practice/Daily Programmer/DP13 - Find number of day in year.py
2,659
4.40625
4
__author__ = 'Stuart' """ http://www.reddit.com/r/dailyprogrammer/comments/pzo4w/2212012_challenge_13_easy/ Find the number of the year for the given date. For example, january 1st would be 1, and december 31st is 365. for extra credit, allow it to calculate leap years, as well. https://docs.python.org/3.4/library/date...
true
185f03b68bac3ca937ecee2d5b4b033314fb3d06
Toruitas/Python
/Practice/Daily Programmer/Random Password Generator.py
811
4.15625
4
__author__ = 'Stuart' """ Random password generator default 8 characters, but user can define what length of password they want """ def password_assembler(length=8): """ Takes user-defined length (default 8) and generates a random password :param length: default 8, otherwise user-defined :return: pass...
true
47567240773ccbedbccd4a4f098e3911419cd163
Toruitas/Python
/Practice/Daily Exercises/day 11 practice.py
1,409
4.25
4
_author_ = 'stu' #exercise 11 #time to complete: 15 minutes """Ask the user for a number and determine whether the number is prime or not. (For those who have forgotten, a prime number is a number that has no divisors.) You can (and should!) use your answer to Exercise 4 to help you. Take this opportunity to practi...
true
e825be3736c83d1579e2e155ac0a1c2d3bc8255c
fabiancaraballo/CS122-IntroToProg-ProbSolv
/project1/P1_hello.py
213
4.25
4
print("Hello World!") print("") name = "Fabian" print("name") print(name) #print allows us to print in the console whenever we run the code. print("") ambition = "I want to be successful in life." print(ambition)
true
634ad3c17d105f95cd627425354fd78826177710
meridian-school-computer-science/pizza
/src/classes_pizza.py
930
4.53125
5
# classes for pizza with decorator design class Pizza: """ Base class for the building of a pizza. Use decorators to complete the design of each pizza object. """ def __init__(self, name, cost): self.name = name self.cost = float(cost) def __repr__(self): return...
true
684ada57ad12df9053cad5f14c71452e1625c0f2
bear148/Bear-Shell
/utils/calculatorBase.py
637
4.28125
4
def sub(num1, num2): return int(num1)-int(num2) def add(num3, num4): return int(num3)+int(num4) def multiply(num5, num6): return int(num5)*int(num6) def divide(num7, num8): return int(num7)/int(num8) # Adding Strings vs Adding Ints # When adding two strings together, they don't combine into a different number, ...
true
bf3a5caa3e68bdf5562bf7270ba11befeb5ab21c
jijo125-github/Solving-Competitive-Programs
/LeetCode/0001-0100/43-Multiply_strings.py
832
4.28125
4
""" Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Note: You must not use any built-in BigInteger library or convert the inputs to integer directly. Example 1: Input: num1 = "2", num2 = "3" Output: "6" Example 2:...
true
95e04761f619193d2190a9d62d5ec9c0ffe0beea
SharmaManish/crimsononline-assignments
/assignment1/question2.py
863
4.15625
4
def parse_links_regex(filename): """question 2a Using the re module, write a function that takes a path to an HTML file (assuming the HTML is well-formed) as input and returns a dictionary whose keys are the text of the links in the file and whose values are the URLs to which those links correspond...
true
130b0896fc57c51d0601eea2483449f51de4142d
xfLee/Python-DeepLearning_CS5590
/Lab_2/Source/Task_1.py
640
4.1875
4
""" Python program that accepts a sentence as input and remove duplicate words. Sort them alphanumerically and print it. """ # Taking the sentence as input Input_Sentence = input('Enter any sentence: ') # Splitting the words words = Input_Sentence.split() # converting all the strings to lowercase words = [elemen...
true
eec458d8c6806cacabeef7b0188edd7db65306bc
xfLee/Python-DeepLearning_CS5590
/Lab_2/Source/Task_2.py
433
4.28125
4
""" Python program to generate a dictionary that contains (k, k*k). And printing the dictionary that is generated including both 1 and k. """ # Taking the input num = int(input("Input a number ")) # Initialising the dictionary dictionary = dict() # Computing the k*k using a for loop for k in range(1,num+1): ...
true
591d265f4773fab8be1362b349278cd8ed41574a
mercy17ch/dictionaries
/dictionaries.py
2,262
4.375
4
'''program to show dictionaries''' #A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets, and they have keys and values # #creating dictionary# thisdict={"name":"mercy", "sex":"female", "age":23} print(thisdict) #...
true
d4e2cb6d1dac6e74e0097146360ac77b5e7132ea
sajjad065/assignment2
/Function/function5.py
270
4.1875
4
def fac(num): fact=1; if(num<0): print(int("Please enter non-negative number")) else: for i in range(1,(num+1)): fact=fact*i print("The factorial is: ") print(fact) number=int(input("Enter number ")) fac(number)
true
b1282fc3cf4bfe3895451cbbbd18fa6517f92dce
sajjad065/assignment2
/Function/function17.py
295
4.28125
4
str1=input("Enter any string:") char=input("enter character to check:") check_char=lambda x: True if x.startswith(char) else False if(check_char(str1)): print(str1 +" :starts with character :" +char) else: print(str1 +": does not starts with character: " +char)
true
d6c476378fac0c7a2ce31678cb34da2f1977ee57
sajjad065/assignment2
/Datatype/qsn28.py
637
4.21875
4
total=int(input("How many elements do you want to input in dictionary ")) dic={} for i in range(total): key1=input("Enter key:") val1=input("Enter value:") dic.update({key1:val1}) print("The dictionary list is :") print(dic) num=int(input("please input 1 if you want to add key to the given dictionary ")) if...
true
8e22e05cf4401dd89fa578671472c856cd9e824c
danielvillanoh/datatypes_operations
/primary.py
2,323
4.5625
5
#author: Daniel Villano-Herrera # date: 7/1/2021 # --------------- Section 1 --------------- # # ---------- Integers and Floats ---------- # # you may use floats or integers for these operations, it is at your discretion # addition # instructions # 1 - create a print statement that prints the sum of two numb...
true
12d70ddace6d64ace1873bd5e1521efe579daf6f
pedronobrega/ine5609-estrutura-de-dados
/doubly-linked-list/__main__.py
967
4.21875
4
from List import List from Item import Item if __name__ == "__main__": lista: List = List(3) # This will throw an exception # lista.go_ahead_positions(3) # This will print None print(lista.access_actual()) # This will print True print(lista.is_empty()) # This will print False print(lista.is_full(...
true
54a38474bcfc39ee234c64a8b7808d3df7e31c7d
payal-98/Student_Chatbot-using-RASA
/db.py
1,205
4.15625
4
# importing module import sqlite3 # connecting to the database connection = sqlite3.connect("students.db") # cursor crsr = connection.cursor() # SQL command to create a table in the database sql_command = """CREATE TABLE students ( Roll_No INTEGER PRIMARY KEY, Sname VARCHAR(20), Class VARCHAR(30...
true
bf0e360370d704920509e4a61e7c0b79f983c2de
Maxim1912/python
/list.py
352
4.15625
4
a = 33 b = [12, "ok", "567"] # print(b[:2]) shop = ["cheese", "chips", "juice", "water", "onion", "apple", "banana", "lemon", "lime", "carrot", "bacon", "paprika"] new_element = input("Что ещё купить?\n") if new_element not in shop: shop.append(new_element) print('We need to buy:') for element in shop: pri...
true
86de52a241ae3645d41c693383b7b232c95126c5
gcnTo/Stats-YouTube
/outliers.py
1,256
4.21875
4
import numpy as np import pandas as pd # Find the outlier number times = int(input("How many numbers do you have in your list: ")) num_list = [] # Asks for the number, adds to the list for i in range(times): append = float(input("Please enter the " + str(i+1) + ". number in your list: ")) num_list.append(ap...
true
03362a677a4b090f092584c63197e01151937781
ihanda25/SCpythonsecond
/helloworld.py
1,614
4.15625
4
import time X = raw_input("Enter what kind of time mesurement you are using") if X == "seconds" : sec = int(raw_input("Enter num of seconds")) status = "calculating..." print(status) hour = sec // 3600 sec_remaining = sec%3600 minutes = sec_remaining // 60 final_sec_remaining = sec_remaini...
true
4785fd11ab80f0e29f7f8ef7ec60a8dab5c893de
japneet121/Python-Design-Patterns
/facade.py
1,006
4.21875
4
''' Facade pattern helps in hiding the complexity of creating multiple objects from user and encapsulating many objects under one object. This helps in providing unified interface for end user ''' class OkButton: def __init__(self): pass def click(self): print("ok clicked") class Can...
true
2f9f0e381ba3e08a5a2487967a942d82292ab48c
Kenny-W-C/Tkinter-Examples
/drawing/draw_image.py
866
4.1875
4
#!/usr/bin/env python3 """ ZetCode Tkinter tutorial In this script, we draw an image on the canvas. Author: Jan Bodnar Last modified: April 2019 Website: www.zetcode.com """ from tkinter import Tk, Canvas, Frame, BOTH, NW from PIL import Image, ImageTk class Example(Frame): def __init__(self): super()...
true
5a9c60245722eb710122e1af18778d212db4a84a
johnnymcodes/computing-talent-initiative-interview-problem-solving
/m07_stacks/min_parenthesis_to_make_valid.py
1,008
4.25
4
# # Given a string S of '(' and ')' parentheses, we add the minimum number of # parentheses ( '(' or ')', and in any positions ) so that the resulting # parentheses string is valid. # # Formally, a parentheses string is valid if and only if: # It is the empty string, or # It can be written as AB (A concatenated with B)...
true
e978f07ced6f205af8593c88b55503e436f75a88
catwang42/Algorithm-for-data-scientist
/basic_algo_sort_search.py
2,886
4.4375
4
#Algorithms """ Search: Binary Search , DFS, BFS Sort: """ #bubble sort -> compare a pair and iterate though 𝑂(𝑛2) #insertion sort """ Time Complexity: 𝑂(𝑛2), Space Complexity: 𝑂(1) """ from typing import List, Dict, Tuple, Set def insertionSort(alist:List[int])->List[int]: #check from index 1 for i...
true
fd84dcb1ea5513f1a8447155147761d345f2e0dd
Taranoberoi/PYTHON
/practicepython_ORG_1.py
580
4.28125
4
# 1 Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old. import datetime as dt Name = input("Please Enter the Name :") # Taking input and converting into Int at the same time Age = int(input("Plea...
true
de4dd804df9777ac13b9e1f4ba3b0b96c701da3a
Taranoberoi/PYTHON
/Practise1.py
874
4.15625
4
#1 Practise 1 in favourites #1Write a Python program to print the following string in a specific format (see the output). Go to the editor #Sample String : "Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what...
true
81e5bd642345c074b4ac9c55ee4e630a7d6ebd73
BSchweikart/CTI110
/M3HW1_Age_Classifier_Schweikb0866.py
726
4.25
4
# CTI - 110 # M3HW1 : Age Classifier # Schweikart, Brian # 09/14/2017 def main(): print('Please enter whole number, round up or down') # This is to have user input age and then classify infant, child,... # Age listing Age_a = 1 Age_b = 13 Age_c = 20 # 1 year or less = infant # 1 y...
true
4bd2765c5c80cdb85fa9a2f6c1d9603ac6f26bd6
Varunaditya/practice_pad
/Python/stringReversal.py
1,454
4.125
4
""" Given a string and a set of delimiters, reverse the words in the string while maintaining the relative order of the delimiters. For example, given "hello/world:here", return "here/world:hello" """ from sys import argv, exit alphabets = ['a', 'b', 'c', 'd', 'e', 'f' , 'g', 'h', 'i', 'j', 'k', 'l', 'm', ...
true
91c5976e429e09729f3857b8e5a633073837b368
Varunaditya/practice_pad
/Python/merge_accounts.py
1,915
4.28125
4
""" Given a list accounts, each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails representing emails of the account. Now, we would like to merge these accounts. Two accounts definitely belong to the same person if there is some email tha...
true
dc363f27cc6e52277b539fbaabd2aedae1691933
gpastor3/Google-ITAutomation-Python
/Course_2/Week_2/iterating_through_files.py
971
4.5
4
""" This script is used for course notes. Author: Erick Marin Date: 11/28/2020 """ with open("Course_2/Week_2/spider.txt") as file: for line in file: print(line.upper()) # when Python reads the file line by line, the line variable will always have # a new line character at the end. In other words, the ne...
true
77efe1b0c6dce387b29f9719ec8be6c217373b86
gpastor3/Google-ITAutomation-Python
/Course_1/Week_4/iterating_over_the_contents_of_a_dictionary.py
1,835
4.6875
5
""" This script is used for course notes. Author: Erick Marin Date: 10/20/2020 """ # You can use for loops to iterate through the contents of a dictionary. file_counts = {"jpg": 10, "txt": 14, "csc": 2, "py": 23} for extension in file_counts: print(extension) # If you want to access the associated values, you ca...
true
2d593998eaf8c47e2b476f7d5c50143ef75f409a
gpastor3/Google-ITAutomation-Python
/Course_2/Week_5/charfreq.py
873
4.1875
4
#!/usr/bing/env python3 """ This script is used for course notes. Author: Erick Marin Date: 12/26/2020 """ # To use a try-except block, we need to be aware of the errors that functions # that we're calling might raise. This information is usually part of the # documentation of the functions. Once we know this we ca...
true
7c1386e726f4867617ac9682657532da2425df07
gpastor3/Google-ITAutomation-Python
/Course_1/Week_2/returning_values.py
1,324
4.25
4
""" This script is used for course notes. Author: Erick Marin Date: 10/08/2020 """ def area_triangle(base, height): """ Calculate the area of triange by multipling `base` by `height` """ return base * height / 2 def get_seconds(hours, minutes, seconds): """ Calculate the `hours` and `minutes` into sec...
true
aa96e9acb44032b35e1b53784b117d989af43758
gpastor3/Google-ITAutomation-Python
/Course_1/Week_4/iterating_over_lists_and_tuples.py
2,405
4.59375
5
""" This script is used for course notes. Author: Erick Marin Date: 10/20/2020 """ animals = ["Lion", "Zebra", "Dolphin", "Monkey"] chars = 0 for animal in animals: chars += len(animal) print("Total characters: {}, Average length: {}".format(chars, chars/len(animals))) # The 'enumerate' function returns a tuple...
true
b0570c87b7a5d7389973b315aca7d79de585a452
gpastor3/Google-ITAutomation-Python
/Course_1/Week_2/defining_functions.py
919
4.125
4
""" This script is used for course notes. Author: Erick Marin Date: 10/08/2020 """ def greeting(name, department): """ Print out a greeting with provided `name` and department parameters. """ print("Welcome, " + name) print("Your are part of " + department) # Flesh out the body of the print_second...
true
123187441133b573b5058569e0a972964d11221b
gpastor3/Google-ITAutomation-Python
/Course_1/Week_4/the_parts_of_a_string.py
1,668
4.34375
4
""" This script is used for course notes. Author: Erick Marin Date: 10/11/2020 """ # String indexing name = "Jaylen" print(name[1]) # Python starts counting indices from 0 and not 1 print(name[0]) # The last index of a string will always be the one less than the length of # the string. print(name[5]) # If we tr...
true
2eb52a42c37125937cbffd68468398956aa7d575
foofaev/python-project-lvl1
/brain_games/games/brain_progression.py
1,454
4.25
4
""" Mini-game "arithmetic progression". Player should find missing element of provided progression. """ from random import randint OBJECTIVE = 'What number is missing in the progression?' PROGESSION_SIZE = 10 MIN_STEP = 1 MAX_STEP = 10 def generate_question(first_element: int, step: int, index_of_missing: int): ...
true
5f1d89b45c61f68d2b23aa01bfb4c83d6e88fd1b
Sungmin-Joo/Python
/Matrix_multiplication_algorithm/Matrix_multiplication_algorithm.py
1,284
4.1875
4
# -*- coding: utf-8 -*- import numpy as np if __name__ == '__main__': print("Func_called - main") A = np.array([[5,7,-3,4],[2,-5,3,6]]) B = np.array([[3,0,8],[-5,1,-1],[7,4,4],[2,4,3]]) len_row_A = A.shape[0] len_col_A = A.shape[1] len_col_B = B.shape[1] result = np.zeros((len_row_A,len_col_...
true
73d9af8a966990d3c06060b56516c7e22e637fda
andyly25/Python-Practice
/data visualization/e01_simplePlot.py
761
4.34375
4
''' 1. import pyplot module and using alias plt to make life easier. 2. create a lit to hold some numerical data. 3. pass into plot() function to try plot nums in meaningful way. 4. after launching, shows you simple graph that you can navigate through. ''' # 1 import matplotlib.pyplot as plt # input values will help ...
true
69681798f10be785c5e6d247222832f32e7fcf91
andyly25/Python-Practice
/AlgorithmsAndChallenges/a001_isEven.py
1,008
4.34375
4
''' I've noticed the question of determining if a number is an even number often, and it seems easy as you can just use modulo 2 and see if 0 or some other methods with multiplication or division. But here's the catch, I've seen a problem that states: You cannot use multiplication, modulo, or divi...
true
1a3689681b252e87b0c323aa73b32166bb3e8469
oktaran/LPTHW
/exercises.py
1,367
4.21875
4
""" Some func problems ~~~~~~~~~~~~~~~~~~ Provide your solutions and run this module. """ import math def add(a, b): """Returns sum of two numbers.""" return a + b def cube(n): """Returns cube (n^3) of the given number.""" # return n * n * n # return n**3 return math.pow(n, 3) def is_od...
true
3a097f2425a884b0869818f8bf2646854f2ef6af
vaibhavyesalwad/Basic-Python-and-Data-Structure
/Basic Programs/Factorial.py
556
4.25
4
"""Find factorial of given number""" def fact(num): if num < 0: return 'factorial of negative number not possible' elif num == 0: return 1 else: factorial= 1 for i in range(1, num+1): factorial *= i return factorial def recurse_fact(num): if num < ...
true
7aa66e034df46248f0a8cc6d12617137533fc4ab
vaibhavyesalwad/Basic-Python-and-Data-Structure
/Python Data Structure/Strings/03_ReplaceChar.py
377
4.1875
4
"""program to get a string from a given string where all occurrences of its first char have been changed to '$', except the first char itself""" string = 'restart' ch = 'r' i = string.index(ch) # using str.replace() method returns new string with all replacements print(string[:i+1]+string[i+1:].replace(c...
true
546f755653d647de1c8afec21f7b630aab5ef626
vaibhavyesalwad/Basic-Python-and-Data-Structure
/Python Data Structure/Dictionary/13_CountValuesAsList.py
343
4.125
4
"""Program to count number of items in a dictionary value that is a list""" dict1 = {'a': [1, 2, 3, 4], 'b': [2, 3, 4, 5], 'c': 1, 'd': 'z', 'e': (1,)} # if value is list added True i.e. 1 else False i.e. 0 count = sum(isinstance(value, list) for value in dict1.values()) # sum fn & generator expression print(f'{co...
true
25778e07eadbe6059b64b6d79cc384bc7150525c
vaibhavyesalwad/Basic-Python-and-Data-Structure
/Python Data Structure/Dictionary/01_SortByValue.py
418
4.4375
4
"""Sort (ascending and descending) a dictionary by value""" d = {'a': 26, 'b': 25, 'y': 2, 'z': 1} # to access and map key value pairs dict.item gives list of tuples of key, value pairs print(f'Ascending order by value {dict(sorted(d.items(),key=lambda x: x[1]))}') # using second element of tuple print(f'Descending or...
true
dcca3f992e91118ce37e7bb14a2942cef6ea431c
vaibhavyesalwad/Basic-Python-and-Data-Structure
/Sorting Algorithms/InsertionSort.py
488
4.15625
4
"""Sort numbers in list using Insertion sort algorithm""" numbers = [int(i) for i in input('Enter list of numbers:').split()] print(numbers) for i in range(1, len(numbers)): # first element already sorted j = i # insert element at j index in left part of array at it's appr...
true
33bb259270a1bc8fd006b9f441a6b3267cff63b5
vaibhavyesalwad/Basic-Python-and-Data-Structure
/Python Data Structure/List/06_RemoveDuplication.py
205
4.15625
4
"""Program to remove duplicates from a list""" numbers = [10, 15, 15, 20, 50, 55, 65, 20, 30, 50] print(f'Unique elements: {set(numbers)}') # set accepts only unique elements so typecasting to set
true
74207f09ecbe9354d93ace2c3d0edd34613997fb
thesayraj/DSA-Udacity-Part-II
/Project-Show Me Data Structures/problem_2.py
863
4.21875
4
import os def find_files(suffix = "", path = "."): """ Find all files beneath path with file name suffix. Note that a path may contain further subdirectories and those subdirectories may also contain further subdirectories. There are no limit to the depth of the subdirectories can be. ...
true
258decfc38f5f05740389356d78bcdfaf780bfc8
lujamaharjan/pythonAssignment2
/question5.py
791
4.75
5
""" 5. Create a tuple with your first name, last name, and age. Create a list, people, and append your tuple to it. Make more tuples with the corresponding information from your friends and append them to the list. Sort the list. When you learn about sort method, you can use the key parameter to sort by any field in th...
true
6065ac1867f7dafea2872a50162e1b8f4f2a2527
lujamaharjan/pythonAssignment2
/question15.py
700
4.3125
4
""" Imagine you are designing a bank application. what would a customer look like? What attributes would she have? What methods would she have? """ class Customer(): def __init__(self, account_no, name, address, email, balance): self.account_no = account_no self.name = name self.add...
true
14569d9e12b63f29b2002c014fe8fdb79d990bcf
babbgoud/maven-project
/guess-numapp/guessnum.py
765
4.15625
4
#! /usr/bin/python3 import random print('Hello, whats your name ?') myname = input() print('Hello, ' + myname + ', I am thinking of a number between 1 and 20.') secretNumber = random.randint(1,20) for guesses in range(1,7): print('Take a guess.?') guessNumber = int(input()) if int(guessNumber) > se...
true
0dcc567b62cb6e81893fd99471a32737388d04b2
ramyanaga/MIT6.00.1x
/Pset2.py
2,332
4.3125
4
""" required math: monthly interest rate = annual interest rate/12 minimum monthly payment = min monthly payment rate X previous balance monthly unpaid balance = previous balance - min monthly payment updated balance each month = monthly unpaid balance + (monthly interest rate X monthly unpaid balance) NEED TO PRINT:...
true
3eb482c7861a7a2ea0e293cacce0d75d2f41de77
AlexDT/Playgarden
/Project_Euler/Python/001_sum.py
542
4.1875
4
# coding: utf-8 # # ONLY READ THIS IF YOU HAVE ALREADY SOLVED THIS PROBLEM! # File created for http://projecteuler.net/ # # Created by: Alex Dias Teixeira # Name: 001_sum.py # Date: 06 Sept 2013 # # Problem: [1] - Multiples of 3 and 5 # If we list all the natural numbers below 10 that are multiples of ...
true
34534abc70987c7c05910c3436868db6b0a97148
sasathornt/Python-3-Programming-Specialization
/Python Basics/Week 4/assess_week5_01.py
331
4.34375
4
##Currently there is a string called str1. Write code to create a list called chars which should contain the characters from str1. Each character in str1 should be its own element in the list chars str1 = "I love python" # HINT: what's the accumulator? That should go here. chars = [] for letter in str1: chars.app...
true
1d71ab1f3585ef7d344998afffe54b01ab443c59
KazuoKitahara/challenge
/cha45.py
275
4.125
4
def f(x): """ Returns float of input string. :param x: int,float or String number try float but if ValueError, print "Invalid input" """ try: return float(x) except ValueError: print("Invalid input") print(f(10)) print(f("ten"))
true
1aba84f4c9ccb999895378980f14101ba10d3adb
Fang-Molly/CS-note
/python3 for everybody/exercises_solutions/ex_09_05.py
897
4.375
4
''' Python For Everybody: Exploring Data in Python 3 (by Charles R. Severance) Exercise 9.5: This program records the domain name (instead of the address) where the message was sent from instead of who the mail came from (i.e., the whole email address). At the end of the program, print out the contents of your diction...
true
537ab14e1654a023e4de4c0cd4c3dc37ab2394e1
paulcockram7/paulcockram7.github.io
/10python/l05/Exercise 2.py
261
4.125
4
# Exercise 2 # creating a simple loop # firtly enter the upper limit of the loop stepping_variable = int(input("Enter the amount of times the loop should run ")) #set the start value i = 0 for i in range(stepping_variable): print("line to print",str(i))
true
92a8edcc1b4419cda07813c301607d0e036de96f
Biytes/learning-basic-python
/loops.py
749
4.15625
4
''' Description: Author: Biytes Date: 2021-04-12 17:55:57 LastEditors: Biytes LastEditTime: 2021-04-12 18:50:23 FilePath: \python\basic\loops.py ''' # A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). people = ['John', 'Paul', 'Sara', 'Susan'] # Simpl...
true
14e5b26ac617c4e2f871fd162b8c07d64132ce9f
koltpython/python-slides
/Lecture7/lecture-examples/lecture7-1.py
828
4.34375
4
# Free Association Game clues = ('rain', 'cake', 'glass', 'flower', 'napkin') # Let's play a game. Give the user these words one by one and ask them to give you the first word that comes to their mind. # Store these words together in a dictionary, where the keys are the clues and the values are the words that the us...
true
8013c5a1d5760cd65eca1c8c3c009003dc53b8a3
JulianTrummer/le-ar-n
/code/01_python_basics/examples/02_lists_tuples_dictionaries/ex4_tuples.py
333
4.34375
4
"""Tuple datatypes""" # A tuple is similar to a list, however the sequence is immutable. # This means, they can not be changed or added to. my_tuple_1 = (1, 2, 3) print(my_tuple_1, type(my_tuple_1)) print(len(my_tuple_1)) my_tuple_2 = tuple(("hello", "goodbye")) print(my_tuple_2[0]) print(my_tuple_2[-1]) print(my_...
true
483d8c2a95519c1e81242ec1420e7b80640595bc
JulianTrummer/le-ar-n
/code/01_python_basics/examples/05_classes/ex1_class_intro.py
606
4.25
4
# Classes introduction # Class definition class Vehicle(): # Initiation function (always executed when the class object is being initiated) def __init__(self, colour, nb_wheels, name): self.colour = colour self.nb_wheels = nb_wheels self.name = name # Creating objects from class vehicl...
true
1d7659b09b39394fbc031fe4799a21530d5cf8f1
jarrettdunne/coding-problems
/daily/problem1.py
1,077
4.21875
4
import unittest class TestStringMethods(unittest.TestCase): def test_upper(self): self.assertEqual('foo'.upper(), 'FOO') def test_isupper(self): self.assertTrue('FOO'.isupper()) self.assertFalse('Foo'.isupper()) def test_split(self): ''' input: [1, 2, 3] ...
true
eb7bc39f59c1d5ed19f206a85ccec13c4a6a7e00
winniewjeng/StockDatabase
/Example.py
2,330
4.40625
4
#! /usr/bin/env python3 """ File: Jeng_Winnie_Lab1.py Author: Winnie Wei Jeng Assignment: Lab 2 Professor: Phil Tracton Date: 10/07/2018 The base and derived classes in this file lay out the structure of a simple stock-purchasing database """ from ExampleException import * # Base Class class ExampleBase: # c...
true
c145820dfe8508a0091293b96dbf1b45d5507bd1
Stephania86/Algorithmims
/reverse_statement.py
449
4.5625
5
# Reverse a Statement # Build an algorithm that will print the given statement in reverse. # Example: Initial string = Everything is hard before it is easy # Reversed string = easy is it before hard is Everything def reverse_sentence(s): word_list = s.split() word_list.reverse() reversed_sentence = " ".jo...
true
c09cbd12035fbd857e646f2379691090df8e267c
Stephania86/Algorithmims
/Even_first.py
674
4.34375
4
# Even First # Your input is an array of integers, and you have to reorder its entries so that the even # entries appear first. You are required to solve it without allocating additional storage (operate with the input array). # Example: [7, 3, 5, 6, 4, 10, 3, 2] # Return [6, 4, 10, 2, 7, 3, 5, 3] def even_first(arr):...
true
8fb6a2464a7c668ea237ed170a3e84a237c4a049
Lincxx/py-PythonCrashCourse
/ch3 lists/motorcycles.py
1,470
4.59375
5
motorcycles = ['honda', 'yamaha', 'suzuki'] print(motorcycles) # change an element in a list motorcycles[0] = 'ducati' print(motorcycles) # append to a list motorcycles.append('Indian') print(motorcycles) # Start with an empty list friends = [] friends.append("Jeff") friends.append("Nick") friends.append("Corey"...
true
fddb55fdc2d951f6c8dbcf265ee894ed6b853c43
Lincxx/py-PythonCrashCourse
/ch3 lists/exercises/3-5.py
1,030
4.25
4
# 3-5. Changing Guest List: You just heard that one of your guests can’t make the # dinner, so you need to send out a new set of invitations. You’ll have to think of # someone else to invite. # • Start with your program from Exercise 3-4. Add a print statement at the # end of your program stating the name of the guest...
true
ec339af34ee862e4be09aa357477f6be7512c868
Lincxx/py-PythonCrashCourse
/ch3 lists/exercises/3-4.py
577
4.34375
4
# 3-4. Guest List: If you could invite anyone, living or deceased, to dinner, who # would you invite? Make a list that includes at least three people you’d like to # invite to dinner. Then use your list to print a message to each person, inviting # them to dinner. interesting_people = ['Einstein', 'Jack Black', 'The Q...
true
42ab61361b181d15deeb79ddcee10368643786c2
tramxme/CodeEval
/Easy/RollerCoaster.py
1,043
4.125
4
''' CHALLENGE DESCRIPTION: You are given a piece of text. Your job is to write a program that sets the case of text characters according to the following rules: The first letter of the line should be in uppercase. The next letter should be in lowercase. The next letter should be in uppercase, and so on. Any characters...
true
569fb617c5b2721bd3df06cf09fd12cc80cd071b
tramxme/CodeEval
/Easy/ChardonayOrCabernet.py
2,096
4.1875
4
''' CHALLENGE DESCRIPTION: Your good friend Tom is admirer of tasting different types of fine wines. What he loves even more is to guess their names. One day, he was sipping very extraordinary wine. Tom was sure he had tasted it before, but what was its name? The taste of this wine was so familiar, so delicious, so ple...
true
f78f231145b031de661340f6bb6dbedcd567b837
randalsallaq/data-structures-and-algorithms-python
/data_structures_and_algorithms_python/challenges/array_reverse/array_reverse.py
350
4.4375
4
def reverse_array(arr): """Reverses a list Args: arr (list): python list Returns: [list]: list in reversed form """ # put your function implementation here update_list = [] list_length = len(arr) while list_length: update_list.append(arr[list_length-1]) l...
true
70291137c6c759f268f7ab8b45591a3d1ec95cd9
dnwigley/Python-Crash-Course
/make_album.py
492
4.21875
4
#make album def make_album(artist_name , album_title): """"Returns a dictionary based on artist name and album title""" album = { 'Artist' : artist_name.title(), 'Title' : album_title.title(), } return album print("Enter q to quit") while True: title = input("Enter album title: ") i...
true
53fb20fc1ba77ca145dea0b93a89cc020f887619
naveensambandan11/PythonTutorials
/tutorial 39_Factorial.py
224
4.34375
4
# Funtion to calculate factorial def Fact(n): fact = 1 for i in range(1, n+1): fact = fact * i return fact n = int(input('enter the number to get factorial:')) result = Fact(n) print(result)
true
da85714a0fea257a811e53d95d5b0bf3d99717a5
TwitchT/Learn-Pythonn-The-Hard-Way
/ex4.py
1,687
4.4375
4
# This is telling me how many cars there is cars = 100 # This is going to tell me how much space there is in a car space_in_a_car = 40 # This is telling me how many drivers there is for the 100 cars drivers = 30 # This is telling how many passengers there is passengers = 90 # This tells me how many empty cars there is ...
true
1dfed477aa45a48f640d4d869f5ae051c99b363a
TwitchT/Learn-Pythonn-The-Hard-Way
/ex13.py
984
4.125
4
from sys import argv # Read the WYSS section for how to run this # These will store the variables script, first, second, third = argv # Script will put the first thing that comes to the line, 13.py is the first thing # So script will put it 13.py and it will be the variable print("The script is called:", script) # If y...
true
33115232faf0951e37f4b48521e3e22f6bbc2a00
TwitchT/Learn-Pythonn-The-Hard-Way
/ex23.py
916
4.125
4
import sys # Will make the code run on bash script, input_encoding, error = sys.argv # Defines the function to make it work later on def main(language_file, encoding, errors): line = language_file.readline() if line: print_line(line, encoding, errors) return main(language_file, encoding, e...
true
03cd39bc59234bd30b84a89ae3157a44363f8a93
Ishan-Bhusari-306/applications-of-discrete-mathematics
/dicestrategy.py
988
4.28125
4
def find_the_best_dice(dices): # you need to use range (height-1) height=len(dices) dice=[0]*height #print(dice) for i in range(height-1): #print("this is dice number ",i+1) # use height for j in range(i+1,height): #print("comparing dice number ",i+1," with dice number ",j+1) check1=0 check2=0 fo...
true
892ba5dc80b77da4916db1e1afb0f0b4a06c75ba
ibndiaye/odd-or-even
/main.py
321
4.25
4
print("welcome to this simple calculator") number = int(input("Which number do you want to check? ")) divider = int(input("what do you want to divide it by? ")) operation=number%divider result=round(number/divider, 2) if operation == 0: print(f"{result} is an even number") else: print(f"{result} is an odd number")...
true
d475df99c67157cfad58ce2514cae3e378ed785c
adwardlee/leetcode_solutions
/0114_Flatten_Binary_Tree_to_Linked_List.py
1,520
4.34375
4
''' Given the root of a binary tree, flatten the tree into a "linked list": The "linked list" should use the same TreeNode class where the right child pointer points to the next node in the list and the left child pointer is always null. The "linked list" should be in the same order as a pre-order traversal of the bin...
true
6bf88ae9e8933f099ed1d579af505fc8ef0d04b4
Abicreepzz/Python-programs
/Decimal_to_binary.py
462
4.25
4
def binary(n): result='' while n>0: result=str(n%2)+str(result) n//=2 return int(result) binary(5) ##output= 101 # Another simple one line code for converting the decimal number to binary is followed: def f(n): print('{:04b}'.format(n)) binary(5) ##output =101 # If we want to print in the 8 bit digi...
true
9e188e9dcd5fd64231f883943ab83e307158a5f7
Jewel-Hong/SC-projects
/SC101Lecture_code/SC101_week6/priority_queue_list.py
1,402
4.46875
4
""" File: priority_queue_list.py Name: ---------------------------------- This program shows how to build a priority queue by using Python list. We will be discussing 3 different conditions while appending: 1) Prepend 2) Append 3) Append in between """ # This constant controls when to stop the user input EXIT = '' d...
true
7ce2f22d370784db0284cac76eba4becb42f7556
Jewel-Hong/SC-projects
/SC101Lecture_code/SC101_week3/word_occurrence.py
1,397
4.21875
4
""" File: student_info_dict.py ------------------------------ This program puts data in a text file into a nested data structure where key is the name of each student, and the value is the dict that stores the student info """ # The file name of our target text file FILE = 'romeojuliet.txt' # Contains the chars we ...
true
80f2cfaaa82a18157ebc3b8d6015ac36b3412bc4
uppala-praveen-au7/blacknimbus
/AttainU/Robin/Code_Challenges/Day2/Day2/D7CC3.py
1,984
4.21875
4
# 3) write a program that takes input from the user as marks in 5 subjects and assigns a grade according to the following rules: # Perc = (s1+s2+s3+s4+s5)/5. # A, if Perc is 90 or more # B, if Perc is between 70 and 90(not equal to 90) # C, if Perc is between 50 and 70(not equal to 90) # D, if Perc is between 30 and 50...
true
2c49ef300a9d5a6b783f103e064132f222fe4977
ruchirbhai/Trees
/PathSum_112.py
2,125
4.15625
4
# https://leetcode.com/problems/path-sum/ # Given a binary tree and a sum, determine if the tree has a root-to-leaf path such # that adding up all the values along the path equals the given sum. # Note: A leaf is a node with no children. # Example: # Given the below binary tree and sum = 22, # 5 # / \ # ...
true
58118aa6dac147138a91cdfb393ddf328be961b0
44858/variables
/multiplication and division.py
484
4.34375
4
#Lewis Travers #12/09/2014 #Multiplying and dividing integers first_integer = int(input("Please enter your first integer: ") second_integer = int(input("Please enter an integer that you would like the first to be multiplied by: ")) third_integer = int(input("Please enter an integer that you would like the total...
true
9995de8314efb0c98d03f0c893bb7b7ddbbfd239
jjsherma/Digital-Forensics
/hw1.py
2,967
4.3125
4
#!/usr/bin/env python import sys def usage(): """Prints the correct usage of the module. Prints an example of the correct usage for this module and then exits, in the event of improper user input. >>>Usage: hw1.py <file1> """ print("Usage: "+sys.argv[0]+" <file1>") sys.exit(2) def getFi...
true
2f9c1a23384af6b52ab218621aa937a294a6b793
bainjen/python_madlibs
/lists.py
895
4.125
4
empty_list = [] numbers = [2, 3, 5, 2, 6] large_animals = ["african elephant", "asian elephant", "white rhino", "hippo", "guar", "giraffe", "walrus", "black rhino", "crocodile", "water buffalo"] a = large_animals[0] b = large_animals[5] # get the last animal in list c = large_animals[-1] # return index number d = lar...
true
36e830aa4a52c6f8faa1347722d1dab6333088c8
tom1mol/core-python
/test-driven-dev-with-python/refactoring.py
1,197
4.3125
4
#follow on from test-driven-development def is_even(number): return number % 2 == 0 #returns true/false whether number even/not def even_number_of_evens(numbers): evens = sum([1 for n in numbers if is_even(n)]) return False if evens == 0 else is_even(evens) """ this reduc...
true
bc547b6f91f5f3133e608c4aa479eb811ddf7c58
sgspectra/phi-scanner
/oldScripts/wholeFile.py
835
4.40625
4
# @reFileName is the name of the file containing regular expressions to be searched for. # expressions are separated by newline # @fileToScanName is the name of the file that you would like to run the regex against. # It is read all at once and the results returned in @match import re #reFileName = input("Please ente...
true
b28a938c098b5526fb6541b41f593d30a665b185
elguneminov/Python-Programming-Complete-Beginner-Course-Bootcamp-2021
/Codes/StringVariables.py
1,209
4.46875
4
# A simple string example short_string_variable = "Have a great week, Ninjas !" print(short_string_variable) # Print the first letter of a string variable, index 0 first_letter_variable = "New York City"[0] print(first_letter_variable) # Mixed upper and lower case letter variable mixed_letter_variable = "ThI...
true
201a2b05930cd4064623156c2b9248665d378647
Dumacrevano/Dumac-chen_ITP2017_Exercise2
/3.1 names.py
234
4.375
4
#Store the names of a few of your friends in a list called names . # Print each person’s name by accessing each element in the list, one at a time . names=["Suri", "andy", "fadil", "hendy"] print(names[0],names[1],names[2],names[3])
true
9454b32184aa1c29ad0db72ec564036666dff0f9
EnriqueStrange/portscannpy
/nmap port-scanner.py
1,508
4.1875
4
#python nmap port-scanner.py #Author: P(codename- STRANGE) #date: 10/09/2020 import argparse import nmap def argument_parser(): """Allow target to specify target host and port""" parser = argparse.ArgumentParser(description = "TCP port scanner. accept a hostname/IP address and list of ports to" ...
true
f484aab33a5142f6fbe20f6072e035339f561d0b
programmer290399/Udacity-CS101-My-Solutions-to-Exercises-
/CS101_Shift_a_Letter.py
387
4.125
4
# Write a procedure, shift, which takes as its input a lowercase letter, # a-z and returns the next letter in the alphabet after it, with 'a' # following 'z'. def shift(letter): ASCII = ord(letter) if ASCII == 122 : return chr(97) else : return chr(ASCII + 1) print shift...
true
62c129920b2c9d82d35eaba02a73924596696280
Maxrovr/concepts
/python/sorting/merge_sort.py
1,982
4.21875
4
class MergeSort: def _merge(self, a, start, mid, end): """Merges 2 arrays (one starting at start, another at mid+1) into a new array and then copies it into the original array""" # Start of first array s1 = start # Start of second array s2 = mid + 1 # The partially so...
true
a5333dc221c0adcb79f583faceb53c7078333601
tocheng/Book-Exercises-Intro-to-Computing-using-Python
/Book-Chapter5_2-Range.py
1,922
4.21875
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 29 09:48 2020 Introduction to Computation and Programming Using Python. John V. Guttag, 2016, 2nd ed Book Chapter 5 Structured types, mutability and higher-order functions Ranges @author: Atanas Kozarev - github.com/ultraasi-atanas RANGE the Theory The range function t...
true
0240f939041db7bfe697fecd110ca33dd83f84b8
tocheng/Book-Exercises-Intro-to-Computing-using-Python
/Book-Chapter2_2-FE-odd-number.py
1,173
4.46875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Nov 11 09:54:53 2020 Introduction to Computation and Programming Using Python. John V. Guttag, 2016, 2nd ed Book Chapter 2 Finger Exercises - Find the largest odd number @author: Atanas Kozarev - github.com/ultraasi-atanas """ # edge cases 100, 2, 3 an...
true
32edc5c1c32209e99e6b51d2bf0cb14ba3f1a07c
tocheng/Book-Exercises-Intro-to-Computing-using-Python
/Book-Chapter2_3-Exercises-LargestOddNumberOf10.py
1,186
4.28125
4
# -*- coding: utf-8 -*- """ Created on Fri Nov 13 14:15:03 2020 Introduction to Computation and Programming Using Python. John V. Guttag, 2016, 2nd ed Book Chapter 2 Finger Exercises Largest Odd number of 10, using user input Prints the largest odd number that was entered If no odd number was entered, it should print ...
true
1b049dc1145f1269bcbf38c96965fa0b13d585ca
guyjacks/codementor-learn-python
/string_manipulation.py
872
4.1875
4
print "split your and last name" name = "guy jacks" # split returns a list of strings print name.split() print "/n" print "split a comma separated list of colors" colors = "yellow, black, blue" print colors.split(',') print "\n" print "get the 3rd character of the word banana" print "banana"[2] print "\n" blue_moon...
true
427e6f0978cd52b339ef4f89256ace7ff9298c4d
learnthecraft617/dev-sprint1
/RAMP_UP_SPRINT1/exercise54.py
291
4.21875
4
def is_triangle (a, b, c): if a > b + c print "YES!" else print "NO!" is_triangle (4, 2, 5) #5.4 question = raw_input('Please enter 3 lengths to build this triangle in this order (a, b, c)/n') length = raw_input (a, b, c) is triangle (raw_input)
true
afed5225df3b7a8cc6b42ba7691710a8a019459d
colten-cross/CodeWarsChallenges---Python
/BouncingBalls.py
784
4.375
4
# A child is playing with a ball on the nth floor of a tall building. The height of this floor, h, is known. # He drops the ball out of the window. The ball bounces (for example), to two-thirds of its height (a bounce of 0.66). # His mother looks out of a window 1.5 meters from the ground. # How many times will the ...
true