blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
ac68226a997c7c29a695f8a7f980010eeb5c2ae8 | satyam4853/PythonProgram | /Functional-Programs/Quadratic.py | 613 | 4.15625 | 4 | """
* Author - Satyam Vaishnav
* Date - 21-SEP-2021
* Time - 10:30 PM
* Title - Quadratic
"""
#cmath module using to compute the math function for complex numbers
import cmath
#initalize the variables taking from UserInput.
a=float(input("Enter the value of a: "))
b=float(input("Enter the value of b: ")... | true |
3b24e2a04e23058ab07b84286471a9fcb5df678e | luzonimrod/PythonProjects | /Lessons/MiddleEX1.py | 250 | 4.125 | 4 | #Write a Python program to display the current date and time. Sample Output :
#Current date and time :
#14:34:14 2014-07-05
from datetime import date
today=date.today()
ti=today.strftime("%d/%m/%Y %H:%M:%S")
print("current date and time :\n " + ti)
| true |
f8551faa26b591b1ee0d4325d236a87da3e5ad6e | imshawan/ProblemSolving-Hackerrank | /30Days-OfCode/Dictionaries and Maps.py | 469 | 4.125 | 4 | # Day 8: Dictionaries and Maps
# Key-Value pair mappings using a Map or Dictionary data structure
# Enter your code here. Read input from STDIN. Print output to STDOUT
N=int(input())
phoneBook={}
for _ in range(N):
name,contact=input().split()
phoneBook[name]=contact
try:
while(True):
check=str... | true |
5fddff1509c6cdd53ecf20c4230f1db35f769544 | tawrahim/Taaye_Kahinde | /Kahinde/chp6/tryitout (2).py | 1,912 | 4.125 | 4 | print "First Question:"
firstname="Kahinde"
lastname="Giwa"
print "Hello,my name is,",firstname,lastname
print "\n\n\n"
print "**************************\n"
firstname=raw_input("Enter your first name please:")
lastname=raw_input("Now enter your lastname:")
print "You entered",firstname,"for your firstname,"
pr... | true |
77ef1a85e93549c28e6eeef9fdeeeab5a1365350 | tawrahim/Taaye_Kahinde | /Taaye/chp4/dec-int.py | 1,346 | 4.625 | 5 | print "Question #1, Try it out"
print"\n"
print'This is a way to change a string to a float'
string1=12.34
string="'12.34'"
print 'The string is,',string
point= '12.34'
formula= float(string1)
print "And the float is,",point
print 'We use this formala to change a string into a float, the formula is,', formul... | true |
07566268fa1ca3f0e66a41f8fc4d6f758fdaa9d0 | tawrahim/Taaye_Kahinde | /Kahinde/chp8/looper_tio.py | 1,077 | 4.125 | 4 | #Kainde's work,Chapter 8,tryitout,question1
number=int(raw_input("Hello, what table should I display? Type in a number:"))
print "Here is your table:"
for looper in range(number):
print looper, "*",number,"=",looper*number
print "\n*************************************"
#Chapter 8,tryitout,question2
... | true |
89ba7658b45e09a370813e75845e4009e9d4fa28 | TrinityChristiana/py-classes | /main.py | 882 | 4.15625 | 4 | # **************************** Challenge: Urban Planner II ****************************
"""
Author: Trinity Terry
pyrun: python main.py
"""
from building import Building
from city import City
from random_names import random_name
# Create a new city instance and add your building instances to it. Once all buildings ar... | true |
a2e72fc8db97045e7b33c13ec8d40eb9dcb37ca6 | lokeshom1/python | /datetransformer.py | 682 | 4.21875 | 4 | month = eval(input('Please enter the month as a number(1-12): '))
day = eval(input('Please enter the day of the month : '))
if month == 1:
print('January', end='')
elif month == 2:
print('February', end='')
elif month == 3:
print('March', end='')
elif month == 4:
print('April', end='')
elif month ==... | true |
311ab08d466143062b58036743236330b0c92f57 | khamosh-nigahen/linked_list_interview_practice | /Insertion_SLL.py | 1,692 | 4.5625 | 5 | # Three types of insertion in Single Linked List
# ->insert node at front
# ->insert Node after a given node
# ->insert Node at the tail
class Node(object):
def __init__(self, data):
self.data = data
self.nextNode = None
class singleLinkedList(object):
def __init__(self):
... | true |
2f69c84b0517375ad6e4591ca8ad4dab9279d708 | AkashKadam75/Kaggle-Python-Course | /Boolean.py | 716 | 4.125 | 4 | val = True;
print(type(val))
def can_run_for_president(age):
"""Can someone of the given age run for president in the US?"""
# The US Constitution says you must "have attained to the Age of thirty-five Years"
return age >= 35
print("Can a 19-year-old run for president?", can_run_for_president(19))
print("C... | true |
3a5ba0d910522c04787252d6a8afc8e8cae27952 | AdamsGeeky/basics | /04 - Classes-inheritance-oops/51-classes-descriptor-magic-methods.py | 2,230 | 4.25 | 4 | # HEAD
# Classes - Magic Methods - Building Descriptor Objects
# DESCRIPTION
# Describes the magic methods of classes
# __get__, __set__, __delete__
# RESOURCES
#
# https://rszalski.github.io/magicmethods/
# Building Descriptor Objects
# Descriptors are classes which, when accessed through either getting, sett... | true |
2b4ee967304815ea875dfc6e943a298df143ef48 | AdamsGeeky/basics | /04 - Classes-inheritance-oops/05-classes-getters-setters.py | 784 | 4.34375 | 4 | # HEAD
# Classes - Getters and Setters
# DESCRIPTION
# Describes how to create getters and setters for attributes
# RESOURCES
#
# Creating a custom class
# Class name - GetterSetter
class GetterSetter():
# An class attribute with a getter method is a Property
attr = "Value"
# GETTER - gets values for at... | true |
6f45acaeec134b92f051c4b43d100eeb45533be4 | AdamsGeeky/basics | /02 - Operators/10-membership-operators.py | 1,363 | 4.59375 | 5 | # HEAD
# Membership Operators
# DESCRIPTION
# Describe the usage of membership operators
# RESOURCES
#
# 'in' operator checks if an item is a part of
# a sequence or iterator
# 'not in' operator checks if an item is not
# a part of a sequence or iterator
lists = [1, 2, 3, 4, 5]
dictions = {"key": "valu... | true |
57e6b0b5cbb90562a02251739653f405b8237114 | AdamsGeeky/basics | /03 - Types/3.1 - InbuiltTypes-String-Integer/05-integer-intro.py | 952 | 4.15625 | 4 | # HEAD
# DataType - Integer Introduction
# DESCRIPTION
# Describes what is a integer and it details
# RESOURCES
#
# int() is a function that converts a
# integer like characters or float to a integer
# float() is a function that converts a
# integer or float like characters or integer to a float
# Work... | true |
b04ae7f2eea4a5301c9439e4403403599358a05f | AdamsGeeky/basics | /04 - Classes-inheritance-oops/54-classes-overwriting.py | 1,525 | 4.375 | 4 | # Classes
# Overriding
# Vehicle
class Vehicle():
maneuver = "Steering"
body = "Open Top"
seats = 4
wheels = 4
start = 0
end = 0
def __init__(self, maneuver, body, seats, wheels):
self.maneuver = maneuver
self.body = body
self.seats = seats
self.wheels = whe... | true |
a0f7967a83d0876a37cc74dd8c3c3dc8e1f2eaf3 | AdamsGeeky/basics | /01 - Basics/33-error-handling-try-except-intro.py | 1,137 | 4.1875 | 4 | # HEAD
# Python Error Handling - UnNamed Excepts
# DESCRIPTION
# Describes using of Error Handling of code in python
# try...except is used for error handling
#
# RESOURCES
#
# 'try' block will be be executed by default
# If an error occurs then the specific or
# related 'except' block will be trigered
# ... | true |
a30f5ca5fac728d808ef78763f16ca54290765f6 | AdamsGeeky/basics | /01 - Basics/11-flowcontrol-for-enumerate-loops.py | 1,129 | 4.78125 | 5 | # HEAD
# Python FlowControl - for loop
# DESCRIPTION
# Describes usage of for loop in different ways
# for different usages
#
# 'for' loop can iterate over iterable (sequence like) or sequence objects
# Result provided during every loop is an index and the relative item
#
# RESOURCES
#
# # USAGE
# 1
# # for i... | true |
0640d7d0149ef291a99d472edcaf9e6d6c80ebe4 | AdamsGeeky/basics | /01 - Basics/50-datatypes-type-conversion.py | 2,961 | 4.5625 | 5 | # HEAD
# Python Basics - Conversion of Data Types
# DESCRIPTION
# Type Conversion
# DESCRIPTION
# Describes type conversion methods (inter-conversion) available in python
#
# RESOURCES
#
# These function can also be used to declare specific types
# When appropriate object is used, these functions can be
# use... | true |
ee34a13657d64a8f3300fdf73e34362ad5a49206 | AdamsGeeky/basics | /04 - Classes-inheritance-oops/17-classes-inheritance-setters-shallow.py | 1,030 | 4.46875 | 4 | # HEAD
# Classes - Setters are shallow
# DESCRIPTION
# Describes how setting of inherited attributes and values function
# RESOURCES
#
# Creating Parent class
class Parent():
par_cent = "parent"
# Parent Init method
def __init__(self, val):
self.par_cent = val
print("Parent Instantiated ... | true |
f96d6651e41ca733e06d7b0346137a65688cd20a | RAVURISREESAIHARIKRISHNA/Python-2.7.12-3.5.2- | /Reading_list_INTs_Exception.py | 816 | 4.21875 | 4 | def Assign(n):
try:
return(int(n))
except ValueError: # Managing Inputs Like 's'
print("Illegal Entery\nRetry..")
n=input() # Asking User to Re-entry
Assign(n) # Calling the Same function,I correct input entered..Integer will be Returned,Else..Calling Recursively
return(int(n)) #Ret... | true |
d673103b6d9361916427652b337b9fbbf1fe7eae | cnkarz/Other | /Investing/Python/dateCreator.py | 1,743 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
This script writes an array of dates of weekdays as YYYYMMDD
in a csv file. It starts with user's input,
which must be a monday in the same format
Created on Wed Jan 25 07:36:22 2017
@author: cenka
"""
import csv
def displayDate(year, month, day):
date = "%d%02d%02d" % (year, month, da... | true |
b3ee3c37efe6d97d32869f14d6e5bba5e9e8fc91 | bglogowski/IntroPython2016a | /students/Boundb3/Session05/cigar_party.py | 594 | 4.125 | 4 | #!/usr/bin/env python
"""
When squirrels get together for a party, they like to have cigars.
A squirrel party is successful when the number of cigars is between
40 and 60, inclusive. Unless it is the weekend, in which case there
is no upper bound on the number of cigars.
Return True if the party with the given values ... | true |
73a241b1ba5d6337a93fe53fdfdb85815953d13e | AaryaVora/Python-Level-1-2 | /hw3.py | 266 | 4.125 | 4 | fnum = int(input("Please enter a number: "))
snum = int(input("Please enter a number: "))
if fnum == snum :
print("Both numbers are equal")
elif fnum < snum:
print("Second number is greater")
else:
print("First number is greater than the second number")
| true |
e61e0925cb261ff53f4a3ce9cf90314a3d9c4ed9 | Harrison-Z1000/IntroProgramming-Labs | /labs/lab_03/pi.py | 1,077 | 4.34375 | 4 | # Introduction to Programming
# Author: Harrison Zheng
# Date: 09/25/19
# This program approximates the value of pi based on user input.
import math
def main():
print("This program approximates the value of pi.")
n = int(input("Enter the number of terms to be summed: "))
piApproximation = approximate(n)... | true |
1b2dea794f55fab9398ec2fcbf258df7007f0f90 | yash95shah/Leetcode | /swapnotemp.py | 284 | 4.28125 | 4 | '''
know swapping works on python without actually using temps
'''
def swap(x, y):
x = x ^ y
y = x ^ y
x = x ^ y
return (x, y)
x = int(input("Enter the value of x: "))
y = int(input("Enter the value of y: "))
print("New value of x and y: " + str(swap(x, y)))
| true |
ca312b4e02650221b6bb5f34871ef12f45ad98d9 | yash95shah/Leetcode | /sumwithoutarith.py | 411 | 4.3125 | 4 | '''
Sum of two integers without actually using the arithmetic operators
'''
def sum_without_arith(num1, num2):
temp_sum = num1 ^ num2
and_sum = num1 & num2 << 1
if and_sum:
temp_sum = sum_without_arith(temp_sum, and_sum)
return temp_sum
n1 = int(input("Enter your 1st number: "))
n2 = int(i... | true |
3962ed28f3ccc7d4689d73f5839bc6d016e43736 | Juhkim90/Multiplication-Game-v.1 | /main.py | 980 | 4.15625 | 4 | # To Run this program,
# Press Command + Enter
import random
import time
print ("Welcome to the Multiplication Game")
print ("Two Numbers are randomly picked between 0 and 12")
print ("Try to Answer ASAP. If you do not answer in 3 seconds, You FAIL!")
score = 0
ready = input("\n... | true |
442554266ce87af7740511669163b8c575a96950 | OliviaParamour/AdventofCode2020 | /day2.py | 1,553 | 4.25 | 4 | import re
def load_file(file_name: str) -> list:
"""Loads and parses the input for use in the challenge."""
input = []
with open(file_name) as file:
for line in file:
parts = re.match(r"^(\d+)-(\d+) ([a-z]): (\w+)$", line)
input.append((int(parts.group(1)), int(parts.group(... | true |
1b120b65333495c5bd98f63e0e016942b419a708 | DarshAsawa/ML-and-Computer-vision-using-Python | /Python_Basics/Roll_Dice.py | 413 | 4.28125 | 4 | import random
no_of_dices=int(input("how many dice you want :"))
end_count=no_of_dices*6
print("Since you are rolling %d dice or dices, you will get numbers between 1 and %d" % (no_of_dices,end_count))
count=1
while count==1 :
user_inp=input("Do you want to roll a dice : ")
if user_inp=="yes" or user_inp=="y" or use... | true |
f1d228b0afac00ffc567698775fc594b8e2b1069 | nischalshk/pythonProject2 | /3.py | 385 | 4.3125 | 4 | """ 3. Write code that will print out the anagrams (words that use the same
letters) from a paragraph of text."""
print("Question 3")
string1 = input("Enter First String: ")
string2 = input("Enter Second String: ")
sort_string1 = sorted(string1.lower())
sort_string2 = sorted(string2.lower())
if sort_string1 == so... | true |
e838332cbe89a89c11746c421c6b284c0c05af94 | jkfer/LeetCode | /Find_Largest_Value_in_Each_Tree_Row.py | 1,117 | 4.15625 | 4 | """
You need to find the largest value in each row of a binary tree.
"""
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
root = TreeNode(1)
root.left = TreeNode(3)
root.right = TreeNode(2)
root.left.left = TreeNode... | true |
ee1f838de3652e533b1600bce3fa33f59ad8d26d | Yasune/Python-Review | /Files.py | 665 | 4.28125 | 4 | #Opening and writing files with python
#Files are objects form the class _io.TEXTIOWRAPPER
#Opening and reading a file
myfile=open('faketext.txt','r')
#opening options :
#'r' ouverture en lecture
#'w' ouverture en ecriture
#'a' ouverture en mode append
#'b' ouverture en mode binaire
print type(myfile)
content=myfile... | true |
688c1740371fdc204941281724563f4c813b2ab7 | Introduction-to-Programming-OSOWSKI/2-9-factorial-beccakosey22 | /main.py | 208 | 4.21875 | 4 | #Create a function called factorial() that returns the factorial of a given variable x.
def factorial(x):
y = 1
for i in range (1, x + 1):
y = y*i
return y
print(factorial(5)) | true |
bfa4cd171831f50848856dd016fb4fdf0461bc47 | davidjeet/Learning-Python | /PythonHelloWorld/MoreLists 2/MoreLists_2.py | 948 | 4.125 | 4 | z = 'Demetrius Harris'
for i in z:
print(i,end = '*')
print()
eggs = ('hello', 323, 0.5)
print(eggs[2])
#eggs[1] = 400 # illegal
#converting tuple to list
a = list(eggs)
a[1] = 500
b = tuple(a)
print(b)
spam = 42
cheese = 100
print(spam)
print(cheese) #different than spam, because by-value
spam = [0,1,2,3,4,5]
c... | true |
aa1d86e1bd876632b1db4d2d5f9381a162db051f | wavecrasher/Turtle-Events | /main.py | 416 | 4.21875 | 4 | import turtle
turtle.title("My Turtle Game")
turtle.bgcolor("blue")
turtle.setup(600,600)
screen = turtle.Screen()
bob = turtle.Turtle()
bob.shape("turtle")
bob.color("white")
screen.onclick(bob.goto)
#bob.ondrag(bob.goto)
screen.listen()
#The pattern above consists of circles drawn repeatedly at different angles -... | true |
b9bc55c14baaf0d0f11234c3c8593fe4b5a4ba47 | Benzlxs/Algorithms | /sorting/merge_sort.py | 1,103 | 4.125 | 4 | # merge sortting https://en.wikipedia.org/wiki/Merge_sort
import os
import time
def merge(left, right):
# merging two parts
sorted_list = []
left_idx = right_idx = 0
left_len, right_len = len(left), len(right)
while (left_idx < left_len) and (right_idx < right_len):
if left[left_idx] <=... | true |
cac68f6a0cb20080f211d0c83f6482a2827f60c7 | Benzlxs/Algorithms | /sorting/selection_sort.py | 784 | 4.40625 | 4 | # merge sortting https://en.wikipedia.org/wiki/Selection_sort
# time complexity is O(n^2)
import os
import time
def selection_sort(list_nums):
for i in range(len(list_nums)):
lowest_value_index = i
# loop through unsorted times
for j in range(i+1, len(list_nums)):
if list_nu... | true |
251b46112a4ba9c6983a3baa6545bd2f47a10edb | PersianBuddy/emailsearcher | /main.py | 1,039 | 4.25 | 4 | #! Python 3
# main.py - finds all email addresses
import re , pyperclip
# user guid
print('Copy your text so it saves into clipboard')
user_response = input('Are you ready? y=\'yes\' n=\'no\' :')
while str(user_response).lower() != 'y':
user_response = input("Make sure type 'y' when you copied your desired text :... | true |
7ce7b8965c78c0e772953895bc81b4bd9023f15a | pezLyfe/algorithm_design | /intro_challenges/max_pairwise_product_2.py | 615 | 4.15625 | 4 | # Uses python3
'''
The starter file provided by the course used nested for loops to calculate the solution
as a result, the submission failed due to an excessive runtime. The list.sort() method in python works really fast, so use that to order the list and then multiply the largest entry in the list by the second large... | true |
d5af7c56bda22cef4a6855838d23b33ade9ef340 | WilliamMcCann/holbertonschool-higher_level_programming | /divide_and_rule/h_fibonacci.py | 520 | 4.21875 | 4 | '''prints out the Fibonacci number for a given input'''
import threading
class FibonacciThread(threading.Thread):
def __init__(self, number):
threading.Thread.__init__(self)
try:
val = int(number)
except ValueError:
print("number is not an integer")
self.numb... | true |
5ed3875dee928cc5a1b65ad7d9f1f582e2358660 | ShruKin/Pre-Placement-Training-Python | /WEEK-3/1.py | 215 | 4.625 | 5 | # 1. Write a python program to check if a user given string is Palindrome or not.
n = input("Enter a string: ")
if(n == n[::-1]):
print("Its a palindrome string")
else:
print("Its not a palindrome string") | true |
9663393bb56c77a277bc1b62c44a3c6ae3b8b4ee | ShruKin/Pre-Placement-Training-Python | /WEEK-3/2.py | 364 | 4.46875 | 4 | # 2. Write a python program to take Firstname and lastname as input.
# Check whether the first letter of both strings are in uppercase or not.
# If not change accordingly and print reformatted string.
fn = input('Firstname: ')
ln = input('Lastname: ')
if not fn[0].isupper():
fn = fn.title()
if not ln[0].isupper(... | true |
ceaf2f949eb9840fbeed64d74c0cd37b808f5816 | kb7664/Fibonacci-Sequence | /fibonacciSequence.py | 673 | 4.3125 | 4 | ##############################
# Fibinacci Sequence
#
# Author: Karim Boyd
##############################
# This program demonstrates one of the many ways to build the Fibonacci
# sequence using recursion and memoization
# First import lru_cache to store the results of previous runs to
# memory
from functools i... | true |
d48b59a7708afea878e06c1d910ff304e2772316 | hintermeier-t/projet_3_liberez_macgyver | /graph/maze.py | 1,601 | 4.125 | 4 | # -*coding: UTF-8-*
"""Module containing the MazeSpriteClass."""
import pygame as pg
from . import gdisplay
class MazeSprite (pg.sprite.Sprite):
"""Class displaying the maze sprite.
Gathering all we need to display the walls sprites,
and the path sprites. (position, source picture etc...).
Inherit ... | true |
be80b0aea58b2005699f667c15102be2d2398d42 | riaz4519/python_practice | /programiz/_6_list.py | 922 | 4.375 | 4 | #list
#create list
myList = [5,6,7,8]
print(myList)
#mixed data type list
myList = [5,8,'data',3.5]
print(myList)
#nested list
myList = ['hello',[5,6]]
print(myList)
#accessing the list
myList = ['p','r','o','b','e']
#by index
print(myList[0])
#nested
n_list = ["Happy", [2,0,1,5]]
print(n_list[1][1])
print(n... | true |
51eb5831e885cff30bdefa175b7ba153222156ac | CupidOfDeath/Algorithms | /Bisection Search.py | 402 | 4.15625 | 4 | #Finding the square root of a number using bisection search
x = int(input('Enter the number which you want to find the square root of: '))
epsilon = 0.01
n = 0
low = 1
high = x
g = (low+high) / 2
while abs(g*g-x) >= epsilon:
if (g*g) > x:
high = g
elif (g*g) < x:
low = g
g = (low+high) / 2
n += 1
print('The ... | true |
42a8dcd380e302595f43a72bea8eb5c0c0a1fff3 | mightymax/uva-inleiding-programmeren | /module-1-numbers/sequence.alt.py | 1,530 | 4.25 | 4 | highestPrime = 10000
number = 1 #Keep track of current number testing for prime
nonPrimes = []
while number < highestPrime:
number = number + 1
if (number == 2 or number % 2 != 0): #test only uneven numbers and 2
#loop thru all integers using steps of 2, no need to test even numbers
for x in ra... | true |
0bca3a56b899c73b9f63201d6eb1cb0070976972 | lasj00/Python_project | /OOP.py | 1,965 | 4.1875 | 4 | import math
class Rectangle:
# the init method is not mandatory
def __init__(self, a, b):
self.a = a
self.b = b
# self.set_parameters(10,20)
def calc_surface(self):
return self.a * self.b
# Encapsulation
class Rectangle2():
def __init__(self, a, b):
self.__... | true |
b451055efe0de3395b4c49beb4d67ee77694bece | KaylaBaum/astr-119-hw-1 | /variables_and_loops.py | 706 | 4.375 | 4 | import numpy as np #we use numpy for many things
def main():
i = 0 #integers can be declared with a number
n = 10 #here is another integer
x = 119.0 #floating point nums are declared with a "."
#we can use numpy to declare arrays quickly
y = np.zeros(n,dtype=float) ... | true |
5fd79aec14f570b55d10153e52c7d67e751d5877 | ch1huizong/study | /lang/py/cookbook/v2/19/merge_source.py | 1,096 | 4.1875 | 4 | import heapq
def merge(*subsequences):
# prepare a priority queue whose items are pairs of the form
# (current-value, iterator), one each per (non-empty) subsequence
heap = []
for subseq in subsequences:
iterator = iter(subseq)
for current_value in iterator:
# subseq is not empty, therefor... | true |
5afb03eae042cc84d9c770e3153fa07d12884906 | shashikant231/100-Days-of-Code- | /Pascal Traingle.py | 938 | 4.1875 | 4 | '''Given an integer numRows, return the first numRows of Pascal's triangle.
In Pascal's triangle, each number is the sum of the two numbers directly above it as shown:
Example 1:
Input: numRows = 5
Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]
solution
We are first creating an 2D array .our array after creatio... | true |
6763a48aa0e4c976e75b68ae74f18394512b1e85 | DrN3RD/PythonProgramming | /Chapter 3/c03e01.py | 378 | 4.34375 | 4 | #Volume calculator
from math import *
def main():
r = float(input("Enter the radius of the shpere to be calculated: "))
volume = (4/3)*pi*(r**3)
area = 4*pi * r**2
print("The area of the Shpere is {0:0.1f} square meters ".format(area))
print("\n The Volume of the sphere is {0:0.1f} cubic m... | true |
1ae36388c286daad1d37d101d9ca05db4bd7384a | mamatha20/ifelse_py | /IF ELSE_PY/if else4.py | 276 | 4.34375 | 4 | #write a program to check whethernit is alphabet digit or special character
ch=input("enter any character=")
if ch>="a" and ch<="z" or ch>="A" and ch<="Z":
print("it is alphabet")
elif ch>="0" and ch<="9":
print("it is digit")
else:
print("it is special charcter") | true |
75c9868ff8d055492da5bb749b20d5a919a440e8 | mamatha20/ifelse_py | /IF ELSE_PY/if else25.py | 658 | 4.125 | 4 | day=input('enter any day')
size=input('enter any size')
if day=='sunday':
if size=='large':
print('piza with free brounick')
elif size=='medium':
print('piza with free garlick stick')
else:
print('free coca')
elif day=='monday' or day=='tuesday':
if size=='large':
print('pizza with 10%discount')
elif size=... | true |
a566f238d1a9cc97699986160a108e3c9e88cbd5 | yameenjavaid/bigdata2019 | /01. Jump to python/Chap07/3_Python_Exercise/21.py | 281 | 4.21875 | 4 | import re
# Write a Python program to find the substrings within a string.
while True :
original_setence = input("입력하세요 : ")
if original_setence == "ㅈㄹ" :
exit()
m = re.findall("exercises", original_setence)
for i in m :
print(i)
| true |
9d6ea6b45c26fccabafd08a13e39d54ce906f918 | yameenjavaid/bigdata2019 | /01. Jump to python/Chap07/3_Python_Exercise/18.py | 342 | 4.40625 | 4 | import re
# Write a Python program to search the numbers (0-9) of length between 1 to 3 in a given string.
p = re.compile(r"([0-9]{1,3})")
while True :
original_setence = input("입력하세요 : ")
if original_setence == "ㅈㄹ" :
exit()
m = p.finditer(original_setence)
for i in m :
print(i.gr... | true |
8822adfd5f0a1d8732e8fa92f0834af2de2764e2 | shaheenery/udacity_ds_and_a_project2 | /problem_5.py | 2,548 | 4.375 | 4 | # Blockchain
# A Blockchain is a sequential chain of records, similar to a linked list. Each
# block contains some information and how it is connected related to the other
# blocks in the chain. Each block contains a cryptographic hash of the previous
# block, a timestamp, and transaction data. For our blockchain we w... | true |
efce9bd907d2493ea03807cd09ef298ac5facf58 | zoecahill1/pands-problem-set | /collatz.py | 1,060 | 4.34375 | 4 | # Zoe Cahill - Question 4 Solution
# Imports a function from PCInput which was created to handle user input
from PCInput import getPosInt
def collatz1():
# Calls the function imported above
# This function will check that the number entered is a positive integer only
num = getPosInt("Please enter a posit... | true |
f9dfbf8b29d1a1673076aa512e2d89653af38b6a | codeshef/SummerInternship | /Day5/classesPython.py | 483 | 4.125 | 4 |
# <------- Day 8 work ------->
# classes in python
class User:
def __init__(self):
print("Hello!! I am constructor of class user")
def setUserName(self, fn, ln):
print("I am inside setUserNameFunc")
self.firstName = fn
self.lastName = ln
def printData(self):
p... | true |
bc502be94ca45d1750cce48ca3c39f0eb9dd389c | dergaj79/python-learning-campus | /unit5_function/test.py | 959 | 4.125 | 4 | # animal = "rabbit"
#
# def water():
# animal = "goldfish"
# print(animal)
#
# water()
# print(animal)
# a = 0
#
#
# def my_function() :
# a = 3
# print(a)
#
#
# my_function()
# print(a)
# a=1
# def foo1():
# print(a)
# foo1()
# print(a)
# def amount_of_oranges(small_cups=20, large_cups=10):
# ... | true |
9f8220cbed18b0e05822ae99a652b649c682b08f | sandeeppal1991/D08 | /mimsmind0.py | 2,527 | 4.5625 | 5 | """In this version, the program generates a random number with number of digits
equal to length. If the command line argument length is not provided, the
default value is 1. Then, the program prompts the user to type in a guess,
informing the user of the number of digits expected. The program will then
read the user in... | true |
46888f48af85aa51067e50b537e670510dad01c8 | asuddenwhim/DM | /own_text.py | 776 | 4.125 | 4 |
from nltk import word_tokenize, sent_tokenize
text = "Generally, data mining (sometimes called data or knowledge discovery) is the process of analyzing data from different perspectives and summarizing it into useful information - information that can be used to increase revenue, cuts costs, or both. Data mining softwa... | true |
1e7db90033a0f66814ddd3eada5fbaf26424755d | rashedrahat/wee-py-proj | /hangman.py | 1,407 | 4.25 | 4 | # a program about guessing the correct word.
import random
i = random.randint(0, 10)
list = [["H*ng*a*", "Hangman"], ["B*n**a", "Banana"], ["*wk*ar*", "Awkward"], ["B*n**", "Banjo"], ["Ba*pi*e*", "Bagpipes"], ["H*p**n", "Hyphen"], ["J*k*b*x", "Jukebox"], ["O*y**n", "Oxygen"], ["Num*sk*l*", "Numbskull"], ["P*j*m*... | true |
ae8899b2735de9b712b11e1e20f95afcd5008be2 | erikac613/PythonCrashCourse | /11-1.py | 483 | 4.15625 | 4 | from city_functions import city_country
print("Enter 'q' at any time to quit.")
while True:
city = raw_input("\nPlease enter the name of a city: ")
if city == 'q':
break
country = raw_input("Please enter the name of the country where that city is located: ")
if country == 'q':
... | true |
6db90e6de92dc5a3ca12f22a6e94577abd42a6c1 | gungorefecetin/CS-BRIDGE-2020 | /Day3PM - Lecture 3.1/khansole_academy.py | 1,021 | 4.375 | 4 | """
File: khansole_academy.py
-------------------
This program generates random addition problems for the user to solve, and gives
them feedback on whether their answer is right or wrong. It keeps giving them
practice problems until they answer correctly 3 times in a row.
"""
# This is needed to generate random numb... | true |
52963e18085b20a2f20020a0093b01ea26e34e0c | LucianoAlbanes/AyEDI | /TP1/Parte1/1/restrictions.py | 250 | 4.125 | 4 | ## The purpose of the following code is to have certain functions
## that python provides, but they are restricted in the course.
# Absolute Value (Aka 'abs()')
def abs(number):
if number < 0: return number*-1
else: return number
| true |
6735f531a626eb2dd8999e26136e950299a978d4 | LucianoAlbanes/AyEDI | /TP6/1/fibonacci.py | 1,058 | 4.25 | 4 | # Calc the n-th number of the Fibonacci sequence
def fibonacci(n):
'''
Explanation:
This function calcs and return the number at a given position of the fibonacci sequence.
Params:
n: The position of the number on the fibonacci sequence.
Return:
The number at the given position ... | true |
c828a8ab988f60b7a7c73a79ca678e5d7264415e | navbharti/java | /python-cookbook/other/ex7.py | 2,366 | 4.1875 | 4 | '''
Created on Sep 19, 2014
@author: rajni
'''
months = ('January','February','March','April','May','June',\
'July','August','September','October','November',' December')
print months
cats = ['Tom', 'Snappy', 'Kitty', 'Jessie', 'Chester']
print cats
#fetching items from tupble and list
print cats[2]
print months[2]... | true |
fc7dd582f1d3fcff14bd071ddf53081faa20488a | mrmezan06/Python-Learning | /Real World Project-2.py | 364 | 4.25 | 4 | # Design a program to find avarage of three subject marks
x1 = int(input("Enter subject-1 marks:"))
x2 = int(input("Enter subject-2 marks:"))
x3 = int(input("Enter subject-3 marks:"))
sum = x1 + x2 + x3
avg = sum / 3
print("The average marks:", int(avg))
print("The average marks:", avg)
# Formatting the float value
pri... | true |
c765b56d4d457bd428b05d59a0c882ccf7325910 | kkkansal/FSDP_2019 | /DAY 02/pangram.py | 956 | 4.21875 | 4 | """
Code Challenge
Name:
Pangram
Filename:
pangram.py
Problem Statement:
Write a Python function to check whether a string is PANGRAM or not
Take input from User and give the output as PANGRAM or NOT PANGRAM.
Hint:
Pangrams are words or sentences containing every letter of the alphabet at ... | true |
0e58b02c59fe57bf55e8c1c61a0442f35146876f | dev-di/python | /helloworld.py | 323 | 4.1875 | 4 | #name = input("What is your name my friend? ")
name = "Diana"
message = "Hello my friend, " + name + "!"
print(message) #comment
print(message.upper())
print(message.capitalize())
print(message.count("i"))
print(f"message = '{message}', name = '{name}'")
print("Hello {}!!".format(name))
print("Hello {0}!".format(nam... | true |
6cf6799c4f652c47a3cb818ab1910b4c8d3d6d1c | JustinTrombley96/Python-Coding-Challenges | /drunk_python.py | 730 | 4.1875 | 4 | '''
Drunken Python
Python got drunk and the built-in functions str() and int() are acting odd:
str(4) ➞ 4
str("4") ➞ 4
int("4") ➞ "4"
int(4) ➞ "4"
You need to create two functions to substitute str() and int(). A function called int_to_str() that converts integers into strings and a function called str_to_int() tha... | true |
94db4a5c592136be5afeccac3323c5c598e41900 | STProgrammer/PythonExercises | /Rock Paper Scissor.py | 1,571 | 4.125 | 4 | import random
print("Welcome to \"Rock Paper Scissor\" game")
print("""Type in "rock", "paper", or "scissor" and see who wins.
first one that win 10 times win the game.""")
HandsList = ["rock", "paper", "scissor"]
while True:
x = int() #Your score
y = int() #Computer's score
while x < 10 and y < 10:
... | true |
8f7e92a384cf95b4b45ee3eb41d0edf8afdb38ff | Esther-Guo/python_crash_course_code | /chapter4-working with lists/4.10-slices.py | 265 | 4.40625 | 4 | odd = list(range(1,21,2))
for number in odd:
print(number)
print('The first three items in the list are: ')
print(odd[:3])
print('Three items from the middle of the list are: ')
print(odd[4:7])
print('The last three items in the list are: ')
print(odd[-3:]) | true |
0777824a168e8bc5eabcb35a58e2c6aa62e122d2 | Esther-Guo/python_crash_course_code | /chapter8-functions/8.8-user_albums.py | 651 | 4.21875 | 4 | def make_album(name, title, tracks=0):
"""builds a dictionary describing a music album"""
album_dict = {
'artist name': f'{name.title()}',
'album title': f'{title.title()}'
}
if tracks:
album_dict['tracks'] = tracks
return album_dict
name_prompt = 'Please input the name... | true |
5e29635e085e9f0199f8e7e6b7e97e47fae30fcd | hefeholuwah/wejapa_internship | /Hefeholuwahwave4 lab/Scripting labs/match_flower_name.py | 1,388 | 4.34375 | 4 | #For the following practice question you will need to write code in Python in the workspace below. This will allow you to practice the concepts discussed in the Scripting lesson, such as reading and writing files. You will see some older concepts too, but again, we have them there to review and reinforce your understan... | true |
73c3bcce9c5509b858bb2d149ded24f592b78207 | xuyichen2010/Leetcode_in_Python | /general_templates/tree_bfs.py | 1,170 | 4.1875 | 4 | # https://www.geeksforgeeks.org/level-order-tree-traversal/
# Method 1 (Use function to print a given level)
# O(n^2) time the worst case
# Because it takes O(n) for printGivenLevel when there's a skewed tree
# O(w) space where w is maximum width
# Max binary tree width is 2^h. Worst case when perfect binary tree
# ... | true |
c03486f525084d5fd5f06c48f371db8cbdfa9666 | phganh/CSC110---SCC | /Labs/Lab 3/coffeeShop.py | 984 | 4.15625 | 4 | # Project: Lab 03 (TrinhAnhLab03Sec03.py)
# Name: Anh Trinh
# Date: 01/20/2016
# Description: Calculate the cost of a coffee
# shop's products
def coffeeShop():
#Greeting
print("Welcome to the Konditorei Coffee Shop!\n")
#User's Input
fltPound = float(input("Enter ... | true |
4a0989e726ccdea9ec4b69028dd3f5b1c5e54312 | ccchao/2018Spring | /Software Engineering/hw1/good.py | 858 | 4.34375 | 4 | """
1. pick a list of 100 random integers in the range -500 to 500
2. find the largest and smallest values in the list
3. find the second-largest and second-smallest values in the list
4. calculate the median value of the elements in the list
"""
import random
#Generate a list containing 100 randomly generated intege... | true |
1a5decdca960e40d6c0bd1939d4461176a7fee70 | parastooveisi/CtCI-6th-Edition-Python | /Linked Lists/palindrome.py | 1,202 | 4.1875 | 4 | # Implement a function to check if a linked list is a palindrome
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def printList(self):
curr = self.head
while curr:
print(cur... | true |
5819dbb5b6c308ac62f478185a3d52718832a533 | jbehrend89/she_codes_python | /functions/functions_exercises.py | 429 | 4.125 | 4 | # Q1)Write a function that takes a temperature in fahrenheitand returns the temperature in celsius.
def convert_f_to_c(temp_in_f):
temp_in_c = (temp_in_f - 32) * 5 / 9
return round(temp_in_c, 2)
print(convert_f_to_c(350))
# Q2)Write a function that accepts one parameter (an integer) and returns True when tha... | true |
9dcd83d636b054f122adb049fb0ecb97b342d3f4 | nishanthegde/bitesofpy | /105/slicing.py | 1,848 | 4.3125 | 4 | from string import ascii_lowercase
text = """
One really nice feature of Python is polymorphism: using the same operation
on different types of objects.
Let's talk about an elegant feature: slicing.
You can use this on a string as well as a list for example
'pybites'[0:2] gives 'py'.
The first value is inclus... | true |
1ad2e7463aff6086e9506fe45d87a94b0d6b9226 | nishanthegde/bitesofpy | /9/palindrome.py | 1,805 | 4.21875 | 4 | """A palindrome is a word, phrase, number, or other sequence of characters
which reads the same backward as forward"""
import os
import urllib.request as ur
import re
local = '/tmp'
# local = os.getcwd()
DICTIONARY = os.path.join(local, 'dictionary_m_words.txt')
ur.urlretrieve('http://bit.ly/2Cbj6zn', DICTI... | true |
489a9fbaa6d206101364ed5db32b3bf291c3d875 | nishanthegde/bitesofpy | /304/max_letter.py | 2,435 | 4.25 | 4 | from typing import Tuple
import re
from collections import Counter
sample_text = '''It is a truth universally acknowledged, that a single man in
possession of a good fortune, must be in want of a wife.'''
with_numbers_text = '''20,000 Leagues Under the Sea is a 1954 American
Tec... | true |
c2e0d08cf977c216e326da83a6e1580b01c3af7b | nishanthegde/bitesofpy | /66/running_mean.py | 666 | 4.125 | 4 | import itertools
def running_mean(sequence: list) -> list:
"""Calculate the running mean of the sequence passed in,
returns a sequence of same length with the averages.
You can assume all items in sequence are numeric."""
it = iter(sequence)
n = len(sequence)
run_mean = []
... | true |
f70649cbba312ef901ac9aa035cc529e46127200 | Caleb-o/VU405 | /sort.py | 694 | 4.1875 | 4 | """
Author: Caleb Otto-Hayes
Date: 11/2/2021
"""
def swap(x: int, y: int) -> tuple:
return (y, x)
def bubbleSort(unsorted: list) -> None:
length: int = len(unsorted)
full_pass: bool = False
# Cannot parse if only 1 number exists
if length < 2:
return
while not full_p... | true |
1572a767db054bb13877a5d56f5efb212d0b844d | ahumoe/dragonfly-commands | /_text_utils.py | 1,978 | 4.15625 | 4 | #!/usr/bin/env python
# (c) Copyright 2015 by James Stout
# (c) Copyright 2016 by Andreas Hagen Ulltveit-Moe
# Licensed under the LGPL, see <http://www.gnu.org/licenses/>
"""Library for extracting words and phrases from text."""
import re
def split_dictation(dictation, strip=True):
"""Preprocess dictation to do ... | true |
c3062c4b5da4a684bb5ce8a19b074e6585618620 | josepicon/practice.code.py | /Exercise Files/Ch2/functions_start.py | 747 | 4.34375 | 4 | #
# Example file for working with functions
#
# define a basic function
def func1():
print("i am a function")
# function that takes arguments
def func2(arg1, arg2):
print(arg1, "", arg2)
# function that returns a value
def cube(x):
return x*x*x
# function with default value for an argument
def power(n... | true |
080fa1a292fe225984f8889d5e5bd13ed05b0f07 | MayThuHtun/python-exercises | /ex3.py | 444 | 4.28125 | 4 | print("I will now count my chickens")
print("Hens", 25+30/6)
print("Roosters", 100-25*3 % 4)
print("Now I will count the egg:")
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("What is 3+2?", 3+2)
print("What is 5-7?", 5-7)
print("Oh, that is why it is false")
print("How about some m... | true |
aeb5e4b72d128ac04131053125ed663ad059d5f5 | Patricia888/data-structures-and-algorithms | /sorting_algos/merge_sort/merge_sort.py | 927 | 4.5 | 4 | def merge_sort_the_list(lst):
''' Performs a merge sort on a list. Checks the length and doesn't bother sorting if the length is 0 or 1. If more, it finds the middle, breaks the list in to sublists, sorts, puts in to a single list, and then returns the sorted list '''
# don't bother sorting if list is less than... | true |
e10e5f413c7f9e4b84f8fe20a314a4be4d36a9a9 | TheWronskians/capture_the_flag | /turtlebot_ws/src/turtle_pkg/scripts/primeCalc.py | 912 | 4.125 | 4 | from math import *
import time
def checkingPrime(number): #Recieves number, true if prime. Algorithem reference mentioned in readme file.
checkValue = int(sqrt(number))+1
printBool = True
#print checkValue
for i in range(2, checkValue):
if (number%i) == 0:
printBool = False
break
return printBool
def c... | true |
273b92997f588d6aeee2ae42928258d04f0a4187 | drliebe/python_crash_course | /ch7/restaurant_seating.py | 214 | 4.28125 | 4 | dinner_party_size = input("How many people are in your dinner group? ")
if int(dinner_party_size) > 8:
print("I'm sorry, but you will have to wait to be seated.")
else:
print('Great, we can seat you now.')
| true |
1a747fc8d6fefd929318c717954420f3e36ce54a | drliebe/python_crash_course | /ch9/ice_cream_stand.py | 888 | 4.28125 | 4 | class Restaurant():
"""A class modeling a simple restaurant."""
def __init__(self, restaurant_name, cuisine_type):
self.restaurant_name = restaurant_name
self.cuisine_type = cuisine_type
def describe_restaurant(self):
print('Restaurant name: ' + self.restaurant_name +
... | true |
42b2a2848527d4f024d2bdc5ff385b2ce9753dc4 | aurafrost/Python | /DivisorCheck.py | 518 | 4.21875 | 4 | """
This program takes an int from the user then returns all divisors of that int from lowest to highest.
"""
num = int(input("Enter an integer: "))
divisorList = []
for x in range(1,num+1):
if num%x==0:
divisorList.append(x) #adds x to divisorList if it has no remainder when divided into num
print("The div... | true |
edaaa9d51915039e033c950b030fbc08a9ef4084 | fharookshaik/Mobius_GUI | /mobius.py | 2,932 | 4.28125 | 4 | '''
Möbius function:
For any positive integer n,n, define μ(n)μ(n) as the sum of the primitive n^\text{th}nth roots of unity.
It has values in \{-1, 0, 1\}{−1,0,1} depending on the factorization of nn into prime factors:
a) \mu(n) = 1μ(n)=1 if nn is a square-free positive integer with an even number of prime facto... | true |
cb98c118df80bbe3ef89900bc63d6e38d01514c8 | jpozin/Math-Projects | /TriangleStuff.py | 652 | 4.375 | 4 | import sys
from math import sqrt
class TriangleException(Exception):
pass
def isValidTriangle(a, b, c):
return (a + b > c) and (a + c > b) and (b + c > a)
def Perimeter(a, b, c):
return a + b + c
def Area(a, b, c):
s = Perimeter(a, b, c) / 2
return sqrt(s*(s-a)*(s-b)*(s-c))
if __name__ == '__m... | true |
52756187aec18fc94ecc77d26594ab3d50a502a5 | kellylougheed/raspberry-pi | /bubble_sort.py | 956 | 4.375 | 4 | #!/usr/bin/env python
# This program sorts a list of comma-separated integers using bubble sort
# Swaps two numbers in a list given their indices
def swap(l, index1, index2):
temp = l[index2]
l[index2] = l[index1]
l[index1] = temp
numbers = input("Enter a list of comma-separated integers: ")
lst = numbers.split... | true |
473d78088b698ab07eca912a5ef5bf23a76d32dc | dibaggioj/bioinformatics-rosalind | /textbook/src/ba1d.py | 2,138 | 4.3125 | 4 | #!/usr/bin/env
# encoding: utf-8
"""
Created by John DiBaggio on 2018-07-28
Find All Occurrences of a Pattern in a String
In this problem, we ask a simple question: how many times can one string occur as a substring of another? Recall from “Find the Most Frequent Words in a String” that different occurrences of a sub... | true |
b2b59660795297211f00f7b98497fb289583e46a | FierySama/vspython | /Module3StringVariables/Module3StringVariables/Module3StringVariables.py | 1,330 | 4.5625 | 5 | #String variables, and asking users to input a value
print("What is your name? ") # This allows for the next line to be user input
name = input("")
country = input("What country do you live in? ")
country = country.upper()
print(country)
# input is command to ask user to enter info!!
# name is actually the name of... | true |
75db23491fd660c007860b03e4ed99cca64a9025 | zengh100/PythonForKids | /lesson02/07_keyboard_number.py | 316 | 4.15625 | 4 | # keyboard
# we can use keyboard as an input to get informations or data (such as number or string) from users
x1 = input("please give your first number? ")
#print('x1=', x1)
x2 = input("please give your second number? ")
#print('x2=', x2)
sum = x1 + x2
#sum = int(x1) + int(x2)
print('the sum is {}'.format(sum))
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.