blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
7a7ab6085f25abdc688ab65ebe6373cdc9e05530 | Anonsurfer/Simple_Word_List_Creator | /Word_List_Creator.py | 835 | 4.28125 | 4 | # This simple script allows you to create a wordlist and automatically saves it as .txt
# if the final value of wordlist is 100 - it will create the wordlist from 0,1,2,3,4.... so on to 100.
import os # Importing the Os Module
keys_ = open("keys.txt",'w') # Creating a new txt file
keys_range = int(input("Enter the fin... | true |
7f12c500ecd0bac47473615ddf95185f7bc23993 | josterpi/python | /python1.py | 2,734 | 4.21875 | 4 | #!/usr/bin/env python
# initialized at 1, I have two actions I can do on the number
# line. I can jump forward and jump backwards.
# The jump forward is 2*current position + 1
# The jump back is the current position - 3
# Can you hit all of the integers?
# If not, what can't you hit? What can you? Any patterns?
# When... | true |
2b8a5961e68d32283401892eec11dbfade6c80d2 | HarrisonHelms/helms | /randomRoll/roll2.py | 350 | 4.25 | 4 | from random import random
R = random()
sides = input("Enter the number of sides on the die: ")
'''
rolled = (sides - 1) * R
rolled = round(rolled)
rolled += 1
'''
def roll(sides):
rolled = (sides - 1) * R
rolled = round(rolled)
rolled += 1
return rolled
num = roll(int(sides))
num = str(num)
print("Y... | true |
e4a71284092ec0a1cc7a9e2a29eaf719e51a6ca4 | denglert/python-sandbox | /corey_schafer/sorting/sort.py | 2,775 | 4.4375 | 4 | # - Original list
lst = [9,1,8,2,7,3,6,4,5]
print('Original list:\t', lst )
# - Sort list with sorted() function
s_lst = sorted(lst)
print('Sorted list: {0}'.format(s_lst) )
# - Sort lits Using subfunction .sort()
lst.sort()
print('Sorted list:\t', lst )
# - Sort list in reverse order with sorted() function
s_l... | true |
3dbfd602383d5791f2f5a4bcfc4c5e54b07e9ce7 | denglert/python-sandbox | /corey_schafer/namedtuples/namedtuples.py | 932 | 4.40625 | 4 | ############################
### --- Named tuples --- ###
############################
from collections import namedtuple
### --- Tuple --- ###
# Advantage:
# - Immutable, can't change the values
color_tuple = (55, 155, 255)
print( color_tuple[0] )
### --- Dictionaries --- ###
# Disadvantage:
# - Requires more ty... | true |
fe7dad7782ed143451c1c48fe9b82333393a41e3 | mmarotta/interactivepython-005 | /guess-the-number.py | 2,540 | 4.15625 | 4 | import simplegui
import random
import math
# int that the player just guessed
player_guess = 0
# the number that the player is trying to guess
secret_number = 0
# the maximum number in the guessing range (default 100)
max_range = 100
# the number of attempt remaining (default 7)
attempts_remaining = 7
# helper functi... | true |
0fabb98b1c2a86dc202f5eecb58b9a5d3011019e | effedib/the-python-workbook-2 | /Chap_06/Ex_142.py | 463 | 4.4375 | 4 | # Unique Characters
# Determine which is the number of unique characters that composes a string.
unique = dict()
string = input('Enter a string to determine how many are its unique characters and to find them: ')
for c in string:
if c not in unique:
unique[c] = 1
num_char = sum(unique.values())
print(... | true |
f3a3d5e579092cfe05d7dd072336f7bb1336aafc | effedib/the-python-workbook-2 | /Chap_04/Ex_87.py | 536 | 4.28125 | 4 | # Shipping Calculator
# This function takes the number of items in an orger for an online retailer and returns the shipping charge
def ShippingCharge(items: int) -> float:
FIRST_ORDER = 10.95
SUBSEQ_ORDER = 2.95
ship_charge = FIRST_ORDER + (SUBSEQ_ORDER * (items - 1))
return ship_charge
def main(... | true |
182bf7a4858162954223f42c72bae8ff258c9ef0 | effedib/the-python-workbook-2 | /Chap_04/Ex_96.py | 816 | 4.125 | 4 | # Does a String Represent an Integer?
def isInteger(string: str) -> bool:
string = string.strip()
string = string.replace(' ', '')
if string == "":
return False
elif string[0] == '+' or string[0] == '-':
if len(string) == 1:
return False
for i in string[1... | true |
0050797557855d27088eed9dbf73027031d5de12 | effedib/the-python-workbook-2 | /Chap_01/Ex_14.py | 390 | 4.46875 | 4 | # Height Units
# Conversion rate
FOOT = 12 # 1 foot = 12 inches
INCH = 2.54 # 1 inch = 2.54 centimeters
# Read height in feet and inches from user
feet = int(input("Height in feet: "))
inches = int(input("Add the number of inches: "))
# Compute the conversion in centimeters
cm = (((feet * FOOT) + inches) *... | true |
9b15b4f104947f8fd306784d22c0d4f12c574c55 | effedib/the-python-workbook-2 | /Chap_02/Ex_48.py | 1,934 | 4.46875 | 4 | # Birth Date to Astrological Sign
# Convert a birth date into its zodiac sign
# Read the date from user
birth_month = input("Enter your month of birth: ").lower()
birth_day = int(input("Enter your day of birth: "))
# Find the zodiac sign
if (birth_month == 'december' and birth_day >= 22) or (birth_month == 'january'... | true |
cc33896b761eba91b55e31d018a0b90fcfc46321 | effedib/the-python-workbook-2 | /Chap_05/Ex_113.py | 504 | 4.28125 | 4 | # Avoiding Duplicates
# Read words from the user and display each word entered exactly once
# Read the first word from the user
word = input("Enter a word (blank to quit): ")
# Create an empty list
list_words = []
# Loop to append words into the list until blank is entered and if is not a duplicate
while word != ''... | true |
2acaac01a17a6d6f066b5f0a07cd1d59c8edccf1 | effedib/the-python-workbook-2 | /Chap_03/Ex_69.py | 708 | 4.1875 | 4 | # Admission Price
# Compute the admission cost for a group of people according to their ages
# Read the fist age
first_age = input("Enter the age of the first person: ")
# Set up the total
total_cost = 0
age = first_age
while age != "":
# Cast age to int type
age = int(age)
# Check the cost
if age ... | true |
dcbcbadbe3b33e0e50b792d7dafb00039f7ac41a | effedib/the-python-workbook-2 | /Chap_08/Ex_183.py | 1,706 | 4.21875 | 4 | # Element Sequences
# This program reads the name of an element from the user and uses a recursive function to find the longest
# sequence of elements that begins with that value
# @param element is the element entered by the user
# @param elem_list is the list of elements to check to create the sequence
# @return t... | true |
95cffa4e93b281b5534b209ec831400b7c320de7 | effedib/the-python-workbook-2 | /Chap_04/Ex_99.py | 463 | 4.21875 | 4 | # Next Prime
# This function finds and returns the first prime number larger than some integer, n.
def nextPrime(num: int):
from Ex_98 import isPrime
prime_num = num + 1
while isPrime(prime_num) is False:
prime_num += 1
return prime_num
def main():
number = int(input("Enter a non negati... | true |
aaa01b2ce41701e351067b0ea953db842e7a391f | effedib/the-python-workbook-2 | /Chap_03/Ex_84.py | 784 | 4.3125 | 4 | # Coin Flip Simulation
# Flip simulated coins until either 3 consecutive faces occur, display the number of flips needed each time and the average number of flips needed
from random import choices
coins = ('H', 'T')
counter_tot = 0
for i in range(10):
prev_flip = choices(coins)
print(prev_flip[0], end=" ")
... | true |
ecc22e65773bcc269fbd5fcc18abff21ab301162 | effedib/the-python-workbook-2 | /Chap_04/Ex_95.py | 734 | 4.1875 | 4 | # Capitalize It
# This function takes a string as its only parameter and returns a new copy of the string that has been correctly capitalized.
def Capital(string: str) -> str:
marks = (".", "!", "?")
new_string = ""
first = True
for i, c in enumerate(string):
if c != " " and first is True:
... | true |
c0e3387fb01e402d647e3c7954a4d8ccba653f6f | effedib/the-python-workbook-2 | /Chap_01/Ex_22.py | 325 | 4.34375 | 4 | import math
s1 = float(input('Enter the length of the first side of the triangle:'))
s2 = float(input('Enter the length of the second side of the triangle:'))
s3 = float(input('Enter the length of the third side of the triangle:'))
s = (s1+s2+s3)/2
A = math.sqrt(s*(s-s1)*(s-s2)*(s-s3))
print('The area of the triangle i... | true |
d41046ceabddad69bcbf57fdf7cad495c3a2b6d0 | effedib/the-python-workbook-2 | /Chap_03/Ex_76.py | 908 | 4.1875 | 4 | # Multiple Word Palindromes
# Extend the solution to EX 75 to ignore spacing, punctuation marks and treats uppercase and lowercase as equivalent
# in a phrase
# Make a tuple to recognize only the letters
letters = (
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
... | true |
4259b2e9d383daf2f189f50f7e40923b3354b1ae | effedib/the-python-workbook-2 | /Chap_08/Ex_182.py | 2,174 | 4.21875 | 4 | # Spelling with Element Symbols
# This function determines whether or not a word can be spelled using only element symbols.
# @param word is the word to check
# @param sym is the list of symbols to combine to create the word
# @param result is the string to return at the end, it was initialized as empty string
# @pa... | true |
edbe35d0172d1c78007e551e10f97d53ac12cee4 | axelniklasson/adventofcode | /2017/day4/part2.py | 1,640 | 4.34375 | 4 | # --- Part Two ---
# For added security, yet another system policy has been put in place. Now, a valid passphrase must contain no two words that are anagrams of each other - that is, a passphrase is invalid if any word's letters can be rearranged to form any other word in the passphrase.
# For example:
# abcde fghij... | true |
bcd5658e96365509fc455058cdb7d7a7fc7109c2 | couchjd/School_Projects | /Python/EXTRA CREDIT/6PX_12.py | 2,279 | 4.25 | 4 | #12 Rock, Paper, Scissors Game
import random
import time
def numberGen(): #generates a random value to be used as the computer's choice
random.seed(time.localtime())
return random.randrange(1,3)
def compare(compChoice, userChoice): #compares user choice vs computer choice
compDict = {1:'rock', 2:'pa... | true |
dee422c3e12ec0314c0e72fe187454934fd3104e | couchjd/School_Projects | /Python/EXTRA CREDIT/6PX_5.py | 394 | 4.15625 | 4 | #5 Kinetic Energy
def kinetic_energy(mass, velocity):
kEnergy = ((1/2)*mass*velocity**2) #calculates kinetic energy, given a
return kEnergy #mass and velocity
def main():
print("The kinetic energy is %.2f joules." %
kinetic_energy(float(input("Enter mass of object: ")),
... | true |
0cb19f7f08eafd81fcffed36d46a2a7ac42eda3a | MandipGurung233/Decimal-to-Binary-and-vice-versa-conversion-and-adding | /validatingData.py | 2,976 | 4.25 | 4 | ## This file is for validating the entered number from the user. When user are asked to enter certain int number then they may enter string data type
## so if such cases are not handled then their may occur run-time error, hence this is the file to handle such error where there is four different function..:)
de... | true |
73ef198d2a47801f75df1a48393244febed9e85a | daneven/Python-programming-exercises | /Exersise_4.py | 1,034 | 4.34375 | 4 | #!/usr/bin/python3
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'''
@Filename : Exersises
@Date : 2020-10-28-20-31
@Project: Python-programming-exercises
@AUTHOR : Dan Even
'''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'''
Question 4
Level 1
Question:
Write ... | true |
e1bf679159088e4653f0c21ebac8311e63b6b304 | daneven/Python-programming-exercises | /Exersise_5.py | 1,104 | 4.375 | 4 | #!/usr/bin/python3
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'''
@Filename : Exersises
@Date : 2020-10-28-20-31
@Project: Python-programming-exercises
@AUTHOR : Dan Even
'''
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'''
Question 5
Level 1
Question:
Define... | true |
386a08d884f31869297b8579cd3e2742bfe796a7 | dragomir-parvanov/VUTP-Python-Exercises | /03/2-simple-calculator.py | 1,049 | 4.375 | 4 | # Python Program to Make a Simple Calculator
def applyOperator(number1, operator,number2):
if currentOperator == "+":
number1 += float(number2)
elif currentOperator == "-":
number1 -= float(number2)
elif currentOperator == "*":
number1 *= float(number2)
elif currentO... | true |
e937a40b941f9599bcd2ecf407d8cc03376403b4 | dragomir-parvanov/VUTP-Python-Exercises | /02/8-negative-positive-or-zero.py | 237 | 4.40625 | 4 | # Check if a Number is Positive, Negative or 0
numberInput = int(input("Enter a number: "))
if numberInput > 0:
print("Number is Positive")
elif numberInput < 0:
print("Number is negative")
else:
print("Number is 0(ZERO)")
| true |
88ff525e751b4e21af01de0d2aa9cc52d988ed40 | da1dude/Python | /OddOrEven.py | 301 | 4.28125 | 4 | num1 = int(input('Please enter a number: ')) #only allows intigers for input: int()
check = num1 % 2 # Mudelo % checks if there is a remainder based on the number dividing it. In this case 2 to check if even or odd
if check == 0:
print('The number is even!')
else:
print('The number is odd!') | true |
b9bd153886194726840fa940231afed161399585 | andrew5205/Python_cheatsheet | /string_formatting.py | 712 | 4.15625 | 4 |
name = "Doe"
print("my name is John %s !" %name)
age = 23
print("my name is %s, and I am %d years old" %(name, age))
data = ["Jonh", "Doe", 23]
format_string = "Hello {} {}. Your are now {} years old"
print(format_string.format(data[0], data[1], data[2]))
# tuple is a collection of objects which ordered and i... | true |
0edbe19fc1c3b187309f943ad7c1c1c18383c733 | ersmindia/accion-sf-qe | /workshop_ex1.py | 697 | 4.25 | 4 | '''Exercise 1:
A) Create a program that asks the user to enter their name and their age. Print out a message that tells them the year that they will turn 50 and 100 years old.
B)Add on to the previous program by asking the user for another number and printing out that many copies of the previous message.
'''
from date... | true |
d08c53ba5fe5c06c84b199b253554cfb6cecdc80 | standrewscollege2018/2019-year-13-classwork-ostory5098 | /Object orientation Oscar.py | 1,608 | 4.6875 | 5 | # This is an intro to Object orientation
class Enemy:
""" This class contains all the enemies that we will fight.
It has attributes for life and name, as well as functions
that decrease its health and check its life. """
def __init__(self, name, life):
""" the init function runs automat... | true |
a3d457ff813c70b7e43e6903222308eaae6ff7ae | FreeTymeKiyan/DAA | /ClosestPair/ClosestPair.py | 2,642 | 4.4375 | 4 | # python
# implement a divide and conquer closest pair algorithm
# 1. check read and parse .txt file
# 2. use the parsed result as the input
# 3. find the closest pair in these input points
# 4. output the closest pair and the distance between the pair
# output format
# The closest pair is (x1, x2) and (y1, y2).
# The ... | true |
7e5f9155c0e22abb671c826d940da51c3ba46294 | danmaher067/week4 | /LinearRegression.py | 985 | 4.1875 | 4 | # manual function to predict the y or f(x) value power of the input value speed of a wind turbine.
# Import linear_model from sklearn.
import matplotlib.pyplot as plt
import numpy as np
# Let's use pandas to read a csv file and organise our data.
import pandas as pd
import sklearn.linear_model as lm
# read the datase... | true |
56635b0819e7cdbc8b96ec68bb4de313ca0da587 | Woobs8/data_structures_and_algorithms | /Python/Sorting/bubble_sort.py | 2,850 | 4.1875 | 4 | import argparse
import timeit
from functools import partial
import random
from sorting import BaseSort
class BubbleSort(BaseSort):
"""
A class used to encapsulate the Bubble Sort algorithm
Attributes
----------
-
Methods
-------
sort(arr, in_place=False)
Sorts an array using ... | true |
2e6ebd01b1e1e5b508501d5a2536d5b85883af23 | lbray/Python-3-Examples | /file-analyzer.py | 370 | 4.28125 | 4 | # Program returns the number of times a user-specified character
# appears in a user-specified file
def char_count(text, char):
count = 0
for c in text:
if c == char:
count += 1
return count
filename = input("Enter file name: ")
charname = input ("Enter character to analyze: ")
with open(filename) as f:
da... | true |
281085709d44facc168cbb6324aa7429bc36f9ce | macoopman/Python_DataStructures_Algorithms | /Recursion/Projects/find.py | 1,934 | 4.15625 | 4 | """
Implement a recrsive function with the signature find(path, name) that reports
all entries of the file system rooted at the given path having the given file name
"""
import os, sys
def find(path, name):
"""
find and return list of all matches in the given path
"""
found = [] ... | true |
83046855b03c830defd9e840123d8a6abe0d44f5 | macoopman/Python_DataStructures_Algorithms | /Recursion/Examples/Linear_Recursion/recursive_binary_search.py | 968 | 4.25 | 4 | """
Recursive Binary Search:
locate a target value within a "sorted" sequence of n elements
Three Cases:
- target == data[mid] - found
- target < data[mid] - recur the first half of the sequence
- target > data[mid] - recur the last half of the sequence
Runtime => O(log n)
"""
def binary_search(data, targ... | true |
008317fe6ca28ef600fc024c049a39c6bf7db163 | myszunimpossibru/shapes | /rectangles.py | 1,843 | 4.25 | 4 | # coding: utf8
from shape import Shape
import pygame
class Rectangle(Shape):
"""
Class for creating the rectangular shape
Parameters:
pos: tuple
Tuple of form (x, y) describing the position of the rectangle on the screen.
Reminder: PyGame sets point (0, 0) as the upper lef... | true |
fe0d6c09f4eacfc2d14944e9a7661ad7d1658a3a | rufi91/sw800-Coursework | /ML-14/ex.py | 1,442 | 4.21875 | 4 | """
1) Implement MLPClassifier for iris dataset in sklearn.
a. Print confusion matrix for different activation functions
b. Study the reduction in loss based on the number of iterations.
2) Implement MLPRegressor for boston dataset in sklearn . Print performance
metrics like RMSE, MAE , etc.
"""
from sklearn.neural_ne... | true |
6049135043f6aa6b446c2856ee89cee66e7f706f | rufi91/sw800-Coursework | /Python/py-24/ex.py | 2,164 | 4.375 | 4 | """
Open python interpreter/ipython and do the following.
0.import pandas
1.create a dataframe object from a (10,4)2D array consisting of random integers between 10 and 20 by making c1,c2,c3,c4 as column indices.
2.Sort the above oject based on the key 'c1' in ascending and then by 'c3' in descending order.
"""... | true |
e7b8ac86e23d9ddd1a03dba8f75789e4b3288b57 | nshoa99/Leetcode | /List/1324.py | 1,268 | 4.1875 | 4 | '''
Medium
Given a string s. Return all the words vertically in the same order in which they appear in s.
Words are returned as a list of strings, complete with spaces when is necessary. (Trailing spaces are not allowed).
Each word would be put on only one column and that in one column there will be only one word.
... | true |
076ac8dcc7af8424b0e1b5fb4da98a8b9a9478c3 | nshoa99/Leetcode | /String/524.py | 1,338 | 4.1875 | 4 | '''
Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, return the longest word with the smallest lexicographical order. If there is no possible result, return the empty string.... | true |
ee64bbec7eee7449b7d526f5147d749b07942740 | haroldhyun/Algorithm | /Sorting/Mergesort.py | 1,998 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 7 20:04:26 2021
@author: Harold
"""
def Mergesort(number):
"""
Parameters
----------
number : list or array of numbers to be sorted
Returns
-------
sorted list or array of number
"""
# First divide the... | true |
a985d1439e1f07522b6d141260b8e299278e045b | Kritika05802/DataStructures | /area of circle.py | 235 | 4.21875 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[3]:
radius = float(input("Enter the radius of the circle: "))
area = 3.14 * (radius) * (radius)
print("The area of the circle with radius "+ str(radius) +" is " + str(area))
# In[ ]:
| true |
f066e25dd7044e0a2e7fb37a9f0729e6190c38e7 | prd-dahal/sem4_lab_work | /toc/lab7.py | 684 | 4.5625 | 5 | #Write a program for DFA that accepts all the string ending with 3 a's over {a,b}\#Write a program for DFA that accepts the strings over (a,b) having even number of a's and b's
def q0(x):
if(x=='a'):
return q1
else:
return q0
def q1(x):
if(x=='a'):
return q2
else:
return q0
d... | true |
0b7c2b351c39fa1b718a156eb41ffc9e19b9382e | felixguerrero12/operationPython | /learnPython/ex12_Prompting_asking.py | 397 | 4.1875 | 4 | # -*- coding: utf-8 -*-
# Created on July 27th
# Felix Guerrero
# Exercise 12 - Prompting - Learn python the hard way.
#Creating Variables with Direct Raw_Input
age = raw_input("How old are you? \n")
height = raw_input("How tall are you? \n")
weight = raw_input("How much do you weight? \n")
# Print Variables
print "... | true |
3a069734693a40536828bdaf82eb3db7188d5e2e | felixguerrero12/operationPython | /learnPython/ex03_Numbers_And_Variable_01.py | 703 | 4.34375 | 4 | # Created on July 26th
# Felix Guerrero
# Exercise 3 - Numbers and math - Learn python the hard way.
#Counting the chickens
print "I will now count my chickens:"
print "Hens", 25 + 30 / 6
print "Roosters", 100 - 25 * 3 % 4
#Counting the eggs
print "Now I will count the eggs:"
print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6
... | true |
840747d89d7f2d84c7b819b5d26aa4ac1ea93254 | felixguerrero12/operationPython | /learnPython/ex15_Reading_Files.py | 739 | 4.25 | 4 | # Felix Guerrero
# Example 15 - Reading Files
# June 28th, 2016
# Import the sys package and import the arguement module
from sys import argv
# The first two command line arguements in the variable will be
# these variables
script, filename = argv
# 1. Open up variable filename
# 2. Give the content of the file to t... | true |
451700ee74f47681206b30f81e7c61b80c798f8c | ChiefTripodBear/PythonCourse | /Section7/utils/database.py | 1,803 | 4.1875 | 4 | import sqlite3
"""
Concerned with storing and retrieving books from a list.
Format of the csv file:
[
{
'name': 'Clean Code',
'author': 'Robert',
'read': True
}
]
"""
def create_book_table():
connection = sqlite3.connect('Section7/da... | true |
625707a1917c8f1e91e3fd9f2ee4a51102f27af5 | golddiamonds/LinkedList | /LinkedList.py | 2,790 | 4.28125 | 4 | ##simple linked list and node class written in python
#create the "Node" structure
class Node:
def __init__(self, data, next_node=None):
self.data = data
self.next_node = next_node
def getData(self):
return self.data
#create the structure to hold information about the list
#including ... | true |
3d289735bca17f15a1e100fdaa01b4a86b871a25 | emuyuu/design_pattern | /3_behavioral_design_patterns/iterator_pattern.py | 1,704 | 4.59375 | 5 | # iterate = 繰り返す
# Iterator:
# > Anything that is iterable can be iterated,
# > including dictionaries, lists, tuples, strings, streams, generators, and classes
# > for which you implement iterator syntax.
# 引用:http://ginstrom.com/scribbles/2007/10/08/design-patterns-python-style/
# ----------------------------------... | true |
99a214e31f4f1251f04f6f66fb4c96ef57049873 | crashley1992/Alarm-Clock | /alarm.py | 2,189 | 4.28125 | 4 | import time
from datetime import datetime
import winsound
# gets current time
result = time.localtime()
# setting varable for hour, minute, seconds so it can be added to user input
current_hour = result.tm_hour
current_min = result.tm_min
current_sec = result.tm_sec
# test to make sure format is correct
print(f'{cur... | true |
cf823ebcf1c564bef2ed6103588b2ff8ed1e86da | donrax/point-manipulation | /point_side_line.py | 623 | 4.34375 | 4 | import numpy as np
def point_side_line(p1, p2, p):
"""
Computes on which side of the line the point lies.
:param p1: [numpy ndarray] start of line segment
:param p2: [numpy ndarray] end of line segment
:param p: [numpy ndarray] point
:return: 1 = LEFT side, 0 = ON the line, -1 = RIGHT side
... | true |
e562b59876199bf03b6aa533afe98f5f8d385fd5 | Meethlaksh/Python | /again.py | 1,899 | 4.1875 | 4 | #Write a python function to find the max of three numbers.
def m1(l):
d = max(l)
return d
l = [1,2,3,4,5]
print(m1(l))
#Write a python function to sum up all the items in a list
def s1(s):
e = sum(s)
return e
s = [1,2,3,4,5]
print(s1(s))
#multiply all the items in a list
import math
def mul1(x):
... | true |
baff5161fd319ce26fd9d5de0e68078885b9983e | Meethlaksh/Python | /studentclass.py | 985 | 4.125 | 4 | """Create a Student class and initialize it with name and roll number. Make methods to :
1. Display - It should display all informations of the student.
2. setAge - It should assign age to student
3. setMarks - It should assign marks to the student.
"""
"""
keywords:
parameter
methods
difference between functions and m... | true |
58a96988ee925d1c65148817e500a3dee2e0216d | kylastyles/Python1000-Practice-Activities | /PR1000_03/PR03_HexReaderWriter.py | 970 | 4.40625 | 4 | #!usr/bin/env python3
# Problem Domain: Integral Conversion
# Mission Summary: Convert String / Integral Formats
user_string = input("Please enter a string to encode in hexadecimal notation: ")
def hex_writer(user_string):
hex_string = ""
if user_string == "":
return None
for char in user_stri... | true |
2e8fb160337f084912b9ed384f11891ab01fe63e | AwjTay/Python-book-practice | /ex4.py | 1,207 | 4.25 | 4 | # define the variable cars
cars = 100
# define the variable space_in_a_car
space_in_a_car = 4.0
# define the variable drivers
drivers = 30
# define the variable passengers
passengers = 90
# define the variable cars_not_driven
cars_not_driven = cars - drivers
# define the variable cars_driven as equal to drivers
ca... | true |
72cb7e9d73041025ecd0e17490fb4cf1dcf1b508 | jw0711qt/Lab4camelcase | /Lab4_camelCase.py | 641 | 4.3125 | 4 | def camel_case(sentence):
if sentence.isnumeric(): #if statment handling empty and numeric number
return 'enter only words'
elif sentence=="":
return 'please enter your input'
else:
split_sentence=sentence.split() #for loop handling the camel case.
cap_sentence=[split_senten... | true |
2f5eeabbad6d9f7cc4a53e85da174af7ab891002 | tushushu/pads | /pads/sort/select_sort.py | 1,315 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
@Author: tushushu
@Date: 2018-09-10 22:23:11
@Last Modified by: tushushu
@Last Modified time: 2018-09-10 22:23:11
"""
def _select_sort_asc(nums):
"""Ascending select sort.
Arguments:
nums {list} -- 1d list with int or float.
Returns:
list -- List in ascendin... | true |
7fd24f06f3e47581d35635e1767bc230da26b20b | NortheastState/CITC1301 | /chapter10/Course1301.py | 1,507 | 4.1875 | 4 | # ===============================================================
#
# Name: David Blair
# Date: 04/14/2018
# Course: CITC 1301
# Section: A70
# Description: You can think of this Python file as a "driver"
# that tests the Student class. It can also be
# thought of as a... | true |
475cee6f9b8424e9028087a90c96fc1c6c69a2e8 | NortheastState/CITC1301 | /chapter1/foobar.py | 964 | 4.21875 | 4 | # ===============================================================
#
# Name: David Blair
# Date: 01/01/2018
# Course: CITC 1301
# Section: A70
# Description: In the program we will examine simple output
# using a function definition with no parameters
# and a print statem... | true |
9bc5bf07fbc4a04940394c23bfd0d0116422749e | sahilg50/Python_DSA | /Array/reverse_array.py | 782 | 4.3125 | 4 | #Function to reverse the array
def reverse(array):
if(len(array)==0):
return ("The array is empty!")
L = 0
R = len(array)-1
while(L!=R and L<R):
array[R], array[L] = array[L], array[R]
L+=1
R-=1
return array
#Ma... | true |
8a962ec652a3d239af3a3b860cf7663ab173c070 | sahilg50/Python_DSA | /Array/Max_Min_in_Array.py | 1,463 | 4.28125 | 4 | # Find the maximum and minimum element in an array
def get_min_max(low, high, array):
"""
(Tournament Method) Recursive method to get min max.
Divide the array into two parts and compare the maximums and minimums of the two parts to get the maximum and the minimum of the whole array.
"""
# If arr... | true |
7b62197a3a0395b563b62d68bc34066d8fa2643f | Libbybacon/Python_Projects | /myDB.db.py | 1,068 | 4.125 | 4 | # This script creates a new database and adds certain files from a given list into it.
import sqlite3
conn = sqlite3.connect('filesDB.db')
fileList = ('information.docx','Hello.txt','myImage.png', \
'myMovie.mpg','World.txt','data.pdf','myPhoto.jpg')
# Create a new table with two fields in filesDB datab... | true |
8f1507a5140d329d2234f13fe0987291a7ff4df5 | Libbybacon/Python_Projects | /buildingClass2.py | 2,665 | 4.25 | 4 |
# Parent class Building
class Building:
# Define attributes:
numberSides = 4
numberLevels = 1
architectureType = 'unknown'
primaryUse = 'unknown'
energyEfficient = True
def getBuildingDetails(self):
numberSides = input("How many sides does the building have?\n>>> ")
number... | true |
3f2884d5da68f9fc7f684e63ed5a8a2144f0f39f | agrepravin/algorithms | /Sorting/MergeSort.py | 1,193 | 4.15625 | 4 | # Merge sort follows divide-conquer method to achieve sorting
# As it divides array into half until one item is left these is done in O(log n) time complexity
# While merging it linear compare items and merge in order which is achieved in O(n) time complexity
# Total time complexity for MergeSort is O(n log n) in all t... | true |
612e527762f60567874da66187cdaecf1063874e | khch1997/hw-python | /timing.py | 462 | 4.125 | 4 | import time
def calculate_time(func):
"""
Calculate and print the time to run a function in seconds.
Parameters
----------
func : function
The function to run
Examples
--------
def func():
time.sleep(2)
>>> calculate_time(func)
2.0001738937
"""
def wra... | true |
6c0d5375fda176642668a007e65f8ae9f4c21e4a | josgard94/CaesarCipher | /CesarEncryption.py | 1,915 | 4.53125 | 5 | """
Author: Edgard Diaz
Date: 18th March 2020
In this class, the methods of encrypting and decrypting the plain
text file using modular arithmetic are implemented to move the original
message n times and thus make it unreadable in the case of encryption,
the same process is performed for decryption usi... | true |
f9b109cc9d356431ae79bf53b635889cd56465f3 | Kertich/Linked-List | /linkedList.py | 777 | 4.15625 | 4 | # Node class
class Node:
def __init__(self, value):
self.value = value
self.next = None
class LinkedList:
def __init__(self):
self.start = None
# Inserting in the Linked List
def insert(self, value):
if self.start == None:
self.start = Node(value)
... | true |
47321ae0df841cdc0c790d1692b65d9411aa8f7d | Croxy/The-Modern-Python-Bootcamp | /Section 10: Loops/examples/whileExample1.py | 332 | 4.28125 | 4 |
# Use a while loop to check user input matches a specific value.
msg = input("what is the secret password?")
while msg != "bananas":
print("WRONG!")
msg = input("what is the secret password?")
print("CORRECT!")
# Use a while loop to create for loop functionality.
num = 1
while num < 11:
print(num)
n... | true |
ba30a449793ff270e61284e1d4598629647f5681 | pradeepraja2097/Python | /python basic programs/arguments.py | 543 | 4.1875 | 4 | '''
create a function for adding two variables. It will be needed to calculate p=y+z
'''
def calculateP( y , z ) :
return int( y ) + int( z )
'''
create a function for multiplying two variables. It will be needed to calculate p=y+z
'''
def calculateResult( x, p ) :
return int( x ) * int( p )
#Now this... | true |
23f95e08d2678366d97400ade96b85453ce265e5 | EdwinaWilliams/MachineLearningCourseScripts | /Python/Dice Game.py | 484 | 4.28125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Jan 10 22:18:01 2019
@author: edwinaw
"""
import random
#variable declaration
min = 1
max = 6
roll = "yes"
while roll == "yes" or roll == "y":
print("Rolling the dices...")
dice = random.randint(min, max)
#Printing the random number generated
print("Yo... | true |
69237dabe784446234868c8f59c6e1b0173c8df5 | hfu3/codingbat | /logic-1/date_fashion.py | 719 | 4.28125 | 4 | """
You and your date are trying to get a table at a restaurant.
The parameter "you" is the stylishness of your clothes,
in the range 0..10, and "date" is the stylishness of your
date's clothes. The result getting the table is encoded
as an int value with 0=no, 1=maybe, 2=yes. If either of
you is very styli... | true |
4505f8a1fe1c9cc5b04a326896c1648ec5415fee | jmockbee/While-Blocks | /blocks.py | 390 | 4.1875 | 4 | blocks = int(input("Enter the number of blocks: "))
height = 0
rows = 1
while rows <= blocks:
height += 1
# is the height +1
blocks -= rows
#blocks - rows
if blocks <= rows:
break
# while the rows are less than the blocks keep going.
# if the rows become greater than the blocks... | true |
e9bb62ab1fceeb98599946ef6a0c00650baa5d29 | ioannispol/Py_projects | /maths/main.py | 2,337 | 4.34375 | 4 | """
Ioannis Polymenis
Main script to calculate the Area of shapes
There are six different shapes:
- square
- rectangle
- triangle
- circle
- rhombus
- trapezoid
"""
import os
import class_area as ca
def main():
while True:
os.system('cls')
print("*" * 30)
print("... | true |
e467818f8fe5e8099aaa6fb3a9c10853ff92b00b | wiznikvibe/python_mk0 | /tip_calci.py | 610 | 4.25 | 4 | print("Welcome to Tip Calculator")
total_bill = input("What is the total bill?\nRs. ")
tip_percent = input("What percent tip would you like to give? 10, 12, 15?\n ")
per_head = input("How many people to split the bill?\n")
total_bill1 = float(total_bill)
(total_bill)
tip_percent1 = int(tip_percent)
per_head1 = i... | true |
0e4cf1b1837a858cfb92830fa38c93879980b80c | sifisom12/level-0-coding-challenges | /level_0_coding_task05.py | 447 | 4.34375 | 4 | import math
def area_of_a_triangle (side1, side2, side3):
"""
Calculating the area of a triangle using the semiperimeter method
"""
semiperimeter = 1/2 * (side1 + side2 + side3)
area = math.sqrt(semiperimeter* ((semiperimeter - side1) * (semiperimeter - side2) * (semiperimeter - side3)))
... | true |
110ca5d0377417a8046664b114cfd28140827ed4 | christinalycoris/Python | /arithmetic_loop.py | 1,741 | 4.34375 | 4 | import math
print ("This program will compute addition, subtraction,\n"
"multiplication, or division. The user will\n"
"provide two inputs. The inputs could be any real\n"
"numbers. This program will not compute complex\n"
"numbers. The program will run until the user\n"
"chooses to terminate the program. Th... | true |
224d9fa0622c1b7509f205fa3579a4b42a8a73a6 | MurasatoNaoya/Python-Fundamentals- | /Python Object and Data Structure Basics/Print Formatting.py | 1,397 | 4.59375 | 5 | # Print Formatting ( String Interpolation ) -
# .format method -
print('This is a string {}'.format('okay.')) # The curly braces are placeholders for the variables that you want to input.
# Unless specified otherwise, the string will be formatted in the order you put them in your .format function.
print('T... | true |
f62dd5c65eb6c397c7aa0d0557192b8a53768591 | lxmambo/caleb-curry-python | /60-sets.py | 557 | 4.15625 | 4 | items = {"sword","rubber duck", "slice of pizza"}
#a set cannot have duplicates
items.add("sword")
print(items)
#what we want to put in the set must be hashable, lists are not
conjunctions = {"for","and","nor","but","or","yet","so"}
seen = set()
copletely_original_poem = """yet more two more times
i feel nor but or bu... | true |
390e46a938f9b7f819a9e59f517a9de9848b387e | lxmambo/caleb-curry-python | /25-reverse-list-w-slice.py | 308 | 4.15625 | 4 | data = ["a","b","c","d","e","f","g","h"]
#prints every 2 items
print(data[::2])
#prints reversed
print(data[::-1])
data_reversed = data
data[:] = data[::-1]
print(data)
print(id(data))
print(id(data_reversed))
#doint the slice like this changes only the content of the list
#but doesn't change de list... | true |
02d504e4b5a9658e643c3d10a5dc13b7a2e427f5 | yennanliu/CS_basics | /leetcode_python/Hash_table/group-shifted-strings.py | 2,917 | 4.21875 | 4 | """
Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequence:
"abc" -> "bcd" -> ... -> "xyz"
Given a list of strings which contains only lowercase alphabets, group all strings that belong to the same shifting sequence.
For... | true |
4e2a77b9611c8885a882a290dc99070f53655c49 | yennanliu/CS_basics | /leetcode_python/Dynamic_Programming/best-time-to-buy-and-sell-stock-iii.py | 2,900 | 4.15625 | 4 | """
123. Best Time to Buy and Sell Stock III
Hard
You are given an array prices where prices[i] is the price of a given stock on the ith day.
Find the maximum profit you can achieve. You may complete at most two transactions.
Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the ... | true |
e21178720f6c4a17fd9efa5a90062082a6c94655 | Guimez/SecsConverter | /SecondsConverter.py | 1,067 | 4.46875 | 4 | print()
print("===============================================================================")
print("This program converts a value in seconds to days, hours, minutes and seconds.")
print("===============================================================================")
print()
Input = int(input("Please, enter a val... | true |
b18737a279e3b4511d708ae94bd53bc59a2be024 | datastarteu/python-edh | /Lecture 1/Lecture.py | 2,367 | 4.28125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Oct 10 18:00:20 2017
@author: Pablo Maldonado
"""
# The "compulsory" Hello world program
print("Hello World")
###########################
### Data types
###########################
## What kind of stuff can we work with?
# First tipe: Boolean
x = True
y = 100 < 10
y
x*y
x+... | true |
e2bb2d975de5ede39c8393da03e9ad7f48a19b7f | TenzinJam/pythonPractice | /freeCodeCamp1/try_except.py | 1,080 | 4.5 | 4 | #try-except block
# it's pretty similar to try catch in javascript
# this can also help with some mathematical operations that's not valid. such as 10/3. It will go through the except code and print invalid input. The input was valid because it was a number, but mathematically it was not possible to compute that number... | true |
c1c368937073a6f68e60d72a72d5c5f36f0243c1 | kristinnk18/NEW | /Project_1/Project_1_uppkast_1.py | 1,481 | 4.25 | 4 |
balance = input("Input the cost of the item in $: ")
balance = float(balance)
x = 2500
monthly_payment_rate = input("Input the monthly payment in $: ")
monthly_payment_rate = float(monthly_payment_rate)
monthly_payment = monthly_payment_rate
while balance < x:
if balance <= 1000:
for month in range(1, ... | true |
06119d936bbe22687f7b163aee7cda895eae7957 | kristinnk18/NEW | /Skipanir/whileLoops/Timi_3_2.py | 327 | 4.1875 | 4 | #Write a program using a while statement, that given the number n as input, prints the first n odd numbers starting from 1.
#For example if the input is
#4
#The output will be:
#1
#3
#5
#7
num = int(input("Input an int: "))
count = 0
odd_number = 1
while count < num:
print(odd_number)
odd_number += 2
cou... | true |
5bb9558126505e69beda2cfb5e076e33a7cffa48 | kristinnk18/NEW | /Skipanir/whileLoops/Timi_3_6.py | 426 | 4.125 | 4 | #Write a program using a while statement, that prints out the two-digit number such that when you square it,
# the resulting three-digit number has its rightmost two digits the same as the original two-digit number.
# That is, for a number in the form AB:
# AB * AB = CAB, for some C.
count = 10
while count <= 10... | true |
8d51a0547e26c0a4944ff04866cc37fd83c2ad35 | kristinnk18/NEW | /Skipanir/Lists/pascalsTriangle.py | 444 | 4.1875 | 4 | def make_new_row(x):
new_list = []
if x == []:
return [1]
elif x == [1]:
return [1,1]
new_list.append(1)
for i in range(len(x)-1):
new_list.append(x[i]+x[i+1])
new_list.append(1)
return new_list
# Main program starts here - DO NOT CHANGE
height = int(input("Height o... | true |
26f7474ef39d8d92a78e605b92bdb46e73b77e45 | Bioluwatifemi/Assignment | /assignment.py | 345 | 4.15625 | 4 | my_dict = {}
length = int(input('Enter a number: '))
for num in range(1, length+1):
my_dict.update({num:num*num})
print(my_dict)
numbers = {2:4, 3:9, 4:16}
numbers2 = {}
your_num = int(input('Enter a number: '))
for key,value in numbers.items():
numbers2.update({key*your_num:value*you... | true |
7028471a2d611b32767fb9d62a2acaab98edb281 | free4hny/network_security | /encryption.py | 2,243 | 4.5625 | 5 | #Key Generation
print("Please enter the Caesar Cipher key that you would like to use. Please enter a number between 1 and 25 (both inclusive).")
key = int(input())
while key < 1 or key > 25:
print(" Unfortunately, you have entered an invalid key. Please enter a number between 1 and 25 (both inclusive) only.")
... | true |
aacace9f445f6f26d1f1e12c1e38802cb4d58c69 | Kiara-Marie/ProjectEuler | /4 (palindrome 3digit product).py | 706 | 4.34375 | 4 | def isPalindrome(x):
"Produces true if the given number is a palindrome"
sx = str(x) # a string version of the given number
lx = len(sx) # the number of digits in the given number
n = lx - 1
m = 0
while 5 == 5:
if sx[m] != sx[n] :
return (False)
break
elif... | true |
a09f7b9417baef1b2635f3ba4245b503f493f14d | AaqibAhamed/Python-from-Begining | /ifpyth.py | 419 | 4.25 | 4 | responds= input('Do You Like Python ?(yes/no):')
if responds == "yes" or responds == "YES" or responds == "Yes" or responds== "Y" or responds== "y" :
print("you are on the right course")
elif responds == "no" or responds == "NO" or responds == "No" or responds == "N" or responds == "n" :
print(" y... | true |
8dd72e83e364d450cafab02d2d099a4c3190d5ae | Maker-Mark/python_demo | /example.py | 831 | 4.15625 | 4 |
grocery_list = ["Juice", "Apples", "Potatoes"]
f = 1
for i in grocery_list:
print( "Dont forget to buy " + i + '!')
##Demo on how to look though characters in a string
for x in "diapers":
print(x)
#Conditional loop with a if statment
desktop_app_list = ["OBS", "VMware", "Atom", "QR Generator", "Potato... | true |
ffc172de327a528fe0b4b6266080d16d0012f23c | sentientbyproxy/Python | /JSON_Data.py | 638 | 4.21875 | 4 | # A program to parse JSON data, written in Python 2.7.12.
import urllib
import json
# Prompt for a URL.
# The URL to be used is: http://python-data.dr-chuck.net/comments_312354.json
url = raw_input("Please enter the url: ")
print "Retrieving", url
# Read the JSON data from the URL using urllib.
uh = urllib.urlopen... | true |
cc12ace41f10bfc03fd6fda0bfa7d3d95694768c | Ontefetse-Ditsele/Intro_python | /week_3/cupcake.py | 1,744 | 4.125 | 4 | #Ontefetse Ditsele
#
#19 May 2020
print("Welcome to the 30 second expect rule game--------------------")
print("Answer the following questions by selection from among the options")
ans = input("Did anyone see you(yes/no)\n")
if ans == "yes":
ans = input("Was it a boss/lover/parent?(yes/no)\n")
if ans == "no":
... | true |
d09b3c2711d9df4ea00c917aabfe2c0f191055ee | Ontefetse-Ditsele/Intro_python | /week_3/pi.py | 356 | 4.28125 | 4 | #Ontefetse Ditsele
#
#21 May 2020
from math import sqrt
denominator = sqrt(2)
next_term = 2/denominator
pi = 2 * 2/denominator
while next_term > 1:
denominator = sqrt(2 + denominator)
next_term = 2/denominator
pi *= next_term
print("Approximation of PI is",round(pi,3))
radius = float(input("Enter the radius:... | true |
a61ad782abbf9a3c0f2b76a561c1c190474264e0 | rohini-nubolab/Python-Learning | /dictionary.py | 551 | 4.28125 | 4 | # Create a new dictionary
d = dict() # or d = {}
# Add a key - value pairs to dictionary
d['xyz'] = 123
d['abc'] = 345
# print the whole dictionary
print d
# print only the keys
print d.keys()
# print only values
print d.values()
# iterate over dictionary
for i in d :
print "%s %d" %(i,... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.