blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
f0c79b529e1f66b89f5c55859926cb724d249871 | tayyabmalik4/MatplotlibWithTayyab | /2_line_plot_matplotlib.py | 663 | 4.5 | 4 | # (2)*************line plot in matplotlib*************
# ///////to show the graphical line plot than we use line plot function in matplotlib
# ////import matplotlib
import matplotlib.pyplot as plt
days =[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
tem=[36.6,37,37.7,39,40,36.8,43,44,45,45.5,40,44,34,47,46]
# //////start t... | true |
2234f9ba4e9cda121f2687d48597af84fc34a325 | seshgirik/python-practice | /class_emp.py | 811 | 4.125 | 4 | class Employee():
raise1 = 10
def __init__(self, name, age):
self.name = name
self.age = age
def increment(self):
print(f'increment is percentage {self.raise1}') # to access class variable we should use either class name or class instance
rama = Employee('rama', 10)
rama.increme... | true |
be8eee178a6fc4354447d46ee616ab2716209ff6 | rizkariz/dental_school | /sialolit, sialadeni, mukolel.py | 853 | 4.125 | 4 | # sialolithiasis, sialadenitis, or mukokel
print("Answer the question with y/n")
while True:
num_1 = input("Does the swelling painful?")
if num_1 == "y":
num_1a = input("Is there any prodromal sympton?")
if num_1a == "y":
print("It might be Sialadenitis")
break
... | true |
2dcf55a666a4d134eba54a7c4b350e676270b91e | GabrielVSMachado/42AI_Learning | /00/text_analyzer/count.py | 724 | 4.125 | 4 | def text_analyzer(text=None, *args) -> str:
"""Return a string with the number of characters and other elements:
number of upper_cases, lower_cases, punctuation_marks and spaces"""
if len(args) != 0:
return "ERROR"
while text is None:
text = input("What is the text to analyse?\n")
pu... | true |
99f465d787dc0d99c03575b767478dbe2aa0d17a | Pallavi2000/adobe-training | /day1/p1.py | 263 | 4.15625 | 4 | #Program to check if integer is a perfect square or not
number = int(input("Enter a number "))
rootNum = int(number ** 0.5)
if rootNum * rootNum == number:
print(number,"is a perfect square number")
else:
print(number, " is not a perfect square number") | true |
c1412481b55052471dc56ced35b17fb48f18c904 | otaviocv/spin | /spin/distances/distances.py | 1,987 | 4.25 | 4 | """Distances module with utilities to compute distances."""
import numpy as np
def general_distance_matrix(X, dist_function):
"""General distance matrix with custom distance function.
Parameters
----------
X : array, shape (n, k)
The first set of column vectors. This is a set of k vectors wit... | true |
95258c4e533cda362105cb844888cfa7f8aa8629 | joycecodes/problems | /collatz.py | 836 | 4.15625 | 4 | """
The following iterative sequence is defined for the set of positive integers:
n โ n/2 (n is even)
n โ 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 โ 40 โ 20 โ 10 โ 5 โ 16 โ 8 โ 4 โ 2 โ 1
It can be seen that this sequence (starting at 13 and finishing at 1) c... | true |
ed1ae18ed0aaa1b1ecfeac5a9357fe376ab69deb | almcd23/python-textbook | /ex4.py | 960 | 4.1875 | 4 | #tells number of cars
cars = 100
#tells the amount of people a car can hold
space_in_a_car = 4.0
#tells the number of people to drive the cars
drivers = 30
#tells the number of passengers needing cars
passengers = 90
#subtracts the number of cars from the number of drivers
cars_not_driven = cars - drivers
#there is one... | true |
7d5ad77f9b30edfc698bed052baf7300cf668bc9 | jorge-gx/dsi-minicourse | /004_ml_example.py | 1,331 | 4.40625 | 4 | """
Supervised learning example:
An overview of the scikit-learn library for Machine Learning in Python
"""
import pandas as pd
# importing model type and other useful techniques and eval metrics
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from skle... | true |
e427debab3fb641525ed5c97a0f086ee194b60d3 | AugPro/Daily-Coding-Problem | /Airbnb/e009.py | 615 | 4.125 | 4 | """This problem was asked by Airbnb.
Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. Numbers can be 0 or negative.
For example, [2, 4, 6, 2, 5] should return 13, since we pick 2, 6, and 5. [5, 1, 1, 5] should return 10, since we pick 5 and 5.
Follow-up: Can you do thi... | true |
02b919b015d4c6dcb841f834707d0c89ab7daa80 | Pravin2796/python-practice- | /chapter 2/operators.py | 457 | 4.1875 | 4 | a = 3
b = 4
# Arithematic operator
print("value of 3+4 is", 3 + 4)
print("value of 3+4 is", 3 - 4)
print("value of 3+4 is", 3 * 4)
print("value of 3+4 is", 3 / 4)
# Assignment operators
a= 20
a += 2
print (a)
# comparison operator
a = (4>5)
print(a)
#logical operator
bool1= True
bool2= False
print("the value of bo... | true |
ed233d7c5c7b0885f4fbeaabda7e9d957da30e10 | surajbnaik90/devops-essentials | /PythonBasics/PythonBasics/Sets/set1.py | 1,156 | 4.28125 | 4 | #Creating sets
companies = {"Microsoft", "Amazon", "Google"}
print(companies)
for company in companies:
print(company)
print("-" * 100)
companies_set = set(["Microsoft", "Amazon", "Google"])
print(companies_set)
for company in companies_set:
print(company)
#Add item to a set
companies.add("VMWare")
compani... | true |
e1a6ae9518a2dbf164af4691fe0f5b1d7fee7838 | surajbnaik90/devops-essentials | /PythonBasics/PythonBasics/Challenges/challenge2.py | 450 | 4.1875 | 4 | #Write a program to guess a number between 1 and 10.
import random
highest = 10
randomNumber = random.randint(1, highest)
print("Please guess a number between 1 and {}: ".format(highest))
guess = 0
while guess!= randomNumber:
guess = int(input())
if guess < randomNumber:
print("Please guess higher")... | true |
05368d6c238aced1d80909d6f546363caf05df48 | riddhi-jain/DSAready | /Arrays/Reverse a List.py | 714 | 4.15625 | 4 | #Problem Statement : Reversing a List.
#Approach :
"""
Step1 : Find the "mid" of the List.
Step2 : Take two pointers. initial >> start pointer , last >> end pointer
Step3 : Keep running the loop until initial < last or mid-1 does not equals to zero.
Step4 : Swap the element at initial position with the element at the... | true |
03f32157fc9a2383fd6d1e3f27db19134b1e6ab9 | G00398347/programming2021 | /week04/w3schoolsOperators.py | 1,263 | 4.625 | 5 | #This is for trying out python operators
#assignment operator example
x = 5
x += 3
print (x) #this prints x as 8
#in and not in- membership operators example
x = "Just for fun"
y = {1:"a", 2:"b"}
print ("J"in x)
print ("just" not in x)
print (1 in y)
print ("a" in y)
#identity operators is and is not example 1
... | true |
9e20d191a2fbbfadc803c6e46a873f92add4dc8d | G00398347/programming2021 | /week02/lab2.3.1testTypes.py | 633 | 4.1875 | 4 | #This programme uses type function in python to check variable types
#Author: Ruth McQuillan
#varialbes are assigned names
i = 3
fl = 3.5
isa = True
memo = "how now Brown Cow"
lots = []
#command to output the variable name, type and value
print ("variable {} is of type:{} and value:{}" .format ("i", type(i), i))
pri... | true |
42fbfbc90c1385626001445374b671011d236107 | G00398347/programming2021 | /week03/lab3.3Strings/lab3.3.3normalise.py | 1,200 | 4.6875 | 5 | #This programme reads in a string, strips any leading or trailing spaces,
#converts the string to lowercase
#and outputs length for the input and output strings
#Author: Ruth McQuillan
#This question was also asked in lab2.3.5
string1 = input (str( " Please enter a string: " )) ... | true |
4275495d3b83a80169a04e060967a6fdca27bbad | DavidFliguer/devops_experts_course | /homework_3/exercise_7_8_9_10.py | 731 | 4.125 | 4 | import os
def print_file_content(path_to_file, ec):
# Read content
with open(path_to_file, "r", encoding=ec) as file:
content = file.read()
# Print the content
print(content)
encoding = "utf-8"
file_name = "words.txt"
# If file exists delete it (So we can run same script multiple times)
if... | true |
8870d8bd5e38c5c28bf81fa4737e0582daa0bab3 | aliu31/IntroToProgramming17 | /Day26/textprocessing78b.py | 830 | 4.1875 | 4 | import string
text = "I hope that in this year to come, you make mistakes. Because if you are making mistakes, then you are making new things, trying new things, learning, living, pushing yourself, changing yourself, changing your world. You're doing things you've never done before, and more importantly, you're doing ... | true |
c1e9826eaa6eb14e1943fd42f94c923533e82752 | Lava4creeper/RockPaperScissors | /User_Choice.py | 760 | 4.1875 | 4 | #Functions
def choice_checker(question):
valid = False
error = 'Error. Please enter Paper, Scissors or Rock'
while not valid:
#Ask user for choice
response = input(question).lower()
if response == 'r' or response == 'rock':
response = 'Rock'
print('You selected {}'.format(response))
el... | true |
18ea1470ebed93614532e2c8e55515dec1e31fef | Kasimir123/python-projects | /games/hangman.py | 2,662 | 4.1875 | 4 | import re
print ("Welcome to Hangman, please enter a word which you would like to use for the game, and then enter how many failed guesses you wish to give to the players.")
# Initializes constants for the program
word = input("What is the word?")
# Checks to see if the player actually put a word or phrase into the i... | true |
45be00401b1fcf6095e7fb3a219ae39abb76f368 | jpsalviano/ATBSWP_exercises | /chapter7/strongPasswordDetection.py | 1,718 | 4.25 | 4 | # Strong Password Detection
'''
A strong password is defined as one that:
-is at least 8 characters long
-contains both uppercase and lowercase characters
-has at least 1 digit
You may need to test the string against multiple regex patterns to validade its strength.
'''
import re
passRegex1 = re.compile(r'[a-z]+[A-... | true |
cd7d01e883759a9234932a317d22838fc47c71e7 | chutki-25/python_ws | /M1_Q/q6.py | 261 | 4.1875 | 4 | """Write a program to accept a number from the user; then display the reverse of the entered number."""
num=int(input("Enter a number: "))
temp=num
rem=0
rev=0
while num!=0:
rem=num%10
rev=rev*10+rem
num=num//10
print(f"Reverse of {temp} is {rev}") | true |
41993386ffc1730a981a99d01f3c6830166c4f2e | dglo/dash | /IntervalTimer.py | 1,275 | 4.375 | 4 | #!/usr/bin/env python
"Timer which triggers each time the specified number of seconds has passed"
from datetime import datetime
class IntervalTimer(object):
"""
Timer which triggers each time the specified number of seconds has passed.
"""
def __init__(self, name, interval, start_triggered=False):
... | true |
10b6d0ecc6acc199ea3f15eff3b229bbb4f9d26e | jstev680/cps110 | /examples/guess/guess_inclass.py | 827 | 4.125 | 4 | import random
def generateSecretNumber():
"""returns a random number from 1 to 10"""
# generate secret number
secretNum = random.randrange(1, 11)
return secretNum
def giveFeedback(guess, secretNum):
"""compares `guess` to `secretNum` and gives appropriate feedback"""
# Give feedback on guess
... | true |
0feeab54988a6274ba965f51c10d241086a1cd99 | boragungoren-portakalteknoloji/METU-BUS232-Spring-2021 | /Week 3 - More on Variables and Operations/Week 3 - Numerical Operations.py | 2,040 | 4.28125 | 4 | # License : Simplified 2-Clause BSD
# Developer(s) : Bora Gรผngรถren
# Let's begin with some basics
a = 2
b = 3
c = a + b
print("a:",a,"b:",b,"c:",c)
# So how did this work?
# operator+ (summation) works and its result is passed as RHS of operator= (assignment)
# operator= assigns the results to variable c.
# Val... | true |
377b578cff00723a50624c78e010a659e6923acc | bjmarsh/insight-coding-practice | /daily_coding_problem/2020-08-22.py | 1,130 | 4.28125 | 4 | """
Run-length encoding is a fast and simple method of encoding strings. The basic idea is to
represent repeated successive characters as a single count and character.
For example, the string "AAAABBBCCDAA" would be encoded as "4A3B2C1D2A".
Implement run-length encoding and decoding. You can assume the string to be ... | true |
5fe85104289ab957ad5e755eee09c056616aa398 | bjmarsh/insight-coding-practice | /daily_coding_problem/2020-09-08.py | 817 | 4.3125 | 4 | """
Given a string, find the longest palindromic contiguous substring.
If there are more than one with the maximum length, return any one.
For example, the longest palindromic substring of "aabcdcb" is "bcdcb".
The longest palindromic substring of "bananas" is "anana".
"""
def find_palindromic_substring(s):
max... | true |
7996c5bc03affa4cca148438229aaa9c592a3ac6 | bjmarsh/insight-coding-practice | /daily_coding_problem/2020-08-03.py | 668 | 4.28125 | 4 | """
Implement a queue using two stacks. Recall that a queue is a FIFO (first-in, first-out)
data structure with the following methods: enqueue, which inserts an element into the queue,
and dequeue, which removes it.
"""
class Queue:
def __init__(self):
self.data = [] # a stack
def enqueue(self, val)... | true |
b05924b936ae42c05b7c36ffb9a0c9cde6cc261c | Marcus-Jon/common_algroithms_python | /prime_checker.py | 601 | 4.125 | 4 | # common prime checker
# import in other programs to make use of this function
# place in same directory as the file calling it
def prime_check():
x = 2
is_prime = False
prime = input('Enter a prime number: ')
while is_prime != True and x < prime:
print '\r', prime % x, x,
i... | true |
cf5767864913ce69d767036259df39dc3a7bc444 | NataFediy/MyPythonProject | /codingbat/make_pi.py | 306 | 4.125 | 4 | #! Task from http://codingbat.com:
# Return an int array length 3 containing the first 3 digits of pi, {3, 1, 4}.
#
# Example:
# make_pi() โ [3, 1, 4]
def make_pi():
pi = {0:3, 1:1, 2:4}
str_pi = []
for i in range(len(pi)):
str_pi.append(pi[i])
return str_pi
print(make_pi())
| true |
f49c940491bbb3361cfe5bb6bc109288086f29ef | NataFediy/MyPythonProject | /hackerrank/functions_filter.py | 2,404 | 4.40625 | 4 | #! You are given an integer N followed by N email addresses.
# Your TASK is to print a list containing only valid email addresses
# in lexicographical order.
#
# Valid email addresses must follow these rules:
# It must have the username@websitename.extension format type.
# The username can only contain letters, digits,... | true |
e3f173cb7d8ae4c1dc91802446a426eb00c02a37 | alex9985/python-and-lists | /find-smallest-item.py | 252 | 4.1875 | 4 | #find smalest number in a list
#
my_list = []
num = int(input("Enter number of elements to put into the list "))
for i in range(1, num + 1):
elem = int(input("Enter elements: "))
my_list.append(elem)
print("Smallest element is ", min(my_list))
| true |
790786a09d8a57b423fb745270f23bd1e8e8c4ad | hmol/learn-python | /learn-python/dragon.py | 1,545 | 4.125 | 4 | import random
import time
# In this game, the player is in a land full of dragons. The dragons all live in caves with their large
# piles of collected treasure. Some dragons are friendly and share their treasure with you. Other
# dragons are hungry and eat anyone who enters their cave. The player is in front of two ca... | true |
7aa018723ff8f18fd78e55eed042888448177111 | shoaib-intro/algorithms | /primetest.py | 511 | 4.15625 | 4 | ''' Prime Test '''
def is_prime(n):
'prime started 2,3,5 ....'
if (n>=2):
'divides number by its whole range numbers'
for i in range(2,n):
'if whole dividisible returns false=0'
if not(n%i):
return False
else:
return False
return True
... | true |
84b93b4f2ca4b9804d502a1557a51595cd49dd1c | tanni-Islam/test | /partial_func.py | 349 | 4.15625 | 4 | '''from functools import partial
def multiply(x,y):
return x * y
dbl = partial(multiply,2)
print dbl(4)
'''
#Following is the exercise, function provided:
from functools import partial
def func(u,v,w,x):
return u*4 + v*3 + w*2 + x
#Enter your code here to create and print with your partial function
dbl = part... | true |
b43f3646d54bffa29d4640e018bf66f27764d8b8 | Sangram19-dev/Python-GUI-Projects | /lived.py | 2,522 | 4.40625 | 4 | # Python Programming Course:GUI Applications sections
# - Sangram Gupta
# Source code for creating the age calculator
from tkinter import *
from datetime import datetime
# Main Window & Configuration
App = Tk()
App.title("Age Calculator")
App['background'] = 'white'
A... | true |
90714eeaf5e4fc0e98499de79496c93d12f78e16 | clacap0/simple | /counting_vowel.py | 351 | 4.25 | 4 | """
Count the vowels in a string
"""
def count_vowels(phrase):
vowels = 'aeiou'
counter = 0
for letter in phrase:
for vowel in vowels:
if vowel==letter:
counter += 1
return f'There are {counter} vowel(s) in your phrase.'
print(count_vowels(input('What phrase would ... | true |
f42055a17f024c6985169a32686cfcec7fd8ad6d | akmishra30/python-projects | /python-basics/file-handling/file-reader.py | 1,099 | 4.5 | 4 | #!/usr/bin/python
# This program is to show basic of python programming
# I'm opening a file using python
#
import os
import sys
import time
from datetime import datetime
# This function is to open a file
def open_file(fileName):
print('Hello First Python program', fileName)
_currDir = os.getcwd() + os.... | true |
03a0f66855fd2aeac2218d0cf662e0dd357e728b | LouStafford/My-Work | /RevisionLabsInputCommand.py | 1,152 | 4.28125 | 4 | # This is for my own practice only and revision by following Andrews lectures re input prompts
# & to practice push/pull/commit on Github (also commands) without having to refer to notes from inital lessons
# Here we will ~ Read in a Name/Age & print it out
# Author Louise Stafford
# input('Please enter your name: ')... | true |
b8db05cb708fcb42f0ef742779075f96ece1193d | Rosebotics/PythonGameDesign2018 | /camp/SamuelR/Day 1 - The Game Loop, Colors, Drawing and Animation/01-HelloWorld.py | 636 | 4.21875 | 4 | # Authors: David Mutchler, Dave Fisher, and many others before them.
print('Hello, World')
print('Samuel Ray can make Python programs!!!!')
print('one', 'two', 'through my shoe')
print(3 + 9)
print('3 + 9', 'versus', 3 + 9)
# DONE: After we talk together about the above, add PRINT statements that print:
# DONE: 1... | true |
655313660a5bc48feacc71232bf51942b0021bea | richardlam96/notepack2 | /notepack/output.py | 431 | 4.21875 | 4 | """
Output functions
Functions to aid in outputting messages to the console in specified format.
Console logger with datetime and spacing.
"""
from datetime import datetime
def print_welcome_message():
"""Print a welcome message to the output."""
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
# Welc... | true |
7ac0798213c0e010dc86ef10f746e7274a49340a | sauuyer/python-practice-projects | /day2.py | 696 | 4.34375 | 4 | # Ask the user for their name and age, assign theses values to two
# variables, and then print them.
name = input("Name, please: ")
age = input("Now age: ")
print("This is your name: ", name)
print("This is your age: ", age)
# Investigate what happens when you try to assign a value
# to a variable that youโve already ... | true |
cd4c089f7bdd43d3bcea05709f0afc962715e005 | mrdbourke/LearnPythonTheHardWay | /ex15.py | 734 | 4.25 | 4 | from sys import argv
#This tells that the first word of argv is the script (ex15.py)
#The second part of argv (argv[1]) is the filename
script, filename = argv
#This sets up the txt variable to open the previously entered filename
txt = open(filename)
#This prints the filename
print "Here's your file %r:" % filename
... | true |
238ee5e9a26c8ae49590894032cf49d02fa2a28d | ucsd-cse-spis-2019/spis19-lab04-Emily-Jennifer | /recursiveDrawings.py | 2,337 | 4.375 | 4 | #Turtle draws a spiral depending on initialLength, angle, and multiplier
#Also draws a tree. A very nice tree
#Emily and Jennifer
import turtle
def spiral(initialLength, angle, multiplier):
'''draws a spiral using a turtle and recursion'''
if initialLength < 1 and multiplier < 1:
return
if initial... | true |
acabf73ae50a5983b6be3dbf46b5bad20a911167 | hayesmit/PDXCodeGuildBootCamp | /lab12-Guess_the_Number.py | 1,099 | 4.1875 | 4 | #lab12-Guess_the_Number.py
import random
#user guesses code lines 5-25
#computer = random.randint(1, 10)
#
#last_guess = 1000
#x = 1
#while x:
# my_guess = int(input("guess number " + str(x) + " >> "))
# if last_guess < 100 and abs(my_guess-computer) > abs(last_guess-computer):
# print("you are further f... | true |
9b87dce51612568e0b1b769f6ed776d77897d4b2 | lentomurri/python | /pw.py | 1,434 | 4.25 | 4 | #! python3
# PASSWORD MANAGER PROJECT
# command line arguments: takes what we insert in the command line and store them as arguments to be used in the program
import sys, pyperclip, json
with open("C:\\Users\\Lento\\personalBatches\\dict.json", "r") as read_file:
data = json.load(read_file)
read_file.close()... | true |
1b6717f643047565037b73b36de95e78eba121d5 | lentomurri/python | /searchRegex.py | 1,554 | 4.5625 | 5 | #! python3
# This program will ask for a folder where the files are stored.
# It will find all .txt files and apply the regex search the user entered.
# It will display the results in the terminal and even paste them automatically in the clipboard for storage purposes.
import re, sys, os, pyperclip
# write folder p... | true |
8a5da6d101f861aa6f522ef789cd0d335f6a5e83 | mira0993/algorithms_and_linux_overview | /Python/Graphs/floyd_warshall_algorithm.py | 2,384 | 4.34375 | 4 | '''
The Floyd Warshall Algorithm is for solving the All Pairs Shortest Path problem.
The problem is to find shortest distances between every pair of vertices in a
given edge weighted directed Graph.
Input:
graph[][] = { {0, 5, INF, 10},
{INF, 0, 3, INF},
{INF, INF,... | true |
4356f13dd09f59459789cee8dd71487597fb4a37 | ArkaprabhaChakraborty/Datastructres-and-Algorithms | /Python/OptimalmergePattern.py | 1,152 | 4.1875 | 4 | class PriorityQueue(object):
def __init__(self):
self.queue = []
def __str__(self):
return ' '.join([str(i) for i in self.queue])
# for checking if the queue is empty
def isEmpty(self):
return len(self.queue) == 0
# for inserting an element in the queue
def inser... | true |
0aa2272fd5db353f938d6604ba80388fa66cb042 | walyncia/ConvertString | /StringConversion.py | 1,234 | 4.15625 | 4 | import time
def StringToInt ():
"""
This program prompts the user for a string and converts
it to a integer if applicable.
"""
string = input('Desired Number:')
print('The current state:\nString:',string,' ->', type(string))
if string == '': #handle no input
raise Exception ('In... | true |
d8a519673a68f8c8e09824826c1fc1d50eaa2c67 | Elijah3502/CSE110 | /Programming Building Blocks/Week 3/08Team.py | 254 | 4.3125 | 4 |
num_of_col_row = int(input("How many columns and rows would you like? : "))
col = 1
row = 1
while(col <= num_of_col_row):
print()
while(row <= num_of_col_row):
print(f"{(row) * col:3}", end=" ")
row += 1
col += 1
row = 1
| true |
dae01c802a2d232d17e9194f2dd7dce4fcc5eb4d | Elijah3502/CSE110 | /Programming Building Blocks/Week 2/04Teach.py | 2,111 | 4.25 | 4 | """
Team Activity
Week 04
Purpose: Determine how fast an object will fall using the formula:
v(t) = sqrt(mg/c) * (1 - exp((-sqrt(mgc)/m)*t))
"""
import math
print("To calculate how fast an object will fall, enter these informations:")
#input mass (in kg)
m = float(input("Mass (in kg): "))
#input acceleration due to gra... | true |
bf9e9ea38ce0b81cedef651ba98c0b4499a8a9b8 | francisamani/RockPaperScissors | /automated_rps.py | 1,631 | 4.1875 | 4 | # Name: Francis Oludhe
# Homework on coding Rock, Paper, Scissors
import random
print "Welcome to a game of Rock, Paper, Scissors\nMake your choice?\n"
""" Placing suitable inputs for both players """
right = ["rock", "paper", "scissors"]
one = raw_input("Your choice? \n")
comp = random.choice(right)
... | true |
19de4e48ed2c15fa5f713b5292f34cccc9de4199 | chengxxi/dailyBOJ | /2021. 2./4714.py | 1,523 | 4.15625 | 4 | # 4714: Lunacy
while True:
weight = float(input())
if weight < 0:
break
print(f'Objects weighing {weight:.2f} on Earth will weigh {(weight * 0.167):.2f} on the moon.')
# Objects weighing 100.00 on Earth will weigh 16.70 on the moon.
"""
# ใ
์ ์ปด์์
# ใ
๋๋๋ฐ์
nums = list(map(float... | true |
56249a0afb87df8d6603ef943e52466e80773279 | Kushagar-Mahajan/Python-Codes | /slicer.py | 840 | 4.28125 | 4 | #slice is to take out particular text from a string using their indexes
word = "Encyclopedia"
a = word[0] #will print out word written at index 0
print(a)
#here [a:b:c] is the format
a = word[0:3:1] #where a is starting index, b is ending index and c is step
print(a)
a = word[0:3:2]
print(a) #it can be matched with pr... | true |
214ccd8211e8e78fd1c3ddc237c4a7b6969edb37 | Kushagar-Mahajan/Python-Codes | /variables.py | 356 | 4.28125 | 4 | #Variables are used to store stuff
#It has name and value and used to store value for later in easy and convenient way.
number = 1
print("Number is",number) #prints the variable
print("Type of the number is",type(number)) #tells the type of variable
number= "hello" # will overwrite the previous variable
print("Overwri... | true |
858e3823bf27b0060d1cccde85b0623f44c2ab78 | forabetterjob/learning-python | /01-data-types-and-structures/numbers.py | 949 | 4.1875 | 4 | import math
import random
# integer will convert up to float
result = 1 + 3.14
print "1 + 3.14 is " + str(result) # 4.14
# order of operations
result = 1 + 2 * 3
print "1 + 2 * 3 is " + str(result) # 7
# order of operations
result = (1 + 2) * 3
print "(1 + 2) * 3 is " + str(result) # 9
# exponential
result = 10 ** ... | true |
a823de068433836d63fc055ed5f465958c92b819 | doper0/firstcode | /ff2.py | 345 | 4.15625 | 4 | num=int(raw_input("write number between 50 to 100 "))
if 50>num : #The program shows all the numbers that divide by three with no remainder
print ('you cant enter that number')
elif num>100 :
print ('you cant enter that number')
else :
i=-1
for i in xrange(50,num+1) :
if ... | true |
fe7af938d21a96ebdc8e36709688891eb24a1622 | ariamgomez/8-14-2015 | /bisection.py | 856 | 4.28125 | 4 | ## This square root calculator will depict the 'Bisection Method'
## to calculate the root and will compare to 'Exhaustive Enumeration' (Brute Force approach)
## Python 2.7.9
# Error
epsilon = 0.01
# Counters
ans = 0.0
count = 0.0
# My algorithmic boundaries
low = 0.0
high = 0.0
x = raw_input ("Please enter a numbe... | true |
ed86be3cda08c69bd5d8e455fc8db610d7d0b777 | liurong92/python-exercise | /exercises/number/one.py | 711 | 4.21875 | 4 | '''
Let's assume you are planning to use your Python skills to build a social networking service.
You decide to host your application on servers running in the cloud. You pick a hosting provider
that charges $0.51 per hour. You will launch your service using one server and want to know
how much it will cost to operate ... | true |
b32016104985b870b9ca81114f17fefacfc47ea1 | liurong92/python-exercise | /exercises/files/one.py | 431 | 4.5 | 4 | '''
Create a program that opens file.txt. Read each line of the file and prepend it with a line
number.
The contents of files.txt:
This is line one.
This is line two.
Finally, we are on the third and last line of the file.
Sample output:
1: This is line one.
2: This is line two.
3: Finally, we are on the third and last... | true |
c10ae30c238bf9e6398c771aadd511a28c0d2228 | paddumelanahalli/agile-programming | /factorial.py | 685 | 4.28125 | 4 | factorial=1 #To store the factorial of a no.
num=int(input("Enter a no. whose factorial is needed: ")) #Accepting a no. from user
if(num<0):
print("Its an negative integer so factorial is not possible")
#Checking for a negative integer entered from user
elif(num==0):
print("Factorial of 0 i... | true |
9da5403525bbd225046b635766faf107353b1d28 | susyhaga/Challanges-Python | /Udemy python/control_structure/Intersection_SET_10.py | 692 | 4.1875 | 4 | #Create a constant with a set of forbidden words.
#Then create a list with some phrases.
#Check if these prohibited words are inside the sentences and point out those words,
#Otherwise the text will be authorized.
#Intersection set
FORBIDDEN_WORDS = {'asshole', 'bastard', 'Bolsonaro', 'hate', 'garlic'}
phrases = [
... | true |
5e81439854d2f4fa8a4996e3cda2b10f37852e4b | TomScavo/python | /student2.py | 313 | 4.21875 | 4 | import csv
from student import Student
students=[]
for i in range(3):
name=input("name: ")
dorm=input("dorm: ")
students.append(Student(name,dorm))
file=open("student.csv","w")
writer=csv.writer(file)
for student in students:
writer.writerow((student.name,student.dorm))
file.close
| true |
76d1f9a00c06094d82ce75ddbc3b9982e5582e76 | TomScavo/python | /calculation.py | 447 | 4.15625 | 4 |
# prompt user int x
x=int(input("please enter int x: "))
# prompt user int y
y=int(input("please enter int y: "))
# a list of calculations
print("{} plus {} is {} ".format(x,y,x+y))
print("{} minus {} is {} ".format(x,y,x-y))
print("{} times {} is {} ".format(x,y,x*y))
print("{} divided by {} is {:.55f} ".format(... | true |
75c6b0414fa68565cf96be70507f89172ca59e42 | ILA-J/Ch.03_Input_Output | /3.0_Jedi_Training.py | 1,544 | 4.5 | 4 | # Sign your name: Lalrinpuia Hmar
# In all the short programs below, do a good job communicating with your end user!
# 1.) Write a program that asks someone for their name and then prints a greeting that uses their name.
name = input("What's your name?")
print("Hey", name, "have a good day")
# 2. Write a program whe... | true |
18a4a0d7f7a98d075b686c46d0d711d955c3fdc8 | t0ri-make-school-coursework/cracking-the-coding-interview | /trees-and-graphs/list_of_depths.py | 1,417 | 4.28125 | 4 | from minimal_tree import min_tree
from Node import LinkedListNode, TreeNode
from LinkedList import LinkedList
# 4.3
# List of Depths
# Given a binary tree, design an algorithm which creates a linked list of all the
# nodes at each depth (eg you have a tree with depth D, you'll have D linked lists)
# loop through dept... | true |
a9bfe1ef788b21c4dc4d2b33a3eb3dec2e08e7fb | atharva07/python-files | /Numbers.py | 883 | 4.28125 | 4 | print(2) # the basic of numbers #
print(3 + 5) # addition in numbers #
print(4 * 5 + 6) # fisrt multiply then add the result with 6 #
print(4 * (5 + 6)) # now add the 5 and 6 then multiply #
my_num = 5
print(str(my_num) + " is my favourite number")
# use of functions in math #
my_num = 44
print(abs(my_num)) # this f... | true |
fd170f76440b0169407e2ab8364021359611eca2 | atharva07/python-files | /If-statement.py | 552 | 4.1875 | 4 | is_male = True
if is_male:
print("You are awesome")
else:
print("You are beautiful")
# making it little complex
is_captain = True
is_worthy = False
if is_captain or is_worthy: # OR condition is applied
print("You are captain america")
else:
print("you are just an ordinary man")
if is_captain and i... | true |
1b045ea6cd2f0aa0f2ee4a93a8cdab4bd4b740b0 | wimarbueno/python3-course | /course/functions/functions/functions.py | 1,012 | 4.28125 | 4 | # consider identation
def nothing():
pass
# the string is called, "docstring"
def my_function(param1, param2):
"""This functions print params"""
print param1
print param2
my_function('Hello', "World")
# to indicate the params
my_function(param2 = "World", param1="Hello")
# To Assign default values
... | true |
5b843d88bf439a3b96bfd7b7e7edbec32de6800c | fipl-hse/2019-2-level-labs | /lab_1/main.py | 2,352 | 4.15625 | 4 | """
Labour work #1
Count frequencies dictionary by the given arbitrary text
"""
def calculate_frequences(text: str) -> dict:
"""
Calculates number of times each word appears in the text
"""
frequencies = {}
new_text = ''
if text is None:
return frequencies
if not isinstance(text, s... | true |
c3399773b1858e4faca2d1f215ff9fbdae6c0134 | kazanture/leetcode_tdd | /leetcode_tdd/zig_zag_conversion.py | 925 | 4.125 | 4 | """
https://leetcode.com/problems/zigzag-conversion/submissions/
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
P A H N
A P L S I I G
Y I R
And then read line by line: "PAHNAPLSIIGYIR... | true |
d1e269aeb3fb308ad35c7aafff644648bb418c86 | Prashant-Bharaj/A-December-of-Algorithms | /December-04/python_nivethitharajendran_4fibanocci.py.py | 352 | 4.25 | 4 | #getting a number from the user
n=int(input("Enter the nth number:"))
#function definition
def fibo(num):
if num ==0:
return 0
elif num==1:
return 1
else:
#calling recursively
return fibo(num-1)+fibo(num-2)
#function call
x=fibo(n)
#displaying the output
pri... | true |
938864c21ad2e268585d88a5c75c0b0d66a7faac | Prashant-Bharaj/A-December-of-Algorithms | /December-12/py_imhphari.py | 891 | 4.125 | 4 | class Node:
def __init__(self, data):
self.data= data
self.next= None
class LinkedList:
def __init__(self):
self.head=None
def reverse(self):
prev=None
current=self.head
while(current is not None):
next=current.next
cu... | true |
5908d9cfdadde2a35e23718151ddb3e6f997f129 | mykhamill/Projects-Solutions | /solutions/fib.py | 773 | 4.53125 | 5 | # Generate the Fibonacci sequence up to term N
from sys import argv
def fib(m, n = None, cache = None):
if n is None:
i = 2
else:
i = n
if cache is None:
cache = (0, 1)
if i > 0:
i -= 2
while i > 0:
cache = (cache[1], sum(cache))
i -= 1
while m >= 0:
n_1 = sum(cache)
p... | true |
e593e56d1a1b4d53dec06686bf65948e73cf83bb | mca-pradeep/python | /arrays.py | 1,050 | 4.34375 | 4 | #Array is the special variable which can hold more than one value at a time
#Python has no built in support for arrays. Python lists are used for this purpose instead
arr = [1,3,5,7, 'test', 'test1']
print(arr)
print('---------------')
print('Finding Length')
print(len(arr))
print('---------------')
print('remove all ... | true |
64886698b575819bc3ed87e95c9e8d80bf6c2b1a | 387358/python-test | /decorator/log_decorator.py | 1,482 | 4.21875 | 4 | #! /usr/bin/python
def logged1(func):
def with_logging(*args, **kwargs):
print 'func: ' + func.__name__ + ' was called'
return func(*args, **kwargs)
return with_logging
@logged1
def f(x):
print 'into f(x)'
return x*x
'''
above decorated func is equal to
def f(x):
print 'into f(x)'... | true |
b5dee728085c62ddb5895a03fab5aecda26b88a0 | deepcharles/datacamp-assignment-pandas | /pandas_questions.py | 2,609 | 4.125 | 4 | """Plotting referendum results in pandas.
In short, we want to make beautiful map to report results of a referendum. In
some way, we would like to depict results with something similar to the maps
that you can find here:
https://github.com/x-datascience-datacamp/datacamp-assignment-pandas/blob/main/example_map.png
To... | true |
8562aa1729a642b17bb7850dcb2c889c0f3f4985 | MelodyChu/Juni-Python-Practice | /insertion_sort copy.py | 1,953 | 4.125 | 4 | """We begin by assuming that a list with one item (position 00) is already
sorted. On each pass, one for each item 1 through nโ1nโ1, the current item
is checked against those in the already sorted sublist. As we look back into '
the already sorted sublist, we shift those items that are greater to the right.
When we rea... | true |
c8c3ac9560cc12840c45f90da5302f52ee9ac550 | MelodyChu/Juni-Python-Practice | /dictionaries2.py | 1,440 | 4.28125 | 4 | # function that takes in a list of numbers and return a list of numbers that occurs most frequently
# [1,1,2,2,3,3,4] return [1,2,3]
def frequency(numbers):
result = {} #use a dictionary
variable = 0
for i in numbers: # think about how to store it as a data type; does it need a variable?
if i not i... | true |
694dd67e903f7c08379d124eece6a51b171f6a32 | jchan221/CIS2348_HW_1 | /CIS2348_HW_1.py | 936 | 4.4375 | 4 | # Joshua Chan
# 1588459
# Birthday Calculator
current_day = int(input('What is the calendar day?'))
current_month = int(input('What is the current month?'))
current_year = int(input('What is the current year?'))
# The three prompts above will collect the current date
birth_day = int(input('What day is your birth... | true |
07376ae9a68370f688e273382c2dc70f2c8e20b2 | AnkitMishra19007/DS-Algo | /Searching/Binary Search/BinarySearch.py | 974 | 4.375 | 4 | #below is a function that iteratively performs binary search
def binarySearch(arr,left,right,find):
#calculating mid pointer
mid= (left+right)//2
#if we found the value then just return the index
if(arr[mid]==find):
return mid
#if the below condition occurs that means the value not found
... | true |
a58fe8e0972658f679b4a0892427d20f4fda79a7 | hannaht37/Truong_story | /evenOrOdd.py | 396 | 4.375 | 4 | number = int(input("Please enter a number: "))
if(number%2 == 0):
print("The number you entered, " + str(number) + ", is even!")
elif(number%2 == 1):
print("The number you entered, " + str(number) + ", is odd.")
decimal = float(input("Please enter an integer please: "))
if(decimal%2 == 0):
print("You have ... | true |
229ed74334d97ad232fcc0804203b216b3e6af44 | Mschlies/00a-Practice-Expressions | /04_area_rectangle.py | 732 | 4.28125 | 4 | # Compute the area of a rectangle, given its width and height.
# The area of a rectangle is wh, where w and h are the lengths
# of its sides. Note that the multiplication operation is not
# shown explicitly in this formula. This is standard practice
# in mathematics, but not in programming. Write a Python statem... | true |
b189ecc9cb26f14ebebaeee5ddd05ac9d9ca4376 | SaltHunter/CP1404_Practicals_2020 | /prac_02/exceptions.py | 885 | 4.34375 | 4 | """
CP1404/CP5632 - Practical
Answer the following questions:
1. When will a ValueError occur?
2. When will a ZeroDivisionError occur?
3. Could you change the code to avoid the possibility of a ZeroDivisionError?
"""
try:
numerator = int(input("Enter the numerator: "))
denominator = int(input("Enter the denomi... | true |
083c4285c91d40ca7641df8343e97192058a686b | SemihDurmus/Python_Helper | /2_Codes/Assignment_7_Comfortable_Words.py | 861 | 4.21875 | 4 | # Assignment_7_Comfortable_Words
"""
Task : Find out if the given word is "comfortable words" in relation to the ten-finger keyboard use.
A comfortable word is a word which you can type always alternating the hand you type with
(assuming you type using a Q-keyboard and use of the ten-fingers standard).
The word will... | true |
0e41edbad5f423baa14a673eea6030cbcab74dcc | SemihDurmus/Python_Helper | /2_Codes/Assignment_2_Covid_19_Possibility.py | 926 | 4.21875 | 4 | # Assignment_2_Covid_19_Possibility
"""
Task : Estimating the risk of death from coronavirus.
Consider the following questions in terms of True/False regarding someone else.
Are you a cigarette addict older than 75 years old? Variable โ age
Do you have a severe chronic disease? Variable โ chronic
Is your immune sy... | true |
d88b67bba27bc94eeb35c9478ebfd9627d36d553 | Aksid83/crckng_cdng_ntrvw | /factorial_with_recursion.py | 257 | 4.4375 | 4 | """
Calculate factorial of the given number using recursion
"""
def factorial_recursion(num):
if num < 0:
return -1
elif num == 0:
return 1
else:
return num * factorial_recursion(num - 1)
print factorial_recursion(6)
| true |
d595b75b703f329d87dd40c068631e43a88f1b56 | khushi3030/Master-PyAlgo | /Topic Wise Questions with Solutions/Array/Longest_Consecutive_Subsequence.py | 1,248 | 4.125 | 4 | """
Given an array of positive integers. Find the length of the longest sub-sequence
such that elements in the subsequence are consecutive integers,
the consecutive numbers can be in any order.
"""
def LargeSubseq(A):
# Create a set to remove the duplicacy
S = set(A)
# initialize result by ... | true |
b61bbac8451374a2539983c0dd842a1c005abe12 | khushi3030/Master-PyAlgo | /Topic Wise Questions with Solutions/Linked List/reverse_of_ll_recursive.py | 1,835 | 4.4375 | 4 | """ The Program is to reverse a linked list using recursion """
class Node: #node creation
def __init__(self, data):
self.data = data
self.next = None
class linkedlist: #intially node head is pointing to null
def __init__... | true |
6d93e6004586628e4ee20329184bad55c282237d | khushi3030/Master-PyAlgo | /String/Word_Score.py | 1,663 | 4.1875 | 4 | '''
Aim: The score of a single word is 2 if the word contains an even number of
vowels. Otherwise, the score of this word is 1. The score for the whole list
of words is the sum of scores of all words in the list. The aim is to output
this score for the entered string.
'''
# function to check for vowels
def... | true |
d4153e59967bd769928cb12087c51cfcc28fab2e | jlrobbins/class-work | /gradecom.py | 875 | 4.25 | 4 | def computegrade (fruit):
if fruit < 0:
return('Oops! That number was too small. I need something between 0.0 and 1.0, please.')
elif fruit > 1:
return('Oops! That number was too big. I need something between 0.0 and 1.0, please.')
elif fruit == 1:
return ('Your letter grade is: A')
... | true |
573f9abbef5b681e73206a4ca0d063667f9cab81 | jlrobbins/class-work | /paydif.py | 266 | 4.15625 | 4 | hours = float(input('Enter Hours: '))
rate = float(input('Enter Rate: '))
overtime = rate * 1.5
if hours > 40.0:
hours2 = hours - 40.0
pay = ((hours - hours2) * rate) + (hours2 * overtime)
print('Pay:',pay)
else:
pay = hours * rate
print('Pay:',pay) | true |
ece7d8f33b05a2112b732c54fac44ec300d49b13 | guti7/DifficultPython | /ex20.py | 907 | 4.1875 | 4 | # Exercise 20: Functions and Files
# Using functions and files together.
from sys import argv
script, input_file = argv # unpacking
# print the contents of the file
def print_all(file):
print file.read()
# put cursor back at the start of the file
def rewind(file):
file.seek(0)
# print a line from the curr... | true |
1341796bb376c35f450da6323a3632161095a64e | csteachian/Brampton-1 | /LinkedLists.py | 798 | 4.125 | 4 |
class node:
def __init__(self):
self.data = None # contains the data
self.pointer = None # contains the reference to the next node
class linked_list:
def __init__(self):
self.cur_node = None # cur meaning current
def add_node(self, data): # add nodes to linked list
new_no... | true |
bae14c0ae2ac15ed2b7e34690c3b7dafc00a4036 | divya-kustagi/python-stanford-cip | /assignments/assignment2/nimm.py | 1,627 | 4.59375 | 5 | """
File: nimm.py
-------------------------
Nimm is an ancient game of strategy that where Players alternate
taking stones until there are zero left.
The game of Nimm goes as follows:
1. The game starts with a pile of 20 stones between the players
2. The two players alternate turns
3. On a given turn, a player may tak... | true |
1ca356d1262de4b4434ff1d53abbd290664b441b | divya-kustagi/python-stanford-cip | /assignments/assignment2/hailstones.py | 1,106 | 4.625 | 5 | """
File: hailstones.py
-------------------
This program reads in a number from the user and then
displays the Hailstone sequence for that number.
The problem can be expressed as follows:
* Pick some positive integer and call it n.
* If n is even, divide it by two.
* If n is odd, multiply it by three and add one.
* Co... | true |
ca259b4ad0aadf96054ab221e50d3e471f6b175d | divya-kustagi/python-stanford-cip | /diagnostic/ramp_climbing_karel_v2.py | 1,151 | 4.25 | 4 | """
ramp_climbing_karel.py
A program that makes Karel-the robot draw a diagonal line across the world, with a slope of 'slope_y/slope_x'
"""
from karel.stanfordkarel import *
def main():
draw_diagonal()
def draw_diagonal():
"""
Function for Karel to draw diagonal line
of slope 1/2 across any world
... | true |
35498e7426acd2a5ab337b2f3399c318829d88c1 | Ranadip-Das/FunWithTurtle | /spiralhelix.py | 289 | 4.4375 | 4 | # Python program to draw Spiral Helix pattern using Turtle programming.
import turtle
window = turtle.Screen()
turtle.speed(2)
turtle.bgcolor('Black')
for i in range(120):
turtle.pencolor('Blue')
turtle.circle(5*i)
turtle.circle(-5*i)
turtle.left(i)
turtle.exitonclick() | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.