blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
f70f72b4d449726be0bb53878d32116d999756f5 | dlingerfelt/DSC-510-Fall2019 | /Steen_DSC510/Assignment 2.1 - Jonathan Steen.py | 1,105 | 4.28125 | 4 | # File: Assignment 2.1 - Jonathan Steen.py
# Name: Jonathan Steen
# Date: 12/2/2019
# Course: DSC510 - Introduction to Programing
# Desc: Program calculates cost of fiber optic installation.
# Usage: The program gets company name,
# number of feet of fiber optic cable, calculate
# installation c... | true |
2155f32ff8af7f310124f09964e576fe5b464398 | dlingerfelt/DSC-510-Fall2019 | /DSC510- Week 5 Nguyen.py | 2,139 | 4.3125 | 4 | '''
File: DSC510-Week 5 Nguyen.py
Name: Chau Nguyen
Date: 1/12/2020
Course: DSC_510 Intro to Programming
Desc: This program helps implement variety of loops and functions.
The program will add, subtract, multiply, divide two numbers and provide the average of multiple numbers input by the user.
'''
def performCa... | true |
7bd2456b0c77f97e11f16454bfa9890c28d93f35 | mun5424/ProgrammingInterviewQuestions | /MergeTwoSortedLinkedLists.py | 1,468 | 4.15625 | 4 | # given two sorted linked lists, merge them into a new sorted linkedlist
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode:
# set iterators
dummy = ListNode(0)
... | true |
b9d16e4a06e0485a6e4e5c26bf4673d063c1eb7e | JaydeepKachare/Python-Classwork | /Session3/Arithematic6.py | 429 | 4.125 | 4 | # addition of two number
def addition(num1, num2):
ans = num1+num2
return ans
num1 = int(input("Enter num1 : "))
num2 = int(input("Enter num2 : "))
ans = addition(num1,num2)
print("Addition : ",ans)
num1 = int(input("Enter num1 : "))
num2 = int(input("Enter num2 : "))
ans = ad... | true |
7ccff781110f6a1cdefcda48c00fca3c9be5e0b6 | AbrahamCain/Python | /PasswordMaker.py | 1,501 | 4.375 | 4 | #Password Fancifier by Cyber_Surfer
#This program takes a cool word or phrase you like and turns it into a decent password
#you can comment out or delete the following 3 lines if using an OS other than Windows
import os
import sys
os.system("color e0") #It basically alters the colors of the terminal
#Enter a passwo... | true |
0f679c78696c3d221458ece5c214502f58449c9d | GuillermoDeLaCruz/python--version3 | /name.py | 726 | 4.4375 | 4 |
#
name = "ada lovelace"
print(name.title())
print(name.upper())
print(name.lower())
# Combining or Concatenating Strings
# Python uses the plus symbol (+) to combine strings
first_name = "ada"
last_name = "lovelace"
full_name = first_name + " " + last_name
print(full_name)
print("Hello, " + full_name.title() + "!")
... | true |
ad8ad997ed8f9103cff43928d968f78201856399 | kevyo23/python-props | /what-a-birth.py | 1,489 | 4.5 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# what-a-birth.py - simple birthday monitor, check and add birthdays
# Kevin Yu on 28/12/2016
birthdays = {'Alice': 'Apr 1', 'Bob': 'Dec 12', 'Carol': 'Mar 4'}
all_months = 'January February March April May June July August September October November December'
while True... | true |
f98aeb7d429aae2a54eaaa52530889c6129ddc57 | Vikas-KM/python-programming | /repr_vs_str.py | 741 | 4.375 | 4 | # __str__ vs __repr__
class Car:
def __init__(self, color, mileage):
self.color = color
self.mileage = mileage
# print and it returns always string
# for easy to read representation
def __str__(self):
return '__str__ : a {self.color} car with {self.mileage} mileage'.format(self... | true |
cbb68b5a739a298268d2f150aa25841ff4156ffe | sp2013/prproject | /Assgn/Linear_Regression2.py | 1,597 | 4.1875 | 4 | '''
Linear_Regression2.py
Implements Gradient Descent Algorithm
'''
import numpy as np
import random
import matplotlib.pyplot as plt
def linear_regression2():
'''
1. Read training data in to input, output array.
2. Initialize theta0 - y intercept, theta1 - slope of line.
3. Repeat f... | true |
5c33baae0e50f099028f50a221f18e0d1437f30a | babzman/Babangida_Abdullahi_day30 | /Babangida_Abdullahi_day30.py | 1,429 | 4.28125 | 4 | def nester(n):
"""Given a string of digits S, This function inserts a minimum number of opening and closing parentheses into it such that the resulting
string is balanced and each digit d is inside exactly d pairs of matching parentheses.Let the nesting of two parentheses within a string be
the substring that oc... | true |
74789b8d7f88978a688db1b902cdb8954f315a22 | AlvinJS/Python-practice | /Group6_grades.py | 747 | 4.15625 | 4 | # Function to hold grade corresponding to score
def determinegrade(score):
if 80 <= score <= 100:
return 'A'
elif 65 <= score <= 79:
return 'B'
elif 64 <= score <= 64:
return 'C'
elif 50 <= score <= 54:
return 'D'
else:
return 'F'
count = 0
# Use range(10... | true |
fab1979adbfa20245e24943f73ba15566cd06f69 | magotheinnocent/Simple_Chatty_Bot | /Simple Chatty Bot/task/bot/bot.py | 1,188 | 4.25 | 4 | print("Hello! My name is Aid.")
print("I was created in 2020.")
print("Please, remind me your name.")
name = str(input())
print(f"What a great name you have, {name}!")
print("Let me guess your age.")
print("Enter remainders of dividing your age by 3, 5 and 7")
remainder1 = int(input())
remainder2 = int(input())
remaind... | true |
fd73641925aa29814156330883df9d132dbcb802 | goodwjsphone/WilliamG-Yr12 | /ACS Prog Tasks/04-Comparision of two.py | 296 | 4.21875 | 4 | #write a program which takes two numbers and output them with the greatest first.
num1 = int(input("Input first number "))
num2 = int(input("Input second number "))
if num1 > num2:
print (num1)
else:
print(num2)
## ACS - You need a comment to show where the end of the if statement is.
| true |
a606701ff19aeb87aa7747cd39d40feb826ccb29 | PhyzXeno/python_pro | /transfer_to_x.py | 991 | 4.25 | 4 | # this piece of code will convert strings like "8D4C2404" into "\x8D\x4C\x24\x04"
# which will then be disassembled by capstone and print the machine code
import sys
from capstone import *
# print("the hex string is " + sys.argv[1])
the_str = sys.argv[1]
def x_encode(str):
the_str_len = len(str)
count = 0
the_x... | true |
de62d877172215f9cbb0b30b24e8009b3485bf47 | cpkoywk/IST664_Natural_Language_Processing | /Lab 1/assignment1.py | 1,148 | 4.21875 | 4 | '''
Steps:
get the text with nltk.corpus.gutenberg.raw()
get the tokens with nltk.word_tokenize()
get the words by using w.lower() to lowercase the tokens
make the frequency distribution with FreqDist
get the 30 top frequency words with most_common(30) and print the word, frequency pairs
'''
#Import required modules
im... | true |
eb9d5ad1a3bb38c87c64f435c2eabd429405ddc3 | niall-oc/things | /codility/odd_occurrences_in_array.py | 2,360 | 4.28125 | 4 | # -*- coding: utf-8 -*-
"""
Author: Niall O'Connor
# https://app.codility.com/programmers/lessons/2-arrays/odd_occurrences_in_array/
A non-empty array A consisting of N integers is given. The array contains an odd
number of elements, and each element of the array can be paired with another
element that has the sam... | true |
db239ae5d7cc670f71e8af8d99bc441f4af2503a | niall-oc/things | /puzzles/movies/movies.py | 2,571 | 4.1875 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Given the following list in a string seperated by \n characters.
Jaws (1975)
Starwars 1977
2001 A Space Odyssey ( 1968 )
Back to the future 1985.
Raiders of the lost ark 1981 .
jurassic park 1993
The Matrix 1999
A fist full of Dollars
10,... | true |
e6ea4c49d3012708cededb29a1f79f575561c82f | niall-oc/things | /codility/frog_jmp.py | 2,058 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Author: Niall O'Connor
# https://app.codility.com/programmers/lessons/3-time_complexity/frog_jmp/
A small frog wants to get to the other side of the road. The frog is currently
located at position X and wants to get to a position greater than or equal to Y.
The small frog always jumps a f... | true |
fdec6fee3a57a11783c40eafcb9125b11e174f51 | Anshu-Singh1998/python-tutorial | /fourty.py | 289 | 4.28125 | 4 | # let us c
# Write a function to calculate the factorial value of any integer enyered
# through the keyboard.
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
n = int(input("Input a number to compute the factorial : "))
print(factorial(n))
| true |
5ca65e5362eca7bf9cfeda1021564e6c20ccb4a5 | Anshu-Singh1998/python-tutorial | /eight.py | 228 | 4.25 | 4 | # let us c
# input a integer through keyboard and find out whether it is even or odd.
a = int(input("Enter a number to find out even or odd:"))
if a % 2 == 0:
print("the number is even")
else:
print("the number is odd")
| true |
4516d98fd3db1d9c9049bb6cb3d1fe18e9e7914b | Anshu-Singh1998/python-tutorial | /nineteen.py | 268 | 4.15625 | 4 | # From internet
# Write a program to remove an element from an existing array.
from array import *
num = list("i", [4, 7, 2, 0, 8, 6])
print("This is the list before it was removed:"+str(num))
print("Lets remove it")
num.remove(2)
print("Removing performed:"+str(num)) | true |
a17e198eeaac4a06b472845f6dffdd2bcf1f74c3 | damsonli/mitx6.00.1x | /Mid_Term/problem7.py | 2,190 | 4.4375 | 4 | '''
Write a function called score that meets the specifications below.
def score(word, f):
"""
word, a string of length > 1 of alphabetical
characters (upper and lowercase)
f, a function that takes in two int arguments and returns an int
Returns the score of word as defined by t... | true |
622b10cab635fa09528ffdeab353bfd42e69bdc7 | damsonli/mitx6.00.1x | /Final Exam/problem7.py | 2,105 | 4.46875 | 4 | """
Implement the class myDict with the methods below, which will represent a dictionary without using
a dictionary object. The methods you implement below should have the same behavior as a dict object,
including raising appropriate exceptions. Your code does not have to be efficient. Any code that
uses a Python di... | true |
de17bb8bd8f94f087845cd59e2ad83f7b43f8ebd | Nicolanz/holbertonschool-web_back_end | /0x00-python_variable_annotations/3-to_str.py | 269 | 4.21875 | 4 | #!/usr/bin/env python3
"""Module to return str repr of floats"""
def to_str(n: float) -> str:
"""Function to get the string representation of floats
Args:
n (float): [float number]
Returns:
str: [str repr of n]
"""
return str(n)
| true |
94c63cf09da1e944b67ca243ee40f67ad3550cf5 | Nicolanz/holbertonschool-web_back_end | /0x00-python_variable_annotations/9-element_length.py | 435 | 4.28125 | 4 | #!/usr/bin/env python3
"""Module with correct annotation"""
from typing import Iterable, Sequence, List, Tuple
def element_length(lst: Iterable[Sequence]) -> List[Tuple[Sequence, int]]:
"""Calculates the length of the tuples inside a list
Args:
lst (Sequence[Iterable]): [List]
Returns:
... | true |
aedfe44fe94a31da053f830a56ad5842c77b4610 | jesseklein406/data-structures | /simple_graph.py | 2,747 | 4.28125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""A data structure for a simple graph using the model from Martin BroadHurst
http://www.martinbroadhurst.com/graph-data-structures.html
"""
class Node(object):
"""A Node class for use in a simple graph"""
def __init__(self, name, value):
"""Make a new nod... | true |
dfc818c931c516d40f82d5d2b16c18bd2b2ff20d | vibhor3081/GL_OD_Tracker | /lib.py | 2,986 | 4.1875 | 4 | import pandas as pd
def queryTable(conn, tablename, colname, value, *colnames):
"""
This function queries a table using `colname = value` as a filter.
All columns in colnames are returned. If no colnames are specified, `select *` is performed
:param conn: the connection with the database to be used t... | true |
e617e0788ff6129a6717d7cc26bb2a9fe2e7f12b | yasmineElnadi/python-introductory-course | /Assignment 2/2.9.py | 330 | 4.1875 | 4 | #wind speed
ta=float(input("Enter the Temperature in Fahrenheit between -58 and 41:"))
v=eval(input("Enter wind speed in miles per hour:"))
if v < 2:
print("wind speed should be above or equal 2 mph")
else:
print("the wind chill index is ", format(35.74 + (0.6215*ta) - (35.75* v**0.16) + (0.4275 * ta * v**0.16)... | true |
1b6d2d0843efad0980c4fa09aa7388c3b1eb609c | birkirkarl/assignment5 | /Forritun/Æfingardæmi/Hlutapróf 1/practice2.py | 241 | 4.28125 | 4 | #. Create a program that takes two integers as input and prints their sum.
inte1= int(input('Input the first integer:'))
inte2= int(input('Input the second integer:'))
summan= int(inte1+inte2)
print('The sum of two integers is:',+summan)
| true |
18ad8bcf6e920438f101c955b30c4e4d11f72e4b | birkirkarl/assignment5 | /Forritun/Assignment 10 - lists/PascalTriangle.py | 422 | 4.15625 | 4 | def make_new_row(row):
new_row = []
for i in range(0,len(row)+1):
if i == 0 or i == len(row):
new_row.append(1)
else:
new_row.append(row[i]+row[i-1])
return new_row
# Main program starts here - DO NOT CHANGE
height = int(input("Height of Pascal's triangle (... | true |
b74ac298e5cba51c032cee6114decf658a67f494 | dhurataK/python | /score_and_grades.py | 804 | 4.1875 | 4 | def getGrade():
print "Scores and Grades"
for i in range(0,9):
ip = input()
if(ip < 60):
print "You failed the exam. Your score is: "+str(ip)+" Good luck next time!"
elif (ip >= 60 and ip <= 69):
print "Score: "+str(ip)+"; Your grade is D"
elif (ip >= 70 a... | true |
495dffd2bb07f45cc5bb355a1a00d113c2cd6288 | cadyherron/mitcourse | /ps1/ps1a.py | 981 | 4.46875 | 4 | # Problem #1, "Paying the Minimum" calculator
balance = float(raw_input("Enter the outstanding balance on your credit card:"))
interest_rate = float(raw_input("Enter the annual credit card interest rate as a decimal:"))
min_payment_rate = float(raw_input("Enter the minimum monthly payment rate as a decimal:"))
monthl... | true |
f3fb695d70656cd48495be8fc89af09dd3cee40a | learning-triad/hackerrank-challenges | /gary/python/2_if_else/if_else.py | 838 | 4.40625 | 4 | #!/bin/python3
#
# https://www.hackerrank.com/challenges/py-if-else/problem
# Given a positive integer n where 1 <= n <= 100
# If n is even and in the inclusive range of 6 to 20, print "Weird"
# If n is even and greater than 20, print "Not Weird"
def check_weirdness(n):
"""
if n is less than 1 or greater than... | true |
1083052e37b5556980972557425aeac95fa7931b | arensdj/math-series | /series_module.py | 2,753 | 4.46875 | 4 | # This function produces the fibonacci Series which is a numeric series starting
# with the integers 0 and 1. In this series, the next integer is determined by
# summing the previous two.
# The resulting series looks like 0, 1, 1, 2, 3, 5, 8, 13, ...
def fibonacci(n):
"""
Summary of fibonacci function: compu... | true |
ce9d1cd697671c12003a39b17ee7a9bfebf0103d | dlaststark/machine-learning-projects | /Programming Language Detection/Experiment-2/Dataset/Train/Python/letter-frequency-3.py | 890 | 4.125 | 4 | import string
if hasattr(string, 'ascii_lowercase'):
letters = string.ascii_lowercase # Python 2.2 and later
else:
letters = string.lowercase # Earlier versions
offset = ord('a')
def countletters(file_handle):
"""Traverse a file and compute the number of occurences of each letter
retu... | true |
7424e3d1c91b4052176e86aeedc9261a86490a14 | kiukin/codewars-katas | /7_kyu/Descending_order.py | 546 | 4.125 | 4 | # Kata: Descending Order
# https://www.codewars.com/kata/5467e4d82edf8bbf40000155/train/python
# Your task is to make a function that can take any non-negative integer as a argument and
# return it with its digits in descending order. Essentially, rearrange the digits to
# create the highest possible number.
# Exam... | true |
36a0cb1db271953430c191c321286014bc97ed6d | Asabeneh/Fundamentals-of-python-august-2021 | /week-2/conditionals.py | 997 | 4.40625 | 4 | is_raining = False
if is_raining:
print('I have to have my umbrella with me')
else:
print('Go out freely')
a = -5
if a > 0:
print('The value is positive')
elif a == 0:
print('The value is zero')
elif a < 0:
print('This is a negative number')
else:
print('It is something else')
# weather = in... | true |
d6e5435f634beb7a11f6095bb3f697fbeb426fb8 | hossein-askari83/python-course | /28 = bult in functions.py | 898 | 4.25 | 4 |
number = [0, 9, 6, 5, 4, 3, -7, 1, 2.6]
print("-----------") # all , any
print(any(number)) # if just one of values was true it show : true (1 and other numbers is true)
print(all(number)) # if just one of values was false it show : false (0 is false)
print("-----------") # min , max
print(max(number)) # show m... | true |
0e4a586b1bfb3a97d3311b61d8653e0041c42eb0 | sinceresiva/DSBC-Python4and5 | /areaOfCone.py | 499 | 4.3125 | 4 | '''
Write a python program which creates a class named Cone and write a
function calculate_area which calculates the area of the Cone.
'''
import math
class ConeArea:
def __init__(self):
pass
def getArea(self, r, h):
#SA=πr(r+sqrt(h**2+r**2))
return math.pi*r*(r+math.sqrt(h**2+r**2))
con... | true |
928d5d403a69cd99e6c9ae579a6fc34b87965c1c | kostyafarber/info1110-scripts | /scripts/rain.py | 468 | 4.125 | 4 | rain = input("Is it currently raining? ")
if rain == "Yes":
print("You should take the bus.")
elif rain == "No":
travel = int(input("How far in km do you need to travel? "))
if travel > 10:
print("You should take the bus.")
elif travel in range(2, 11):
print("You should ride your bike.... | true |
a2d0a7288f4fc9ce22f9f1447e1e70046b80b30b | tschutter/skilz | /2011-01-14/count_bits_a.py | 733 | 4.125 | 4 | #!/usr/bin/python
#
# Given an integer number (say, a 32 bit integer number), write code
# to count the number of bits set (1s) that comprise the number. For
# instance: 87338 (decimal) = 10101010100101010 (binary) in which
# there are 8 bits set. No twists this time and as before, there is
# no language restriction.... | true |
1d48da6a7114922b7e861afa93ddc03984815b0c | iZwag/IN1000 | /oblig3/matplan.py | 477 | 4.21875 | 4 | # Food plan for three residents
matplan = { "Kari Nordmann": ["brod", "egg", "polser"],
"Magda Syversen": ["frokostblanding", "nudler", "burger"],
"Marco Polo": ["oatmeal", "bacon", "taco"]}
# Requests a name to check food plan for
person = input("Inquire the food plan for a resident, by typi... | true |
914134c3475f4618fa39fbbde917a4ada837968f | iZwag/IN1000 | /oblig5/regnefunksjoner.py | 1,933 | 4.125 | 4 | # 1.1
# Function that takes two parameters and returns the sum
def addisjon(number1, number2):
return number1 + number2
# 1.2
# Function that subtracts the second number from the first one
def subtraksjon(number1, number2):
return number1 - number2
# 1.2
# Function that divides the first argument by the sec... | true |
67b284c3f8dcaed9bdde75429d81c7c96f31847c | keithkay/python | /python_crash_course/functions.py | 2,432 | 4.78125 | 5 | # Python Crash Course
#
# Chapter 8 Functions
# functions are defined using 'def'
def greeting(name):
"""Display a simple greeting""" # this is an example of a docstring
print("Hello, " + name.title() + "!")
user_name = input("What's your name?: ")
greeting(user_name)
# in addition to the normal positional ... | true |
03ec200798e7dfd44352b6997e3b6f2804648732 | keithkay/python | /python_crash_course/classes.py | 776 | 4.5 | 4 | # Python Crash Course
#
# Chapter 9 OOP
# In order to work with an object in Python, we first need to
# define a class for that object
class Dog():
"""A simple class example"""
def __init__(self, name, age):
"""Initializes name and age attributes."""
self.name = name
self.age = age
... | true |
d146d5541c713488ed3e3cc0497baea68cf368ff | tcsfremont/curriculum | /python/pygame/breaking_blocks/02_move_ball.py | 1,464 | 4.15625 | 4 | """ Base window for breakout game using pygame."""
import pygame
WHITE = (255, 255, 255)
BALL_RADIUS = 8
BALL_DIAMETER = BALL_RADIUS * 2
# Add velocity component as a list with X and Y values
ball_velocity = [5, -5]
def move_ball(ball):
"""Change the location of the ball using velocity and direction."""
ba... | true |
56cb3dc1b9ef863246aa518d8a83b90b3f0c2d9d | trcooke/57-exercises-python | /src/exercises/Ex07_area_of_a_rectangular_room/rectangular_room.py | 830 | 4.125 | 4 | class RectangularRoom:
SQUARE_FEET_TO_SQUARE_METER_CONVERSION = 0.09290304
lengthFeet = 0.0
widthFeet = 0.0
def __init__(self, length, width):
self.lengthFeet = length
self.widthFeet = width
def areaFeet(self):
return self.lengthFeet * self.widthFeet
def areaMeters(sel... | true |
9ba7fb40eacf3ebca5c5fb9a5ac9e823f1ef9df0 | mccabedarren/python321 | /p12.p3.py | 1,098 | 4.46875 | 4 | #Define function "sqroot" (Function to find the square root of input float)
#"Sqroot" calculates the square root using a while loop
#"Sqroot" gives the number of guesses taken to calculate square root
#The program takes input of a float
#if positive the program calls the function "sqroot"
#if negative the program... | true |
dc5b545562df84e36ce8696cdaa33e0239a37001 | mccabedarren/python321 | /p13.p2.py | 431 | 4.46875 | 4 | #Program to print out the largest of two user-entered numbers
#Uses function "max" in a print statement
def max(a,b):
if a>b:
return a
else:
return b
#prompt the user for two floating-point numbers:
number_1 = float(input("Enter a number: "))
number_2 = float(input("Enter another number: "))
... | true |
e0fc45ba2b2da28b629f3c6bf7ce6c85d4334ca4 | elizabethadventurer/Treasure-Seeker | /Mini Project 4 part 1.py | 1,575 | 4.28125 | 4 | # Treasure-Seeker
#Introduction
name = input("Before we get started, what's your name?")
print("Are you ready for an adventure", name, "?")
print("Let's jump right in then, shall we?")
answer = input("Where do you thnk we should start? The old bookstore, the deserted pool, or the abandoned farm?")
if answer == "the d... | true |
6e6545bf2e9b4a7ff360d8151e6418168f777ff8 | sagarujjwal/DataStructures | /Stack/StackBalancedParens.py | 986 | 4.15625 | 4 | # W.A.P to find the given parenthesis in string format is balanced or not.
# balanced: {([])}, [()]
# non balanced: {{, (()
from stack import Stack
def is_match(p1, p2):
if p1 == '[' and p2 == ']':
return True
elif p1 == '{' and p2 == '}':
return True
elif p1 == '(' and p2 == ')':
... | true |
380769147add0ecf5e071fa3eb5859ee2eded6da | alexmeigz/code-excerpts | /trie.py | 1,185 | 4.40625 | 4 | # Trie Class Definition
# '*' indicates end of string
class Trie:
def __init__(self):
self.root = dict()
def insert(self, s: str):
traverse = self.root
for char in s:
if not traverse.get(char):
traverse[char] = dict()
traverse = traver... | true |
03995a46974520e6d587e3c09a24fa1c98a6423f | brownboycodes/problem_solving | /code_signal/shape_area.py | 443 | 4.1875 | 4 | """
Below we will define an n-interesting polygon.
Your task is to find the area of a polygon for a given n.
A 1-interesting polygon is just a square with a side of length 1.
An n-interesting polygon is obtained by taking the n - 1-interesting polygon
and appending 1-interesting polygons to its rim, side by side.
Y... | true |
298ce4a268c6242ee4b18db1b5029995ebaa183f | brownboycodes/problem_solving | /code_signal/adjacent_elements_product.py | 362 | 4.125 | 4 | """
Given an array of integers,
find the pair of adjacent elements that has the largest product
and return that product.
"""
def adjacentElementsProduct(inputArray):
product=0
for i in range(0,len(inputArray)-1):
if inputArray[i]*inputArray[i+1]>product or product==0:
product=inputArray[i... | true |
98edf9ce118f9641f55d08c6527da8d01f03b49a | kirubeltadesse/Python | /examq/q3.py | 604 | 4.28125 | 4 | # Kirubel Tadesse
# Dr.Gordon Skelton
# J00720834
# Applied Programming
# Jackson State University
# Computer Engineering Dept.
#create a program that uses a function to determine the larger of two numbers and return the larger to the main body of the program and then print it. You have to enter the numbers from the... | true |
9b773282655c5e3a6a35f9b59f22ddb221386870 | AyvePHIL/MLlearn | /Sorting_alogrithms.py | 2,275 | 4.21875 | 4 | # This is the bubbleSort algorithm where we sort array elements from smallest to largest
def bubbleSort(arr):
n = len(arr)
# Traverse through all array elements
for i in range(n - 1):
# range(n) also work but outer loop will repeat one time more than needed (more efficient).
# Last i eleme... | true |
2486925e16396536f048f25889dc6d3f7675549a | NathanielS/Week-Three-Assignment | /PigLatin.py | 500 | 4.125 | 4 | # Nathaniel Smith
# PigLatin
# Week Three Assignment
# This program will take input from the usar, translate it to PigLatin,
# and print the translated word.
def main ():
# This section of code ask for input from the usar and defines vowels
word = input("Please enter an English word: ")
vowels = "AEIOUaeiou"
... | true |
4d872b88871da0fd909f4cb71954a3f0f8d0f43f | RocketDonkey/project_euler | /python/problems/euler_001.py | 470 | 4.125 | 4 | """Project Euler - Problem 1
If we list all the natural numbers below 10 that are multiples of 3 or 5,
we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
"""
def Euler001():
num = 1000
r = range(3, num)
for index, i in enumerate(xrange(3, num)):
... | true |
54406e46376433c727027b350e1b7b6a6f818181 | kamil-fijalski/python-reborn | /@Main.py | 2,365 | 4.15625 | 4 | # Let's begin this madness
print("Hello Python!")
int1 = 10 + 10j
int2 = 20 + 5j
int3 = int1 * int2
print(int3)
print(5 / 3) # floating
print(5 // 3) # integer
str1 = "Apple"
print(str1[0])
print(str(len(str1)))
print(str1.replace("p", "x") + " " + str1.upper() + " " + str1.lower() + " " + str1.swapcase())
# me... | true |
7b2d9aa4ece7d8a777def586cb3af02685eac071 | omer-goder/python-skillshare-beginner | /conditions/not_in_keyword.py | 347 | 4.1875 | 4 | ### 17/04/2020
### Author: Omer Goder
### Checking if a value is not in a list
# Admin users
admin_users = ['tony','frank']
# Ask for username
username = input("Please enter you username?")
# Check if user is an admin user
if username not in admin_users:
print("You do not have access.")
else:
p... | true |
f457e6763c190e10b297912019aa76ad7dc899a4 | omer-goder/python-skillshare-beginner | /dictionary/adding_user_input_to_a_dictionary.py | 997 | 4.375 | 4 | ### 04/05/2020
### Author: Omer Goder
### Adding user input to a dictionary
# Creat an empty dictionary
rental_properties = {}
# Set a flag to indicate we are taking apllications
rental_open = True
while rental_open: # while True
# prompt users for name and address.
username = input("\nWhat is your nam... | true |
fd1ccd8e94a9a2f7d68ce5caade21b4727a5356e | omer-goder/python-skillshare-beginner | /conditions/or_keyword.py | 418 | 4.21875 | 4 | ### 17/04/2020
### Author: Omer Goder
### Using the OR keyword to check values in a list
# Names registered
registered_names = ['tony','frank','mary','peter']
username = input("Please enter username you would like to use.\n\n").lower()
#Check to see if username is already taken
if username in registered_na... | true |
34c12dde56d3cb3176565750b4292d6a062105df | omer-goder/python-skillshare-beginner | /list/a_list_of_numbers.py | 552 | 4.25 | 4 | ### 15/04/2020
### Author: Omer Goder
### Creating a list of numbers
# Convert numbers into a list
numbers = list(range(1,6))
print(numbers)
print('\n')
# print("List of even number in the range of 0 to 100:")
even_numbers = list(range(0,102, 2))
print(even_numbers)
print('\n')
print("List of square va... | true |
97360bd4a55477713e3868b9c9af811143151aca | omer-goder/python-skillshare-beginner | /class/class_as_attribute(2).py | 1,127 | 4.34375 | 4 | ### 11/05/2020
### Author: Omer Goder
### Using a class as an attribute to another class
class Tablet():
"""This will be the class that uses the attribute."""
def __init__(self, thickness, color, battery):
"""Initialize a parameter as a class"""
self.thickness = thickness
self.color = color
self.battery = ... | true |
f385856290585e7e625d82c6f1d0b6f5aa171f71 | akram2015/Python | /HW4/SECURITY SCANNER.py | 631 | 4.4375 | 4 | # this program Prompt user for a file name, and read the file, then find and report if file contains a string with a string ("password=") in it.
# file name = read_it.txt
found = True
userinput = input ("Enter the file name: ")
string = input ("Enter the string: ")
myfile = open (userinput) # open the file that might... | true |
8e2989008f52b56dee43360378533c5b4a757d90 | josego85/livescore-cli | /lib/tt.py | 2,078 | 4.40625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import re
'''
module to convert the given time in UTC to local device time
_convert() method takes a single time in string and returns the local time
convert() takes a list of time in string format and returns in local time
NOTE: any string not in the format "... | true |
0c900e9b4ad2f2b3e904ee61661cda39ed458646 | shivraj-thecoder/python_programming | /Swapping/using_tuple.py | 271 | 4.34375 | 4 | def swap_tuple(value_one,value_two):
value_one,value_two=value_two,value_one
return value_one,value_two
X=input("enter value of X :")
Y=input("enter value of Y :")
X, Y=swap_tuple(X,Y)
print('value of X after swapping:', X)
print('value of Y after swapping:', Y) | true |
1c77967940f1f8b17e50f4f2632fb34a13b3daf0 | sweetysweat/EPAM_HW | /homework1/task2.py | 692 | 4.15625 | 4 | """
Given a cell with "it's a fib sequence" from slideshow,
please write function "check_fib", which accepts a Sequence of integers, and
returns if the given sequence is a Fibonacci sequence
We guarantee, that the given sequence contain >= 0 integers inside.
"""
from typing import Sequence
def check_fibonacci... | true |
d10cd2ab04df7e4720f72bf2f5057768e8bfad3f | sweetysweat/EPAM_HW | /homework8/task_1.py | 1,745 | 4.21875 | 4 | """
We have a file that works as key-value storage,
each line is represented as key and value separated by = symbol, example:
name=kek last_name=top song_name=shadilay power=9001
Values can be strings or integer numbers.
If a value can be treated both as a number and a string, it is treated as number.
Write a wrappe... | true |
50e50015e425e4ba5a924775ded68b79cba31edc | sawall/advent2017 | /advent_6.py | 2,729 | 4.21875 | 4 | #!/usr/bin/env python3
# memory allocation
#
#### part one
#
# The debugger would like to know how many redistributions can be done before a blocks-in-banks
# configuration is produced that has been seen before.
#
# For example, imagine a scenario with only four memory banks:
#
# The banks start with 0, 2, 7, and 0 bl... | true |
910db0a0156d0f3c37e210ec1931fd404f1357e9 | aymhh/School | /Holiday-Homework/inspector.py | 1,095 | 4.125 | 4 | import time
print("Hello there!")
print("What's your name?")
name = input()
print("Hello there, " + name)
time.sleep(2)
print("You have arrived at a horror mansion!\nIt's a large and spooky house with strange noises coming from inside")
time.sleep(2)
print("You hop out of the car and walk closer...")
time.sleep(2)
pri... | true |
24d025d8a89380a8779fbfdf145083a9db64fc07 | shahad-mahmud/learning_python | /day_16/unknow_num_arg.py | 324 | 4.15625 | 4 | def sum(*nums: int) -> int:
_sum = 0
for num in nums:
_sum += num
return _sum
res = sum(1, 2, 3, 5)
print(res)
# Write a program to-
# 1. Declear a funtion which can take arbitary numbers of input
# 2. The input will be name of one or persons
# 3. In the function print a message to greet every ... | true |
382a8a2f5c64f0d3cd4c1c647b97e19e2c137fda | shahad-mahmud/learning_python | /day_3/if.py | 417 | 4.1875 | 4 | # conditional statement
# if conditon:
# logical operator
# intendation
friend_salary = float(input('Enter your salary:'))
my_salary = 1200
if friend_salary > my_salary:
print('Friend\'s salary is higher')
print('Code finish')
# write a program to-
# a. Take a number as input
# b. Identify if a number is po... | true |
ec55765f79ce87e5ce0f108f873792fecf5731f6 | shahad-mahmud/learning_python | /day_7/python_function.py | 347 | 4.3125 | 4 | # def function_name(arguments):
# function body
def hello(name):
print('Hello', name)
# call the funciton
n = 'Kaka'
hello(n)
# Write a program to-
# a. define a function named 'greetings'
# b. The function print 'Hello <your name>'
# c. Call the function to get the message
# d. Modify your function and add a... | true |
b0824befae2b1d672ac6ec693f97e7c801366c0c | srinivasdasu24/regular_expressions | /diff_patterns_match.py | 1,534 | 4.53125 | 5 | """
Regular expression basics, regex groups and pipe character usage in regex
"""
import re
message = 'Call me at 415-555-1011 tomorrow. 415-555-9999 is my office.'
phoneNum_regex = re.compile(
r'\d\d\d-\d\d\d-\d\d\d\d') # re.compile to create regex object \d is - digit numeric character
mob_num = phoneNum_re... | true |
3865e404fdf198c9b8a6cb674783aa58af2c8539 | rehul29/QuestionOfTheDay | /Question8.py | 561 | 4.125 | 4 | # minimum number of steps to move in a 2D grid.
class Grid:
def __init__(self, arr):
self.arr = arr
def find_minimum_steps(self):
res = 0
for i in range(0, len(self.arr)-1):
res = res + self.min_of_two(self.arr[i], self.arr[i+1])
print("Min Steps: {}".format(res))
... | true |
1e30e88c79c0941f93ce4239a74eb38d4dcd02f5 | dtekluva/first_repo | /datastructures/ato_text.py | 1,616 | 4.125 | 4 | # sentence = input("Please enter your sentence \nWith dashes denoting blank points :\n ")
# replacements = input("Please enter your replacements in order\nseperated by commas :\n ")
# ## SPLIT SENTENCE INTO WORDS
# sentence_words = sentence.split(" ")
# print(sentence_words)
# ## GET CORRESPONDING REPLACEMENTS
# rep... | true |
b9a6f5dfa9f184d24f941addd3aa219dcc16a1bd | harrylb/anagram | /anagram_runner.py | 2,436 | 4.3125 | 4 | #!/usr/bin/env python3
"""
anagram_runner.py
This program uses a module "anagram.py" with a boolean function
areAnagrams(word1, word2)
and times how long it takes that function to correctly identify
two words as anagrams.
A series of tests with increasingly long anagrams are performed,
with the word length and ... | true |
7008f73c39d0cffbb93e317e2e4371b16e4a1152 | ozgecangumusbas/I2DL-exercises | /exercise_01/exercise_code/networks/dummy.py | 2,265 | 4.21875 | 4 | """Network base class"""
import os
import pickle
from abc import ABC, abstractmethod
"""In Pytorch you would usually define the `forward` function which performs all the interesting computations"""
class Network(ABC):
"""
Abstract Dataset Base Class
All subclasses must define forward() method
"""
... | true |
a477f9345fcd496943a6543eba007b5a883bc1d0 | Ayaz-75/Prime-checker-program | /pime_checker.py | 267 | 4.125 | 4 | # welcome to the prime number checker
def prime_checker(number):
for i in range(2, number):
if number % i == 0:
return "not prime"
else:
return "prime"
num = int(input("Enter number: "))
print(prime_checker(number=num))
| true |
52230fa21f292174d6bca6c86ebcc35cc860cb69 | kisyular/StringDecompression | /proj04.py | 2,900 | 4.625 | 5 | #############################################
#Algorithm
#initiate the variable "decompressed_string" to an empty string
#initiate a while True Loop
#prompt the user to enter a string tocompress
#Quit the program if the user enters an empty string
#Initiate a while loop if user enters string
#find the first bracket and... | true |
e3e8af1efd0adbca06cba83b769bc93d10c13d69 | jalalk97/math | /vec.py | 1,262 | 4.125 | 4 | from copy import deepcopy
from fractions import Fraction
from utils import to_fraction
class Vector(list):
def __init__(self, arg=None):
"""
Creates a new Vector from the argument
Usage:
>> Vector(), Vector(None) Vector([]) creates empty vector
>> Vector([5, 6, 6.7, Fracti... | true |
a84f6776548484ef96ab81e0107bdd36385e416e | DasVisual/projects | /temperatureCheck/tempCheck2.py | 338 | 4.125 | 4 | #! python 3
# another version of temperature checker, hopefully no none result
print('What is the current temperature of the chicken?')
def checkTemp(Temp):
if Temp > 260:
return 'It is probably cooked'
elif Temp < 260:
return 'More heat more time'
Temp = int(input())
Result = checkTemp(Tem... | true |
cd3b288dc03da30a69439727191cb18e429d943a | olympiawoj/Algorithms | /stock_prices/stock_prices.py | 1,934 | 4.3125 | 4 | #!/usr/bin/python
"""
1) Understand -
Functions
- find_max_profit should receive a list of stock prices as an input, return the max profit that can be made from a single buy and sell. You must buy first before selling, no shorting
- prices is an array of integers which represent stock prices and we need to find the ... | true |
17209e6ac514e763706e801ef0fb80a88ffb56b7 | Swaraajain/learnPython | /learn.python.loops/stringQuestions.py | 457 | 4.1875 | 4 | # we have string - result must be the first and the last 2 character of the string
name = "My Name is Sahil Nagpal and I love Programming"
first2index = name[:2]
last2index = name[len(name)-2:len(name)]
print(first2index + last2index)
#print(last2index)
#string.replace(old, new, count)
print(name.replace('e','r',2))... | true |
fbc2b174ff0abcb78531105634d19c6ec9022184 | 40309/Files | /R&R/Task 5.py | 557 | 4.28125 | 4 | checker = False
while checker == False:
try:
user_input = int(input("Please enter a number between 1-100: "))
except ValueError:
print("The value entered was not a number")
if user_input < 1:
print("The number you entered is too low, Try again")
elif user_input > 100:
... | true |
707681af05d6cb4521bf4f729290e96e6c347287 | Dirac26/ProjectEuler | /problem004/main.py | 877 | 4.28125 | 4 | def is_palindromic(num):
"""Return true if the number is palindromic and false otehrwise"""
return str(num) == str(num)[::-1]
def dividable_with_indigits(num, digits):
"""Returns true if num is a product of two integers within the digits range"""
within = range(10 ** digits - 1)
for n in within[1:]... | true |
774edd572b1497b9a8bc9e1c0f6107147626f276 | max-moazzam/pythonCoderbyte | /FirstFactorial.py | 541 | 4.1875 | 4 | #Function takes in a number as a parameter and returns the factorial of that number
def FirstFactorial(num):
#Converts parameter into an integer
num = int(num)
#Creates a factorial variable that will be returned
factorial = 1
#While loop will keep multipying a number to the number 1 less than it until 1 is ... | true |
d9fbdc7310218e85b562a1beca25abe48e72ee8b | lcantillo00/python-exercises | /randy_guessnum.py | 305 | 4.15625 | 4 | from random import randint
num = randint(1, 6)
print ("Guess a number between 1 and 6")
answer = int(raw_input())
if answer==num:
print ("you guess the number")
elif num<answer:
print ("your number is less than the random #")
elif num>answer:
print("your number is bigger than the random #")
| true |
7b692f7ea4d8718261e528d07222061dc3e35de8 | michelmora/python3Tutorial | /BegginersVenv/dateAndTime.py | 757 | 4.375 | 4 | # Computers handle time using ticks. All computers keep track of time since 12:00am, January 1, 1970, known as epoch
# time. To get the date or time in Python we need to use the standard time module.
import time
ticks = time.time()
print("Ticks since epoch:", ticks)
# To get the current time on the machine, you can ... | true |
4dd9a591648531943ccd60b984e1d3f0b72a800c | michelmora/python3Tutorial | /BegginersVenv/switch(HowToSimulate).py | 2,519 | 4.21875 | 4 | # An if ... elif ... elif ... sequence is a substitute for the switch or case statements found in other languages.
# OPTION No.1
def dog_sound():
return 'hau hau'
def cat_sound():
return 'Me au'
def horse_sound():
return 'R R R R'
def cow_sound():
return 'M U U U'
def no_sound():
return "T... | true |
8dee8c987a27474de2b12a4a783dddc7aa142260 | darrengidado/portfolio | /Project 3 - Wrangle and Analyze Data/Update_Zipcode.py | 1,333 | 4.21875 | 4 | '''
This code will update non 5-digit zipcode.
If it is 8/9-digit, only the first 5 digits are kept.
If it has the state name in front, only the 5 digits are kept.
If it is something else, will not change anything as it might result in error when validating the csv file.
'''
def update_zipcode(zipcode):
"""C... | true |
3177bc787712977e88acaa93324b7b43c25016f9 | sudharsan004/fun-python | /FizzBuzz/play-with-python.py | 377 | 4.1875 | 4 | #Enter a number to find if the number is fizz,buzz or normal number
n=int(input("Enter a number-I"))
def fizzbuzz(n):
if (n%3==0 and n%5==0):
print(str(n)+"=Fizz Buzz")
elif (n%3==0):
print(str(n)+"=Fizz")
elif (n%5==0):
print(str(n)+"=Buzz")
else:
print(str(n)+... | true |
da04ab784745cdce5c77c0b6159e17d802011129 | sclayton1006/devasc-folder | /python/def.py | 561 | 4.40625 | 4 | # Python3.8
# The whole point of this exercise is to demnstrate the capabilities of
# a function. The code is simple to make the point of the lesson simpler
# to understand.
# Simon Clayton - 13th November 2020
def subnet_binary(s):
""" Takes a slash notation subnet and calculates the
number of host addresse... | true |
bbfa62e0a73aa476ff8c7a2abd98c021c956d20e | Zeonho/LeetCode_Python | /archives/535_Encode_and_Decode_TinyURL.py | 1,708 | 4.125 | 4 | """
TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it
returns a short URL such as http://tinyurl.com/4e9iAk.
Design the encode and decode methods for the TinyURL service. There is no restriction on how your
encode/decode algorithm should work. You j... | true |
ad6c9704c7f09a5fa1d1faab38eb5d43967026a4 | fagan2888/leetcode-6 | /solutions/374-guess-number-higher-or-lower/guess-number-higher-or-lower.py | 1,199 | 4.4375 | 4 | # -*- coding:utf-8 -*-
# We are playing the Guess Game. The game is as follows:
#
# I pick a number from 1 to n. You have to guess which number I picked.
#
# Every time you guess wrong, I'll tell you whether the number is higher or lower.
#
# You call a pre-defined API guess(int num) which returns 3 possible resul... | true |
6a097f9f7027419ba0649e5017bc2e17e7f822d3 | fagan2888/leetcode-6 | /solutions/557-reverse-words-in-a-string-iii/reverse-words-in-a-string-iii.py | 773 | 4.1875 | 4 | # -*- coding:utf-8 -*-
# Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
#
# Example 1:
#
# Input: "Let's take LeetCode contest"
# Output: "s'teL ekat edoCteeL tsetnoc"
#
#
#
# Note:
# In the string, each word is... | true |
6f4b3f90db0be1ccc197aacca9b625642c498aee | Raziel10/AlgorithmsAndMore | /Probability/PowerSet.py | 267 | 4.34375 | 4 | #Python program to find powerset
from itertools import combinations
def print_powerset(string):
for i in range(0,len(string)+1):
for element in combinations(string,i):
print(''.join(element))
string=['a','b','c']
print_powerset(string) | true |
da7bd9d5abbdd838c1110515dde30c459ed8390c | Smita1990Jadhav/GitBranchPracticeRepo | /condition&loops/factorial.py | 278 | 4.25 | 4 | num=int(input("Enter Number: "))
factorial=1
if num<1:
print("Factorial is not available for negative number:")
elif num==0:
print("factorial of 1 is zero: ")
else:
for i in range(1,num+1):
factorial=factorial*i
print("factorial of",num,"is",factorial) | true |
a3e1eadfdf24f44dc353726180eee97269844c45 | jjspetz/digitalcrafts | /py-exercises3/hello2.py | 517 | 4.34375 | 4 | #!/usr/bin/env python3
# This is a simple function that says hello using a command-line argument
import argparse
# formats the arguments for argparse
parser = argparse.ArgumentParser()
# requires at least one string as name
parser.add_argument('username', metavar='name', type=str, nargs='*',
help... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.