blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
35131f3bff52c30cf0ca3f99445ec08a53f020f6 | anatulea/codesignal_challenges | /Intro_CodeSignal/07_Through the Fog.py/31_depositProfit.py | 953 | 4.25 | 4 | '''
You have deposited a specific amount of money into your bank account. Each year your balance increases at the same growth rate. With the assumption that you don't make any additional deposits, find out how long it would take for your balance to pass a specific threshold.
Example
For deposit = 100, rate = 20, and ... | true |
40da9655f1ceb1450d203efa31a6bfc9a3748220 | anatulea/codesignal_challenges | /Intro_CodeSignal/01_The Jurney Begins/02_centuryFromYear.py | 1,220 | 4.1875 | 4 | '''
Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc.
Example
For year = 1905, the output should be
centuryFromYear(year) = 20;
For year = 1700, the output should be
centuryFromYear... | true |
67801342d06b60b610ee909bf60712796894cbad | anatulea/codesignal_challenges | /Python/11_Higher Order Thinking/73_tryFunctions.py | 1,391 | 4.40625 | 4 | '''
You've been working on a numerical analysis when something went horribly wrong: your solution returned completely unexpected results. It looks like you apply a wrong function at some point of calculation. This part of the program was implemented by your colleague who didn't follow the PEP standards, so it's extreme... | true |
7d95aafc8e3b783c05196c5ba11e448578bf5a9e | anatulea/codesignal_challenges | /Python/08_Itertools Kit/48_cyclicName.py | 1,147 | 4.71875 | 5 | '''
You've come up with a really cool name for your future startup company, and already have an idea about its logo. This logo will represent a circle, with the prefix of a cyclic string formed by the company name written around it.
The length n of the prefix you need to take depends on the size of the logo. You haven... | true |
ae12622ea7ab0959a7e0896b504f683487cac457 | anatulea/codesignal_challenges | /isIPv4Address.py | 1,229 | 4.125 | 4 | '''
An IP address is a numerical label assigned to each device (e.g., computer, printer) participating in a computer network that uses the Internet Protocol for communication. There are two versions of the Internet protocol, and thus two versions of addresses. One of them is the IPv4 address.
Given a string, find out ... | true |
79efe0f71e3216d25af3d67500a29423af62a35f | anatulea/codesignal_challenges | /Intro_CodeSignal/03_Smooth Sailing/13_reverseInParentheses.py | 1,577 | 4.21875 | 4 | '''
Write a function that reverses characters in (possibly nested) parentheses in the input string.
Input strings will always be well-formed with matching ()s.
Example
For inputString = "(bar)", the output should be
reverseInParentheses(inputString) = "rab";
For inputString = "foo(bar)baz", the output should be
reve... | true |
0f30ab84f246ce8c842d54dd760106bcb464304e | anatulea/codesignal_challenges | /Python/02_SlitheringinStrings/19_newStyleFormatting.py | 1,234 | 4.125 | 4 | '''
Implement a function that will turn the old-style string formating s into a new one so that the following two strings have the same meaning:
s % (*args)
s.format(*args)
Example
For s = "We expect the %f%% growth this week", the output should be
newStyleFormatting(s) = "We expect the {}% growth this week".
'''
d... | true |
d4d9a9ae96ebf4a33a9758802b9acdfeb555ccdc | ivn-svn/Python-Advanced-SoftUni | /Functions-Advanced/Exercises/12. recursion_palindrome.py | 401 | 4.25 | 4 | def palindrome(word, index=0, reversed_word=""):
if index == len(word):
if not reversed_word == word:
return f"{word} is not a palindrome"
return f"{word} is a palindrome"
else:
reversed_word += word[-(index + 1)]
return palindrome(word, index + 1, reversed_word)
... | true |
3a7baad4cf891fe0d8bb6a7b5fa11ce938cbfda8 | om-100/assignment2 | /11.py | 519 | 4.6875 | 5 | """Create a variable, filename. Assuming that it has a three-letter
extension, and using slice operations, find the extension. For
README.txt, the extension should be txt. Write code using slice
operations that will give the name without the extension. Does your
code work on filenames of arbitrary length?"""
def filen... | true |
13d759a3accaba9725d3b70f6a261fe9d9eca1a9 | owaisali8/Python-Bootcamp-DSC-DSU | /week_1/2.py | 924 | 4.125 | 4 | def average(x):
return sum(x)/len(x)
user_records = int(input("How many student records do you want to save: "))
student_list = {}
student_marks = []
for i in range(user_records):
roll_number = input("Enter roll number:")
name = input("Enter name: ")
age = input("Enter age: ")
marks = int(input("E... | true |
f7ccdb31cc184e3603f2f465c1d68f5c694ef9d7 | Ollisteka/Chipher_Breaker | /logic/encryptor.py | 2,968 | 4.3125 | 4 | #!/usr/bin/env python3
# coding=utf-8
import json
import sys
import tempfile
from copy import copy
from random import shuffle
def read_json_file(filename, encoding):
"""
Read data, written in a json format from a file, and return it
:param encoding:
:param filename:
:return:
"""
with open(... | true |
f84cf15c04be752423408f06737cc5100c7f0cf4 | af94080/bitesofpy | /9/palindrome.py | 1,406 | 4.3125 | 4 | """A palindrome is a word, phrase, number, or other sequence of characters
which reads the same backward as forward"""
import os
import urllib.request
DICTIONARY = os.path.join('/tmp', 'dictionary_m_words.txt')
urllib.request.urlretrieve('http://bit.ly/2Cbj6zn', DICTIONARY)
def load_dictionary():
"""Lo... | true |
2a482264dc15fc4c17fc27e08d9247351e47815a | chinmaygiri007/Machine-Learning-Repository | /Part 2 - Regression/Section 6 - Polynomial Regression/Polynomial_Regression_Demo.py | 1,317 | 4.25 | 4 | #Creating the model using Polynomial Regression and fit the data and Visualize the data.
#Check out the difference between Linear and Polynomial Regression
#Import required libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
#Reading the data
data = pd.read_csv("Position_Salaries.csv")
... | true |
96d90ae34f7e20c90adcc4637b04bdd885aa6865 | HimanshuKanojiya/Codewar-Challenges | /Disemvowel Trolls.py | 427 | 4.28125 | 4 | def disemvowel(string):
vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
for items in vowels:
if items in string:
cur = string.replace(items,"") #it will replace the vowel with blank
string = cur #after completing the operation, it will update the current string
else... | true |
7d1547f6d3d93fc3253321c5edd6509165493910 | JCarter111/Python-kata-practice | /Square_digits.py | 2,368 | 4.46875 | 4 | # Kata practice from codewars
# https://www.codewars.com/kata/546e2562b03326a88e000020/train/python
# Welcome. In this kata, you are asked to square every digit of a number.
# For example, if we run 9119 through the function, 811181 will come out, because 92 is 81 and 12 is 1.
# Note: The function accepts an integer a... | true |
fc22ede62dbfff1d6ad38bc27c353d41def148fe | Talw3g/pytoolbox | /src/pytoolbox_talw3g/confirm.py | 1,356 | 4.5 | 4 | #! /usr/bin/env python3
# -*- coding: utf-8 -*-
def confirm(question, default_choice='yes'):
"""
Adds available choices indicator at the end of 'question',
and returns True for 'yes' and False for 'no'.
If answer is empty, falls back to specified 'default_choice'.
PARAMETERS:
- question is man... | true |
e7d9e99375459e1031bf9dd0c2059421978ef31b | KartikeyParashar/Algorithm-Programs | /calendar.py | 1,434 | 4.28125 | 4 | # To the Util Class add dayOfWeek static function that takes a date as input and
# prints the day of the week that date falls on. Your program should take three
# commandline arguments: m (month), d (day), and y (year). For m use 1 for January,
# 2 for February, and so forth. For output print 0 for Sunday, 1 for Monda... | true |
b59b0b070037764fc71912183e64d047c53f9cf1 | aruntonic/algorithms | /dynamic_programming/tower_of_hanoi.py | 917 | 4.375 | 4 | def tower_of_hanoi(n, source, buffer, dest):
'''
In the classic problem of the wers of Hanoi, you have 3 towers and N disks of different sizes which can slide onto any tower.
The puzzle starts with disks sorted in ascending order of size from top to bottom (i.e., each disk sits on top of an even larger one).You ha... | true |
f9f3819c0cacfd8d0aba22d64628ab343e94b5b7 | amulyadhupad/My-Python-practice | /square.py | 202 | 4.15625 | 4 | """ Code to print square of the given number"""
def square(num):
res =int(num) * int(num)
return res
num=input("Enter a number")
ans=square(num)
print("square of "+str(num)+" "+"is:"+str(ans)) | true |
c93c2c8f1a4a7a0a2d8a69ad312ea8c06dc54446 | tuanvp10/eng88_python_oop | /animal.py | 555 | 4.25 | 4 | # Create animal class via animal file
class Animal:
def __init__(self): # self refers to this class
self.alive = True
self.spine = True
self.eyes = True
self.lungs = True
def breath(self):
return "Keep breathing to stay alive"
def eat(self):
return "Nom no... | true |
0acbad19ec29c8ce0e13d9d44eff09759e921be0 | Patrick-J-Close/Introduction_to_Python_RiceU | /rpsls.py | 1,779 | 4.1875 | 4 | # Intro to Python course project 1: rock, paper, scissors, lizard, Spock
# 0 - rock
# 1 - Spock
# 2 - paper
# 3 - lizard
# 4 - scissors
# where each value beats the two prior values and beats the two following values
import random
def name_to_number(name):
# convert string input to integer value
if name == ... | true |
ee8ff8648e324b2ca1c66c4c030a68c816af1464 | Merrycheeza/CS3130 | /LabAss2/LabAss2.py | 1,331 | 4.34375 | 4 | ###################################
# #
# Class: CS3130 #
# Assignment: Lab Assignment 2 #
# Author: Samara Drewe #
# 4921860 #
# #
###################################
#!/usr/bin/env python3
import sys, re
running = True
# prints the menu
print("--")
print("Phone Number ")
print(" ")
while(r... | true |
30e22c55bb0fe9bd5221270053564adbe4d83932 | ine-rmotr-projects/INE-Fractal | /mandelbrot.py | 854 | 4.21875 | 4 | def mandelbrot(z0:complex, orbits:int=255) -> int:
"""Find the escape orbit of points under Mandelbrot iteration
# If z0 isn't coercible to complex, TypeError
>>> mandelbrot('X')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/davidmertz/git/INE/unittest/0... | true |
0d24827c20ed97cbdf445f2691554cac1b99f8c8 | naochaLuwang/Candy-Vending-Machine | /tuto.py | 1,288 | 4.25 | 4 | # program to mimic a candy vending machine
# suppose that there are five candies in the vending machine but the customer wants six
# display that the vending machine is short of 1 candy
# And if the customer wants the available candy, give it to the customer else ask for another number of candy.
av = 5
x = int(input("... | true |
789ac887653860972e9788eb9bc2d7c4e6064abc | Sajneen-Munmun720/Python-Exercises | /Calculating the number of upper case and lower case letter in a sentence.py | 432 | 4.1875 | 4 | def case_testing(string):
d={"Upper_case":0,"Lower_case":0}
for items in string:
if items.isupper():
d["Upper_case"]+=1
elif items.islower():
d["Lower_case"]+=1
else:
pass
print("Number of upper case is:",d["Upper_case"])
print("Numbe... | true |
edf7b53def0fffcecef3b00e4ea67464ba330d9c | Malcolm-Tompkins/ICS3U-Unit5-06-Python-Lists | /lists.py | 996 | 4.15625 | 4 | #!/usr/bin/env python3
# Created by Malcolm Tompkins
# Created on June 2, 2021
# Rounds off decimal numbers
def round_off_decimal(user_decimals, number_var):
final_digit = ((number_var[0] * (10 ** user_decimals)) + 0.5)
return final_digit
def main():
number_var = []
user_input1 = (input("Enter your... | true |
3e78ea8629c13cefe4fdcbf42f475eb4da525b2a | vladbochok/university-tasks | /c1s1/labwork-2.py | 1,792 | 4.21875 | 4 | """
This module is designed to calculate function S value with given
accuracy at given point.
Functions:
s - return value of function S
Global arguments:
a, b - set the domain of S
"""
from math import fabs
a = -1
b = 1
def s(x: float, eps: float) -> float:
"""Return value of S at given point x with gi... | true |
6f0bc83046ec214818b9b8cc6bc5962a5d819977 | thivatm/Hello-world | /Python/Counting the occurence of each word.py | 223 | 4.21875 | 4 | string=input("Enter string:").split(" ")
word=input("Enter word:")
from collections import Counter
word_count=Counter(string)
print(word_count)
final_count=word_count[word]
print("Count of the word is:")
print(final_count)
| true |
0cb00f6f4798c9bc5770f04b8a2a09cb0e3f0c43 | ssavann/Python-Data-Type | /MathOperation.py | 283 | 4.25 | 4 | #Mathematical operators
print(3 + 5) #addition
print(7 - 4) #substraction
print(3 * 2) #multiplication
print(6 / 3) #division will always be "Float" not integer
print(2**4) #power: 2 power of 4 = 16
print((3 * 3) + (3 / 3) - 3) #7.0
print(3 * (3 + 3) / 3 - 3) #3.0
| true |
c54d75b36108590ba19569ae24f6b72fd13b628b | Alankar-98/MWB_Python | /Functions.py | 239 | 4.15625 | 4 | # def basic_function():
# return "Hello World"
# print(basic_function())
def hour_to_mins(hour):
mins = hour * 60
return mins
print(hour_to_mins(float(input("Enter how many hour(s) you want to convert into mins: \n")))) | true |
ce788f6c65b9b8c4e3c47585b7024d2951b59d19 | GLARISHILDA/07-08-2021 | /cd_abstract_file_system.py | 928 | 4.15625 | 4 | # Write a function that provides a change directory (cd) function for an abstract file system.
class Path:
def __init__(self, path):
self.current_path = path # Current path
def cd(self, new_path): # cd function
parent = '..'
separator = '/'
# Absolute path
... | true |
a84755fd8627c33535f669980de25c072e0a3c83 | sandeshsonje/Machine_test | /First_Question.py | 555 | 4.21875 | 4 | '''1. Write a program which takes 2 digits, X,Y as input and generates a
2-dimensional array.
Example:
Suppose the following inputs are given to the program:
3,5
Then, the output of the program should be:
[[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8]]
Note: Values inside array can be any.(it's up to candida... | true |
f5e7a155de761f83f9ad7b8293bc5c81edda3f1f | Luciekimotho/datastructures-and-algorithms | /MSFT/stack.py | 821 | 4.1875 | 4 | #implementation using array
#class Stack:
# def __init__(self):
# self.items = []
# def push(self, item):
# self.items.append(item)
# def pop(self):
# return self.items.pop()
#implementation using lists
class Stack:
def __init__(self):
self.stack = list()
#inse... | true |
eab5e0186698af32d9301abf155e1d0af25e5f6f | jzamora5/holbertonschool-interview | /0x03-minimum_operations/0-minoperations.py | 647 | 4.1875 | 4 | #!/usr/bin/python3
""" Minimum Operations """
def minOperations(n):
"""
In a text file, there is a single character H. Your text editor can execute
only two operations in this file: Copy All and Paste. Given a number n,
write a method that calculates the fewest number of operations needed to
resu... | true |
746c24e8e59f8f85af4414d5832f0ec1bf9a4f7c | joeblackwaslike/codingbat | /recursion-1/powerN.py | 443 | 4.25 | 4 | """
powerN
Given base and n that are both 1 or more, compute recursively (no loops) the
value of base to the n power, so powerN(3, 2) is 9 (3 squared).
powerN(3, 1) → 3
powerN(3, 2) → 9
powerN(3, 3) → 27
"""
def powerN(base, n):
if n == 1:
return base
else:
return base * powerN(base, n - 1)... | true |
d6fb1774f0abf4a7dfacc3630206cc2e8fda883c | shenxiaoxu/leetcode | /questions/1807. Evaluate the Bracket Pairs of a String/evaluate.py | 1,448 | 4.125 | 4 | '''
You are given a string s that contains some bracket pairs, with each pair containing a non-empty key.
For example, in the string "(name)is(age)yearsold", there are two bracket pairs that contain the keys "name" and "age".
You know the values of a wide range of keys. This is represented by a 2D string array knowled... | true |
bfe9ecfe1e7c5e04be74a9ad86e0deed0535063e | nikonst/Python | /Core/lists/big_diff.py | 691 | 4.125 | 4 | '''
Given an array length 1 or more of ints, return the difference between the largest and smallest values in the array.
Note: the built-in min(v1, v2) and max(v1, v2) functions return the smaller or larger of two values.
big_diff([10, 3, 5, 6]) - 7
big_diff([7, 2, 10, 9]) - 8
big_diff([2, 10, 7, 2]) - 8
'''
i... | true |
29dc483eabdfada41277bd0879d4d30db4c5e9e1 | nikonst/Python | /Core/lists/centered_average.py | 859 | 4.21875 | 4 | '''
Return the "centered" average of an array of ints, which we'll say is the mean average of the values,
except ignoring the largest and smallest values in the array. If there are multiple copies of the smallest value,
ignore just one copy, and likewise for the largest value. Use int division to produce the final a... | true |
e924c76da60630526344873dfd5523c3bf9bec7d | nikonst/Python | /Core/lists/max_end3.py | 792 | 4.40625 | 4 | '''
Given an array of ints length 3, figure out which is larger, the first or last element in the array,
and set all the other elements to be that value. Return the changed array.
max_end3([1, 2, 3]) - [3, 3, 3]
max_end3([11, 5, 9]) - [11, 11, 11]
max_end3([2, 11, 3]) - [3, 3, 3]
'''
def maxEnd3(nums):
... | true |
2dde45ecac9827dc9804a3d4277054bb07e5be02 | Vaishnavi-cyber-blip/LEarnPython | /Online library management system.py | 1,658 | 4.1875 | 4 | class Library:
def __init__(self, list_of_books, library_name):
self.library_name = library_name
self.list_of_books = list_of_books
def display_books(self):
print(f"Library name is {self.library_name}")
print(f"Here is the list of books we provide:{self.list_of_books}")
def... | true |
0d70416d7d6d50d3f69d38ab8bb6878b3e673667 | MarkVarga/python_to_do_list_app | /to_do_list_app.py | 1,819 | 4.21875 | 4 |
data = []
def show_menu():
print('Menu:')
print('1. Add an item')
print('2. Mark as done')
print('3. View items')
print('4. Exit')
def add_items():
item = input('What do you need to do? ')
data.append(item)
print('You have added: ', item)
add_more_items()
def add_more_items()... | true |
ff3ccbf45d3be6f6933f03ec3be4ec8c03c15be1 | j-hmd/daily-python | /Object-Oriented-Python/dataclasses_intro.py | 600 | 4.1875 | 4 | # Data classes make the class definition more concise since python 3.7
# it automates the creation of __init__ with the attributes passed to the
# creation of the object.
from dataclasses import dataclass
@dataclass
class Book:
title: str
author: str
pages: int
price: float
b1 = Book("A Mao e a Luva",... | true |
975f43786306ca83189c8a7f310bec5b38c1ac84 | Pawan459/infytq-pf-day9 | /medium/Problem_40.py | 1,587 | 4.28125 | 4 | # University of Washington CSE140 Final 2015
# Given a list of lists of integers, write a python function, index_of_max_unique,
# which returns the index of the sub-list which has the most unique values.
# For example:
# index_of_max_unique([[1, 3, 3], [12, 4, 12, 7, 4, 4], [41, 2, 4, 7, 1, 12]])
# would return 2 si... | true |
1e7f67cd95ecd74857bcc0a2aeb4a45e6b13947d | harshonyou/SOFT1 | /week5/week5_practical4b_5.py | 440 | 4.125 | 4 | '''
Exercise 5:
Write a function to_upper_case(input_file, output_file) that takes two
string parameters containing the name of two text files. The function reads the content of the
input_file and saves it in upper case into the output_file.
'''
def to_upper_case(input_file, output_file):
with open(input_file) as x... | true |
dd0b87ac56156e3f3f7397395752cd9f57d33972 | harshonyou/SOFT1 | /week7/week7_practical6a_6.py | 1,075 | 4.375 | 4 | '''
Exercise 6:
In Programming, being able to compare objects is important, in particular determining if two
objects are equal or not. Let’s try a comparison of two vectors:
>>> vector1 = Vector([1, 2, 3])
>>> vector2 = Vector([1, 2, 3])
>>> vector1 == vector2
False
>>> vector1 != vector2
True
>>> vector3 = vector1
>>>... | true |
13138f7e7f105cb917d3c28995502f01ace2c46a | harshonyou/SOFT1 | /week4/week4_practical3_5.py | 829 | 4.25 | 4 | '''
Exercise 5: Where’s that bug!
You have just started your placement, and you are given a piece of code to correct. The aim of
the script is to take a 2D list (that is a list of lists) and print a list containing the sum of each
list. For example, given the list in data, the output should be [6, 2, 10].
Modify the co... | true |
7209b64a1bfbca67fa750370a6b2a2f35f04085b | harshonyou/SOFT1 | /week3/week3_ex1_1.py | 870 | 4.125 | 4 | '''
Exercise 1: Simple while loopsExercise 1: Simple while loops
1. Write a program to keep asking for a number until you enter a negative number. At the end, print the sum of all entered numbers.
2. Write a program to keep asking for a number until you enter a negative number. At the end, print the average of all en... | true |
ae485d7078b0a130d25f508fa3bbf2654b288fbd | carlosberrio/holbertonschool-higher_level_programming-1 | /0x0B-python-input_output/4-append_write.py | 312 | 4.34375 | 4 | #!/usr/bin/python3
"""Module for append_write method"""
def append_write(filename="", text=""):
"""appends a string <text> at the end of a text file (UTF8) <filename>
and returns the number of characters added:"""
with open(filename, 'a', encoding='utf-8') as file:
return file.write(text)
| true |
129c7dfb7e4704916d6a3c70c7b88de3f4ee5ab4 | carlosberrio/holbertonschool-higher_level_programming-1 | /0x07-python-test_driven_development/2-matrix_divided.py | 1,673 | 4.3125 | 4 | #!/usr/bin/python3
""" Module for matrix_divided method"""
def matrix_divided(matrix, div):
"""Divides all elements of a matrix by div
Args:
matrix: list of lists of numbers (int or float)
div: int or float to divide matrix by
Returns:
list: a new matrix list of lists
Raises:
... | true |
ac98781df6169c661443e347c22760b6a88fad1c | KamalAres/Infytq | /Infytq/Day8/Assgn-55.py | 2,650 | 4.25 | 4 | #PF-Assgn-55
#Sample ticket list - ticket format: "flight_no:source:destination:ticket_no"
#Note: flight_no has the following format - "airline_name followed by three digit number
#Global variable
ticket_list=["AI567:MUM:LON:014","AI077:MUM:LON:056", "BA896:MUM:LON:067", "SI267:MUM:SIN:145","AI077:MUM:CAN:060","SI267... | true |
5a195c58bc440fce91c4a7ebc3a1f9eeb61d1ce1 | Wallabeee/PracticePython | /ex11.py | 706 | 4.21875 | 4 | # 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 practice using functions, described below.
def isPrime(num):
... | true |
02e8b295591e79c057481be775219e2143915e4f | SaidhbhFoley/Promgramming | /Week04/even.py | 370 | 4.15625 | 4 | #asks the user to enter in a number, and the program will tell the user if the number is even or odd.
#Author: Saidhbh Foley
number = int (input("enter an integer:"))
if (number % 2) == 0:
print ("{} is an even number".format (number))
else:
print ("{} is an odd number".format (number))
i = 0
while i > 0:
... | true |
c158785cfd4d1ef3704194e7a1fea2d1a1210308 | tdchua/dsa | /data_structures/doubly_linkedlist.py | 2,805 | 4.34375 | 4 | #My very own implementation of a doubly linked list!
#by Timothy Joshua Dy Chua
class Node:
def __init__(self, value):
print("Node Created")
self.value = value
self.next = None
self.prev = None
class DLinked_List:
def __init__(self):
self.head = None
self.tail = None
def traverse(self)... | true |
22aa6b4daeb05936eb5fd39b361e2945d02a5f64 | 786awais/assignment_3-geop-592-sharing | /Assignment 3 GEOP 592 | 2,512 | 4.125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[50]:
#GEOP_592 Assigment_3
#Codes link: https://www.datarmatics.com/data-science/how-to-perform-logistic-regression-in-pythonstep-by-step/
#We are Provided with a data for 6800 micro-earthquake waveforms. 100 features have been extracted form it.
#We need to perform logist... | true |
63b2b212b2e42f539fb802cc95633eae00c34a7f | jskimmons/LearnGit | /Desktop/HomeWork2017/1006/Homework1/problem2.py | 825 | 4.1875 | 4 | # jws2191
''' This program will, given an integer representing a number of years,
print the approximate population given the current population and the
approximate births, deaths, and immigrants per second. '''
# Step 1: store the current population and calculate the rates of births,
# deaths, and immigrations per... | true |
773442a1cdd867d18af6c7578af1f5e208be9a7c | jskimmons/LearnGit | /Desktop/HomeWork2017/1006/Homework2/untitled.py | 552 | 4.28125 | 4 | '''
This is a basic dialog system that prompts the user to
order pizza
@author Joe Skimmons, jws2191
'''
def select_meal():
possible_orders = ["pizza" , "pasta" , "salad"]
meal = input("Hello, would you like pizza, pasta, or salad?\n")
while meal.lower() not in possible_orders:
meal = input("Sorry, ... | true |
6210f2e37e1ce5e93e7887ffa73c8769fae0a35a | garg10may/Data-Structures-and-Algorithms | /searching/rabinKarp.py | 1,862 | 4.53125 | 5 | #Rabin karp algorithm for string searching
# remember '^' : is exclusive-or (bitwise) not power operator in python
'''
The algorithm for rolling hash used here is as below. Pattern : 'abc', Text : 'abcd'
Consider 'abc' its hash value is calcualted using formula a*x^0 + b*x^1 + c*x^2, where x is prime
Now when we need... | true |
e1be3b9664e172dc71a2e3038a1908c5e49dd57b | Fueled250/Intro-Updated-Python | /intro_updated.py | 881 | 4.1875 | 4 | #S.McDonald
#My first Python program
#intro.py -- asking user for name, age and income
#MODIFIED: 10/18/2016 -- use functions
#create three functions to take care of Input
def get_name():
#capture the reply and store it in 'name' variable
name = input ("what's your name?")
return name
def get... | true |
1c60d291a1d02ee0ebefd3544843c918179e5254 | aiswaryasaravanan/practice | /hackerrank/12-26-reverseLinkedList.py | 956 | 4.125 | 4 | class Node:
def __init__(self,data):
self.data=data
self.next=None
class LinkedList:
def __init__(self):
self.head=None
def add(self,data):
if not self.head:
self.head=Node(data)
else:
cur=self.head
while cur.next:
... | true |
781b93dd583dc43904e9b3d5aa4d6b06eaa5705b | spno77/random | /Python-programs/oop_examples.py | 1,399 | 4.625 | 5 | """ OOP examples """
class Car:
""" Represent a car """
def __init__(self,make,model,year):
self.make = make
self.model = model
self.year = year
self.odometer_reading = 0
def get_descriptive_name(self):
"""Return a neatly formatted descritive name"""
long_name = f"{self.year} {self.make} {self.model}"
... | true |
052193ea7c43ccaf0406b3c34cf08b906d6c74fd | GitDavid/ProjectEuler | /euler.py | 812 | 4.25 | 4 | import math
'''
library created for commonly used Project Euler problems
'''
def is_prime(x):
'''
returns True if x is prime; False if not
basic checks for lower numbers and all primes = 6k +/-1
'''
if x == 1 or x == 0:
return False
elif x <= 3:
return True
elif x % 2 == 0 ... | true |
7bc09ed3640e3f0e32e2ea12725a65cb87d6d39f | SavinaRoja/challenges | /Rosalind/String_Algorithms/RNA.py | 2,275 | 4.1875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Transcribing DNA into RNA
Usage:
RNA.py <input> [--compare]
RNA.py (--help | --version)
Options:
--compare run a speed comparison of various methods
-h --help show this help message and exit
-v --version show version and exit
"""
problem_desc... | true |
d122d93baa813af861b12346e82003bdc91e7d47 | Jessica-Luis001/shapes.py | /shapes.py | 1,042 | 4.46875 | 4 | from turtle import *
import math
# Name your Turtle.
marie = Turtle()
color = input("What color would you like?")
sides = input("How many sides would you like?")
steps = input("How many steps would you like?")
# Set Up your screen and starting position.
marie.penup()
setup(500,300)
x_pos = -250
y_pos = -150
marie.set... | true |
14f15835a90bc85b84528f40622ee216d4bfd2a4 | GaloisGroupie/Nifty-Things | /custom_sort.py | 1,247 | 4.28125 | 4 | def merge_sort(inputList):
"""If the input list is length 1 or 0, just return
the list because it is already sorted"""
inputListLength = len(inputList)
if inputListLength == 0 or inputListLength == 1:
return inputList
"""If the list size is greater than 1, recursively break
it into 2 pieces and we... | true |
7fd5693cd6e035bb230eb535f4d9b0b0a5ce23bf | israel-dryer/Just-for-Fun | /mad_libs.py | 2,489 | 4.125 | 4 | # create a mad-libs | random story generator
# randomly select words to create a unique mad-libs story
from random import randint
import copy
# create a dictionary of the words of the type you will use in the story
word_dict = {
'adjective':['greedy','abrasive','grubby','groovy','rich','harsh','tasty','slow'],
... | true |
3dd09e91200b964ae1114bf6d655fcb9776816fd | EnricoFiasche/assignment1 | /scripts/target_server.py | 1,276 | 4.125 | 4 | #!/usr/bin/env python
import rospy
import random
from assignment1.srv import Target, TargetResponse
def random_target(request):
"""
Function that generates two random coordinates (x,y) given the range
(min,max)
Args:
request: The request of Target.srv
- minimum value of the random coordinate
- maximum va... | true |
a3af77c55562a3c70c9b1ee570086bc941b9bbee | Sidhved/Data-Structures-And-Algorithms | /Python/DS/Trees.py | 1,731 | 4.375 | 4 | #Program to traverse given tree in pre-order, in-order and post-order fashion
class TreeNode:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
class Tree:
def __init__(self, root):
self.root = TreeNode(root)
def inorderTraversal(self, node, path):... | true |
c6899d11bbf0892f42b3b877bbe5f9a2a66bf757 | ben-coxon/cs01 | /sudoku_solver.py | 2,916 | 4.28125 | 4 | #!/usr/bin/python
# THREE GOLD STARS
# Sudoku [http://en.wikipedia.org/wiki/Sudoku]
# is a logic puzzle where a game
# is defined by a partially filled
# 9 x 9 square of digits where each square
# contains one of the digits 1,2,3,4,5,6,7,8,9.
# For this question we will generalize
# and simplify the game.
# Define a... | true |
5421ce966d6b60ec40f9e43ece33809fe9576c84 | Ricky842/Shorts | /Movies.py | 1,404 | 4.40625 | 4 | #Empty list and dictionaries to store data for the movies and their ratings
movies = []
movie_dict = {'movie': '', 'rating': 0}
#Check validity of movie rating
def check_entry(rating):
while rating.isnumeric() is True:
movie_rating = int(rating)
if(movie_rating > 10 or movie_rating < 1):
... | true |
5ed55cdbe3082ebcd87c8cc5ab40defff9542932 | anandavelum/RestApiCourse | /RestfulFlaskSection5/createdb.py | 605 | 4.125 | 4 | import sqlite3
connection = sqlite3.connect("data.db")
cursor = connection.cursor()
cursor.execute("create table if not exists users (id INTEGER PRIMARY KEY,name text,password text)")
users = [(1, "Anand", "Anand"), (2, "Ramya", "Ramya")]
cursor.executemany("insert into users values (?,?,?)", users)
rows = list(c... | true |
72994802e57e471f8cc14515072749eb35d79037 | LadyKerr/cs-guided-project-array-string-manipulation | /src/class.py | 657 | 4.21875 | 4 | # Immutable variables: ints; O(1) [to find new location for them is cheap]; string
# num = 1
# print(id(num))
# num = 100
# print(id(num))
# num2 = num
# print(num2 is num)
# num2 = 2
# print(num)
# print(num2 is num)
# Mutable Variables: arrays, dictionaries, class instances
arr = [1,2,3] #arrays are mutable
print... | true |
8c902651f21a4c5d25b384a3f73922c06eba74aa | gabefreedman/music-rec | /dates.py | 2,624 | 4.4375 | 4 | #!/usr/bin/env python
"""This module defines functions for manipulating and formatting date
and datetime objects.
"""
from datetime import timedelta
def get_month(today):
"""Format datetime to string variable of month name.
Takes in `today` and extracts the full month
name. The name is returned in all... | true |
3b2d9f12bcfee600b30eeb27e34788ae5c8ed4f9 | jc345932/sp53 | /workshopP1/shippingCalculator.py | 368 | 4.1875 | 4 | item =int(input("How many items:"))
while item < 0:
print("Invalid number of items!")
item = int(input("How many items:"))
cost =int(input("How much for item:"))
while cost < 0:
print("Invalid prices")
cost = int(input("How much for item:"))
total = cost * item
if total > 100:
total = total * 0.9
el... | true |
1f45bdd57c3e4381ff05c668fadcb38bcaf589f8 | jc345932/sp53 | /workshopP4/numList.py | 322 | 4.15625 | 4 | list = []
for i in range(5):
num = int(input("Enter the number: "))
list.append(num)
print("The first number is: ",list[0])
print("the last number is: ", list[-1])
print("the smallest number is: ", min(list))
print("the largest number is: ",max(list))
print("the average of the numbers is: ",sum(list)/len(list)... | true |
c7443b333e6f8b64ca5e5d55c3cdaf0b64c8e291 | Necrolord/LPI-Course-Homework-Python-Homework- | /Exercise2-2.py | 1,123 | 4.53125 | 5 | #!/bin/usr/env python3.6
# This method is for reading the strings
def Input_Str():
x = str(input("Enter a String: "))
return x
# This method is for reading the number.
def Input_Num():
num = int(input("Enter a number between 1 and 3 included: "))
if ((num < 1) or (num > 3)):
print('The number ... | true |
23c4b91775a740a59ad4970b20935d3cfb50e768 | shafaypro/AndreBourque | /assignment1/mood2.py | 2,454 | 4.53125 | 5 | mood = input('Enter the mood of yours (angry,sad,happy,excited)') # we are taking an input in the form of a string
"""
if mood == "angry": # check the value of the variable mood if the value is angry compares that with angry
print("Your %s" % mood) # the variable mood value is then replaced in the place of %s
prin... | true |
30db7f2a89d91bdd140df331d0b039d896803ee1 | franciscomunoz/pyAlgoBook | /chap4-Recursion/C-4.19.py | 1,890 | 4.4375 | 4 | """Function that places even numbers before odd
if returns are removed in the else condition, the recursion
tree becomes messy as shown :
(0, 6, [2, 3, 5, 7, 9, 4, 8])
(1, 6, [2, 3, 5, 7, 9, 4, 8])
(2, 5, [2, 8, 5, 7, 9, 4, 3])
(3, 4, [2, 8, 4, 7, 9, 5, 3])
(4, 3, [2, 8, 4, 7, 9, 5, 3])
(3, 4,... | true |
7981d8de44f4d1aaaab8aec30ea50b9fb1a87c48 | franciscomunoz/pyAlgoBook | /chap5-Array-Based_Sequences/C-5.13.py | 1,095 | 4.125 | 4 | """The output illustrates how the list capacity is changing
during append operations. The key of this exercise is to
observe how the capacity changes when inserting data to an
an array that doesn't start at growing from size "0". We
use two arrays, the original from 5.1 and another starting
to grow from a different va... | true |
efd406bd5d1378e7d1d38e2329d5039fdd069730 | franciscomunoz/pyAlgoBook | /chap5-Array-Based_Sequences/P-5.35.py | 2,019 | 4.25 | 4 | """Implement a class , Substitution Cipher, with a constructor that takes a string
with 26 uppercase letters in an arbitrary order and uses that for the forward
mapping for encryption (akin to the self._forward string in our Caesar Cipher
class ) you should derive the backward mapping from the forward version"""
impor... | true |
7ed258a07a00f7092741efd7b9cef6dc69cdc4b8 | Marlon-Poddalgoda/ICS3U-Unit3-06-Python | /guessing_game.py | 980 | 4.25 | 4 | #!/usr/bin/env python3
# Created by Marlon Poddalgoda
# Created on December 2020
# This program is an updated guessing game
import random
def main():
# this function compares an integer to a random number
print("Today we will play a guessing game.")
# random number generation
random_number = rando... | true |
b9862bf717d958e138ffeb6918d21f5fe164a780 | Lutshke/Python-Tutorial | /variables.py | 882 | 4.40625 | 4 | "This is where i will show you the basics ok?"
# to add comments to code you need to start with a hashtag like i did
# there are a few types of numbers
# there are "ints" and "floats"
# an int is a full number (10, 45, 100..)
# an float is (0.1, 1,5...)
# an int or float are variables so they save values
... | true |
231d905f24fa551c060748793eee07c9ce563edd | deepaparangi80/Github_pycode | /sum_numb.py | 254 | 4.21875 | 4 | # program to print sum of 1 to n
n = int(input('Enter n value'))
print('entered value',n)
sum = 0
for i in range(1,n+1):
'''print(i)'''
sum = sum + i
print('total sum of 1 to {} is {}'.format(n,sum))
'''print (range(1,n))''' | true |
d778b446a64b2a12c3cd521aa611ca71937d2381 | JYDP02/DSA_Notebook | /Searching/python/breadth_first_search.py | 1,263 | 4.40625 | 4 | # Python3 Program to print BFS traversal
from collections import defaultdict
class Graph:
# Constructor
def __init__(self):
self.graph = defaultdict(list)
def addEdge(self, u, v):
self.graph[u].append(v)
def BFS(self, s):
# Mark all the vertices as not visited
vis... | true |
8bf11d623899a8640bd99dc352518a2c562c9e87 | lingaraj281/Lingaraj_task2 | /q3.py | 317 | 4.15625 | 4 | print("Enter a text")
a=str(input())
letter = input("Enter a letter\n")
letter_count = 0
for x in a:
if x == letter:
letter_count = letter_count + 1
num_of_letters = 0
for x in a:
if(x != " "):
num_of_letters = num_of_letters + 1
frequency = (letter_count/num_of_letters)*100
print(frequency) | true |
2e7266efc9d0d28413d9b28053d49830f6c85834 | JatinR05/Python-3-basics-series | /17. appending to a file.py | 864 | 4.40625 | 4 | '''
Alright, so now we get to appending a file in python. I will just state again
that writing will clear the file and write to it just the data you specify in
the write operation. Appending will simply take what was already there, and add
to it.
That said, when you actually go to add to the file, you will still use
.... | true |
a429e619657d092618f27c24cd0a30abfbda9e3c | JatinR05/Python-3-basics-series | /9. if elif else.py | 972 | 4.34375 | 4 | '''
What is going on everyone welcome to my if elif else tutorial video.
The idea of this is to add yet another layer of logic to the pre-existing if else statement.
See with our typical if else statment, the if will be checked for sure, and the
else will only run if the if fails... but then what if you want to chec... | true |
4ea711632c6a2bab41d0810384552a220d35eb7a | joe-bollinger/python-projects | /tip_calculator/tip_calculator.py | 1,703 | 4.25 | 4 | print('Tip Calculator')
print()
# TODO: Get the cost of the meal and print the results
get_cost = input('How much did your meal cost? (i.e. 45.67) ')
# Convert the input string to a float
get_cost = float(get_cost)
print(f"Food Cost: ${format(get_cost, '.2f')}")
# TODO: Calculate 10% sales tax for the bill and print... | true |
f6717518f0fc59f794607f32ae3b2c33f8f88356 | sohel2178/Crawler | /file_test.py | 1,983 | 4.15625 | 4 |
# f= open('test.txt','r')
# print(f.mode)
# f.close()
# Context Manager
# with open('test.txt','r') as f:
# Read all the Content
# f_content = f.read()
# There is another method to read a file line by line
# f_content = f.readlines()
# print(f_content)
# Another way to read All of the Li... | true |
80e00f4c0f308f8c361a884b08c56b60f3e6d4b3 | ishan5886/Python-Learning | /Decorators.py | 1,020 | 4.21875 | 4 | #Decorators - Function that takes function as an argument, performs some functionality and returns another function
# def outer_function(msg):
# def inner_function():
# print(msg)
# return inner_function
# def decorator_function(original_function):
# def wrapper_function():
# return or... | true |
661627a12dc195ee9a2c9b26fc340d7e0a2099be | LavanyaBashyagaru/letsupgrade- | /day3assigment.py | 539 | 4.21875 | 4 | '''You all are pilots, you have to land a plane,
the altitude required for landing a plane is 1000ft,
if it is less than that tell pilot to land the plane,
or it is more than that but less than 5000 ft
ask the pilot to come down to 1000 ft,
else if it is more than 5000ft ask the pilot togo around and try later'''
... | true |
953b47f0be6a1c46f7c75b888dccf5d9e484f920 | MarsForever/python_kids | /7-1.py | 316 | 4.125 | 4 | num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
if num1 < num2:
print (num1, "is less than",num2)
if num1 > num2:
print (num2, "is more than",num2)
if num1 == num2:
print (num1,"is equal to",num2)
if num1 != num2:
print (num1,"is not equal to", num2)
| true |
6461becb3ef2198b34feba0797459c22ec886e4c | OrSGar/Learning-Python | /FileIO/FileIO.py | 2,953 | 4.40625 | 4 | # Exercise 95
# In colts solution, he first read the contents of the first file with a with
# He the used another with and wrote to the new file
def copy(file1, file2):
"""
Copy contents of one file to another
:param file1: Path of file to be copied
:param file2: Path of destination file
"""
des... | true |
60ce089cbbc612632e6e249227e3cac374e59ad1 | MNJetter/aly_python_study | /diceroller.py | 1,396 | 4.15625 | 4 | ##################################################
## Begin DICEROLLER. ##
##################################################
## This script is a d20-style dice roller. It ##
## requires the user to input numbers for a ##
## multiplier, dice type, and modifier, and ##
## displays re... | true |
a425af412c404ebbef4e634ce335c58b75b7cee1 | RhettWimmer/Scripting-for-Animation-and-Games-DGM-3670- | /Python Assignments/scripts(old)2/Calculator.py | 2,452 | 4.21875 | 4 | '''
Enter a list of values for the calculator to solve in "Values"
Enter a value in to "Power" to calculate the power of "Values"
Define "userInput" to tell the calculator what function to solve for.
1 = Add
2 = Subtract
3 = Multiply
4 = Divide
5 = Power
6 = Mean
7 = Median
8 ... | true |
db95ed4eccce222cea4b4326ab5e4586f2916ac3 | JimGeist/sb_18-02-20_Python_Data_Structures_Exercise | /17_mode/mode.py | 856 | 4.28125 | 4 | def mode(nums):
"""Return most-common number in list.
For this function, there will always be a single-most-common value;
you do not need to worry about handling cases where more than one item
occurs the same number of times.
>>> mode([1, 2, 1])
1
>>> mode([2, 2, 3, 3, 2])
... | true |
90707b2e54d15dcf7ecdcf4286a2409b271968a4 | ibrahimuslu/udacity-p0 | /Task4.py | 1,555 | 4.15625 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
count =0
textPhoneDict = {}
callingPhoneDict = {}
receiveingPhoneDict = {}
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
for text in texts:
if text[0] not in tex... | true |
35c53757e5669ad24a4b61aa6878b722de8636e1 | martinee300/Python-Code-Martinee300 | /w3resource/Python Numpy/Qn3_PythonNumpy_CreateReshapeMatrix.py | 508 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Aug 27 14:24:51 2018
@author: dsiow
"""
# =============================================================================
# 3. Create a 3x3 matrix with values ranging from 2 to 10.
# Expected Output:
# [[ 2 3 4]
# [ 5 6 7]
# [ 8 9 10]]
# ===================================... | true |
cb0ae7e3a71550c42711351027a21917668560ba | robinrob/python | /practice/print_reverse.py | 441 | 4.125 | 4 | #!/usr/bin/env python
class Node(object):
def __init__(self, data=None, next_node=None):
self.data = data
self.next = next_node
def ReversePrint(head):
if head is not None:
if head.next is not None:
ReversePrint(head.next)
print head.data
head = Node(data=0)
one =... | true |
237a9ccbbfa346ff3956f90df5f52af4272b9291 | robinrob/python | /practice/postorder_traversal.py | 727 | 4.1875 | 4 | #!/usr/bin/env python
class Node:
def __init__(self, data, left=None, right=None):
self.data = data
self.left = left
self.right = right
"""
Node is defined as
self.left (the left child of the node)
self.right (the right child of the node)
self.data (the value of the node)
"""
lr = Nod... | true |
1c047ac76bcb2fa3e902d3f5b6e0e145cc866c5d | KyleLawson16/mis3640 | /session02/calc.py | 871 | 4.21875 | 4 | '''
Exercise 1
'''
import math
# 1.
radius = 5
volume = (4 / 3 * math.pi * (radius**3))
print(f'1. The volume of a sphere with radius {radius} is {round(volume, 2)} units cubed.')
# 2.
price = 24.95
discount = 0.4
copies = 60
cost = (price * discount) + 3 + (0.75 * (copies - 1))
print(f'2. The total wholesale cos... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.