blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
6a7aeb4b770d80379edd2380372df614b5db4d4c | saikiran335/python-projects | /contactlist.py | 2,039 | 4.28125 | 4 | contacts={}
print("--------Contacts---------")
while True:
print("\nSelect the operation")
print("1.Insert the contact")
print("2.Search for the contact")
print("3.Delete the contact")
print("4.Display all the contacts")
print("5.delete all the contacts")
print("6.edit the contact")
prin... | true |
390605ee17a9754ae7ee2f702269a61bb20908cd | Prudhvik-MSIT/cspp1-practice | /m9/Odd Tuples Exercise/odd_tuples.py | 638 | 4.40625 | 4 | '''
Author: Prudhvik Chirunomula
Date: 08-08-2018
'''
#Exercise : Odd Tuples
#Write a python function odd_tuples(a_tup) that takes a some numbers
# in the tuple as input and returns a tuple in which contains odd
# index values in the input tuple
def odd_tuples(a_tup):
'''
a_tup: a tuple
retur... | true |
fd998d3bc0b125e9d775521e37e4ad3d2fd0ad37 | zadrozny/algorithms | /find_list_duplicates.py | 1,255 | 4.125 | 4 | '''
Write a function that finds and returns
the duplicates in a list.
Write a test for this.
'''
def find_duplicates_1(lst):
duplicates = []
for element in set(lst):
if lst.count(element) > 1:
duplicates.append(element)
return duplicates
#Rewritten as a list comprehension
def find_duplicates_2(lst):
r... | true |
547984f82e245a84d8d1122553600f8fd5242f79 | zadrozny/algorithms | /matched_braces.py | 1,299 | 4.125 | 4 | '''
Challenge 2: Braces
Given an array of strings containing three types of braces: round (), square [] and curly {}
Your task is to write a function that checks whether the braces in each string are correctly matched prints 1 to standard output (stdout) if the braces in each string are matched and 0 if they're not (... | true |
74f9d1a7da0af018658e153665870d69b6259d46 | HtetoOs/Practicals | /prac_03/oddName.py | 223 | 4.125 | 4 | name = input("Enter your name!")
while len(name)<=0:
print("Name is blank! Please enter your name!")
name = input("Enter your name!")
print(name[: : 2])
for i in range(0, len(name), 2):
print(name[i], end="") | true |
bf721957e07df6a9ab6fad30ba99e233512a0a15 | gbanfi3/misc | /Euler/a001.py | 331 | 4.15625 | 4 | '''
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.
'''
lim = 1000
sum = 0
for i in range(1,lim):
if not i % 3:
sum +=i
continue
if not i % 5:
sum +=i... | true |
fd2d5ef7a880dc1749d489542ae72a5510f39199 | Al153/Programming | /Python/Misc/maths.py | 959 | 4.34375 | 4 | pi=3.1415926535
from math import *
n=2
operation = "go"
square = 1
circle = 2
elipse = 3
rectangle = 4
while operation != "stop":
operation = (input("which shape do you want to find the area of? "))
if operation == 1:
print("area of a square")
sidelength=float(input("side length = "))
a... | true |
0b545e74b9ec8ba6284590a38cf0f7e24f9bc7bf | Al153/Programming | /Guest/Hour of code/Heapsort.py | 2,174 | 4.25 | 4 | def heapsort(lst):
''' Heapsort. Note: this function sorts in-place (it mutates the list). '''
compare_count = 0
print "Creating heap"
for start in range((len(lst)-2)/2, -1, -1):
compare_count = siftdown(lst, start, len(lst)-1,compare_count)
print lst
print "decomposing heap"
for end in range(len(l... | true |
8a2a07ff7d19edea0d93b5dfdb65d032ad851630 | Adheethaov/InfyTQ-Python | /grade.py | 647 | 4.21875 | 4 | #A teacher in a school wants to find and display the grade of a student based on his/her percentage score.
#The criterion for grades is as given below:
#Score (both inclusive) Grade
#Between 80 and 100 A
#Between 73 and 79 B
#Between 65 and 72 C
... | true |
b026e0fa91ec048ff4a61a95902319a0e3439c4b | anishsaah/Learning-Python | /sample calculator.py | 1,221 | 4.375 | 4 | while True:
print("Options:")
print("Enter 'add' to add two numbers.")
print("Enter 'subtract' to subtract two numbers.")
print("Enter 'multiply' to multiply two numbers.")
print("Enter 'divide' to divide two numbers.")
print("Enter 'quit' to end the program.")
a = input(": ")
... | true |
fdaab6120cacaab50010d1d2c907f6ca625359a3 | SibiSagar/codekata | /problem4.py | 246 | 4.25 | 4 | #Check whether a character is an alphabet or not
alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
char=input()
if char in alphabet:
print("Alphabet")
elif char in alphabet.lower():
print("Alphabet")
else:
print("No")
| true |
5f2b3fdc2e0cedcfba66a2cdd36edf2475c2ca78 | ambergooch/dictionaries | /dictionaryOfWords.py | 828 | 4.625 | 5 |
# Create a dictionary with key value pairs to represent words (key) and its definition (value)
word_definitions = dict()
word_definitions["Awesome"] = "The feeling of students when they are learning Python"
word_definitions["Cool"] = "A descriptor word for a cucumber"
word_definitions["Chill"] = "The act of sinking ... | true |
e534b2fa2a5545f10c26be9245a37f403070c682 | chamoysvoice/p_euler | /problem4.py | 781 | 4.15625 | 4 | # coding=utf-8
from __future__ import division
from math import sqrt
"""
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is
9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
"""
def is_palindrome(sv):
retu... | true |
83d5431831804d453b09cf5670061394685d3418 | TylerHJH/DataStructure | /lab1_e3.py | 762 | 4.34375 | 4 | """
Input:
First we have a empty list Hailstone.
n: Get a number n and put it into the list, then judge whether is even or odd.
If it's even, put n/2 into the list Hailstone, else put 3n+1 into the list.
Then continue to judge whether the calculated number n/2 or 3n+1 is odd or even and do the same o... | true |
053bbf84269b6a100eace6160769e4e370108201 | Muoleehs/Muoleeh | /Task_7.py | 673 | 4.15625 | 4 | import statistics
from array import *
# The * above implies the need to work with all array functions
arr = array ('I', [])
# 'I' represents a type code for unsigned/positive integers as the task demands
length = int(input("Enter the length of the array: "))
# This collects the number of integers expected in ... | true |
85afdfdc5b985e0ed5a51ad251690345e69d94bd | magatj/Job_And_Res_Parser | /Random_Word.py | 2,857 | 4.125 | 4 | import random
import pandas as pd
def rand_word():
'''Transform excel column and row files to a dictionary'''
word_list = []
q1 = input('What is the file location \n (file must only have on column with a header and values \n\
example: C:/Users/jesse/Desktop/Word_list.xlsx)')#'C:/User... | true |
d80e96637b85bc4db58a814e19d7f2724efdded7 | se7enis/learn-python | /webapp/cgi-bin/createDBtables.py | 682 | 4.15625 | 4 | import sqlite3
connection = sqlite3.connect('coachdata.sqlite') # establish a connection to a database; this disk file is used to hold the database and its tables
cursor = connection.cursor() # create a cursor to the data
cursor.execute("""CREATE TABLE athletes(
id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NUL... | true |
b6600be05f7aaab0b30065fdd8efefb6897181e4 | sujay-dsa/ISLR-solutions-python | /Chapter-2-Intro-to-statistical-learning.py | 1,707 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 20 22:28:35 2018
Here I try to map the commands specified in R to
the python equivalent. All commands are as mentioned
in ISLR chapter 2.
@author: Sujay
"""
# Basic Commands
# creating a vector (python equivalent is list)
x=[1,2,3,4]
y = [1,4,3,7]
type(x)
# Findin... | true |
3a30077f0f59df38612411201149dad154069646 | Zerl1990/2020_python_workshop | /12_lists.py | 385 | 4.25 | 4 | # A list can contain values of different types
my_list = ["Hello", "Hi", 10, False]
# Print values in list
print(f'This is my list: {my_list}')
print(f'First Value: {my_list[0]}')
print(f'Second Value: {my_list[1]}')
print(f'Third Value: {my_list[2]}')
print(f'Fourth Value: {my_list[3]}')
# Add extra value
my_list.ap... | true |
dcdfb53769710b6345d2363183167b1adb075ffa | joelcede/programming_languages | /python3/BitCounting.py | 718 | 4.25 | 4 | '''
Write a function that takes an integer as input,
and returns the number of bits that are equal to one in the binary
representation of that number. You can guarantee that input is non-negative.
Example: The binary representation of 1234 is 10011010010,
so the function should return 5 in this case.
'''
def count_bi... | true |
02760cdd7504f5ea11125f313bbe196469866d76 | chyld/berkeley-cs61a | /misc/lab01/lab01_extra.py | 663 | 4.25 | 4 | from functools import reduce
"""Coding practice for Lab 1."""
# While Loops
def factors(n):
"""Prints out all of the numbers that divide `n` evenly.
>>> factors(20)
20
10
5
4
2
1
"""
"*** YOUR CODE HERE ***"
nums = [x for x in range(1, n+1) if not(n%x)]
nums.sort()
... | true |
236385c58e9fd1f164336b632cee97ceab94f215 | sameervirani/week-1-assignments | /fizzbuzz.py | 367 | 4.28125 | 4 | #Take input from the user. If the input is divisible by 3 then print "Fizz",
#if the input it divisible by 5 then print "Buzz".
#If the input is divisible by 3 and 5 then print "Fizz Buzz".
user1 = int(input("Enter number: "))
if user1 % 3 == 0 and user1 % 5 == 0:
print("Fizz Buzz")
elif user1 % 3 == 0:
print(... | true |
1b5a6eca3df1fa66ecf3d3b56b2e41f273af07a5 | Nabdi22/TTA | /DFD-Code.py | 598 | 4.125 | 4 | print("Hello Welcome to Nafisa's Shoe Shop")
shoe_size = int(input("Please enter your shoe size: "))
if shoe_size > 6:
print("You will need to shop from the Adult Section")
else:
print("You will need to shop from the Junior Section")
print("Please choose from our three different brands which are Nike... | true |
e1284e6ec7edccbd7e16479288c8b9a48ecc4dc0 | lakshyarawal/pythonPractice | /Mathematics/computing_power.py | 875 | 4.15625 | 4 | """ Computing Power: Find x raised to the power y efficiently """
import math
""" Naive Solution: """
def comp_power(a, b) -> int:
power_result = 1
if b == 0:
return power_result
for i in range(b):
power_result = power_result * a
return power_result
""" Efficient Solution: Divide t... | true |
4125cc5cddbea0f79f8b4ab1312c78eeb8493274 | dvanduzer/advent-of-code-2020 | /day2-2.py | 1,295 | 4.1875 | 4 | """
For example, suppose you have the following list:
1-3 a: abcde
1-3 b: cdefg
2-9 c: ccccccccc
Each line gives the password policy and then the password. The password policy indicates the lowest and highest number of times a given letter must appear for the password to be valid. For example, 1-3 a means that the pas... | true |
ed0443b6c95d9ec77dafc2dfdd66e0a86a5ed180 | DvorahC/Practice_Python | /exercice2_easy.py | 723 | 4.15625 | 4 | """
Create a program that asks the user to enter their name and their age.
Print out a message addressed to them that tells them the year that they will turn 100 years old.
Extras:
Add: asking the user for another number and printing out that many copies of the previous message.
(Hint: order of operations exists in Py... | true |
f7c25cf743a72a8029f30f5ea059efbc67c7cdc2 | jeremyt0/Practice-Tasks | /reverse.py | 560 | 4.4375 | 4 |
task = """In python, you have a list of values n elements long called value_list.
Create a second list that is the reverse of the first, starting at the last element,
and counting down to the first."""
def reverseList(list1):
newlist = []
n=0
while n<len(list1):
newlist.append(list1[len(list1)-1])
... | true |
cb5993d7038d87f1d89a16986304b04eed125b58 | Amirpatel89/CS-Fundamentals | /Day1/Bubblesort.py | 343 | 4.15625 | 4 | array = [5, 3, 2, 4, 1]
def bubble_sarray(list) =
swapped = True;
while swapped == True:
while swapped: False
for i in range(len(a) - 1):
if list[i]>list[i+1]:
temp = list[i]
list[i] = list[i+1]
list[i+1] = temp
bubbleSort(list)
pri... | true |
fb5d104195bc067404b8b128105e5762497b73d9 | joannaluciana/Python-OOP- | /oop/day2/hwday2/6 he lambda.py | 1,080 | 4.5 | 4 | #6. Write a Python program to square and cube
# every number in a given list
# of integers using Lambda. Go to the editor
#Click me to see the sample solution
items = [1, 2, 3, 4, 5]
squared = list (map(lambda x: x**2, items))
print(squared)
#13 Write a Python program to count the even, odd numbers in
#a given ar... | true |
968b2b4e002d1fae4de0d40a9efd38e34e32c58d | jmontara/become | /Recursion/recursion_start.py | 693 | 4.40625 | 4 | # recursive implementations of power and functions
def power(num,pwr):
""" gives number to the power
inputs:
num - int, number
pwr - int, power
outputs:
ret - int, number to the power
"""
if pwr == 0:
return 1
else:
return num * power(num, pwr - 1)
def factorial(num):
if num == 0:
return 1
e... | true |
f7e90d0db53004d861dba2c1e87bda1a52f80930 | muskanmahajan37/learn-em-all | /learnemall/datasets/iris.py | 2,069 | 4.1875 | 4 | ## Core Functionality to Load in Datasets
import numpy as np
import pathlib
from sklearn.model_selection import train_test_split
def load_data(split=False,ratio=None,path='./data/iris.csv'): ## generalized function to load data
"""
Loads in data from ./data/dataset.csv
Parameters:
=================... | true |
66fcb60cbdb27745ab8e04b104c226b1b37a1889 | congsonag/udacity-data-structures-algorithms-python | /list-based collections/Queue.py | 1,883 | 4.34375 | 4 | """Make a Queue class using a list!
Hint: You can use any Python list method
you'd like! Try to write each one in as
few lines as possible.
Make sure you pass the test cases too!"""
class Element:
def __init__(self, value):
self.value = value
self.next = None
class LinkedList:
def __init__(sel... | true |
3d659dc37006707dad08aedbde8b2f9df9437e09 | bnmcintyre/biosystems-analytics-2020 | /extra/01_dna/dna.py | 1,670 | 4.15625 | 4 | #!/usr/bin/env python3
"""
Author : bnmcintyre
Date : 2020-02-04
Purpose: count the frequency of the nucleotides in a given piece of DNA
"""
import argparse
import os
import sys
# --------------------------------------------------
def get_args():
"""Get command-line arguments"""
parser = argparse.Argument... | true |
928d0729cfdcc0880182ed0a9453f190ff9f9f4a | jessiditocco/calculator2-01-18 | /calculator.py | 922 | 4.28125 | 4 | """A prefix-notation calculator.
Using the arithmetic.py file from Calculator Part 1, create the
calculator program yourself in this file.
"""
from arithmetic import *
while True:
token = raw_input("> ")
token = token.split()
operator = token[0]
if operator == "q":
break
elif operator =... | true |
5143231de6f9ce460c87056834ce6915d7960579 | amithmarilingegowda/projects | /python/python_programs/reverse_list.py | 712 | 4.71875 | 5 | import sys
# Option #1
# ---------
# Using in-built function "reversed()": This would neither reverse a list in-place(modify the original list),
# nor we create any copy of the list. Instead, we get a reverse iterator which we use to cycle through the list.
#
# Option #2
# ---------
# Using in-build function "reverse(... | true |
6786b1a9403fd5127628622b32ad046207ec7fc9 | charliechocho/py-crash-course | /voting.py | 289 | 4.15625 | 4 | age = 101
if age >= 18 and age <= 100:
print("you're old enough to vote!!")
elif age > 100:
print("You're more than 100 years?!? Have you checked the obituaries?? ")
print("If you're not in there, go ahead and vote")
else:
print("Wait til' you're 18 and then you can vote") | true |
b2dd7887583c3d0af946550fb0603ac9ce35e158 | amitchoudhary13/Python_Practice_program | /string_operations.py | 661 | 4.4375 | 4 | #!usr/bin/python
'''
Basic String operations
Write a program to read string and print each character separately.
a) Slice the string using slice operator [:] slice the portion the strings to create a sub strings.
b) Repeat the string 100 times using repeat operator *
c) Read string 2 and concatenate with o... | true |
5713a0f09fbf8439b257469c668d67170992e716 | amitchoudhary13/Python_Practice_program | /odd_or_even.py | 263 | 4.125 | 4 | #!/usr/bin/python
'''Write a program to find given number is odd or Even'''
#variable declaration
a = 10
b = a % 2
if b == 0 : #if Implementation for even
print "Given number is", a, "even"
else: #if Implementation for odd
print "Given number is", a, "odd"
| true |
c41cb4db3290f33593118e98dbc208ec7a9bd332 | amitchoudhary13/Python_Practice_program | /fibonacci_series.py | 719 | 4.375 | 4 | #!/usr/bin/pyhton
'''20.Write a program to generate Fibonacci series of numbers. Starting numbers are 0 and 1, new number in the series is generated by adding previous two numbers in the series. Example : 0, 1, 1, 2, 3, 5, 8,13,21,..... a) Number of elements printed in the series should be N numbers, Where N is any +ve... | true |
e6cfee1b13d05dd52fdf6ee8312688bfcadf8098 | SaiPhani-Erlu/pyScript | /3_DeepDive/CaseStudy1/01_CompactRobot.py | 1,038 | 4.34375 | 4 | import math
from functools import reduce
'''
Q1. A Robot moves in a Plane starting from the origin point (0,0). The robot can move
toward UP, DOWN, LEFT, RIGHT. The trace of Robot movement is as given
following: UP 5, DOWN 3, LEFT 3, RIGHT 2
The numbers after directions are steps. Write a program to compute the
distan... | true |
beee7adf77fca1ddfc925ffdc7b8fbc93f86d248 | SaiPhani-Erlu/pyScript | /2_Seq_FileOps/seqInput.py | 1,758 | 4.1875 | 4 | '''
A website requires a user to input username and password to register.
Write a program to check the validity of password given by user.
Following are the criteria for checking password:
1. At least 1 letter between [a-z]
2. At least 1 number between [0-9]
3. At least 1 letter between [A-Z]
4. At least 1 character fr... | true |
ab9f452e8e1c711da3e27f8fdc101d274a860061 | radam9/CPB-Selfmade-Code | /07_Decorators.py | 1,990 | 4.3125 | 4 | #Decorators
#Mainly used for web developement (Flask and Django)
def func():
return 1
def hello():
return 'Hello!'
hello
greet = hello
greet
print(greet())
#
def hello(name='Adam'):
print('The hello() function has been executed!')
def greet():
return '\t This is the greet() function inside hello... | true |
0f82666397eba43041ecc911652e22d28d6876e8 | sravyapara/python | /icp3/vowels.py | 408 | 4.375 | 4 | str=input("enter the string")
def vowel_count(str):
# Intializing count to 0
count = 0
# Creating a set of vowels
vowel = {"a","e","i","o","u"}
# to find the number of vowels
for alphabet in str:
# If alphabet is present then count is incremented
if alphabet in vowel:
... | true |
dc661840ce903a643db2dd851329fb1bbce006ac | MrRa1n/Python-Learning | /Tuple.py | 388 | 4.53125 | 5 | # Tuples are used to store a group of data
# Empty tuple
tuple = ()
# One item
tuple = (3,)
# Multiple items
personInfo = ("Diana", 32, "New York")
# Data access
print(personInfo[0])
print(personInfo[1])
# Assign multiple variables at once
name,age,country,career = ("Diana", 32, "United States", "CompSci")
print(c... | true |
88c45d54bcf39138644d20b592b17ed02083c45e | courtneyng/GWC-18-PY | /gwc_py/programs/lists/liststuff.py | 739 | 4.28125 | 4 | friends = ["Camille", "Sarah", "Jade", "Aadiba", "Aishe"]
onepiece = ["Luffy", "Zoro", "Nami", "Usopp", "Sanji", "Chopper", "Robin", "Frankie", "Brook"]
friend = "RajabButt"
two = [friends, onepiece]
print(*friends) #list w/o brackets and commas
print(friends) #list with brackets and commas but also quotes
fo... | true |
0ad9fd99507f9d1e1a14e43ce9b4f11b0850a80e | 3deep0019/python | /Input And Output Statements/Command_Line_Arguments.py | 947 | 4.1875 | 4 | # ------> argv is not Array it is a List. It is available sys Module.
# -----> The Argument which are passing at the time of execution are called Command Line
# Arguments.
# Note: ---------->argv[0] represents Name of Program. But not first Command Line Argument.
# argv[1] represent First... | true |
a6e01da933653dca7493296ad2c255bcb6ab2609 | 3deep0019/python | /basic01/ListDataType.py | 414 | 4.15625 | 4 | # if we want to represent a group of values as a single entity where insertion order required
# to preserve and duplicates are allowed are allowwed then we should go for list data type .
list=[10,20,30,40]
print(list[0])
print(list[-1])
print(list[1:3])
list[0]=100
for i in list:print(i)
# --- **** lis... | true |
97e513a0f616d804bf623dba4456b663da277b8a | 3deep0019/python | /Input And Output Statements/Input.py | 2,548 | 4.40625 | 4 | # 2)input():
# input() function can be used to read data directly in our required format.We are not
# required to perform type casting.
# x = input("Enter Value)
# type(x)
# 10 int
# "durga" str
# 10.5 float
# True bool
# ***Note:
# -------> But in Python 3 we have only input() method and raw... | true |
bfb02ba9318aeeceb7f7888063ba57036e965e7f | 3deep0019/python | /basic01/RelationalOperator.py | 700 | 4.1875 | 4 | # > , <= , < , <=
a=10
b=20
print("a > b is ",a>b)
print("a >= b is ",a>=b)
print("a < b is ",a<b)
print("a <= b is ",a<=b)
a > b is False
a >= b is False
a < b is True
a <= b is True
# *** We can apply relational operators for str types also.
#
a="durga"
b="durga"
print("a >... | true |
9ffbab16675a9972956979ae653b3c2d283c860e | 3deep0019/python | /basic01/AssignmentOperators.py | 616 | 4.28125 | 4 | # Assignment operators
# -----------> We can use assignment operator to assign value to the variable.
# Eg:
# x = 10
# ****** We can combine asignment operator with some other operator to form compound
# assignment operator.
# Eg:
# x += 10 ... | true |
68025058491424f25b1b8ff2054283b6c50c8729 | 3deep0019/python | /STRING DATA TYPE/Replacing a String with another String.py | 1,227 | 4.5 | 4 | # Replacing a String with another String
# --------------------->>>>>>>>>> s.replace(oldstring, newstring)
# inside s, every occurrence of old String will be replaced with new String.
# Eg 1:
s = "Learning Python is very difficult"
s1 = s.replace("difficult","easy")... | true |
2a8d3f1ee39455d37885011c0e0aad5aa5173ecd | gum5000/The-Soap-Mystery | /Main.py | 1,821 | 4.25 | 4 | # Python program for implementation of MergeSort
def mergeSort(arr):
if len(arr) >1:
mid = len(arr)//2 #Finding the mid of the array
L = arr[:mid] # Dividing the array elements
R = arr[mid:] # into 2 halves
mergeSort(L) # Sorting the first half
mergeSort(R) # Sorti... | true |
4ea5fe095bb8b14c78421fd592e1198e92e2338f | anthonywww/CSIS-9 | /prime_numbers.py | 632 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Program Name: prime_numbers.py
# Anthony Waldsmith
# 07/12/2016
# Python Version 3.4
# Description: Print out prime numbers between 3 to 100.
# Optional import for versions of python <= 2
from __future__ import print_function
# Loop between 3(start) to 100(end)
for i i... | true |
3cc6d21d24190988ef9c970cbb4e808607cd8e1f | anthonywww/CSIS-9 | /is_triangle.py | 1,249 | 4.375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Program Name: is_triangle.py
# Anthony Waldsmith
# 07/14/2016
# Python Version 3.4
# Description: A function that checks if a triangle can be formed with the following parameters (a, b, c)
import random
# isTriangle function
def isTriangle(a,b,c):
# Check if the length... | true |
9b9305de824ee3d38dcc69da90a2f26ea150979e | anthonywww/CSIS-9 | /TEMPLATE.py | 636 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Program Name: <ENTER PROGRAM NAME>
# <ENTER NAME>
# <ENTER DATE>
# Python Version 3.4
# Description: <ENTER DESCRIPTION>
# Optional import for versions of python <= 2
from __future__ import print_function
# Do this until valid input is given
while True:
try:
# Tex... | true |
1006690d7e272732f7c61093227966af0096e9cc | aymenbelhadjkacem/holbertonschool-higher_level_programming | /0x06-python-classes/4-square.py | 974 | 4.21875 | 4 | #!/usr/bin/python3
"""Module square empty"""
class Square:
"""Square class def"""
def __init__(self, size=0):
"""if size not integer test raise expectation"""
""" attribute size (int): Size of square"""
self.__size = size
"""are function defintion"""
def area(self):
""... | true |
c51065c4ecbe92b79f967e72a8953498bede8c7c | albertsuwandhi/Python-OOP | /abstract_class.py | 624 | 4.1875 | 4 | # ABC = abstract base class
from abc import ABC, abstractmethod
#inheritance form ABC
class Button(ABC):
@abstractmethod
def onClick(self):
pass
class pushButton(Button):
def onClick(self):
print("Push Button Clicked")
class radioButton(Button):
# pass
# onClick must be implement... | true |
b1398fa7502fa47412ba7986d3727b1c944ffc46 | J-sudo-2121/codecademy_projects | /players.py | 1,291 | 4.71875 | 5 | # Working with a specific group of items in a list is called a slice (slicing)
# in Python.
players = ['charles', 'martina', 'michael', 'florence', 'eli']
print(players[0:3])
# You can generate any subset of a list.
print(players[1:4])
# If you omit the first index in a slice Python automatically starts your slice
# ... | true |
cc0742449bd9a5353248bb4d2d33a597c030d505 | J-sudo-2121/codecademy_projects | /toppings.py | 2,570 | 4.5 | 4 | # When you want to determine whether two values are not equal use (!=). !
# represents not.
requested_topping = 'mushrooms'
if requested_topping != 'anchovies':
print("Hold the anchovies!")
# Most of the conditional expressions you write will test for equality. /
# Sometimes you'll find it more efficient to test for ... | true |
1afdd366fccc022e4d4dd66ad7a881c79db8eb3b | J-sudo-2121/codecademy_projects | /cars2.py | 1,926 | 4.34375 | 4 | # Using an if statement.
cars = ['audi', 'bmw', 'subaru', 'toyota']
for car in cars:
if car == 'bmw':
print(car.upper())
else:
print(car.title())
# Python uses the values of True and False to decide whether the code in an if /
# statement should be executed.
# Conditional Tests.
car = 'subaru'
print("Is car == ... | true |
a647288d4d031ffc705c807166d7c2332e1d9638 | vandyliu/small-python-stuff | /madLibs.py | 1,955 | 4.1875 | 4 | #! python3
# Takes a mad libs text file and finds where an ADJECTIVE, NOUN, ADVERB, VERB should be replaced
# and asks users for a suggestion then saves the suggestion to a text file in the same directory
# Idea from ATBS
# To run type python.exe madLibs.py <path of madlibs text>
# Eg. python.exe C:\Users\Vandy\Pychar... | true |
fcfd80443b1dc4eba5b25056252a465057362201 | gravityrahul/PythonCodes | /AttributeConcepts.py | 2,119 | 4.34375 | 4 | '''
Python attribute tutorial based on Sulabh Chaturvedi's online tutorial
www.cafepy.com/article/python_attributes_and_methods/python_attributes_and_methods.html
#method-resolution-order
'''
class C(object):
'''
This example illustrates Attribute concepts
'''
classattribute="a class attribut... | true |
0dc3b3104f4470e167227184602631f12951dab3 | ImprovementMajor/New | /Task1.py | 250 | 4.1875 | 4 | temp = float(input("Welcome to the temperature converter! Please enter a temperature and its units: "))
if units == F :
print(temp_f)
else :
print(temp_c)
temp_f = (9/5) * temp_c + 32
print(temp_f)
temp_c = temp_f - 32 * 5/9
print(temp_c)
| true |
0863297aca2ecae6ce8b6dd76fc268fc4fa1de67 | kishanSindhi/python-mini-projects | /minipro8.py | 358 | 4.28125 | 4 | # Author - Kishan Sindhi
# date - 30-5-2021
# discription - this function take the year as input from the user
# and in return it tells that the entered tear us a leap yaer or not
year = int(input("Enter a year you want to check that is a leap year or not:\n"))
if year % 4 == 0:
print("Year is leap year")
... | true |
e5947d044940b0d42e446919219b6727211a5e6e | tusharsappal/GeneralInterViewquestions | /GeeksForGeeks Questions/LinkedListPrograms/SimpleOrderedLinkedList.py | 1,445 | 4.15625 | 4 |
class Node(object):
def __init__(self,initData):
self.data = initData
self.next = None
def getData(self):
return self.data
def getNext(self):
return self.next
def setData(self,newData):
self.data = newData
def setNext(self,nextNode):
self.next =... | true |
f834cbb5c946259bf32c29c033c2603779f63579 | tusharsappal/GeneralInterViewquestions | /GeeksForGeeks Questions/ArrayPrograms/BinarySearch.py | 1,083 | 4.15625 | 4 | # A simple class demonstrating Binary Search
class BinarySearch(object):
def binarySearch(self):
print "Enter the Sorted Array \n"
string_input = raw_input()
input_list = string_input.split()
input_list = [int(a) for a in input_list]
print "Array to be searched", input_list
... | true |
b396c5e7c99690636400614be744a0bb83d21659 | tusharsappal/GeneralInterViewquestions | /GeeksForGeeks Questions/ArrayPrograms/LeadersInArray.py | 924 | 4.125 | 4 | # This program checks for the leader in the array
#An element is leader if it is greater than all the elements to its right side. And the rightmost element is always a leader.
class FindLeaderInArray(object):
def findLeaderInArray(self):
print "Enter the Array "
string_input = raw_input()
i... | true |
f7b74aa32c21042a530ddac4df0655348dfcf8ce | tusharsappal/GeneralInterViewquestions | /GeeksForGeeks Questions/DynamicProgramming/SumOfAllSubStringRepresentingString.py | 1,370 | 4.125 | 4 | '''This program prints Sum of all substrings of a string representing a number
We will be using the Concept of Dynamic Programing
We can solve this problem using dynamic programming. We can write summation of all substrings on basis of digit at which they are ending in that case,
Sum of all substrings = sumofdigit[0] +... | true |
9fb575247b44fd6cb944b68f0d077285dd80797f | AlyonaKlekovkina/JetBrains-Academy-Multilingual-Online-Translator | /translator.py | 275 | 4.125 | 4 | inp = input('Type "en" if you want to translate from French into English, or "fr" if you want to translate from English into French: \n')
word = input('Type the word you want to translate: \n')
print('You chose "{}" as the language to translate "{}" to.'.format(inp, word))
| true |
99b5e59a7ea63f7900a144b9540f48c241c9094a | 15johare/mockexam.py | /mockexam.py | 1,226 | 4.1875 | 4 | while True:
mood=input("choose what mood you are feeling")
print("this is a program that shows you what music to listen to depending on your mood")
print("all you have to do is type what mood you are and a link to a song will come up")
if mood=="happy":
print("https://www.youtube.com/watch?v=ZbZSe6N_BXs"... | true |
fd88fd1e55b79c6ef5e64f749c8255d2872dbfe8 | Anshikaverma24/if-else-meraki-ques | /if else meraki ques/q7.py | 314 | 4.21875 | 4 |
# take a number as input from the user. Convert this input to integer. Check if it is equal to varx.
# If the number is equal to varx, print "Equal" else print "Not equal".varx = 300 - 123
varx = 300 - 123
answer=int(input("enter the answer : "))
if answer==varx:
print("equal")
else:
print("not equal") | true |
a0f65d7e301ffaa85add12475cd8859afc18b095 | Anshikaverma24/if-else-meraki-ques | /if else meraki ques/q16.py | 281 | 4.1875 | 4 | # meraki debugging questions in if else
# number = input("please enter a decimal number")
# print ("your number divided by 2 is equal to = " + number/2)
# ANSWER
number = int(input("please enter a decimal number"))
print ("your number divided by 2 is equal to = ", + number/2) | true |
18a3633fd7a091250cee523189a7943a8de516a3 | tbaraza/Bootcamp_7 | /Day-3/data_types.py | 770 | 4.1875 | 4 | def data_type(x):
"""
Takes in an argument x:
- For an integer , return x ** 2
- For a float, return x/2
- For a string, returns "Hello " + x
- For a boolean, return "boolean"
- For a long, return squaroot of x
"""
if isinstance(x, int):
... | true |
9f4d6ae9ee32c1a152c1dca4a0ae343390637983 | shenbomo/LintCode | /Implement Queue by Stacks.py | 1,024 | 4.125 | 4 | """
As the title described, you should only use two stacks to implement a queue's actions.
The queue should support push(element), pop() and top() where pop is pop the first(a.k.a front) element in the queue.
Both pop and top methods should return the value of first element.
Example
For push(1), pop(), push(2), push... | true |
e317fdcd87ccf6f8fb70b3255b99862d615ca219 | Alexanra/graphs- | /Guess_my_number_working.py | 1,309 | 4.125 | 4 | print ("Please think of a number between 0 and 100!")
minimum = 0
maximum = 100
guess = minimum + (maximum-minimum)//2
print ("Is your secret number " + str(int(guess)) + "?")
ans = str (input("Enter 'h' to indicate the guess is too high. "+\
"Enter 'l' to indicate the guess is too low. "+\
... | true |
e17ad79242ce3fba5a259fa68d49436d210f2a41 | malarc01/Data-Structures | /binary_search_tree/Data Structures in Python- Singly Linked Lists -- Insertion .py | 1,353 | 4.21875 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def print_list(self):
curr_node = self.head
while curr_node:
print(curr_node.data)
curr_node = curr_node.next
... | true |
4ac0c78234417136cc65611724eb635eeb072b57 | ThakurSarveshGit/CrackingTheCodingInterview | /Chapter 1 Arrays and Strings/1_5.py | 779 | 4.21875 | 4 | # -*- coding: cp1252 -*- // What is this?
# Problem 1.5
# Write a method to replace all spaces in a string with %20.
# I doubt if any interviewer would give this question to be solved in python
# Pythonic Way
def replace(string):
modified_string = string.replace(" ", "%20")
print modified_string
... | true |
7dc54efd48efa8bd557e3171322479ce3e0bd98a | ThakurSarveshGit/CrackingTheCodingInterview | /Chapter 1 Arrays and Strings/1_2.py | 708 | 4.28125 | 4 | # -*- coding: cp1252 -*- # No clue why this came up :/
# Problem 1.2
# Write code to reverse a C-Style String.
#(C-String means that abcd is represented as five characters, including the null character.)
def reverse_in_c(string):
# Python Style of Reversing a string
Reverse_String_Python = string[... | true |
c02cc82c080c24f7b9441c9fd7b4ea35a1f7c464 | Saptarshidas131/Python | /p4e/exercises/ex7_1.py | 470 | 4.40625 | 4 | """
Exercise 1: Write a program to read through a file and print the contents
of the file (line by line) all in upper case. Executing the program will
look as follows:
"""
filename = input("Enter filename: ")
# try opening file
try:
fileh = open(filename)
except:
print("Invalid filename ",filename)
exit()
... | true |
ac308ee29c9e87118d51cb92273aa4fd0d2616f4 | Saptarshidas131/Python | /p4e/exercises/ex3_2.py | 663 | 4.125 | 4 | """
Exercise 2: Rewrite your pay program using try and except so that your
program handles non-numeric input gracefully by printing a message
and exiting the program. The following shows two executions of the
program
"""
# prompt for hours and rate per hour
try:
hours = float(input("Enter Hours: "))
rate = flo... | true |
3c77543a0ab17cadcee5e91695ead226115b1f6e | rohitj205/Python-Basics-Code | /LOOPS.py | 2,096 | 4.34375 | 4 | #Loops
"for loop:"
#If we want to execute some action for every element present in some sequence
# (it may be string or collection)then we should go for for loop.
#Eg
#To Print Character represented in String
s = "Sachin Tendulkar"
for x in s:
print(x)
#For loop
exp = [2310,5000,2500,4500,4500]
total... | true |
304bcfdd829e991fa16a7599acec6069ea4ce02b | alicexue/softdev-hw | /hw07/closure.py | 1,063 | 4.65625 | 5 | # CLOSURES
# 1. A function is declared inside another function
# 2. Inner function accesses a variable from the outer function (outside of the local scope of the inner function)
# 3. The external function binds a value to the variable and finishes (or closes) before the inner function can be completed
def repeat(s):
... | true |
53480cb6f015a3aceab2b74efad30017109bef7b | dexamusx/thPyCh3 | /thPyCh3.py | 2,494 | 4.46875 | 4 | #Exercise 1
#Write a function named right_justify that takes a string named s as a parameter and prints the string
#with enough leading spaces so that the last letter of the string is in column 70 of the display.
#eg: right_justify('monty')
#monty
#Hint: Use string concatenation and repetition. Also, Python provid... | true |
739da86c8ad51a05972c4e0e9efe317f399226d2 | WritingPanda/python_problems | /anagramAlgorithm.py | 942 | 4.21875 | 4 | __author__ = 'Omar Quimbaya'
word_one = input("Enter the first word: ")
word_two = input("Enter the second word: ")
def is_anagram(string_one, string_two):
stripped_string_one = string_one.strip()
stripped_string_two = string_two.strip()
if not stripped_string_one.isalpha() and not stripped_string_two.i... | true |
20318d3eb76e871efcaee27efd60bff76ca48823 | nirbhaysinghnarang/CU_Boulder_DSA | /merge_sort.py | 826 | 4.125 | 4 | def merge_sort(array,left,right):
if(left<right):
mid = (left+right)//2
merge_sort(array,left,mid)
merge_sort(array,mid+1,right)
merge(array,left,right,mid)
def merge(array,left,right,mid):
tmp = [0] * (right - left + 1)
left_ctr = left
right_ctr = mid+1
tmp_index=0
while(left_ctr<=mid and right_ctr<=ri... | true |
abed9991559fd5066191f3a64e457761148f4a42 | lisawei/director_to_python | /string.py | 375 | 4.15625 | 4 | name=raw_input("what's your name")
quest=raw_input("what's you quest")
color=raw_input("what is you favorite color")
print "Ah, so your name is %s, your quest is %s, your favorite color is %s." % (name,quest,color)
my_string="wow, you\'re great"
my_age="your age is"
age=18
print len(my_string)
print my_string.upper()... | true |
96cb4ac82227897b2048fc37e969135c40960b2a | Umakant463/Mini_Projects | /Calculator/cal1.py | 1,110 | 4.21875 | 4 | import math
print ("========== SIMPLE CALCULATOR =========== \n \n ")
print ("--- Enter two numbers ---- \n ")
num1 = int(input('Enter first number : '))
num2 = int(input('Enter second number : '))
# Addition of numbers
def add(a,b):
return (a + b)
#First checks the largest among two numbers and then subtract t... | true |
2f69f87e503e3de98397c50726072bb3198bbe76 | bhabnish/Python-Project | /Project_My_Captain.py | 612 | 4.375 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
# In this programme I took a radious from the user and found the area of the given radious
radius = int(input(" Please give the radius of your circle: "))
area = (22/7)*(radius)*(radius)
print ("The area of your circle is: " + str(area))
# In[3]:
# In this program... | true |
90a815d623eea0e183394bba7dc56925d73dd326 | EnginKosure/Jupyter_nb | /ch34.py | 2,634 | 4.25 | 4 | # For the sake of simplicity I'll refer to the array as "arr",
# the beginning index as "left", the end index as "right",
# and the element that we're searching for as "elem".
# The input for left and right initially will be left = 0 and right = sizeOfArray - 1.
# The rest of the algorithm can be broken down in five st... | true |
b08c72697fb4c9e7943f597cf01b07d2039aed34 | pasignature/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/2-matrix_divided.py | 1,308 | 4.1875 | 4 | #!/usr/bin/python3
'''
2-matrix_divided.py
Contains function that divides all elements of a matrix
'''
def matrix_divided(matrix, div):
'''
Python Function that divide a matrix by variable div
'''
listError = 'matrix must be a matrix (list of lists) of integers/floats'
# Check if matri... | true |
4641f57df69aa565059f5c88006b63fd8ed5f8d4 | malmike/SelfLearningClinic | /Car/app/car.py | 2,046 | 4.28125 | 4 | class Car(object):
"""
Added constructor taking arguments *args and **kwargs where *args
expects a list of items and **kwargs expects a dictionary. This allows
a class to be initialised with dynamic number of variables
"""
def __init__(self, *args, **kwargs):
self.type = ''
... | true |
924fb3e750ab299c9dcd51a04d57d0efc1ca2ea4 | skaramicke/editpycast | /tools.py | 682 | 4.25 | 4 | def map_range(s: float, a: (float, float), b: (float, float)):
'''
Map a value from one range to another.
:param s: The source value, it should be a float.
:param a: The range where s exists
:param b: The range onto which we want to map s.
:return: The target value, s transformed from between a... | true |
67107dc72eb55a203ab779b52df685e5ec7c233b | predator1019/CTI110 | /P4HW1_BudgetAnalysis_alexvanhoof.py | 896 | 4.125 | 4 | # program that calculates the users budget expenses and if they went over it or not
# 9/18/18
# CTI-110 P4HW1 - Budget Analysis
# Alex VanHoof
#
userBudget = float(input("please enter how much you have budgeted "+ \
"for the month:"))
moreExpenses = 'y'
usertotalExpenses = 0
while mo... | true |
203b87d5cd8b1e6417bd4b7494b301417c59f387 | ShiekhRazia29/Extra_Questions | /Q8.py | 296 | 4.25 | 4 | #Q12 To check the given caracter is an Alphabet,digit or a special case
ch2 = input("Enter any character:")
if(ch2 >= 'A' or ch2 >='Z' or ch2 >='a' or ch2 >='z'):
print("This character is an ALPHABET")
elif (ch2 <=0 or ch2 >=9):
print("DIGIT")
else:
print("SPECIAL CHARACTER") | true |
2d3dd7d8b26f08e5292d4f29eab4a3dcb782f714 | eoinparkinson/basic-library-manager-compsci | /app.py | 2,452 | 4.375 | 4 | # importing libraries
import sys # using this to "END" the program, in theory it's not actually required.
print("Welcome to the coolboy library\nChoose one of three options:\n\n1. View all available books:\n2. Add a book:\n3. Search for a book:\nEND to end the program.\n\n") # opening spiel
# first choice, list ... | true |
b1d014312d4b452c7057d4db132f3f8acc79ed3b | yamogi/Python_Exercises | /ch02/ch02_exercises/ch02_ex02.py | 491 | 4.28125 | 4 | # ch02_ex02.py
#
# Write a program that allows a user to enter his or her two favorite foods.
# The program should then print out the name of a new food by joining the
# original food names together.
#
print("Hi there!")
food_1=input("Please enter one of your favourite foods: ")
print("Great.")
food_2=input("Please en... | true |
06bb63a937f6c42d3fc60746f9327c42267c0b04 | sethips/python3tutorials | /lists.py | 1,687 | 4.6875 | 5 |
# ways to initiate a tuple
tupleExample = 5, 6, 2, 6
tupleExample1 = (5, 6, 7, 8)
print("Tuple ", tupleExample)
# accessing a tuple's element
print("Second element of tupleExample ", tupleExample[1])
# ways to create a list, use square brackets
listExample = [5, 2, 4, 1]
print("List:", listExample)
# accessing a L... | true |
81b7b3cfb37d991de284a855b3de084b3c74e7b0 | tommy-dk/projecteuler | /p12.py | 1,323 | 4.375 | 4 | #!/usr/bin/env python
from math import sqrt
def factors(n):
# 1 and n are automatically factors of n
fact=[1,n]
# starting at 2 as we have already dealt with 1
check=2
# calculate the square root of n and use this as the
# limit when checking if a number is divisible as
# fac... | true |
8303693c0075d541f530b714ba2dbc1ce7b57bf9 | CiscoDevNet/netprog_basics | /programming_fundamentals/python_part_1/example3.py | 1,884 | 4.59375 | 5 | #! /usr/bin/env python
"""
Learning Series: Network Programmability Basics
Module: Programming Fundamentals
Lesson: Python Part 1
Author: Hank Preston <hapresto@cisco.com>
example3.py
Illustrate the following concepts:
- Creating and using dictionaries
- Creating and using lists
- Working with for loops
- Conditional ... | true |
b47ee9b72263f1a4fd7a5090d73f8dd47771bcb8 | joebary/Challenge-Module-2-Columbia | /Module 2 assignments/Starter_Code/qualifier/qualifier/utils/fileio.py | 1,933 | 4.375 | 4 | # -*- coding: utf-8 -*-
"""Helper functions to load and save CSV data.
This contains a helper function for loading and saving CSV files.
"""
import csv
from pathlib import Path
import sys
def load_csv(csvpath):
"""Reads the CSV file from path provided.
Args:
csvpath (Path): The csv file path.
Re... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.