blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
547cb83f7e01c386f187bcdf01994b6e904f859f | honnali/ADP_Assignment | /phmail.py | 392 | 4.15625 | 4 | #Design and Implement python code for Phone Number and Email Address Extractor using Regular Expression
import re
s1="Phone number is 5648213488,9876543210"
x=re.search("[6-9]\d{9}",s1)
print(x.group())
e='^[a-zA-Z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,6}$'
def check(email):
if(re.search(e,email)):
print("Valid"... | false |
95af810ee907a31e305afca8e4f7413807b82213 | BT-WEBDEV/Volcano-Web-Map | /script.py | 1,674 | 4.25 | 4 | #folium - lets us generate a map within python
#pandas - lets us read the csv file containing volcano locations.
import folium
import pandas
#dataframe variable will let us read the txt file.
df=pandas.read_csv("Volcanoes.txt")
#map variable - this creates our map object.
map=folium.Map(location=[df['LAT'... | true |
74bde0e83f315810c5a80032527d31780d6e7200 | DavidLohrentz/LearnPy3HardWay | /ex3.py | 946 | 4.5 | 4 | # print the following text
print("I will now count my chickens:")
# print Hens and add 25 + (30/6)
print("Hens", 25 + 30.0/6)
# print Roosters calc the following
print("Roosters", 100 - 25.0 * 3 % 4)
# print this text
print("Now I will count the eggs:")
# print the following calc total
print(3.0 + 2 + 1 - 5 ... | true |
e9578f654f6e9e0c8f2d9a450bb7010814a36230 | DavidLohrentz/LearnPy3HardWay | /ex15.py | 740 | 4.375 | 4 | # get the argv module ready
# from sys import argv
# tell argv what to do with the command line input
#script, filename = argv
# define txt; mode r is read only
# save filename text to txt variable
# txt = open(filename, mode = 'r')
# put in a blank line at the top
print("\n")
# print a string with filename va... | true |
288b48493795a69feb81d2da83d2239c977344c4 | jiyifan2009/calculator | /main.py | 891 | 4.25 | 4 | #Calculator
def add(n1, n2):
return n1 + n2
def subtract(n1, n2):
return n1 - n2
def multiply(n1, n2):
return n1 * n2
def divide(n1, n2):
return n1 / n2
operations = {
"+": add,
"-": subtract,
"*": multiply,
"/": divide
}
def calculator():
num1 = int(input("What's the first number?: "))
for symb... | true |
13ac170d8fa2a582b5bd2c045142f4f7973e6509 | yuenliou/leetcode | /lcof/06-cong-wei-dao-tou-da-yin-lian-biao-lcof.py | 1,923 | 4.1875 | 4 | #!/usr/local/bin/python3.7
# -*- coding: utf-8 -*-
from typing import List
from datatype.list_node import ListNode, MyListNode
def reversePrint(head: ListNode) -> List[int]:
return reversePrint(head.next) + [head.val] if head else []
def reversePrint3(head: ListNode) -> List[int]:
list = []
def reverse(h... | true |
e6eae9ba50431852dd588b56dc975cabe2be8a98 | 73nko/daily-interview | /Python/matrix-spiral-print.py | 2,042 | 4.1875 | 4 | ###
# 13-12-2020
# Hi, here's your problem today. This problem was recently asked by Amazon:
# You are given a 2D array of integers. Print out the clockwise spiral traversal of the matrix.
# Example:
# grid = [[1, 2, 3, 4, 5],
# [6, 7, 8, 9, 10],
# [11, 12, 13, 14, 15],
# [16, 17, 18, 19... | true |
b628c6fcf630b12388ea72c75bec610993c7fa25 | 73nko/daily-interview | /Python/cal-angle.py | 1,087 | 4.34375 | 4 | ###
# 16-01-2021
# Hi, here's your problem today. This problem was recently asked by Microsoft:
#
# Given a time in the format of hour and minute, calculate the angle of the hour and minute hand on a clock.
###
###
# SOLUTION
# This is primarily breaking down the problem into a formula.
# It is more tricky than algori... | true |
e0c4b786df476a43bb9210912fdc1df62cfe6601 | 73nko/daily-interview | /Python/falling-dominoes.py | 1,465 | 4.125 | 4 | ###
# 05-12-2020
# Hi, here's your problem today. This problem was recently asked by Twitter:
# Given a string with the initial condition of dominoes, where:
# . represents that the domino is standing still
# L represents that the domino is falling to the left side
# R represents that the domino is falling to the rig... | true |
b870fbb7bf5c9ecdefd05971e372aa1242a17113 | ismailft/Data-Structures-Algorithms | /LinkedLists/LinkedList.py | 746 | 4.21875 | 4 | #Implementation of a linked list:
class Node(object):
def __init__(self, data):
self.Data = data
self.next = None
self.prev = None
class LinkedList(object):
def __init__(self):
self.head = None
print("Linked List Created!")
def addNode(self, data):
node = No... | true |
87a1288436eeb85f7d485ee347c254da06855fd6 | loveplay1983/daily_python | /python_module_with_example/Text/str_cap.py | 543 | 4.1875 | 4 | # Manually accomplish the same functionality of string.capwords()
# separate text first then use a temp list add each part of the text in which each text has already been convert to captalized by for loop, then use join() to combine all together
# import string
text = 'hello world'
def captalize(text):
text_sep =... | true |
01882010d5ec0d5fab6e89804a09fe05c3fb1a58 | WitheredGryphon/witheredgryphon.github.io | /python/HackerRank/Regex/detect_the_email_addresses.py | 936 | 4.15625 | 4 | '''
You will be provided with a block of text, spanning not more than hundred lines.
Your task is to find the unique e-mail addresses present in the text.
You could use Regular Expressions to simplify your task.
And remember that the "@" sign can be used for a variety of purposes!
Input Format
The first line conta... | true |
11bbb77f4b587d8863076daafee3138f29241f13 | WitheredGryphon/witheredgryphon.github.io | /python/Code Wars/count_the_smiley_faces.py | 1,457 | 4.125 | 4 | '''
Description:
Given an array (arr) as an argument complete the function countSmileys that should return the total number of smiling faces.
Rules for a smiling face:
-Each smiley face must contain a valid pair of eyes. Eyes can be marked as : or ;
-A smiley face can have a nose but it does not have to. Valid charact... | true |
bb2d4ac961ebd2e517cc2e29ebcc47011e420027 | ruvvet/File-Rename | /Rename.py | 2,862 | 4.125 | 4 | # BATCH FILE RENAMER PROGRAM
# Rename all files within a folder using the folder name, a specified name, or last modified date as the prefix.
import os
import glob
import sys
import time
def main():
# Input the directory with all files.
# Returns all files in the folder and the # of files in the fol... | true |
cb97e7dd2d356b76a8fc46cb1bac5ebbea3c20ff | DiogoConcerva/NextPython | /Aula07_Aprofundamento01.py | 882 | 4.21875 | 4 | # coding=utf8
# Escreva um programa que pergunte nomes de alunos de uma sala de aula. O número de alunos é
# desconhecido, por isso o programa deve perguntar até que seja digitada a palavra “fim”.
# Depois, o programa deve sortear um aluno para apresentar o trabalho primeiro.
# Exemplo:
# Digite um nome: Yann
#
# Digit... | false |
f7c6dacf0211aab0aea782506786e633e245711a | DiogoConcerva/NextPython | /Aula03_Ex06.py | 242 | 4.125 | 4 | # Escreva um programa que substitui as ocorrencias
# de um caractere 0 em uma string por outro caractere 1
# 010101 -> 111111
entrada = input('Entre com uma string que contenha 0: ')
print('Substituindo 0 por 1: ', entrada.replace('0', '1')) | false |
8cc6f71d98b5ec71e2d6dee8baba8e22641ec5de | DiogoConcerva/NextPython | /Aula05_Ex06.py | 504 | 4.25 | 4 | # Crie um programa que tenha uma função que receba uma lista de números inteiros e exiba todos os
# seus valores em ordem invertida. Obs.: Sem usar invert ou o fatiador com passo -1
l = []
def ordena_contrario(l):
for num in reversed(l):
print(num)
def leitura_numeros(numeros):
for c in range(numeros... | false |
f5c6213aac0f6d02789e29dd82d82b3054b7e69b | rishabhjhaveri10/Linear-Regression | /linear_regression_scipy.py | 2,337 | 4.4375 | 4 | #This code has its inspiration from Data Science and Machine Learning with Python course by Frank Kane on www.udemy.com.
import numpy as np
from matplotlib import pyplot as plt
from scipy import stats
#Model 1
#Generating page speeds randomly with a mean of 3, standard deviation of 0.5 and for 1000 people.
pa... | true |
bfaa2c9608606117ad7ed4bdf552f1f51feb61d5 | namkyu/test_python | /test/classTest/class1.py | 512 | 4.1875 | 4 | # -*- coding: utf-8 -*-
class Athlete:
def __init__(self, a_name="", a_times=[]):
## 여기서 멤버 변수를 선언해 주는 것임
self.name = a_name
self.times = a_times
def how_big(self):
return (len(self.name))
def add_time(self, time_value):
self.times.append(time_value)
def add_times(self, list_of_times):
self.times.e... | false |
0778ccfd4830cb34d032acaf51f4dfd764f07cb3 | marlonrenzo/A01054879_1510_assignments | /A3/character.py | 1,300 | 4.34375 | 4 | def get_character_name():
"""
Inquire the user to provide a name.
:return: a string
"""
name = input("What is your name?").capitalize()
print(f"Nice to meet you {name}\n")
return name
def create_character() -> dict:
"""
Create a dictionary including attributes to associate to a ch... | true |
0a571afe9dc8d96a68d51d74efbd9af73adeb66c | marlonrenzo/A01054879_1510_assignments | /A4/Question_3.py | 1,371 | 4.34375 | 4 | import doctest
def dijkstra(colours: list) -> None:
"""
Sort the colours into a pattern resembling dutch flag.
Capitalize all letters except for strings starting with 'b' in order to sort the way we need to.
:param colours: a list
:precondition: colours must be a non-empty list
:post conditi... | true |
cf9a22378eb8cb4bd42f5821b51ccf9123c32e4d | Saketh1196/Programming | /Python/Weather Measurement.py | 367 | 4.21875 | 4 | Temp=float(input("Enter the temperature in Fahrenheit: "))
Celsius=(5/9)*(Temp-32)
print("The temperature in Celsius is: ",Celsius)
while True:
if Celsius>30:
print("The Weather is too hot. Please take care")
elif Celsius<10:
print("The Weather is too Cold. Wear Warm Clothes")
else:
... | true |
3408d16e00c283cdb9f6f96b7aafa5909146beb8 | Sumanth-Sam-ig/pythoncode | /quadratic.py | 397 | 4.15625 | 4 | print('consider the quadrtic equation of the form')
print('a*x**2+b*x+c')
print('enter the value of a ')
a=int(input())
print('enter the value of b ')
b=int(input())
print('enter the value of c ')
c=int(input())
d=b**2-4*a*c
if d<0 :
print('roots are not possible')
else :
x1=(-b+(d)**1/2 )/2*a
x2=(-b-(d)**1... | false |
5cbf031344cab3889dfa61b44b9739befd5abd29 | Sumanth-Sam-ig/pythoncode | /sum of square and cube of series.py | 762 | 4.21875 | 4 | print ('Enter the number n')
a=int(input())
print('Enter the number of the mathematical operation required')
print ('')
print(""" 1 - Sum of the numbers till n
2 - sum of the squares of the numbers
3 -sum of the cubes of the numbers """)
print('\n')
b=int(input())
if b>3:
print('invalid entery'... | true |
76ad14efd7fd787c72dd439f54eb6fc21fd0bb57 | Anancha/Inventing-Phoenix-Getting-to-know-Raspberry-PI-Pico | /1) Blink code for Raspberry PI Pico.py | 734 | 4.125 | 4 | #Code created by Inventing Phoenix
#1 FEB 2021
from machine import Pin # For accessing these pins using the Pin class of the machine module
import time # Time module helps in creating delays
led= Pin(25,Pin.OUT) # The Pin is assigned and the mode of the pin is set in this command
while True: # While T... | true |
054f79d1db651c486c47f347815039e0d87cdef7 | Lucilvanio/Hello-Word | /Exercício 33 - Ler maior e menor número.py | 507 | 4.1875 | 4 | n = int(input('Digite um número: '))
n1 = int(input('Digite outro número: '))
n2 = int(input('Digite mais um número: '))
if n < n1 and n < n2:
print(f'{n} é o menor número.')
if n1 < n and n1 < n2:
print(f'{n1} é o menor número.')
if n2 < n1 and n2 < n:
print(f'{n2} é o menor número.')
if n > n1 an... | false |
9eb18156516741b7e836d6aedfb9305a1b8a8c18 | andy-j-block/COVID_Web_Scraper | /helper_files/get_todays_date.py | 400 | 4.28125 | 4 |
from datetime import date
def get_todays_date():
###################
#
# This function gets today's current day and month values for later use in
# the program.
#
###################
todays_date = str(date.today())
current_day = todays_date.split('-')[2]
cur... | true |
3b883c9774629cc9194dd429045b527ad57100c2 | EnnaSachdeva/Algorithms | /deepcopy_vs_shallowcopy.py | 1,922 | 4.1875 | 4 | import copy
class fruit:
def __init__(self, color, height, width, list1=None):
self.color = color
self.height = height
self.width = width
self.list1 = list1
print()
print("######### Testing classes #######")
apple_1 = fruit("red", 2, 3)
orange_1 = apple_1
apple_1.color = "orange"
p... | false |
b82235bfdb9c233787b1f791e34f293cf739c8dd | Yixuan-Lee/LeetCode | /algorithms/src/Ex_987_vertical_order_traversal_of_a_binary_tree/group_share_jiangyh_dfs.py | 1,229 | 4.1875 | 4 | """
DFS method
Time complexity:
Space complexity: O(N)
"""
import collections
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution(object):
def verticalTrave... | true |
eb0ab4d39ecbda17d7a3903c3825eeb435da3d4a | mozahid1/Easy-Calculator | /Easy_to_Calculate.py | 1,155 | 4.1875 | 4 |
# This function adds two numbers
def add(x,y):
return x + y
# This function subtracts two numbers
def subtract(x,y):
return x - y
# This function multiplies two numbers
def multiply(x,y):
return x * y
# This function divides two numbers
def divide(x,y):
return x / y
print("Select... | true |
ba6b894681b78a1023760739eb2a1731b9aa8965 | Neveon/python-algorithms | /binary_search/binary_search_intro.py | 1,102 | 4.25 | 4 | # Iterative Binary Search
def binary_search_iterative(data, target):
# array is already sorted - we split the array in half to find if the target is
# in the upper half or lower half of the already sorted array
low = 0
high = len(data) - 1
while low <= high:
mid = (low + high) // 2
print('Indices: lo... | true |
0a5d8c0250731a8347c0d80b7d926627da29e29f | jchaconm/PythonGroup_12 | /Python 1/Lesson 2 - 3/Funciones Lambda reduce filter map generadores.py | 1,961 | 4.40625 | 4 | #Las funciones lambda tienen como finalidad ser funciones de corta sentencia, es decir son funciones creadas sobre la marcha
# el esiguente ejemplo refleja como definir esta funcion que no posee una estructura tipica de funciones
lambda argumentos: resultado
doblar = lambda num: num*2
doblar(2)
#Resultado:
4
#La... | false |
e9d5d74c5d6667f525866164554d59d515737a31 | makennamartin97/python-algorithms | /ninjainheritence.py | 1,677 | 4.4375 | 4 | # As you can see, peons have limited abilities. They only have default health
# point of 100 and can't attack but can only takeDamage.
# Imagine that you wanted to create a new class called Warrior. You want
# warrior to have everything that a Peon has. You also want the warrior to
# do everything that a Peon can d... | true |
965fe9cd22babe11276fc0efaf1fd5389498fb0e | makennamartin97/python-algorithms | /sorts/bubblesort.py | 541 | 4.25 | 4 | # bubble sort
# It is a comparison-based algorithm in which each pair of adjacent elements
# is compared and the elements are swapped if they are not in order.
def bubblesort(list):
# Swap the elements to arrange in order
for i in range(len(list)-1,0,-1): # start stop step
for j in range(i):
... | true |
68530451a07c82d1a0c553bf6535fd0dbdf8f95f | makennamartin97/python-algorithms | /stutteringfxn.py | 508 | 4.125 | 4 | # Write a function that stutters a word as if someone is struggling to read it.
# The first two letters are repeated twice with an ellipsis ... and space after
# each, and then the word is pronounced with a question mark ?.
# stutter("incredible") ➞ "in... in... incredible?"
# stutter("enthusiastic") ➞ "en... en...... | true |
df1eba0e96c7a622d0a7f9140d2480e83e930847 | makennamartin97/python-algorithms | /sorts/mergesort.py | 922 | 4.28125 | 4 | # merge sort
# Merge sort first divides the array into equal halves and then combines
# them in a sorted manner.
unsortedlist = [64, 34, 25, 12, 22, 11, 90]
def mergesort(unsortedlist):
if len(unsortedlist) <= 1:
return unsortedlist
# find middle pt and divide it
mid = len(unsortedlist) //2
lef... | true |
be4114feb5e61f82d58686aa757adea9a93f8296 | makennamartin97/python-algorithms | /factorial.py | 315 | 4.375 | 4 | # Create a function that takes an integer and returns the factorial of that
# integer. That is, the integer multiplied by all positive lower integers.
# factorial(3) ➞ 6
# factorial(5) ➞ 120
# factorial(13) ➞ 6227020800
def factorial(num):
if num < 2:
return num
else:
return factorial(num-1) * num | true |
ebd48b50da798e04f5d06e2b47e7a6331d75d80e | renat33/it-academy-python-winter | /Hackerrank5.py | 335 | 4.21875 | 4 | # Напишите программу, которая считывает с клавиатуры целое число,
# вычисляет его факториал и выводит факториал на консоль.
num = int(input())
fac = 1
for i in range(1, num + 1):
num = i * fac
fac = num
print(num)
| false |
3def48fa48e7add42ed31186c7d15327a554d68e | samuel-navarro/calendar | /date_parser.py | 1,080 | 4.46875 | 4 | import yearinfo
def date_str_to_tuple(date_string: str):
"""
Calculates a date tuple (day, month, year) from a date string in the format dd.mm.yyyy
:param date_string: Date string with the form dd.mm.yyyy
:return: The date tuple with three integers if the parsing was successful, None otherwise
"""... | true |
004f67d6f2cab48cd116b90937d2cdb7768c780a | emcd123/Rosalind_solns | /fibfaclog.py | 1,483 | 4.15625 | 4 | def factorial(n):
res = 1
for i in range(1,n+1):
res = res * i
return res
def factorial_log(n):
print("-> factorial({})".format(n))
res = 1
for i in range(1,n+1):
res = res * i
print("<- factorial: {}".format(res))
return res
def factorial2(n):
if n == 1:
... | false |
09d69fb7eb61eefa361141d80f8572862de9090a | atulasati/scripts_lab_test | /user_crud/PROG1326_Lab7_VotreNom.py | 2,104 | 4.1875 | 4 | import getpass
class User(object):
""" Defined user object.
create user object passing params - name, city, phone
Args:
name (str, mandatory): user name, to be provide during the user creation
city (str, mandatory): user city, to be provide during the user creation
"""
def __init__(self, name, city, pho... | true |
3b77508b910db0d8b6781964d76f25389c9597f6 | vaibhavtwr/patterns-and-quiz | /python/kmtom.py | 496 | 4.21875 | 4 | #Python Program to Convert Kilometers to Miles
ch=int(input("enter 1 for change in kilometers to miles \n enter 2 for change in miles to kilometers"))
if (ch==1):
n=int(input("enter the distance in kilometers"))
m=0.621371*n
txt="you distance in kilometer {} and in miles {}"
print(txt.format(n,m))
elif (ch==2) :
... | true |
1178bb0800c6b294a4462d3e08813f772341b721 | dklickman/pyInitial | /Lab 8/workspace2.py | 982 | 4.28125 | 4 |
num_date = input("Please enter a date in mm/dd/yy format: ")
# Create variables to check against the month conditions
# and convert to an integer so we can math on it
month_check = int(num_date[0:2])
day_check = int(num_date[3:5])
year_first_value = (int(num_date[6]))
year_second_value = (int(num_date[7]))
y... | true |
9cf3a51ee95373998a0f10b48714147b82a795e2 | dklickman/pyInitial | /Lab 7/Notes/7.7 Returning a List from a Function.py | 973 | 4.375 | 4 | # This program uses a function to create a list
# The function returns a reference to the list
def main():
# Get a list with values stored in it
numbers = get_values()
# Display the values in the list
print("The numbers are", numbers)
# The get_values() function gets a series of numbers
... | true |
e14f317d78a45ecac9a946cb0448c79a986f62e6 | dklickman/pyInitial | /Lab 7/Notes/7.7 Working with Lists and Files Part D2 reading numbers to a file.py | 856 | 4.1875 | 4 | # While reading numbers from a file into a list; convert the number
# stored as a string back into an integer so math can be performed
# This program reads numbers from a file into a list
def main():
# Open the file
infile = open('numberlist.txt', 'r')
# Read the file's content into a list
... | true |
83e550b09a6b39a2ea66387520f1134f451d97ac | Adrian-Jablonski/python-exercises | /Guess_A_Number/Guess_A_Number.py | 1,243 | 4.15625 | 4 | import random
secret_number = random.randint(1, 10)
guesses_left = 5
game_over = False
print("I am thinking of a number between 1 and 10")
print("You have ", guesses_left, " guesses left.")
while game_over == False:
guess = int(input("What's the number? "))
if guess == secret_number:
print("Yes! Yo... | true |
e5e378fabf26fec9c650ba4d624ac2720a8bbdb8 | nehayd/pizza-deliveries | /main.py | 985 | 4.1875 | 4 | # 🚨 Don't change the code below 👇
print("Welcome to Python Pizza Deliveries!")
size = input("What size pizza do you want? S, M, or L ")
add_pepperoni = input("Do you want pepperoni? Y or N ")
add_cheese = input("Do you want extra cheese? Y or N ")
# 🚨 Don't change the code above 👆
#Write your code below this line ... | true |
8ee2de89c9697171cbd18ff19855e37e320b3d19 | VasudevJaiswal/Python-Quistions-CP | /If-Elif-Else/02 - Test/02.py | 842 | 4.15625 | 4 | # Write a program to accept the cost price of a bike and display the road tax to be paid according to the following criteria :
# Cost price (in Rs) Tax
# > 100000 15 %
# > 50000 and <= 100000 ... | true |
45a80c99c1943ffe147270995fff4fe2eb827d4f | akhilnair111/100DaysOfCode | /Week1/String Slicing.py | 542 | 4.125 | 4 | """ Copeland’s Corporate Company also wants to update how they generate temporary passwords for new employees.
Write a function called password_generator that takes two inputs, first_name and last_name and then concatenate the last three letters of each and returns them as a string. """
first_name = "Reiko"
last_name... | true |
3be4dc6f769698dc958ceeed3e6dc4c50deda0f2 | akhilnair111/100DaysOfCode | /Week2/Delete a Key using dictionaries.py | 1,131 | 4.15625 | 4 | """ 1.
You are designing the video game Big Rock Adventure. We have provided a dictionary of items that are in the player’s inventory which add points to their health meter. In one line, add the corresponding value of the key "stamina grains" to the health_points variable and remove the item "stamina grains" from the ... | true |
6bb25eb72442be16fde69b5bba6cccfafd93010b | akhilnair111/100DaysOfCode | /Week3/part_of_speech.py | 2,399 | 4.15625 | 4 | """ . Import wordnet and Counter
from nltk.corpus import wordnet
from collections import Counter
wordnet is a database that we use for contextualizing words
Counter is a container that stores elements as dictionary keys
2. Get synonyms
Inside of our function, we use the wordnet.synsets() function to get a set of synony... | true |
40a07ac8623ec825f9262ff5bb2839076ca5885a | luismelendez94/holbertonschool-higher_level_programming | /0x06-python-classes/3-square.py | 486 | 4.3125 | 4 | #!/usr/bin/python3
"""This is the class Square"""
class Square:
"""Compute the area of the square"""
def __init__(self, size=0):
"""Initialize variable size"""
try:
self.__size = size
if size < 0:
raise ValueError("size must be >= 0")
except Ty... | true |
944a48e3b0f0714cab53057649706393df849e5e | luismelendez94/holbertonschool-higher_level_programming | /0x06-python-classes/5-square.py | 1,003 | 4.375 | 4 | #!/usr/bin/python3
"""This is the class Square"""
class Square:
"""Print a square"""
def __init__(self, size=0):
"""Initialize variable size"""
self.__size = size
def area(self):
"""Compute the area size of a square"""
return self.__size ** 2
@property
def size... | true |
bae61c16ce9f880b3b0041b229e69deee721f74f | luismelendez94/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/0-add_integer.py | 445 | 4.3125 | 4 | #!/usr/bin/python3
"""Function that make an integer addition
Verifies if it is an integer and if float,
converts it to integer
"""
def add_integer(a, b=98):
"""Function that adds 2 integers"""
if not isinstance(a, int) and not isinstance(a, float):
raise TypeError("a must be an integer")
if not ... | true |
c5e4053bab655882d4530e2d197fdf5a5b2625a1 | akhsham/Karademy-Python-Boot-Camp--Aksham- | /week1/karademy_python_calculator/karademy_python_calculator.py | 990 | 4.15625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 10 12:32:42 2020
@author: darian
"""
num1 = int(input("please insert a number: "))
num2 = int(input("please insert another number: "))
operator = int(input("Please select operator: \n"
"1 => Add [A + B] \n"
... | false |
f71e1facae36061727ccd6673297ab8da0a09bbf | cjoelfoster/pythagorean-triple-finder | /pythagorean-triples.py | 2,349 | 4.625 | 5 | #! /usr/bin/env python3.6
## Find all pythagorean triples within a specified range of values
# 1) input a value, 'z'
# 2) find all pythagorean triples such that x^2 + y^2 = z^2, 0<=x<=z, 0<=y<=z
# 3) return the list of triples in ordered by increasing z, x, y
# 4) future development: include a lower bound for 'z' suc... | true |
7f5c0c8a59160d9d8bf765dc38062c929da37be4 | Banti374/Sorting-Algorithms | /insertion sort.py | 556 | 4.1875 | 4 |
def insertionSort():
arr = []
r = int(input("Enter the length of the array : "))
i = 1
while i <= r:
x = int(input("Enter the value : "))
i += 1
arr.append(x)
print(arr)
n = len(arr)
for i in range(1,n):
key = arr[i]
j = i - 1
... | false |
ea644a40d55c45f5698fac5f0ec3148aceac4101 | Gelitan/IwanskiATLS1300 | /Animating with Turtles/PC02_20200131_Iwanski.py | 2,797 | 4.40625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 31 09:41:11 2020
@author: analiseiwanski
"""
#========
#PC02-Animating with Turtles
#Analise Iwanski
#200131
#
#This code creates an abstract animation of tangent circles with radii based on the fibonacci sequence, then creates a red and blue
#opp... | true |
9f68fc23bba9abef83216264a9233d696495f81f | coflin/Intrusion-Detection-System | /shaktimaan/bashmenu/HiddenPython | 893 | 4.4375 | 4 | #!/usr/bin/python
import os
#Code for searching the hidden files in the given directory
path=raw_input("Enter the path : ")
print("---------------------------------------------")
def hiddenFile(path):
for root,dirs,files in os.walk(path,topdown=False): #looping through the directory '.' means current working director... | true |
1ef857b41c9d6449388b6026d28487716534fdd6 | quezada-raul-9060/CS161_Final_Project | /CS161_project/Brick_class.py | 1,048 | 4.15625 | 4 | class theBrick(object):
"""
Created a class for the brick.
The class is for a brick/rectangle created.
Will make a hitbox for the brick.
"""
def __init__(self, x, y, width, height):
"""
Sets variables for the brick.
This code gives the specifics of the bric... | true |
e68f3a6816d2008674f8fe1f67f1fab62c97a619 | HoaiHoai/btvn-vuthithuhoai | /Assignment1/2.py | 320 | 4.15625 | 4 | import math #library needed to use method acos
pi = math.acos(-1) #get pi value 3.1459265359 (arc cosine of -1 = pi)
radius = float(input("Radius? ")) #read input 'radius' from user
area = radius ** 2 * pi #calculate area r^2*pi
print("Area = %.2f" % area) #print out with 2 numbers after decimal point | true |
350a83984b3caf17099ade37124fac67b08f6cab | Jeremalloch/edX-6.00.1x | /Week 2/Credit card debt 2.py | 878 | 4.25 | 4 | #balance - the outstanding balance on the credit card
#annualInterestRate - annual interest rate as a decimal
#monthlyPaymentRate - minimum monthly payment rate as a decimal
#Month: 1
#Minimum monthly payment: 96.0
#Remaining balance: 4784.0
#balance = 4213
#annualInterestRate = 0.2
#monthlyPaymentRate = 0.04
... | true |
7876bbb52fea9a7cce825001ec66dbb730307eca | richard-yap/Lets_learn_Python3 | /module_11_file_ops.py | 880 | 4.21875 | 4 | #------------------------------File operations---------------------------------
f = open("file.txt", "r") #reading a File
# "w" write File
# "a" append file
#teacher example:
f = open("test.txt", "w") # write or overwrite it
for i in range(10):
f.write("This is line {}\n".format(i + 1)) #must write \n if n... | true |
91f28cba112f73d8778bf3b753991ad7543d1ae3 | richard-yap/Lets_learn_Python3 | /module_7_list_comprehension.py | 2,260 | 4.15625 | 4 | #--------------------------LIST COMPREHENSION-------------------------------
# syntatic sugar
# python advanced shortcuts
# unique in python
[n ** 2 for n in range(10)]
#map method
list(map( lambda x : x ** 2, range(10)))
#map + filtering
# the filter will be done on the data before the map
[n ** 2 for n... | false |
434cf9470be72b22b2b04218eeb9aa1c378d623e | barrymcnamara18/IoT-Software-Dev | /Examples/4_strings.py | 892 | 4.1875 | 4 | ####################
## EXAMPLE: for loops over strings
####################
s = "idemou loops"
for index in range(len(s)):
if s[index] == 'i' or s[index] == 'u':
print("There is an i or u")
print "Here we do again ..."
for char in s:
if char == 'i' or char == 'u':
print("There is an i or u")
... | false |
b7cb25e3ad93ba04ec69d0d9e9b5764af206917e | fmeccanici/thesis_workspace | /gui/nodes/tutorials/getting_started.py | 1,210 | 4.125 | 4 | ## https://techwithtim.net/tutorials/pyqt5-tutorial/basic-gui-application/
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel
import sys
class MyWindow(QMainWindow):
def __init__(self):
super(MyWindow,self).__init__()
self.initUI()
def initUI(self):
... | true |
2ebe3ca2166f2c0d23723d7b470649a980589bf8 | pacefico/crackingcoding | /hackerrank/python/stacks_balanced_brackets.py | 1,397 | 4.375 | 4 | """
A bracket is considered to be any one of the following characters: (, ), {, }, [, or ].
Two brackets are considered to be a matched pair if the an opening bracket (i.e., (, [, or {)
occurs to the left of a closing bracket (i.e., ), ], or }) of the exact same type.
There are three types of matched pairs of brackets... | true |
404d0bb546bbdde263fecebafd3cbc2d692d8539 | leasoussan/DIpython | /week5/w5d2/w5d2xp/w5d2xp.py | 2,891 | 4.5 | 4 | # # Exercise 1 : Pets
# # Consider this code
# class Pets():
# def __init__(self, animals):
# self.animals = animals
# def walk(self):
# for animal in self.animals:
# print(animal.walk())
# class Cat():
# is_lazy = True
# def __init__(self, name, age):
# self.name... | true |
a149fd11632bbeca1fe86340029eec23e55cdb1a | leasoussan/DIpython | /week4/w4d3/w4d3xpninja.py | 1,665 | 4.15625 | 4 |
# Don’t forget to push on Github
# Exercise 1: List Of Integers - Randoms
# !! This is the continuation of the Exercise Week4Day2/Exercise 2 XP NINJA !!
# 2. Instead of asking the user for 10 integers, generate 10 random integers yourself. Make sure that these random integers lie between -100 and 100.
# 3. Instead of ... | true |
4f96e87e1178254694b5e1beafafe6599d25dc97 | Ehotuwe/Py111-praktika1 | /Tasks/a3_check_brackets.py | 951 | 4.3125 | 4 | def check_brackets(brackets_row: str) -> bool:
"""
Check whether input string is a valid bracket sequence
Valid examples: "", "()", "()()(()())", invalid: "(", ")", ")("
:param brackets_row: input string to be checked
:return: True if valid, False otherwise
"""
brackets_row = list (brackets_... | true |
329f9021dc36cb1c1f29b986aa1ec9377c9b351d | dkaimekin/webdev_2021 | /lab9/Informatics_4/d.py | 223 | 4.21875 | 4 | number = int(input("Insert number: "))
def is_power(number):
if number == 1:
print("YES")
elif number < 1:
print("NO")
else:
is_power(number/2)
return 0;
is_power(number) | false |
b781edf2a60aca47feb2a0800a8f3e2c8c27a2de | dkaimekin/webdev_2021 | /lab9/Informatics_4/e.py | 220 | 4.46875 | 4 | number = int(input("Insert number: "))
def find_power_of_two(number):
temp = 1
power = 0
while temp < number:
temp *= 2
power += 1
return power
print(find_power_of_two(number)) | true |
ef068651162e5a8954b8a0a9880c4810245f0d6e | hemanth430/DefaultWeb | /myexp21.py | 1,462 | 4.40625 | 4 | #sentence = "All good things come to those who wait"
def break_words(stuff):
"""This funciton will break up words for us."""
words = stuff.split(' ')
return words #This is used to split sentence into words , ouput = ['All', 'good', 'things', 'come', 'to', 'those', 'who', 'wait']
def sort_words(words):
"""Sorts t... | true |
d09a68f92d09bcac8a5fedeb0455aa125d17921f | adonispuente/Intro-Python-I | /src/14_cal.py | 2,500 | 4.53125 | 5 | """
The Python standard library's 'calendar' module allows you to
render a calendar to your terminal.
https://docs.python.org/3.6/library/calendar.html
Write a program that accepts user input of the form
`14_cal.py [month] [year]`
and does the following:
- If the user doesn't specify any input, your program should
... | true |
16d8fd7a76d8d9c662e3b4ae81ece990542d0496 | Colin0523/Ruby | /Ruby/Advanced Topics in Python.py | 1,033 | 4.125 | 4 | my_dict = {
"Name": "Colin",
"Age": 20,
"A": True
}
print my_dict.keys()
print my_dict.values()
for key in my_dict:
print key,my_dict[key]
doubles_by_3 = [x*2 for x in range(1,6) if (x*2) % 3 == 0]
# Complete the following line. Use the line above for help.
even_squares = [x**2 for x in range(1,11) ... | false |
afa43852fca155cd5aaad6d2bb91a02cbe4fd2e3 | dnguyen289/Python | /nguyen_dana_payment.py | 752 | 4.375 | 4 | # Variables and Calculations 2
# Dana Nguyen June 22 2016
# Part 1: Monthly interest Rate Calculator
# Calculate monthly payments on a loan
# Variables: p = initial amount
# Variables: r = monthly interest rate
# Variables: n = number of months
# Print, properly labeled the monthly payment ( m )
from math... | true |
e4e9f100067fc2b5dd8a1feb50deccd35c3a0614 | CatherineBose/DOJO-Python-Fundametals | /mul_sum_average_Range.py | 716 | 4.59375 | 5 | # Multiples
# Part I - Write code that prints all the odd numbers from 1 to 1000. Use the for loop and don't use a list to do this exercise.
# Part II - Create another program that prints all the multiples of 5 from 5 to 1,000,000.
# Sum List
# Create a program that prints the sum of all the values in the list: a = [... | true |
c3d7ed0322ad497f78590ab3c6d770e9571b7718 | Shubh0520/Day_2_Training | /Dict_1.py | 405 | 4.28125 | 4 | """ Write a Python program to sort (ascending and descending) a dictionary by value. """
import operator
dict_data = {3: 4, 2: 3, 5: 6, 0: 1}
print(f"Dictionary defined is {dict_data}")
ascend = sorted(dict_data.items())
print(f"Sorted Dictionary in ascending order is: {ascend}")
descend = sorted(dict_data.it... | true |
fafb4a235295ff42f74933c70b48ff8e2aa1072e | EvanZch/PythonNoteEvanZch | /6、函数与变量作用域/4、序列解包和链式赋值.py | 320 | 4.4375 | 4 | """
序列解包和链式赋值
两个也有一定的关系
"""
a = 1
b = 2
c = 3
# 改进, 链式赋值
a, b, c = 1, 2, 3
# 一个变量接收三个赋值
d = 1, 2, 3
print(type(d)) # <class 'tuple'> 结果是一个元组
# 序列解包
# a,b,c = d
d = 1, 2, 3, 4
x, y, z, q = d
print(x, y, z, q) # 1 2 3 4
| false |
ec867013d462774255852078e48002a7ec645caf | EvanZch/PythonNoteEvanZch | /1、Python基本类型/1、Number.py | 1,371 | 4.4375 | 4 | # 基本类型:数字 Number (大分类)
# 整数:int
# 浮点数:float
# type() : 查看某个变量的基本类型
print(type(1)) # <class 'int'>
print(type(1.1)) # <class 'float'>
print(type(1.111111111111111111111)) # <class 'float'>
print(type(1 + 1)) # <class 'int'>
print(type(1 + 1.0)) # <class 'float'>
print(type(1 + 0.1)) # <class 'float'>
print(type(1... | false |
87553f24b3a74d2e2db1242aa4af7784c8324356 | EvanZch/PythonNoteEvanZch | /6、函数与变量作用域/5、必须参数和关键字参数.py | 732 | 4.5 | 4 | """
函数的参数
必须参数和关键字参数
区别在函数的调用上而不是在定义上
"""
# 1、必须参数
#这里的x和y就是必须参数,如果调用的时候不传入或者少传就会报错,参数有顺序
# x 和 y 称之为形参
def add (x,y):
return x+y
# 我们在调用的时候传入的值称为实参
# 这里的1,和2就是实参
add(1,2)
# 2、关键字参数
# 作用:方便,代码的可读性
# 我们知道参数是有顺序的,但是我们在调用的时候,可以通过关键字传入参数,如下
# 一样可以正常运行
def add (x,y):
return x+y
# 我们这里通过指定关键字参数传值,这个时候跟顺序没有关系
c... | false |
f3115da63107ac4ada00fe11e58270a621d4c312 | Infra1515/edX-MITx-6.00.1x-Introduction-to-Computer-Science-and-Programming-Using-Python---May-August-2017 | /midterm_exam + extra problems/print_without_vowels.py | 425 | 4.3125 | 4 | def print_without_vowels(s):
'''
s: the string to convert
Finds a version of s without vowels and whose characters appear in the
same order they appear in s. Prints this version of s.
Does not return anything
'''
vowels = 'aeiou'
no_vowels = []
for letter in list(s):
if letter not i... | true |
2fa6f16a91a36b179931fce892595a8d4a85c72c | sekR4/random_walk | /Codewars/python/quest20190802.py | 508 | 4.25 | 4 | #Find the missing letter
# Example:
#
# ['a','b','c','d','f'] -> 'e'
# ['O','Q','R','S'] -> 'P'
def find_missing_letter(chars):
alphabet = list(set('abcdefghijklmnopqrstuvwxyz'))
alphabet.sort()
# for letter in alphabet:
# print(letter)
for i in range(len(alphabet)):
print(i,alphabet[i... | false |
235ac2bf53b66b2df9d10a07bdfe0ccc66181a97 | rajal123/pythonProjectgh | /LabExercise/q7.py | 897 | 4.40625 | 4 | ''' you live 4 miles from university. The bus drives at 25mph but spends 2 minutes at each of the 10 stops on the way.
How long will the bus journey take? Alternatively,you could run to university.you jog the first mile at 7mph;then run
the next two at 15mph;before jogging the last at 7mph again.Will this be quicker or... | true |
56b5482b39acc25c53af9dde98302db19a5106b2 | TAMU-IEEE/programming-101-workshop | /Workshop 2/decisions_2.py | 676 | 4.4375 | 4 | '''Gets a number from the user, and prints “yes” if that number is divisible by
4 or 7, and “no” otherwise.
Test Suite:
inputs: outputs: domain:
-7 "yes" Negative factors
1 "no" Positive integers, nonfactors
0 "no" Zero (border case)
4 "yes" Positive integers, factors of 4
7 "yes" Positive integers, factor... | true |
7b580887c8858cc36fa63eed979dedabb981e5f4 | TAMU-IEEE/programming-101-workshop | /Workshop 3/funcs_2.py | 589 | 4.3125 | 4 | '''Write a function that returns two given strings in alphabetical order.
Test suite:
input: output: domain:
"hi", "man" "hi man" ordered
"zz", "aa" "aa zz" unordered '''
# think about how we compare characters and their hidden ascii value!
def alphabetizeMe(string1, string2):
for i in range(0, len(... | true |
e5f75a207712c3866750c0e4ff1392054d9a990e | ShriPunta/Python-Learnings | /Python Basics/Phunctions.py | 1,507 | 4.1875 | 4 | #Each Function named with keyword 'def'
def firstFuncEver(x,y,z):
sum=x+y+z
return sum
#Scope of Variable is defined by where its declaration in the program
#Higher (higher from start of program) declarations means greater scope of variable
#if you give value in the function start, it is the default value
de... | true |
47c450984b7263d1072fd232397d3c6645b3edc0 | Basileus1990/Receipt | /ShopAssistant.py | 2,435 | 4.15625 | 4 | import Main
from ChosenProducts import ChosenProduct
# class meant to check which and how many products you want to buy. then he displays a receipt
def ask_for_products():
list_of_chosen_products = []
while True:
Main.clear_console(True)
chosenNumber = chose_product()
if chos... | true |
1d86e2c7234b1659cfb9ec11c3421f8e6f9333fb | SAN06311521/compilation-of-python-programs | /my prog/sum_of_digits.py | 259 | 4.21875 | 4 | num = int(input("enter the number whose sum of digits is to be calculated: "))
def SumDigits(n):
if n==0:
return 0
else:
return n % 10 + SumDigits(int(n/10))
print("the sum of the digits is : ")
print(SumDigits(num))
| true |
a7fca4dd7d6e51fa67c3e22770a6a7b9cbb24fb3 | SAN06311521/compilation-of-python-programs | /my prog/leap_yr.py | 439 | 4.1875 | 4 | print("This program is used to determine weather the entered year is a leap year or not.")
yr = int(input("Enter the year to be checked: "))
if (yr%4) == 0 :
if (yr%100) == 0 :
if (yr%400) == 0 :
print("{} is a leap year.".format(yr))
else:
print("{} is not a leap year.".for... | true |
9012204f8bde854d3d50139ded69bb038aa58f66 | SAN06311521/compilation-of-python-programs | /my prog/class_circle.py | 475 | 4.375 | 4 | # used to find out circumference and area of circle
class circle():
def __init__(self,r):
self.radius = r
def area(self):
return self.radius*self.radius*3.14
def circumference(self):
return 2*3.14*self.radius
rad = int(input("Enter the radius of the circle: "))
NewCircle... | true |
0089887361f63ff82bfb55468aa678374c562513 | Drabblesaur/PythonPrograms | /CIS_41A_TakeHome_Assignments/CIS_41A_UNIT_B_TAKEHOME_SCRIPT2.py | 2,090 | 4.125 | 4 | '''
Johnny To
CIS 41A Fall 2019
Unit B take-home assignment
'''
# SCRIPT 2
'''
Use three named "constants" for the following:
small beads with a price of 9.20 dollars per box
medium beads with a price of 8.52 dollars per box
large beads with a price of 7.98 dollars per box
'''
SMALL_BEADS_PRICE = 9.20
... | true |
e430729e07dc10717ef0be62f96ab9ac9278670b | dylanbrams/Classnotes | /practice/change/pig_latin.py | 2,056 | 4.40625 | 4 | '''
Pig Latin: put input words into pig latin.
'''
VOWELS = 'aeiouy'
PUNCTUATION = '.,-;:\"\'&!\/? '
def find_consonant(word_in):
"""
:param word_in:
:return:
>>> find_consonant("Green")
2
>>> find_consonant("orange")
0
>>> find_consonant("streetlight")
3
>>> find_consonan... | true |
7a9a7a54b79ad81ce6c7e1dcacb1e51de53f3043 | sshashan/PythonABC | /factorial.py | 491 | 4.375 | 4 | print("Factorial program")
num1= int(input("Enter the number for which you want to see the factorial: "))
value=1
num =num1
while(num > 1):
value=value*num
num =num - 1
print("Factorial of "+str(num1)+" is: " ,value)
def factorial(n):
return 1 if(n==1 or n==0) else n * factorial(n-1)
... | true |
d337fc0ae229454fb657c1830189c31bb12d2f2e | sshashan/PythonABC | /Person_dict.py | 353 | 4.25 | 4 | print("This program gets the property of a person")
person={"name":"Sujay Shashank","age":30,"phone":7744812925,"gender":"Male","address":"Mana tropicale"}
print("What information you want??")
key= input("Enter the property (name,age,phone,gender,address):").lower()
result=person.get(key,"Info what you are look... | true |
d86c1fbb67e71e269e118cc9a6565456c57cd39c | sshashan/PythonABC | /calculator.py | 713 | 4.34375 | 4 | print("Calculator for Addition/Deletion/Multiplication/Subtraction")
print("Select the operation type")
print("1.Addition")
print("2.Subtraction")
print("3.Multiplication")
print("4.Division")
user_opt=int(input("Enter your operation number: "))
num1= int(input("Enter the first number :"))
num2= int(input("... | true |
afde2cea346697fc1f75f8427d574514d9941d76 | greenfox-zerda-lasers/gaborbencsik | /week-03/day-2/38.py | 259 | 4.125 | 4 | numbers = [7, 5, 8, -1, 2]
# Write a function that returns the minimal element
# in a list (your own min function)
def find_min(list):
mini = list[0]
for x in list:
if x < mini:
mini = x
return mini
print find_min(numbers)
| true |
051d2effa49713986d3bc82a296ceb18f3b825ef | greenfox-zerda-lasers/gaborbencsik | /week-04/day-3/09.py | 618 | 4.25 | 4 | #!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
# create a 300x300 canvas.
# create a square drawing function that takes 1 parameter:
# the square size
# and draws a square of that size to the center of the canvas.
# draw 3 squares with that function.
from tkinter import *
root = Tk()
size = 300
canv... | true |
730dabc7497180a3b6314421119d89d7735e2684 | greenfox-zerda-lasers/gaborbencsik | /week-04/day-4/04-n_power.py | 337 | 4.1875 | 4 | #!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
# 4. 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).
def powerN(base,n):
if n < 1:
return 1
else:
return base * powerN(base,(n-1))
pri... | true |
d585e697fde25956f65403c02cfd5d10bc04b530 | greenfox-zerda-lasers/gaborbencsik | /week-03/day-2/37.py | 296 | 4.1875 | 4 | numbers = [3, 4, 5, 6, 7]
# write a function that filters the odd numbers
# from a list and returns a new list consisting
# only the evens
def filter(list):
new_list = []
for x in list:
if x % 2 == 0:
new_list.append(x)
return new_list
print filter(numbers)
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.