blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
0e75e6d92b7aefb4ff3cc69a24681ac462e3316b | M-Jawad-Malik/Python | /Python_Fundamentals/36.Python_function.py | 540 | 4.15625 | 4 | # Here a function for checking a number either it is odd or even is defied#
def even_odd(number):
if number%2==0:
return True
else:
return False
# _________________________________#
# Here main function is defined#
def main():
number=[1,2,3,4,5,6,7]
for i in number:
if... | true |
30927c7b556233523f1c9ef68b55dd0ea9665a47 | herysantos/cursos-em-video-python | /desafios/desafio11.py | 283 | 4.15625 | 4 | l = float(input('Say me how largest is the wall:'))
a = float(input('Say me how higher is the wall'))
print('Ok! your wall have the dimension {:.2f}x{:.2f} e your area is {}m²'.format(l, a, (a*l)))
print('To paint this wall you will need {:.2f} liters of paint.'.format(((a*l)/2)))
| true |
f3f9a1b622820c093d39e210684f9250da820fd6 | elliottqian/DataStructure | /tree/huffman_tree.py | 1,947 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
用Python来定义一个Huffman树
输入例子:
A:13,B:11,C:4,D:22
"""
class Node(object):
"""
The Huffman Tree's Node Structure.
"""
weight = None
left = None
right = None
def __init__(self, left=None, right=None, weight=None, name=None):
self.left = left
self.r... | true |
62410bff55419e32fada6c28270e5ff83fc52913 | JCMolin/hw8Project2 | /main.py | 865 | 4.21875 | 4 | #! /usr/bin/python
# Exercise No. 2
# File Name: hw8Project2.py
# Programmer: James Molin
# Date: July 16, 2020
#
# Problem Statement: make a picture grayscale
#
#
# Overall Plan:
# 1. import the picture
# 2. calculate a way to turn the picture grayscale
# 3. print the result
#
#
# import the necessar... | true |
a7f85a8a4ed7affe287449bd085c7bd10509149f | IrisDyr/demo | /Week 1/H1 Exercise 1.py | 813 | 4.1875 | 4 |
def adding(x,y): #sum
return x + y
def substracting(x,y): #substraction
return x - y
def divide(x,y): #division
return x / y
def multiplication(x, y): #multiplication
return x * y
num1 = int(input("Input the first number ")) #inputing values
num2 = int(input("Input the second number "... | true |
4d47678a12fb82c3f98dc59bfd2a6d69b6b423e0 | ZoltanSzeman/python-bootcamp-projects | /fibonacci_sequence.py | 540 | 4.25 | 4 | # Created by Zoltan Szeman
# 2020-09-09
# Task: Print the fibonacci sequence to the nth digit
while True:
try:
seq_no = int(input('Enter the length of the fibonacci sequence '
'you would like to print: '))
break
except ValueError:
print('\nPlease enter a valid whole number!\... | true |
418cece77b7fc1ed8397623ade04a0d4247000d9 | Mannizhang/learn | /笨方法学python/练习3.py | 485 | 4.1875 | 4 | print('I Will now count my chickens:')
print('Hens')
print(25+30/6)
print("Roosters")
print(100-25*3%4)
print('now i whil count the eggs:')
print(int(3+2+1-5+4%2-1/4+6))
print('is it true that 3+2<5-7?')
print(3+2<5-7)
print('what is 3+2?')
print(3+2)
print('what is 5-7?')
print(5-7)
print("oh no that's why it's fals... | true |
c0ad3d9f12b00aad6a6080edac90d54a422d075b | Minhaj9800/BasicPython | /print_frmt.py | 1,362 | 4.1875 | 4 | another_quote = "He said \"You are amazing\", Yesterday"
print(another_quote)
#or do below
second_quote = "I am doing Okay, 'Man'"
print(second_quote)
multilines="""" Hello This is Minhajur Rahman I am a 4th year student at UPEI. I am planing start my Hnours Thesis at the end of this year.
I am originally from Moulvib... | true |
cdb1afe5559a5c3c9f9bc45d9f504bd79064a960 | Minhaj9800/BasicPython | /destructuring.py | 340 | 4.4375 | 4 | currencies = 0.8, 1.2 # Making a tuple.
usd,euro = currencies # usd = 0.8, euro = 1.2. This is called desturturing. Taking a tuple and make it two different variables.
friends_age = [("Rolf",25),("John",30),("Anne",23)] # List of tuples
for name, age in friends_age: #destructuring inside a for loop.
print(f"{name} is... | true |
9636799164bddc7a2f408bd42ac69772cef007a4 | zvovov/goodrich | /C-4.17.py | 562 | 4.375 | 4 | # Write a short recursive Python function that determines if a string s is a
# palindrome, that is, it is equal to its reverse. For example, racecar and
# gohangasalamiimalasagnahog are palindromes.
def is_palindrome(s):
"""
Returns True if s is palindrome
False otherwise
:param s: input string
:re... | true |
dace58879101e50ee872a8ffa3838a52477cf309 | MosheBakshi/HANGMAN | /Conditions/4.3.1.py | 692 | 4.15625 | 4 | user_input = input("Guess a letter: ")
ENGLISH_FLAG = user_input.isascii()
LENGTH_FLAG = len(user_input) < 2
SIGNS_FLAG = user_input.isalpha()
if (LENGTH_FLAG is False and # IN CASE MORE THAN 1 LETTER BUT ELSE IS FINE
ENGLISH_FLAG is True and
SIGNS_FLAG is True):
print("E1")
elif (LENGTH_FLAG is T... | true |
329dd32bb3263ebcfccdffc0ccbd701e4544e1f7 | mxor111/Play-ROCK-Paper-Scissor | /rps-starter-code12.py | 2,989 | 4.25 | 4 | #!/usr/bin/env python3
# ROCK PAPER SCISSOR - MICHELE
"""This program plays a game of Rock, Paper, Scissors between two Players,
and reports both Player's scores each round."""
import random
moves = ['rock', 'paper', 'scissors']
p1 = input("Player 1 Whats's your name?")
p2 = input("Player 2 What's your name?... | true |
a7515e51deac103a155dca3b88f04f68631f3e70 | mlassoff/PFAB52014 | /greetings.py | 301 | 4.125 | 4 | #raw_input is for strings-- does not attempt conversion
name = raw_input("What is your name?")
print "Hello and greetings", name
#input is for integers or floating point numbers
age = input("How old are you?")
print "You are", age, "years old."
print "In dog years you are ", (age*7) , "years old"
| true |
eb370baa70a807d3f9fa050712235bd94503b7f1 | manitghogar/lpthw | /3/ex3.py | 968 | 4.3125 | 4 | #start of the task, will start counting chickens
print "I will now count my chickens:"
#counts number of hens
print "Hens", 25.0 + 30.0 / 6.0
#counts number of Roosters
print "Roosters", 100.0 - 25.0 * 3.0 % 4.0
#will start counting eggs
print "Now I will count the eggs:"
#counting eggs
print 3.0 + 2.0 + 1.0 - 5.0 + 4.... | true |
2bbb70dfaa362bf182e2d0a314b2bf5895195a45 | manitghogar/lpthw | /14/ex14.py | 1,020 | 4.1875 | 4 |
#importing argv from sys
from sys import argv
#unpacking argv into three variables v0, v1 and v2
script, user_name, birth_country = argv
#setting a consistent prompt that shows up everytime a question is asked
prompt = '>>'
#strings that use the argv arguments
print "Hi %s of %s, I'm the %s script." % (user_name, bi... | true |
397660a71a23fa37977b5db7842b53721c42bb23 | barankurtulusozan/Algorithms-and-Data-Structures | /Python/PY_01_List_Tuple_Dictionary.py | 1,178 | 4.40625 | 4 | #PY_List_Tuple_Dictionary
#Lists
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']
#This will create a list made by characters
print(alphabet[0:6])
#will print characters till g
#Lets create a list of names
names = ["John","Erica","Stephen"]
#If we want to append names to this list
names += ["Joseph... | true |
bf0e35adb8b9fc6ec55a21837105cc864b5fadfd | renchao7060/studynotebook | /基础学习/py94.py | 1,222 | 4.1875 | 4 | # 模拟购物车流程
product_list=[
('Iphone',5800),
('Mac Pro',9800),
('Bike',800),
('Coffee',30),
('Alex python',120)
]
shopping_list=[]
salary=input("Input your salary:")
if salary.isdigit():
salary=int(salary)
while True:
for index,item in enumerate(product_list):
print(index,i... | true |
3f8e44a1c120f3b725d64c83f6b51726ff4830f6 | Codeology/LessonPlans | /Spring2017/Week1/searchInsertPosition.py | 909 | 4.1875 | 4 | #!/usr/local/bin/python
# coding: latin-1
# https://leetcode.com/problems/search-insert-position
#
# Given a sorted array and a target value, return the index if
# the target is found. If not, return the index where it would
# be if it were inserted in order.
#
# You may assume no duplicates in the array.
#
# Here are... | true |
9cfdfab5ed7eea89812de216b4e4fa9e39ea0647 | Akash21-art/solidprinciple | /Inheritance.py | 897 | 4.125 | 4 | # A Python program to demonstrate inheritance
class Parent(object):
# Constructor
def __init__(self, name):
self.name = name
# To get name
def getName(self):
return self.name
# Inherited or Sub class
class Child(parent):
# Constructor
... | true |
26e5cdb0e2c2e9b88bfd438d584d78743faa796c | themarcelor/perfectTheCraft | /coding_questions/matrix/matrix.py | 809 | 4.40625 | 4 | # --- Directions
# Write a function that accepts an integer N
# and returns a NxN spiral matrix.
# --- Examples
# matrix(2)
# [[1, 2],
# [4, 3]]
# matrix(3)
# [[1, 2, 3],
# [8, 9, 4],
# [7, 6, 5]]
# matrix(4)
# [[1, 2, 3, 4],
# [12, 13, 14, 5],
# [11, 16, 15, 6],
# [10, 9, ... | true |
5c231792e7a9bf0578182618690a4df7efcd706b | claireyegian/unit4 | /functionDemo.py | 396 | 4.1875 | 4 | #Claire Yegian
#10/17/17
#functionDemo.py - learning functions
def hw():
print('Hello, world!')
def bigger(num1,num2): #prints which number is bigger
if num1>num2:
print(num1)
else:
print(num2)
def slope(x1,y1,x2,y2): #calculates slope
print((y2-y1)/(x2-x1))
#tests for the various fu... | true |
be0d6748fc3267953041330cdfc66e6cb76a8d95 | claireyegian/unit4 | /stringUnion.py | 325 | 4.25 | 4 | #Claire Yegian
#10/26/17
#stringUnion.py - takes two strings and returns all letters that appear in either word
def stringUnion(word1,word2):
string = ''
for ch in word1 + word2:
if not ch.lower() in string:
string = string+ch.lower()
return string
print(stringUnion('Mississippi','Pens... | true |
44cfa8fa73162bc9618bc6fb2b30f26458c0b0ae | maryclareok/python | /list_class.py | 2,542 | 4.3125 | 4 | # lst=[1,2,3,4,5]
# list=["jane","kemi","obi","mose"]
# print(len(lst))
# print(lst [0 : 3])
# print(list)
# num=lst[0]*lst[1]#using list for mathematical operation
# print(num)
# print(list[1:])
# print(list[1::2])
# print(lst[-1])
# print(lst[:-1])
# list3=["david","john",2,"ben",7,9,"germany"]
# print(list3[1])
# #c... | true |
0d136d5f6e1d4086d232f60c24f92f43abad5949 | ravikuril/DesignPatterns | /facade.py | 1,914 | 4.28125 | 4 | class Washing:
'''Subsystem # 1'''
def wash(self):
print("Washing...")
class Rinsing:
'''Subsystem # 2'''
def rinse(self):
print("Rinsing...")
class Spinning:
'''Subsystem # 3'''
def spin(self):
print("Spinning...")
class WashingMachine... | true |
6a132dc98dde7afabeaed73e31954944eb37f06c | billypriv05/bit-calculater | /image_bit_calc.py | 1,276 | 4.125 | 4 | # checks imput is a number more than
def num_check(question, low):
valid = False
while not valid:
error = "please enter a interger that is more or than "
"(or equal to) {}".format(low)
try:
# ask the user to enter a number
response = int(input(questi... | true |
3ef8781a23a3139f9055129e6c8774a9bbe0de90 | Gaurav812/Learn-Python-the-hard-way | /Ex3.py | 580 | 4.34375 | 4 | #Ex3
# <= less-than-equal
# >= greater-than-equal
#print("I will now count my chickens:")
#print("Hens", 25 + 30 / 6)
#print("Roosters", 100 - 25 * 3 % 4)
#print ("Now I will count the eggs:")
#print (3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6)
#print ("Is it true that 3 + 2 < 5 - 7?")
#print(3+2<5-7)
#print ("Oh, that'... | true |
753cca8c21a22551ecbe3b70e767c638a7a0147e | nyangeDix/automate-the-boring-stuff-with-python | /automate_the_boring_stuff/dictionaries and structuring data/dict_setDefault.py | 419 | 4.40625 | 4 | #Adds a default dictionary item to an already existing dictionary
#This only applies when the key and value are not available in the dictionary
food = {'fruits':'apples',
'vegetables':'kales',
'cereals':'maize',
'drinks':'vodka'
}
"""
if 'drugs' not in food:
food['drugs'] = 'w... | true |
c8c77d1cc9a83234eb5fa2152b931d05a73de0d8 | nyangeDix/automate-the-boring-stuff-with-python | /automate_the_boring_stuff/pattern_matching_with_regex/regex_pipe.py | 2,080 | 4.125 | 4 | #The character "|" is called the pipe key
import re
findName = re.compile(r'Dickson | Nyange')
mo = findName.search('Dickson is Nyange')
print(mo.group())
#note the difference between the two set of codes
findName2 = re.compile(r'Nyange | Dickson')
mo2 = findName2.search('Nyange is Dickson')
print(mo2.group())
... | true |
c827732bd723bd387ddeccc1a4b4ed48135831a4 | jamalamar/Python-function-challenges | /challenges.py | 1,182 | 4.28125 | 4 |
#Function that takes a number "n" and returns the sum of the numbers from 1 to "n".
# def sum_to(n):
# x = list(range(n))
# y = sum(x) + n
# print(y)
def sum_to(num):
sum = 0
for i in range(num + 1):
sum += i
print("The sum from 1 to "+ str(num) + ": " + str(sum))
sum_to(10)
#Function that takes a... | true |
f5402726633ba15c54c8ad1867c16188dcdbb4fb | GauPippo/C4E9-Son | /ss1/ss1.py | 866 | 4.125 | 4 | #1.
'''
- How to check a variable's type?
type()
- Three difference examples of invalid name.
1992abc = 10
abc$ = "name"
True = 'hahaha'
'''
#2.
from math import *
from turtle import *
import turtle
##pi = 3.14
##radius = int(input("Radius?"))
##print ("Area =", radius * pi)
##print ("hihihi")
###3... | true |
88ab14671d8ceda24786eb76c012c2f33f077258 | BattenfE8799/CSC121 | /dictionary example from instructor.py | 763 | 4.15625 | 4 | #example via instructor
petNum = int(input("How many pets do you have? "))
pets = {}
for num in range(1, petNum+1): # always add 1 to userinput # to end there
name = input("Enter name for pet "+str(num)+":") #input only takes one arguement and str(num) converts num into a string
age = input... | true |
3d50d7392672c8fc3080eeb4e1ccfa88210567a2 | burnhamup/facebook-hacker-cup | /2013/pretty.py | 1,821 | 4.125 | 4 | '''
Created on Jan 25, 2013
@author: Chris
'''
"""
The algorithim is to take the string. Make everything lowercase, strip out any thing that isn't a letter.
Calculate frequency of each letter.
Maybe create an array with each index being a different letter and the value is the frequency. Sort this.
The letter with... | true |
d49e21ed77380072e925dd1ff07735d96a2f0594 | nehamehta2110/LeetCode-August-Challenge | /Day2-DesignHashSet.py | 1,649 | 4.125 | 4 | """
Design a HashSet without using any built-in hash table libraries.
To be specific, your design should include these functions:
add(value): Insert a value into the HashSet.
contains(value) : Return whether the value exists in the HashSet or not.
remove(value): Remove a value in the HashSet. If the value does not exis... | true |
a133dd7c5093c6bf9180947048551ef4992c2ee6 | Ranimru/Mycode | /palindrome.py | 251 | 4.15625 | 4 | def isPalindrome(String):
#this is a method to check whether a string is a Palindrome
for s in range(0,len(String)//2):
if String[s]!=String[(len(String)-1)-s]:
return False
return True
print(isPalindrome('foolloof'))
| true |
6a4130acf82fb745bc6688f177afc57c04c9b7ae | Ianwanarua/Password-locker | /user.py | 1,266 | 4.125 | 4 | class Users:
"""
class that generates new instances of users
"""
user_list = []
def __init__ (self,username,first_name,last_name,password):
'''
This is a blueprint that every user instance must conform to
'''
self.username = username
... | true |
83b774feafd4887d086285205a027c660d36d86f | MarkParenti/intermediate-python-course | /dice_roller.py | 569 | 4.15625 | 4 | import random
def main():
dice_sum = 0
dice_rolls = int(input("How many dice would you like to roll?"))
sides = int(input("How many sides should the die have?"))
for i in range(0, dice_rolls):
roll = random.randint(1,sides)
if roll == 1:
print(f'You rolled a {roll}! Critical Fail')
elif... | true |
ec9786119c231f6a43b75cbae4b2bf33318bf701 | MinwooRhee/unit_two | /d4_unit_two_warmups.py | 237 | 4.15625 | 4 | print(9 * 5)
print(2 / 5)
# // sign is integer division
print(12 // 5)
print(27 // 4)
print(2 // 5)
# % sign gives the remainder
# very useful when telling odd or even number
print(5 % 2)
print(9 % 5)
print(6 % 6)
print(2 % 7)
| true |
2253395f3a5f76f00452f3bf03067af3d1d95d7b | amogh-dongre/dotfiles | /python_projects/Binary_search.py | 729 | 4.21875 | 4 | #!/usr/bin/env python3
# This is the python implementation of Binary search
def Binary_searcher(arr, l, f, num):
while f <= l:
mid_index = (l + f) / 2
if num == arr[mid_index]:
return mid_index
elif num < arr[mid_index]:
f = mid_index + 1
else:
l =... | true |
644e2b5ae4e9dce423e812d548f9a3999fd42ae2 | ihuei801/leetcode | /MyLeetCode/python/Merge k Sorted Lists.py | 2,446 | 4.1875 | 4 | #######################################################################
# Priority Queue
# Time Complexity: O(nk*log k) k:num of lists n: num of elements
# Heap implementation: http://algorithms.tutorialhorizon.com/binary-min-max-heap/
# A binary heap is a heap data structure created using a binary tree.
# Two rules ... | true |
a5cc6bdbd44719c30639f8bf040f1ac3fa2d7066 | jdlambright/Hello-World | /100 Days/day 20-29/24 notes/read_write.py | 1,464 | 4.25 | 4 | #these are notes on how to open write and read files
#the first way. this is less efficient because you have to remember to close it
#open is a built in keyword
# file = open("my_file.txt")
#
# #read method returns contents of file as a string
# #we save it into a variable
# contents = file.read()
#
# print(contents)... | true |
622dad3a18f2f2acd6614d81702ca71370b7b98b | pyl135/Introduction-to-Computing-using-Python | /Unit 4- Data Structures/Ch 4.4- File Input and Output/Reading Files in Python 1.py | 942 | 4.3125 | 4 | #Write a function called "find_coffee" that expects a
#filename as a parameter. The function should open the
#given file and return True if the file contains the word
#"coffee". Otherwise, the function should return False.
#
#Hint: the file.read() method will return the entire
#contents of the file as one big string... | true |
122f50f5a0e6298094df98172406ed300afd6690 | pyl135/Introduction-to-Computing-using-Python | /Unit 5- Objects and Algorithms/Ch 5.2- Algorithms/Coding Problem 5.2.5.py | 1,321 | 4.375 | 4 | #Write a function called string_search() that takes two
#parameters, a list of strings, and a string. This function
#should return a list of all the indices at which the
#string is found within the list.
#
#You may assume that you do not need to search inside the
#items in the list; for examples:
#
# string_search(["... | true |
bd3c39f51cf2831fa120921591769c1699e4208f | TytarenkoVictor/Travel_planner_project | /date_estimation.py | 2,342 | 4.15625 | 4 | import datetime
class CheckDate:
"""This class checks users input dates."""
def __init__(self, d1, d2):
"""This method initializes."""
self.day1 = d1.split('/')[0]
self.day2 = d2.split('/')[0]
self.month1 = d1.split('/')[1]
self.month2 = d2.split('/')[1]
... | true |
0e7d762c83a93f480cf1494236eaacd04d6aa92f | flores-jacob/exercism | /python/meetup/meetup.py | 748 | 4.15625 | 4 | from datetime import date
import calendar
def meetup_day(year, month, day_of_the_week, which):
if which == "teenth":
date_range = range(13, 20)
elif which == "last":
last_day_of_month = calendar.monthrange(year, month)[1]
date_range = range(last_day_of_month, 1, -1)
else:
... | true |
4229b121411d36062db4f30122e745d7fd523e0e | WHJR-G8/G8_C15_For_Student_Reference | /Student_Project.py | 568 | 4.125 | 4 | import turtle
turtle.pensize(4)
turtle.pencolor("OliveDrab")
turtle.setpos(-50, 0)
def repeated_tasks(c,s,a):
turtle.fillcolor()
for i in [0, 1, 2]:
#This function call is to make the house shelter i.e upper part of the house
turtle.forward(25)
turtle.right(90)
#Thi... | true |
6c5244b15945d02c986258e76d9da2b1f3da289c | ichan266/Code-Challenges | /Leetcode/Past Code Challenges/05-27-21 shift2Dgrid.py | 1,421 | 4.21875 | 4 | # Leetcode # 1260
# https://leetcode.com/problems/shift-2d-grid/
# Given a 2D grid of size m x n and an integer k. You need to shift the grid k times.
# In one shift operation:
# Element at grid[i][j] moves to grid[i][j + 1].
# Element at grid[i][n - 1] moves to grid[i + 1][0].
# Element at grid[m - 1][n - 1] moves ... | true |
e0ea787e176e1b2e4f868fdb8012ca792e2d9d6c | Sethrick/SelfTaughtP_CompletedExercises | /Python_Althoff_SelfTaughtProgrammer/SelfTaughtP_pp085_Ch05_Challenges.py | 1,797 | 4.46875 | 4 |
# 1) Create a list of your favorite musicians.
band_list = ["TSFH", "Evancho", "Thomas", "Piano Guys"]
print(band_list)
# 2) Create a list of tuples, with each tuple containing the longitude
# and latitude of somewhere you've lived or visited.
Ft_Riley = (39.1101, 96.8100)
Gimli_Peak = (49.7661, 117.6469)
Keystone... | true |
a18650703c788528552895a8a2192dc73d59f70c | Sethrick/SelfTaughtP_CompletedExercises | /Python_Althoff_SelfTaughtProgrammer/SelfTaughtP_pp151_Ch13_Encapsulation.py | 1,676 | 4.4375 | 4 |
# Encapsulation in object oriented programming means that both variables
# (state) and methods (for altering state or doing calculations) are grouped
# together in "objects".
class Rectangle():
def __init__(self, w, l):
self.width = w # Variables (state)
self.len = l
def area(self): # Method ... | true |
5e9a5d8d18445d8a2ddc2f279947648bf30c99c2 | 4RG0S/2021-Summer-Jookgorithm | /안준혁/[21.07.13]3613.py | 840 | 4.15625 | 4 | word = input()
bigger = False
underscore = False
makeBigger = False
error = False
small = False
out = []
for alphabet in word:
if 'a' <= alphabet <= 'z':
small = True
if makeBigger:
out.append(alphabet.upper())
makeBigger = False
else:
out.append(alphab... | true |
fade9fcc59fd25e22249fec0c309e759687a3db4 | JCharlieDev/Python | /Python Programs/TkinterTut/TkGrid.py | 375 | 4.34375 | 4 | from tkinter import *
# Mostly everything is a widget
# Main Window
root = Tk()
# Creating label widget
myLabel1 = Label(root, text = "Hello world")
myLabel2 = Label(root, text = "My name is Charlie")
# Putting it on the screen
myLabel1.grid(row = 0, column = 0)
myLabel2.grid(row = 1, column = 5)
# Event l... | true |
3f0e54298456bd64e7c15f298faba0f3f0b7d93a | Code360In/21092020LVC | /day_01/labs/02_height_of_the_building.py | 438 | 4.28125 | 4 | # Program to calculate the height of the building
# given angle of sight and distance of the measurer from the building
import math
# input
a = float(input("Enter the angle of sight in deg: "))
d = float(input("Enter the distance in mts: "))
# process
h = d * math.tan(math.radians(a))
h = h * 3.281
... | true |
18e91eed6e9810bf6b24c6713f9a74984084c8cf | sofmorona/nucoroCurrency | /currencyRates/utils.py | 1,571 | 4.25 | 4 | import datetime
import decimal
from functools import reduce
def checkDateFormat(date_string, format):
"""
Function to check if the given date has the expected format
:param date_string: string to check if is a valid date format
:param format: the format expected by the date_string
:return: datetime... | true |
aeb99449371c2c2c9bea0311b55e7cc265e973bf | Ganesh-sundaram-82/DatastructuresAndAlgo | /DS/Linked-List/LinkedList.py | 1,069 | 4.15625 | 4 | import Node
# # head = Node.Node("1")
# # head.NextNode = Node.Node("2")
# # print(head.value)
# # print(head.NextNode.value)
#Single Linked-list
class LinkedList:
def __init__(self):
self.head = None
def append(self, value):
if self.head is None:
self.head = Node.Node(va... | true |
2f0caf50c2cd55dc92dc8bc98982da0a2cc1143d | Saberg118/Simple_Python_Programs | /password.py | 1,125 | 4.53125 | 5 | """
This is a password generator that prompts the user the day the were born,
favoriteFruit, and first name.
The new password will contain the the last two letters of their first name,
the last digit of the day they were born times 3, first three letter of their favorit fruit, and
the first letter of their name capit... | true |
9157fb6460d261a48f65e981febc73a2729032f3 | zmarrich/beginning-python | /pltlweek7ses1.py | 1,056 | 4.15625 | 4 |
###SLIDE ONE
print("She said, '"'I dont like to wear a helmet it messes up my hair'"',which is really silly")
print("Yes\\No?")
print("April\nMay\nJune\n")
#####SLide TWO
message= 'I like Python.'
print(message.lower())
print(message.upper())
print(message.replace('Python','Pasta',1))
#slide 3
##statement='I like to g... | true |
d46c23889ec6a85af6e38228d20c8a7215b6d072 | byuniqueman/pyproj | /bdate | 313 | 4.1875 | 4 | #!/usr/bin/env python3
# test test test
import datetime
currentdate = datetime.date.today()
userinput = input ("What is your birthday? (mm/dd/yy) ")
# format expected below 03/24/1964
birthday = datetime.datetime.strptime(userinput, "%m/%d/%Y").date()
print(birthday)
days = birthday - currentdate
print(days)
| true |
567c548fc3250b56aa461da9d3d5e9317fa96398 | itszrong/2020-Statistics-Tools | /Chi square using contingency table.py | 2,387 | 4.3125 | 4 | data = []
columns = int(input("How many columns are there?"))
rows = int(input("How many rows are there?"))
array_of_row_sum = []
array_of_column_sum =[]
grand_total = 0
#initialising array for column restraints
for n in range(columns):
array_of_column_sum.append(0)
#initialising the observed data an... | true |
86194a8c37522488d322d2f6c382aca1d3ec82e6 | mcalidguid/string-manipulation | /string_manipulator.py | 1,875 | 4.34375 | 4 | def swap_case(sentence):
output = ""
for letter in sentence:
if letter == letter.upper():
output += letter.lower()
else:
output += letter.upper()
print(">>>: %s" % output)
def reverse_swap_words(sentence):
output = ""
for letter in sentence:
if lette... | true |
8dfe55144cae789d302f6bcba813b1389e925951 | aviik/intellipat_assignments | /Assignment_2_ComDs/05_character_to_string.py | 314 | 4.375 | 4 | #5.Write a Python program to convert a list of characters into a string.
# enter some characters
my_char = []
while True:
foo = input("==>")
if foo == 'done':
break
my_char.append(foo)
def string_maker(my_char):
my_string = ''.join(my_char)
print(my_string)
string_maker(my_char)
| true |
e6d81842388a1f017975a84b9e97966183acf27a | DTIV/PythonDeepDive | /Variables_and_Memory/dynamic_vs_static.py | 649 | 4.34375 | 4 | # DYNAMIC VS STATIC TYPING
''' Python is dynamically typed - the variable can be whatever, it just changes the memory address for what is needed and rewrites.
Static typed must specify type and the variable is specific to that type always '''
print("Python variables can change dynamically throughout the code, changi... | true |
40efaa887d904eaf1ac46162ad204045f0ab60ab | R-Gasanov/gmgcode | /String DataType/E_StringsTest.py | 1,559 | 4.5625 | 5 | # Not only can we ask for specific parts of the string, we can modify on how we percieve them as well
x = (' Good_Morning ')
# Now what we can do with this its change its case from upper to lower, here are the following commands
print (x.upper())
# The one above is upper
print (x.lower())
# The next one is lower
# As ... | true |
83cffd1b2b720d02ea4cc84173497d42b5df7019 | R-Gasanov/gmgcode | /AllCode/C_Python Practice/B_ DataTypes/String DataType/D_StringsTest.py | 1,267 | 4.625 | 5 | # Now we will be looking at slicing , essentially splitting strings seperately
x = 'Good Morning'
# Now as you can see from the bottom we're using a colon ':'
print (x[:4])
# Now what were doing is we selected a letter through the representation of numericle values
print ('#######################')
# And using the colo... | true |
d02a46f80a02b48025d476b4409155fdda384f19 | R-Gasanov/gmgcode | /AllCode/I_Tuples/E_TupleTest.py | 2,485 | 5.0625 | 5 | # We can't technically change its values with a tuple, although there are some unique ways of doing so
vegtables = ('cucumber','carrot','zuccini','swiss chard','garlic')
# As a small portion of us know, zuccini is not a vegtable
veg_list = list(vegtables)
# What we're doing here, is converting this tuple into a list, w... | true |
95b51884352d71eabe74efbb6466a5744e5135ae | R-Gasanov/gmgcode | /AllCode/B_ DataTypes/NumbersTest.py | 848 | 4.5 | 4 | # We will now be looking at Numbers, and the various types
#There are 3 basic types
# Integer, a basic whole number
x = 1
# Float, a number that is a decimal
y = 17.7
# Complex a number with multiple featurs that involves with symbols and letters
z = 1j
# You can of course convert each number to a different number t... | true |
527e950a38182ee8c94a7d20fe610da64b54ce74 | R-Gasanov/gmgcode | /AllCode/I_Tuples/A_TupleTest.py | 707 | 4.3125 | 4 | # Now first of lets begin our tests with Tuple, since they can store multiple values lets try it
atuple = ('China','America','United Kingdom','Russia','Poland')
print (atuple)
# As you can see when you review the atuple variable you can see the
print ('####################')
# Additionally as we have previously expla... | true |
5dc7dc9d22063290ee88b2821a9e143ca570023c | R-Gasanov/gmgcode | /AllCode/L_Functions/C_Functiontest.py | 1,081 | 4.53125 | 5 | # Now we will be looking at passing a list as an argument throught the function
print ('#######################')
# So lets make our function!
def my_function(movies):
# As per usual we will iterate through the list
for x in movies:
print (x)
# Now lets provide us with the list
horror = ['Scream', 'Frid... | true |
96213221e172e444f5cec4a847d2b71fbaca52c2 | jlheen/python-challenge | /PyPoll/main.py | 2,857 | 4.21875 | 4 | # python-challenge -- PyPoll
# Import Modules
import os
import csv
# Read csv file
PyPoll_Data = os.path.join("./Unit03 - Python_Homework_PyPoll_Resources_election_data.csv")
with open(PyPoll_Data) as csvfile:
csvreader = csv.reader(csvfile, delimiter=",")
# Skip the header row
csv_header = next(csvfile)... | true |
24b6df398f7d67ef5c4fa41ae36129d9689aa1c9 | amaizing-crazy/kv-055 | /python_basic/task3.py | 324 | 4.5625 | 5 | #Define a function reverse() that computes the reversal of a string.
# For example, reverse("I am testing") should return the string "gnitset ma I".
def reverse(string):
rstring = ''
for i in string[::-1]:
# for i in string[-1:0:-1]:
rstring = rstring + i
print(rstring)
reverse("I am testing")
... | true |
7f72822d56efd0bfac9dc8c11d35c1478be6d074 | stemlatina/Python-Code | /h3q5MD.py | 601 | 4.21875 | 4 | #Marilu D
#Q5MD
#User Input
a = float(input("Please enter the length of first side: "))
b = float(input("Please enter the length of second side: "))
c = float(input("Please enter the length of third side: "))
#If Statements
if a == b and b == c and a ==c :
print("This is a equilateral triangle")
elif a == b or a ... | true |
9cfc825230c0c9999879ca4d593c0c241ad9e717 | Kelley12/LearningPython | /Blake/Chapter 3 - Functions/practiceProject.py | 663 | 4.34375 | 4 | # Practice Project from Chapter 3: the Collatz Sequence
def collatz(number):
if number % 2 == 0:
number = number//2
print(str(number))
return number
else:
number = 3 * number + 1
print(number)
return number
def main():
print('Enter a number:')
try:
... | true |
616ae81759d0e0a7535c0224f881092c6df8e407 | Prajnahu/Python-program | /paliendrome.py | 783 | 4.15625 | 4 | def palindrome(string):
backwards=string[::-1].casefold()
return backwards==string.casefold() #returns true or false
return palindrome(string)
word=input("please enter a word to check")
if palindrome(word):
print("{} is a paliendrome".format(word))
else:
print("{} is not a paliendrome".f... | true |
ee1253259b1532b29be46cdc810ce441ebef2a8c | DamocValentin/PythonLearning | /BinarySearchAlgorithm.py | 1,404 | 4.21875 | 4 | # Create a random list of numbers between 0 and 100.
# Ask the user for a number between 0 and 100 to check whether their number is in the list.
# The programme should work like this. The programme will half the list of numbers and see whether
# the users number matches the middle element in the list. If they do not ma... | true |
50c69cb28453275cbfc1cf90ae86620d6b6f341b | elenzi/algorithmsproject | /algorithmsproject/bruteforce.py | 2,204 | 4.125 | 4 | import copy
from algorithmsproject.airportatlas import AirportAtlas
from algorithmsproject.route import Route
from algorithmsproject.travelplan import TravelPlan
import itertools
class BruteForce:
"""Exhaustively searches for the shortest path."""
def __init__(self, travel_plan: TravelPlan):
self.tr... | true |
888d75b81e63ba39cea0efd63d6ef386c44279ec | isakfinnoy/INF200 | /src/isak_finnoy_ex/ex01/tidy_code.py | 1,187 | 4.375 | 4 | from random import randint as dice
__author__ = 'Isak Finnoy'
__email__ = 'isfi@nmbu.no'
"""This is a game of two dices, where the user is trying to guess the correct sum of the two dices,
decided by the random.randint function. The max number of valid guess attempts are 3, though you can make as many
invalid gues... | true |
6c517a29a5eaff0bbde1474f9a6814956f7fd58b | Jhedie/Comfortable_Python | /CodingBat/biggest_number_index.py | 698 | 4.28125 | 4 | # program to print the index of the biggest number in an array
#main function
def get_biggest(array):
position = 0
return biggest_number(array, position)
#recursive function for comparisons
def biggest_number(List, position1):
if position1 == len(List)-1:
return position1
else:
#pos... | true |
917a9a9479b123d6499b194cd85616606b8f2101 | riccab/python-practice | /hello.py | 705 | 4.46875 | 4 | print("hello, world!")
"""This is a doc string
spanning multiple lines"""
#print("Enter your name:")
x = input("Enter Your name \n")
print("Hello, " + x)
#The for loop acts as an iterator, does not require an indexing variable
#In this example banana will not be printed because print is being skipped by the continu... | true |
b4061c0f5fd130dd7fa7d1f78a0edf84b32480fc | joaompinto/enclosed | /enclosed/__main__.py | 564 | 4.15625 | 4 | import argparse
from enclosed import Parser, is_enclosed
def main():
parser = argparse.ArgumentParser(description="Extract enclosed tokens from string")
parser.add_argument(
"target",
metavar="target",
type=str,
help="full string containing enclosed tokens",
)
args = pa... | true |
eb3bab615bff56be26265fef235a7900259e4dc6 | zarjer/Cisco-BlackBeltLevel1 | /Task2.py | 789 | 4.125 | 4 | """
Zar Jerome C. Cajudo
Task 2
"""
#Libraries and Functions always come in handy to developers by allowing reusability of existing code.
#There are certain well known inherent libraries that you have access to after installing python.
#By using these libraries and functions in them,
#write a program (in Pytho... | true |
601c9380d30a6e6291cc77ea76e798c9998c9142 | vinay432/inputs-from-the-user | /inputs from user.py | 434 | 4.21875 | 4 | #Taking inputs from user,we need to explain the user what type of input to be accepted by code like integer or float, it may be string type.
a=input("Enter your lucky number:") #a is a varable to store inputs which is given by user
print(a) #printing the lucky number out.
#if you wanna specify particularly, user c... | true |
14b01be431db3db57e947f724d8978f98f2a3bb2 | Lisa-Mays/CMIS102_Assignments | /salesmanpay.py | 1,326 | 4.1875 | 4 | # This program calculates a salesman's weekly pay with a fixed hourly
# rate and a fixed commission percentage
# Set hourly rate to 27 dollars per hour Declare hourly_rate as float
hourly_rate = float(27.00)
# Set commission percentage to 25 percent
commission_percentage = 0.25
# Prompt for hours worked Declare hour... | true |
d7f76d7af932f16b1202d118982e8825b01e7816 | sunita18808/sunita18808 | /Len's Slice.py | 666 | 4.125 | 4 | # Your code below:
toppings = ["pepperoni", "pineapple", "cheese", "sausage", "olives", "anchovies", "mushrooms"]
prices = [2, 6, 1, 3, 2, 7, 2]
num_two_dollar_slices = prices.count(2)
num_pizzas = len(toppings)
print("We sell " + str(num_pizzas) + " different kinds of pizza!")
pizza_and_prices = [[2, "pepperoni"], [6... | true |
65f044891f824b888e9a1bcfb652ef32b0e76d7a | supermitch/Chinese-Postman | /chinesepostman/dijkstra.py | 2,163 | 4.125 | 4 | """Minimum Cost Path solver using Dijkstra's Algorithm."""
def summarize_path(end, previous_nodes):
"""
Summarize a chain of previous nodes and return path.
Chain is a dictionary linked list, e.g. {1: None, 2: 1, 3: None, 4: 2}
returns [1, 2, 4] for end = 4.
"""
route = []
prev = end
... | true |
0733878ff327550bd6d688ec366b0c52dc1e11a0 | jainpiyush26/python_code_snippets | /python_tricks/namedtuples.py | 651 | 4.28125 | 4 | from collections import namedtuple
"""
syntax is to pass the object name and then the key names as a list of space
separated string,
I would prefer passing them explicitly as a list!
They are still tuples but can be used to store initial value of an object or
something like that
"""
test_obj = namedtuple('test_obj', [... | true |
bd4848b15e233d540097077f986b851f57586316 | oleg31947/jobeasy-algorithms-course | /lesson_4/HW_4/Count.py | 644 | 4.34375 | 4 | # Write a Python function, which will count how many times a character (substring)
# is included in a string. DON’T USE METHOD COUNT
# string = input(f"Enter a string ")
# substring = input(f"Enter a substring ")
def count(given_string, given_substring):
counter = 0
if len(given_substring) > len(given_string... | true |
3cf40241d8f485cc2e4b71a6ad9fc78f6093689c | oleg31947/jobeasy-algorithms-course | /lesson_4/No duplicate.py | 528 | 4.125 | 4 | # Your task is to remove all duplicate words from a string, leaving only single (first) words entries.
# Input
# 'alpha beta beta gamma gamma gamma delta alpha beta beta gamma gamma gamma delta'
# Output
# 'alpha beta gamma delta'
def no_duplicate(string):
array = string.split(' ')
result = []
for item ... | true |
3d2de6b37d9b22649f370c9074f1cad602897279 | oleg31947/jobeasy-algorithms-course | /lesson_5/My_head_is_at_the_wrong_end.py | 735 | 4.1875 | 4 | # You're at the zoo... all the meerkats look weird. Something has gone terribly wrong - someone has gone
# and switched their heads and tails around!
# Save the animals by switching them back. You will be given an array which will have three values (tail, body, head).
# It is your job to re-arrange the array so that t... | true |
e4cdb1a97f4b615353ec503717e9bc4ea0df60ef | mpv33/Advance-python-Notes- | /Threads/Threading.py | 1,307 | 4.15625 | 4 | #!/usr/bin/python
import threading
import time
exitFlag = 0
class myThread (threading.Thread):
def __init__(self, threadID, name, counter):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.counter = counter
def run(self):
print("Starting " + self.name)
... | true |
c4c521b0f14ce7a09573df822d15a5ff7160903f | sifatjahan230/Python-programming | /string/sWAP cASE.py | 572 | 4.3125 | 4 | '''
You are given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa.
For Example:
Www.HackerRank.com → wWW.hACKERrANK.COM
Pythonist 2 → pYTHONIST 2
Input Format
A single line containing a string S.
Constraints
0<len(S)<=1000
Out... | true |
820536da887128b6ce19457d296550868b27443e | TanyoTanev/SoftUni---Python-Fundamentals | /Lists_adv_ElectronDistribution.py | 1,246 | 4.15625 | 4 | '''Electron Distribution
You are a mad scientist and you decided to play with electron distribution among atom's shells. You know that basic idea of electron distribution
is that electrons should fill a shell until it's holding the maximum number of electrons.
The rules for electron distribution are as follows:
Maxim... | true |
9ea71c52d86f9b499eecbba238cf33ffc46a0e59 | TanyoTanev/SoftUni---Python-Fundamentals | /Fund_Dictionaries - 6.Courses.py | 2,233 | 4.34375 | 4 | '''6.Courses
Write a program that keeps information about courses. Each course has a name and registered students.
You ewill be receiving a course name and a student name, until you receive the command "end". Check if such course already exists, and if not,
add the course. Register the user into th course. When you rec... | true |
a555a9b776d85e3df2d9d0850bc76141bdc02d1b | TanyoTanev/SoftUni---Python-Fundamentals | /Classes Catalogues.py | 1,784 | 4.28125 | 4 | '''
Catalogue
Create a class Catalogue. The __init__ method should accept the name of the catalogue. Each catalogue should also have an attribute called
products and it should be a list. The class should also have three more methods:
add_product(product) - add the product to the product list
get_by_letter(first_lette... | true |
96be08c6e3211029ca2c689fd6d2110c2a7365e2 | thewalia/CP | /DS/LinkedList.py | 1,642 | 4.1875 | 4 | class Node:
def __init__(self, data):
self.data = data
self.nextNode = None
class LinkedList:
def __init__(self):
self.head = None
self.size = 0
def insertStart(self, data):
self.size+=1
newNode = Node(data)
if not self.head:
... | true |
ffe716689c54473c7305bfebc5069a8b41b0ee8a | RayQinruiWang/SelfLearning | /Learning Space/Datascience/Python/Python notes.py | 849 | 4.59375 | 5 | ####################################### Data science with Python ########################################
# Dictionary
my_dict = {
"brand":"ford",
"model":"Mustang",
"year":1964
}
# or to use constructor dict
my_dict = dict(brand = "ford", model = "Mustang", year = 1964)
# To read by index
rea... | true |
02eb1a5d54c1329cf1cfb8296782a739a4753508 | PBillingsby/CodewarsKata | /Python/oddoreven.py | 214 | 4.4375 | 4 | # Inputs integer and outputs if it is odd or if it is even
def even_or_odd(number):
if type(number) == int:
if int(number) % 2 == 0:
return ("Even")
else:
return ("Odd")
| true |
80efc890da80fc7ec9eef9d50313399f899f315b | adhikaridev/python_assignment_II | /16_game_model_player_class_8puzzle.py | 2,839 | 4.46875 | 4 | # 16. Imagine you are creating a Super Mario game. You need to define
# a class to represent Mario. What would it look like? If you aren't
# familiar with SuperMario, use your own favorite video or board game
# to model a player.
# Because I am not familiar with Super Mario, I am trying to model a
# player of game 8-p... | true |
729b3bf3510acb4897088e31b25b47175e057e8c | adhikaridev/python_assignment_II | /10_camel_snake_kebab.py | 761 | 4.5625 | 5 | # 10. Write a function that takes camel-cased strings (i.e.
# ThisIsCamelCased), and converts them to snake case (i.e.
# this_is_camel_cased). Modify the function by adding an argument,
# separator, so it will also convert to the kebab case
# (i.e.this-is-camel-case) as well.
def to_snake_or_kebab(camel, separator):
... | true |
f69b77574ae862d8fde1040d31fa1e6a5cac9010 | malikyilmaz/Class4-PythonModule-Week4 | /3- Number Guessing Game.py | 1,926 | 4.21875 | 4 | """
WAs a player, I want to play a game which I can guess a number the computer chooses in the range I chose.
So that I can try to find the correct number which was selected by computer.
Acceptance Criteria:
Computer must randomly pick an integer from user selected a range, i.e., from A to B, where A and B belo... | true |
5e58817bdbd6be6b022b467bc79ae44861a4b664 | PyOrSquare/Python | /Module 1/m1_circumference.py | 209 | 4.5 | 4 | # Calculate Circumference of a Circle with known radius
# c = 2 * Pi * radius
import math
print('Enter Radius')
r=input()
c=2*math.pi*r
print ('Circumference of the Circle with radius %d cms = %.2f'% (r,c))
| true |
2712a9f2890a5e022ac77e54665d0ff38a2a81df | Ritzing/Algorithms-2 | /TernarySearch/Python/ternary.py | 647 | 4.25 | 4 | def ternary_search (L, key):
left = 0
right = len(L) - 1
while left <= right:
ind1 = left
ind2 = left + (right - left) // 3
ind3 = left + 2 * (right - left) // 3
if key == L[left]:
print("Key found at:" + str(left))
return
elif key == L[right]:
print("Ke... | true |
186938082eae6b93c9f8d872b59b26e0af6a5e56 | Ritzing/Algorithms-2 | /SelectionSort/Python/selectionSort.py | 906 | 4.40625 | 4 | def selection_sort(array):
"""
Selection sort sorts an array by placing the minimum element element
at the beginning of an unsorted array.
:param array A given array
:return the given array sorted
"""
length = len(array)
for i in range(0, length):
min_index = i ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.