blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
58f99618238ebedc92e013c8b47b259e1fb2b197 | ryadav4/Python-codes- | /EX_05/Finding_largestno.py | 263 | 4.28125 | 4 | #find the largest number :
largest = -1
print('Before',largest)
for i in [1,45,67,12,100] :
if i>largest :
largest = i
print(largest , i)
else :
print(i , 'is less than',largest)
print('largest number is :', largest)
| true |
6faa436ab98bac3d2f6c556f8cb239c48ba72b0f | BusgeethPravesh/Python-Files | /Question6.py | 1,549 | 4.15625 | 4 | """Write a Python program that will accept two lists of integer.
Your program should create a third list such that it contain only odd numbers
from the first list and even numbers from the second list."""
print("This Program will allow you to enter two list of 5 integers "
"\nand will then print the odd num... | true |
04890c636e097a33fdad2ff75e9c00be0da9ee06 | Oluyosola/micropilot-entry-challenge | /oluyosola/count_zeros.py | 544 | 4.15625 | 4 | # Write a function CountZeros(A) that takes in an array of integers A, and returns the number of 0's in that array.
# For example, given [1, 0, 5, 6, 0, 2], the function/method should return 2.
def countZeros(array):
# count declared to be zero
count=0
# loop through array length and count the number of ze... | true |
d9504458070080dca24cf9736564196369483c82 | salmonofdoubt/TECH | /PROG/PY/py_wiki/wiki_code/w8e.py | 1,551 | 4.125 | 4 | #!/usr/bin/env python
#8_Lists - test of knowledge
def get_questions(): #Note that these are 3 lists
return [["What color is the daytime sky on a clear day? ", "blue"],
["What is the answer to life, the universe and everything? ", "42"],
["What is a three letter wor... | true |
df7cfa7f74c9ac6d00ee5f0cb1c059aeac69febb | salmonofdoubt/TECH | /PROG/PY/dicts/ex40.py | 800 | 4.1875 | 4 | #!/usr/bin/env python
# encoding: utf-8
"""
Discription: dicts
Created by André Baumann 2012 Copyright (c) Google Inc. 2012. All rights reserved.
"""
import sys
from sys import exit
import os
def find_city(which_state, cities):
if which_state in cities:
return cities[which_state]
else:
return "Not found."
def ... | true |
3de44b016d5b45e0670397bfe59d69aedb9bef33 | salmonofdoubt/TECH | /PROG/PY/classes/dog.py | 1,881 | 4.53125 | 5 | #!/usr/bin/env python
# encoding: utf-8
'''
How to use classes and subclasses
- classes are templates
Created by André Baumann on 2011-12-11.
Copyright (c)2011 Google. All rights reserved.
'''
import sys
import os
class Dog(object): # means Dog inherits from 'object'
def __init__(self, name, breed): #... | true |
2f3e14bec17b97afd523081d2e116dea6ddcd6d8 | salmonofdoubt/TECH | /PROG/PY/py_wiki/wiki_code/w12a.py | 434 | 4.125 | 4 | #!/usr/bin/env python
# 12_Modules
import calendar
year = int(input('Type in the bloody year: '))
calendar.setfirstweekday(calendar.SUNDAY)
calendar.prcal(year) # Prints the calendar for an entire year as returned by calendar().
from time import time, ctime
prev_time = ""
while True:
the_time = ctim... | true |
cb7e18fd05f7cb9b2bedb14e80ceef0c9d5591ea | molusca/Python | /learning_python/speed_radar.py | 955 | 4.15625 | 4 | '''
A radar checks whether vehicles pass on the road within the 80km/h speed limit.
If it is above the limit, the driver must pay a fine of 7 times the difference between the speed that he was
trafficking and the speed limit.
'''
def calculate_speed_difference(vehicle_speed, speed_limit):
return (vehicle_speed - s... | true |
18fa6287bdfec727517bb2073845c911f1494b2f | swatha96/python | /preDefinedDatatypes/tuple.py | 928 | 4.25 | 4 | ## tuple is immutable(cant change)
## its have index starts from 0
## enclosed with parenthesis () - defaultly it will take as tuple
## it can have duplicate value
tup=(56,'swe',89,5,0,-6,'A','b',89)
t=56,5,'swe'
print(type(t)) ## it will return as tuple
print(tup)
print(type(tup)) ## it will return datatyp... | true |
4205c5ca3e4edd81809135f9aa3f79323a0db129 | swatha96/python | /numberDatatype.py | 327 | 4.3125 | 4 | #int
#float
#complex - real and imaginary number: eg:5 : it will return 5+0j
#type() - to get the datatype - predefined function
#input()- predefined function - to get the inputs from the user
a=int(input("enter the number:"))
b=float(input("enter the number:"))
c=complex(input("enter the number:"))
print(a... | true |
317b17c8ac8c70a11950599c1c150feadf2cf034 | swatha96/python | /large_number_list.py | 478 | 4.1875 | 4 | """
number=[23,98,56,26,96,63]
number.sort()
maxi=len(number)
minus=maxi-1
for i in range(maxi):
if(i==minus):
print("the largest number is :",number[i])
"""
number=[]
n=int(input("how many numbers you wants to add:"))
for i in range(n):
num=int(input("enter the number:"))
num... | true |
fc551bda83861e5a5f921668fc08d3e98b76307e | c344081/learning_algorithm | /01/48_Rotate_Image.py | 1,544 | 4.3125 | 4 | '''
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Note:
You have to rotate the image in-place, which means you have to modify the input 2D matrix directly.
DO NOT allocate another 2D matrix and do the rotation.
Example 1:
Given input matrix =
[
[1,2,3],
[4,5... | true |
f1251d29d364dd65a74150dcdd1c7b4e5a906bbc | 009shanshukla/tkinter_tut_prog | /tkinter3.py | 433 | 4.125 | 4 | from tkinter import*
root = Tk()
######making lable #######
one = Label(root, text="one", bg="red", fg="white") #bg stands for background color
one.pack() #static label
two = Label(root, text="two", bg="green", fg="black")
two.pack(fill=X) #label that streches in x-dir
three = Label(root, t... | true |
6f8af959758fad53d3a36b7da1fb1ea9aeca3777 | einian78/The-Complete-Python-3-Course-Beginner-to-Advanced-Udemy-Course | /Section 3 (Programming Basics)/3. Built-in Functions.py | 706 | 4.21875 | 4 | # print(): prints whatever inside
print("hi!") # hi!
# str(): Converts any type into a string
str(5) # 5
str(True) # True
# int(): Converts any type into a integer
int("5")
# float(): Converts any type into a float
float("5.6")
print(float(1)) # 1.0
# bool(): Converts any type into a boolean
bool("True")
# len... | true |
91945d3b7d3fd6939c0d44e0a08fb8a5e6627af5 | msheikomar/pythonsandbox | /Python/B05_T1_Dictionaries.py | 420 | 4.21875 | 4 | # Dict:
# Name is String, Age is Integer and courses is List
student = {'name':'John', 'age':25, 'courses':['Math', 'CompSys']}
# To get value by using key
print(student['name'])
# To get value by using key
print(student['courses'])
# If you look at the keys are currently being string. But actually it can be any i... | true |
8b393455be6e85cc3825b98fe857d7147c7c1806 | msheikomar/pythonsandbox | /Python/B04_T1_Lists_Tuples_Sets.py | 974 | 4.5 | 4 | # Lists and Tuples allows us to work with sequential data
# Sets are unordered collections of values with no duplicate
# List Example
courses = ['History', 'Math', 'Physics', 'ComSys'] # Create List with elements
print(courses) # To print lists
print(len(courses)) # To print length of list
print(courses[0]) # To a... | true |
d5c7efe1c7f1345be4b3fa2bdc3c1cb218c532e7 | riya1794/python-practice | /py/list functions.py | 815 | 4.25 | 4 | list1 = [1,2,3]
list2 = [4,5,6]
print list1+list2 #[1,2,3,4,5,6]
print list1*3 #[1,2,3,1,2,3,1,2,3]
print 3 in list1 #True
print 3 in list2 #False
print "length of the list : "
print len(list1)
list3 = [1,2,3]
print "comparsion of the 2 list : "
print cmp(list1,list2) # -1 as list1 is small... | true |
c6e4fa1d487e0c922865c44fa8042aad78cf6a96 | crazymalady/Python-Exercises | /ielect_Meeting10/w10_e1fBC_ListOperations_Delete Elements.py | 508 | 4.40625 | 4 | def display():
try:
# We can change the values of elements in a List. Lets take an example to understand this.
# list of nos.
list = [1,2,3,4,5,6]
# Deleting 2nd element
#del list[1]
# Deleting elements from 3rd to 4th
#del list[2:4]
#print(list)
... | true |
d63aa167926b91a246b0219af06e6ffec803a944 | SahityaRoy/get-your-PR-accepted | /Sorting/Python/Insertion_Sort.py | 532 | 4.21875 | 4 | # Python program to implement Insertion Sort
def insertion_sort(arr):
# Traverse through 1 to len(arr)
for i in range(1, len(arr)):
key = arr[i]
j = i - 1
while j >= 0 and key < arr[j]:
arr[j + 1] = arr[j]
j = j - 1
arr[j + 1] = key
# Driver function
if... | true |
db188733063d2315b9ba8b8906b24576fc5883cc | SourabhSaraswat-191939/ADA-BT-CSE-501A | /Assignment-2/Insertion_Sort.py | 1,740 | 4.5 | 4 | #Insertion sort is used when number of elements is small. It can also be useful when input array
# is almost sorted, only few elements are misplaced in complete big array.
import time, random, sys
sys.setrecursionlimit(3010)
def insertionSortRecur(arr,n):
if n<=1:
return
insertionSortRecur(arr,n-... | true |
279eaa1adb84a6362e50c16cbcf77fdb96b8c710 | parinita08/Hacktoberfest2020_ | /Python/wordGuess.py | 1,664 | 4.3125 | 4 | import random
# This lib is used to choose a random word from the list of word
# The user can feed his name
name = input("What's your Name? ")
print("Good Luck ! ", name)
words = ['education', 'rainbow', 'computer', 'science', 'programming',
'python', 'mathematics', 'player', 'condition',
'reverse', ... | true |
e9958c2817a63419482cd59df408a156cd3264ae | SwiftBean/Test1 | /Name or Circle Area.py | 656 | 4.40625 | 4 | #Zach Page
#9/13
#get a users name
##def get_name():
### step one: ask user for name
## name = input("what's your name")
###step two: display the name back for user
## print("the name you entered was", name)
###step three: verify the name
## input("is this correct? yes or no")
##
##print("this is our fu... | true |
297443115f368f6f74954748aea31cf38fdb3aad | abhikrish06/PythonPractice | /CCI/CCI_1_09_isSubstring.py | 732 | 4.15625 | 4 | # Given two strings, sl and s2, write code to check if s2 is a rotation of sl using only one
# call to isSubstring (e.g., "waterbottle" is a rotation of"erbottlewat").
def isRotation(str1, str2):
if len(str1) != len(str2):
return False
return isSubstring(str1 + str1, str2)
def isSubstring(st... | true |
ac98777c509e0e92d030fd29f9fc9e33e175d948 | morvanTseng/paper | /TestDataGeneration/data_generation.py | 2,653 | 4.125 | 4 | import numpy as np
class DataGenerator:
"""this class is for two dimensional data generation
I create this class to generate 2-D data for testing
algorithm
Attributes:
data: A 2-d numpy array inflated with 2-D data
points has both minority and majority class
labels: A 1-D nu... | true |
193ba136e0c667b84dcff683355aee443607c556 | olessiap/glowing-journey-udacity | /6_drawingturtles.py | 1,179 | 4.15625 | 4 | # import turtle
#
# def draw_square():
# window = turtle.Screen()
# window.bgcolor("white")
#
# brad = turtle.Turtle()
# brad.shape("turtle")
# brad.color("green")
# brad.speed(2)
# count = 0
# while count <= 3:
# brad.forward(100)
# brad.right(90)
# count = count... | true |
820b6dc8f092a7128bfd1b55d0db7f3b239d3f9a | olessiap/glowing-journey-udacity | /2_daysold.py | 2,007 | 4.375 | 4 | # Given your birthday and the current date, calculate your age
# in days. Compensate for leap days. Assume that the birthday
# and current date are correct dates (and no time travel).
# Simply put, if you were born 1 Jan 2012 and todays date is
# 2 Jan 2012 you are 1 day old.
##breaking down the problem ##
#PSEUDOCOD... | true |
a9ab2e591e65123d33deb79ffc5467f5199a2f39 | TeeGeeDee/adventOfCode2020 | /Day4/day4.py | 2,221 | 4.125 | 4 |
from typing import List
def parse_records(records_raw:List[str]):
"""Turn list of raw string records (each record across multiple list entries)
to list of dict structured output (one list entry per record)
Parameters
----------
records_raw : List[str]
List of records. Records are se... | true |
ad3564d330aba2b298de30d2f8b41ab2ca6891da | TeeGeeDee/adventOfCode2020 | /Day3/day3.py | 1,066 | 4.125 | 4 |
from typing import List
from math import prod
def traverse(down: int,right: int,terrain: List[str]):
""" Counts number of trees passed when traversing terrane with given step sizes
Parameters
----------
down: int
number of steps to take down each iteration
right: int
number o... | true |
9e72a3b63a392aff565a4cd4bbad93a433a4a29f | matthijskrul/ThinkPython | /src/Fourth Chapter/Exercise7.py | 375 | 4.1875 | 4 | # Write a fruitful function sum_to(n) that returns the sum of all integer numbers up to and including n.
# So sum_to(10) would be 1+2+3...+10 which would return the value 55.
def sum_to(n):
s = 0
for i in range(1, n+1):
s += i
return s
def sum_to_constant_complexity(n):
return ((n*n)+n)/2
to... | true |
90e3aa20ceca89debc99ef5b009ad413dd57c625 | matthijskrul/ThinkPython | /src/Seventh Chapter/Exercise15.py | 2,718 | 4.5 | 4 | # You and your friend are in a team to write a two-player game, human against computer, such as Tic-Tac-Toe
# / Noughts and Crosses.
# Your friend will write the logic to play one round of the game,
# while you will write the logic to allow many rounds of play, keep score, decide who plays, first, etc.
# The two of you... | true |
4da17d0305a8c7473bd24624d04fb148a271bc7e | AbelCodes247/Google-Projects | /Calculator.py | 1,240 | 4.375 | 4 | #num1 = input("Enter a number: ")
#num2 = input("Enter another number: ")
#result = int(num1) + int(num2)
#print(result)
#Here, the calculator works the same way but the
#Arithmetic operations need to be changed manually
print("Select an operation to perform:")
print("1. ADD")
print("2. SUBTRACT")
print("3. MULTIPL... | true |
49d4ae16fba58eaa1ebfeb45553eb575b6962b0a | EJohnston1986/100DaysOfPython | /DAY9 - Secret auction/practice/main.py | 1,283 | 4.65625 | 5 | # creating a dictionary
student = {}
# populating the dictionary with key value pairs
student = {"Name": "John",
"Age": 25,
"Courses": ["Maths", "Physics"]
}
# printing data from dictionary
print(student) # prints all key, value pairs
print(student["name"]) # prints only... | true |
ed583b5475071835db5ac8067ccae943e10c432a | LavanyaJayaprakash7232/Python-code---oops | /line_oop.py | 844 | 4.40625 | 4 | '''
To calculate the slope of a line and distance between two coordinates on the line
'''
#defining class line
class Line():
def __init__(self, co1, co2):
self.co1 = co1
self.co2 = co2
#slope
def slope(self):
x1, y1 = self.co1
x2, y2 = self.co2
retu... | true |
4d386f77d415e5e9335763ebb49bc683af7c0fbf | pbeata/DSc-Training | /Python/oop_classes.py | 2,087 | 4.40625 | 4 | import turtle
class Polygon:
def __init__(self, num_sides, name, size=100, color="black", lw=2):
self.num_sides = num_sides
self.name = name
self.size = size # default size is 100
self.color = color
self.lw = lw
self.interior_angles_sum = (self.num_sides - 2) * 180
self.single_angle = self.interior_ang... | true |
0e087f65ba7b781cda0568712dee4975a49a1bd1 | OkelleyDevelopment/Caesar-Cipher | /caesar_cipher.py | 1,258 | 4.21875 | 4 | from string import ascii_letters
def encrypt(message, key):
lexicon = ascii_letters
result = ""
for char in message:
if char not in lexicon:
result += char
else:
new_key = (lexicon.index(char) + key) % len(lexicon)
result += lexicon[new_key]
return... | true |
f194918b18cd8728d7f5ec5854152b8d5bc4cc2e | rarezhang/ucberkeley_cs61a | /lecture/l15_inheritance.py | 987 | 4.46875 | 4 | """
lecture 15
inheritance
"""
# inheritance
# relating classes together
# similar classes differ in their degree of specialization
## class <name>(<base class>)
# example: checking account is a specialized type of account
class Account:
interest = 0.04
def __init__(self, account_holder):
self.balance = 0
... | true |
21964a6a9150ffc373599207402aef774f5917a8 | rarezhang/ucberkeley_cs61a | /lecture/l10_data_abstraction.py | 1,233 | 4.4375 | 4 | """
lecture 10
Data Abstraction
"""
# data
print(type(1))
## <class 'int'> --> represents int exactly
print(type(2.2))
## <class 'float'> --> represents real numbers approximately eg. 0.2222222222222222 == 0.2222222222222227 True
print(type(1+1j))
## <class 'complex'>
print(type(True))
## <class 'bool'>
print(1+1.2)... | true |
efd57652ea766f2eead4561e8d9737163de0ef8a | cIvanrc/problems | /ruby_and_python/2_condition_and_loop/check_pass.py | 905 | 4.1875 | 4 | # Write a Python program to check the validity of a password (input from users).
# Validation :
# At least 1 letter between [a-z] and 1 letter between [A-Z].
# At least 1 number between [0-9].
# At least 1 character from [$#@].
# Minimum length 6 characters.
# Maximum length 16 characters.
# Input
# W3r@100a
# Output
#... | true |
5ca2ba498860e710f44477f96523c0413ed54cbe | cIvanrc/problems | /ruby_and_python/12_sort/merge_sort.py | 1,497 | 4.40625 | 4 | # Write a python program to sort a list of elements using the merge sort algorithm
# Note: According to Wikipedia "Merge sort (also commonly spelled mergesort) is an 0 (n log n)
# comparasion-baed sortgin algorithm. Most implementations produce a stable sort, which means that
# the implementation preserves the input or... | true |
68456f7fa3638ae327fc6874c22b74099b28f351 | cIvanrc/problems | /ruby_and_python/3_list/find_max.py | 648 | 4.28125 | 4 | # Write a Python program to get the smallest number from a list.
# max_num_in_list([1, 2, -8, 0])
# return 2
def find_max():
n = int(input("How many elements you will set?: "))
num_list = get_list(n)
print(get_max_on_list(num_list))
def get_list(n):
numbers = []
for i in range(1, n+1):
... | true |
9600319f92cf09f3eef5ec5e5cdfbe80c2c8e81a | asingleservingfriend/PracticeFiles | /regExpressions.py | 1,796 | 4.125 | 4 | import re
l = "Beautiful is better than ugly"
matches = re.findall("beautiful", l, re.IGNORECASE)
#print(matches)
#MATCH MULTIPLE CHARACTERS
string = "Two too"
m = re.findall("t[wo]o", string, re.IGNORECASE)
#print(m)
#MATCH DIGITS
line = "123?34 hello?"
d = re.findall("\d", line, re.IGNORECAS... | true |
10a1d131ff6eb33d0f12d8aa67b3e9fd93e05153 | christianmconroy/Georgetown-Coursework | /ProgrammingStats/Week 8 - Introduction to Python/myfunctions.py | 2,006 | 4.375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Mar 07 18:33:25 2018
@author: chris
"""
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 07 18:29:10 2018
@author: chris
"""
# refer slide 41
# Program with functions
# Name this program withfunctions.py
# the entire program; there is one small change
# that small change is ... | true |
3608552cce91138d629a3ad9cb2208b2b8f15b2f | Latoslo/day-3-3-exercise | /main.py | 617 | 4.1875 | 4 | # 🚨 Don't change the code below 👇
year = int(input("Which year do you want to check? "))
# 🚨 Don't change the code above 👆
# > `on every year that is evenly divisible by 4
# > **except** every year that is evenly divisible by 100
# > **unless** the year is also evenly divisible by 400`
#Write your code below... | true |
80b2020aeabd82d5390c8ef044523e6d3fb616c4 | shubhamkanade/all_language_programs | /Evenfactorial.py | 363 | 4.28125 | 4 | def Evenfactorial(number):
fact = 1
while(number != 0):
if(number % 2 == 0):
fact = fact * number
number -= 2
else:
number = number-1
return fact
number = int(input("Enter a number"))
result = Evenfactorial(... | true |
e0461c90da83c9b948352e729a91c80b24ed2817 | shubhamkanade/all_language_programs | /checkpalindrome.py | 460 | 4.21875 | 4 | import reverse
def checkpalindrome(number):
result = reverse.Reverse_number(number)
if(result == number):
return True
else:
return False
def main():
number = int(input("Enter a number\n"))
if(checkpalindrome(number)== True):
print(... | true |
a1a1c971e1fa7008b457aa67d8d784b054f0b671 | workwithfattyfingers/testPython | /first_project/exercise3.py | 553 | 4.40625 | 4 | # Take 2 inputs from the user
# 1) user name
# 2) any letter from user which we can count in SyntaxWarning
# OUTPUT
# 1) user's name in length
# 2) count the number of character that user inputed
user_name=input(print("Please enter any name"))
char_count=input(print("Please enter any character which you want to coun... | true |
8ca6c553c9d2fcf7d142b730e5b455a781cf22da | Phone5mm/MDP-NTU | /Y2/SS/MDP/NanoCar (Final Code)/hamiltonianPath.py | 2,928 | 4.125 | 4 | # stores the vertices in the graph
vertices = []
# stores the number of vertices in the graph
vertices_no = 0
graph = []
#Calculate Distance
def distance(p1, p2):
return ((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2) ** 0.5
#Add vertex to graph
def add_vertex(v):
global graph
global vertices_no
global vertices
... | true |
863817a9ec431234468b53402deaccd657227c15 | brianabaker/girlswhocode-SIP2018-facebookHQ | /data/tweet-visualize/data_vis_project_part4.py | 2,586 | 4.25 | 4 | '''
In this program, we will generate a three word clouds from tweet data.
One for positive tweets, one for negative, and one for neutral tweets.
For students who finish this part of the program quickly,
they might try it on the larger JSON file to see how much longer that takes.
They might also want to try subjective... | true |
f0e1863b39362db65c98698eff2b6c7150984475 | G-Radhika/PythonInterviewCodingQuiestions | /q5.py | 1,469 | 4.21875 | 4 | """
Find the element in a singly linked list that's m elements from the end.
For example, if a linked list has 5 elements, the 3rd element from the end is
the 3rd element. The function definition should look like question5(ll, m),
where ll is the first node of a linked list and m is the "mth number from the
end". You s... | true |
6ed2cd27f06b2bb4f00f0b14afd94e42e7173164 | MichaelAuditore/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/0-add_integer.py | 706 | 4.40625 | 4 | #!/usr/bin/python3
def add_integer(a, b=98):
"""
Add_integer functions return the sum of two numbers
Parameters:
a: first argument can be integer or float
b: Second argument initialized with value 98, can be integer or float
Raises:
TypeError: a must be an integer or float
... | true |
a30bd99e44e61f3223dfa2ba64adb89dc19ad0b2 | Debu381/Conditional-Statement-Python-Program | /Conditional Statement Python Program/Guss.py | 213 | 4.125 | 4 | #write a python program to guess a number between 1 to 9
import random
target_num, guess_num=random.randint(1,10), 0
while target_num !=guess_num:
guess_num=int(input('Guess a number'))
print('Well guessed') | true |
b6ace974b9b55f653fe3c45d35a1c76fd3322f7e | lucasloo/leetcodepy | /solutions/36ValidSudoku.py | 1,530 | 4.1875 | 4 | # Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.
# The Sudoku board could be partially filled, where empty cells are filled with the character '.'.
# A partially filled sudoku which is valid.
# Note:
# A valid Sudoku board (partially filled) is not necessarily solvable. Only the filled ce... | true |
98c092348ce916622847924b48967ef75ce99d9e | SaralKumarKaviti/Problem-Solving-in-Python | /Day-3/unit_convert.py | 1,738 | 4.25 | 4 | print("Select your respective units...")
print("1.centimetre")
print("2.metre")
print("3.millimetre")
print("4.kilometre")
choice= input("Enter choice(1/2/3/4)"
unit1=input("Enter units from converting:")
unit2=input("Enter units to coverting:")
number=float(input("Enter value:"))
if choice == '1':
if unit1 == 'c... | true |
2d082dda2f464f6da9d9a043a90ca7599a4b92bd | anikanastarin/Learning-python | /Homework session 4.py | 1,516 | 4.375 | 4 | '''#1. Write a function to print out numbers in a range.Input = my_range(2, 6)Output = 2, 3, 4, 5, 6
def my_range(a,b):
for c in range(a,b+1):
print (c)
my_range(2,6)
#2. Now make a default parameter for “difference” in the previous function and set it to 1. When the difference value is passed, the d... | true |
6ae607ac50b7fe370e6257fd083fc369a5ac7a14 | Dcnqukin/A_Byte_of_Python | /while.py | 383 | 4.15625 | 4 | number=23
running=True
while running:
guess=int(input("Enter an integer:"))
if guess==number:
print("Congratulation, you guessd it.")
running=False #this causes the while loop to stop
elif guess<number:
print("No, it is a little higher")
else:
print("No, it is a little l... | true |
b5cf0e1ec9d8ad7f5f60e89891ee08ef6e3bc6f9 | marieramsay/IT-1113 | /Miles_To_Kilometers_Converter.py | 2,618 | 4.5625 | 5 | # Marie Ramsay
# Prompts the user to select whether they want to convert Miles-to-Kilometers or Kilometers-to-Miles, then asks the user
# to enter the distance they wish to convert. Program converts value to the desired unit.
# Program will loop 15x.
import sys
# converts input from miles to kilometers
def... | true |
e07ac75e79a257241d4a467320e113247db4df8b | calebwest/OpticsPrograms | /Computer_Problem_2.py | 2,211 | 4.40625 | 4 | # AUTHOR: Caleb Hoffman
# CLASS: Optics and Photonics
# ASSIGNMENT: Computer Problem 2
# REMARKS: Enter a value for the incident angle on a thin lens of 2.0cm, and
# the focal length. A plot will open in a seperate window, which will display
# light striking a thin lens, and the resulting output rays. This program use... | true |
756a096e6c156f1f5be7347067903a3135008535 | 22fansje/python | /modb_challenge.py | 1,034 | 4.21875 | 4 | def main():
#Get's info on the user's name than greets them
first_name = input("What is your first name?: ")
last_name = input("What is your last name?: ")
print("Hello, %s %s!"%(first_name,last_name))
print()
#Lists the foods avaliable
food = ['Cookie', 'Steak', 'Ice cream', 'Apples']
... | true |
19eb4be275bd3a0477a42ec205be2596a5c459db | harry990/coding-exercises | /trees/tree-string-expression-balanced-parenthesis.py | 1,107 | 4.15625 | 4 |
from collections import defaultdict
"""
Given a tree string expression in balanced parenthesis format:
(A(B(C)(D))(E)(F))
A
/ | \
B E F
/ \
C D
The function is to return the root of the tree you build, and if you can please
print the tree with indent... | true |
1c90e6c43a74e92dc37477692317ae008d9ec415 | btrif/Python_dev_repo | /Courses, Trainings, Books & Exams/Lynda - Python 3 Essential Training/11 Functions/generator_01_sequence_tuple_with_yield.py | 1,411 | 4.59375 | 5 | #!/usr/bin/python3
# A generator function is function that return an iterator object.
# So this is how you create functionality that can be used in a for loop or any
# place an iterator is allowable in Python
def main():
print("This is the functions.py file.")
for i in inclusive_range(2, 125, 4): ... | true |
89c5785788e5171d33ef0e2cc34622b8781004af | btrif/Python_dev_repo | /BASE SCRIPTS/Logic/basic_primes_generator.py | 980 | 4.125 | 4 | #!/usr/bin/python3
# comments.py by Bill Weinman [http://bw.org/]
# This is an exercise file from Python 3 Essential Training on lynda.com
# Copyright 2010 The BearHeart Group, LLC
def main():
for n in primes(): #generate a list of prime numbers
if n > 100: break
print(n, end=' ')
def isprime... | true |
6c9a13d67dea2ce2672fc0dad170207bdfce715f | btrif/Python_dev_repo | /BASE SCRIPTS/module bisect pickle.py | 2,002 | 4.46875 | 4 | import bisect, pickle
print(dir(bisect))
########################
# The bisect() function can be useful for numeric table lookups.
# This example uses bisect() to look up a letter grade for an exam score (say)
# based on a set of ordered numeric breakpoints: 90 and up is an ‘A’, 80 to 89 is a ‘B’, and so on:
def gr... | true |
2dbae09466384658d5906425b8aeb6095495ac1a | btrif/Python_dev_repo | /BASE SCRIPTS/searching.py | 1,535 | 4.75 | 5 | # ### Python: Searching for a string within a list – List comprehension
# The simple way to search for a string in a list is just to use ‘if string in list’. eg:
list = ['a cat','a dog','a yacht']
string='a cat'
if string in list:
print ('found a cat!')
# But what if you need to search for just ‘cat’ or some oth... | true |
a42127989a11eabe0a112f58ec1e6ca0a4be9bcd | btrif/Python_dev_repo | /BASE SCRIPTS/OOP/static_variables.py | 2,037 | 4.5 | 4 | # Created by Bogdan Trif on 17-07-2018 , 3:34 PM.
# I noticed that in Python, people initialize their class attributes in two different ways.
# The first way is like this:
class MyClass:
__element1 = 123 # static element, it means, they belong to the class
__element2 = "this is Africa"... | true |
0b4eae1855d2a62e6152419526c4f49d08c1085d | btrif/Python_dev_repo | /Courses, Trainings, Books & Exams/EDX - MIT - Introduction to Comp Science I/bank_credit_account.py | 844 | 4.65625 | 5 | '''
It simulates a credit bank account. Suppose you have a credit. You pay each month a monthlyPaymentRate
and each month an annualInterestRate is calculated for the remaining money resulting in a remaining balance
each month.
'''
balance = 5000 # Balance
monthlyPaymentRate = 2/100 # Monthly payment rate... | true |
53958a00677713402c549640639d87442b94d9d2 | btrif/Python_dev_repo | /plots exercises/line_animation.py | 1,087 | 4.40625 | 4 | __author__ = 'trifb' #2014-12-19
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
# First set up the figure, the axis, and the plot element we want to animate
fig = plt.figure() #defining the figure
ax = plt.axes(xlim=(0, 10), ylim=(-8, 8)) # x-axes limit... | true |
24e78bf77cad25af185baf4fd71d6953e86620c7 | fransikaz/PIE_ASSIGNMENTS | /homework8.py | 2,880 | 4.5 | 4 | import os
# import os.path
from os import path
'''
HOMEWORK #8:
Create a note-taking program. When a user starts it up, it should prompt them for a filename.
If they enter a file name that doesn't exist, it should prompt them to enter the text they want to write to the file.
After they enter the text, it should ... | true |
d20f44d4150c21a96b178b3aac74b45e25c5fab1 | AndersenDanmark/udacity | /test.py | 2,516 | 4.5 | 4 | def nextDay(year, month, day):
"""
Returns the year, month, day of the next day.
Simple version: assume every month has 30 days.
"""
# YOUR CODE HERE
if day+1>30:
day=1
if month+1>12:
month=1
year=year+1
else:
month=month+... | true |
14389832de4c1e1317bd88f01b2686a83eb36017 | KeelyC0d3s/L3arning | /squareroot.py | 1,126 | 4.375 | 4 | # Keely's homework again.
# Please enter a positive number: 14.5
# The square root of 14.5 is approx. 3.8.
# Now, time to figure out how to get the square root of 14.5
#import math
#math.sqrt(14.5)
#print( "math.sqrt(14.5)", math.sqrt(14.5))
#Trying Newton Method.
#Found code here: https://tinyurl.com/v9ob6nm
# Fu... | true |
8aaf6cd5b8634dfdcd5a6e6923dbea448100b983 | carlanlinux/PythonBasics | /9/9.6_ClonningLists.py | 418 | 4.25 | 4 | '''
If we want to modify a list and also keep a copy of the original, we need to be able to make a copy of the
list itself, not just the reference. This process is sometimes called cloning, to avoid the ambiguity of
the word copy.
The easiest way to clone a list is to use the slice operator.
'''
a = [81,82,83]
... | true |
ce9a774c06363afc1f03da671d9276d5ae11b758 | MalteMagnussen/PythonProjects | /week2/objectOriented/Book.py | 974 | 4.21875 | 4 | from PythonProjects.week2.objectOriented import Chapter
class Book():
"""A simple book model consisting of chapters, which in
turn consist of paragraphs."""
def __init__(self, title, author, chapters=[]):
"""Initialize title, the author, and the chapters."""
self.title = title
se... | true |
fdde0b3b81e7987289e4134ff4a523f5b6544587 | saurabh-pandey/AlgoAndDS | /leetcode/binary_search/sqrt.py | 1,075 | 4.25 | 4 | #URL: https://leetcode.com/explore/learn/card/binary-search/125/template-i/950/
#Description
"""
Given a non-negative integer x, compute and return the square root of x.
Since the return type is an integer, the decimal digits are truncated, and only the integer part of
the result is returned.
Note: You are not allowed... | true |
7ff689c4e4d6f95ad27413579ee15919eee29e15 | saurabh-pandey/AlgoAndDS | /leetcode/bst/sorted_arr_to_bst.py | 1,129 | 4.25 | 4 | #URL: https://leetcode.com/explore/learn/card/introduction-to-data-structure-binary-search-tree/143/appendix-height-balanced-bst/1015/
#Description
"""
Given an integer array nums where the elements are sorted in ascending order, convert it to a
height-balanced binary search tree.
A height-balanced binary tree is a bi... | true |
c5361ad406f3da27f7960150fb6afbd44bbae03e | saurabh-pandey/AlgoAndDS | /leetcode/queue_stack/stack/target_sum.py | 2,326 | 4.1875 | 4 | #URL: https://leetcode.com/explore/learn/card/queue-stack/232/practical-application-stack/1389/
#Description
"""
You are given an integer array nums and an integer target.
You want to build an expression out of nums by adding one of the symbols '+' and '-' before each
integer in nums and then concatenate all the integ... | true |
72d27e13ba30f9d65f0e0b4e105389f80d2fcd03 | loolu/python | /CharacterString.py | 830 | 4.15625 | 4 | #使用字符串
#字符串不可改变,不可给元素赋值,也不能切片赋值
website = 'http://www.python.org'
website[-3] = 'com'
#
format = "Hello, %s. %s enough for ya?"
values = ('world', 'hot')
print(format % values)
from string import Template
tmpl = Template("Hello, $who! $what enough for ya?")
print(tmpl.substitute(who='Mars', what='Dusty'))
print("{}... | true |
61bb1f7871db613627d1edd50128a7c5c88d0b4b | Stemist/BudCalc | /BudgetCalculatorCLI.py | 1,577 | 4.28125 | 4 | #!/usr/bin/env python3
people = []
class Person:
def __init__(self, name, income):
self._name = name
self._income = income
self.products = {}
def add_product():
try:
product = str(input("Enter product name: "))
cost = float(input("Enter product cost ($): "))
products[product] = price
except:... | true |
4b67eb4c4a802e7980142f6a8ee644f1bda6d867 | huyilong/python-learning | /fibo_module.py | 720 | 4.25 | 4 | #fibonacci numbers module
#could directly input python3 on mac terminal to invoke version 3
def fib(n):
a, b = 0, 1
while b < n:
print( b),
#there is a trailing comma "," after the print to indicate not print output a new line
a, b = b, a+b
print #this is print out a empty line
#if you use print() then it... | true |
6d70e720d4424c0b948c20561fdec80afae21701 | gregxrenner/Data-Analysis | /Coding Challenges/newNumeralSystem.py | 1,752 | 4.46875 | 4 | # Your Informatics teacher at school likes coming up with new ways to help
# you understand the material. When you started studying numeral systems,
# he introduced his own numeral system, which he's convinced will help clarify
# things. His numeral system has base 26, and its digits are represented by
# English capita... | true |
23de8de49110b4db71833b1b54041bd41fae2b43 | jmobriencs/Intro-to-Python | /O'Brien_Lab1/Lab1-6.py | 436 | 4.3125 | 4 | #John-Michael O'Brien
#w1890922
#CISP 300
#1/31/20
#This program calculates miles walked and calories lost for a specific day of the week.
dayWalked = input('Enter the day of the week you walked: ')
stepsTaken = int(input('Enter the number of steps taken that day: '))
milesWalked = (stepsTaken/2000)
caloriesL... | true |
2c2cd04d5893ebb5e05d463729a999f80e55266c | jmobriencs/Intro-to-Python | /O'Brien_Lab1/Lab1-4.py | 580 | 4.1875 | 4 | #John-Michael O'Brien
#w1890922
#CISP 300
#1/31/20
#This program calculates how many credits are left until graduation.
studentName = input('Enter student name. ')
degreeName = input('Enter degree program name. ')
creditsDegree = int(input('Enter the number of credits needed for the degree. '))
creditsTaken =... | true |
3434b25d66c2edefe39cc30ecc20b8a886d45639 | kundaMwiza/dsAlgorithms | /source/palindrome.py | 869 | 4.1875 | 4 | def for_palindrome(string):
"""
input: string
output: True if palindrome, False o/w
implemented with a for loop
"""
for i, ch in enumerate(string):
if ch != string[-i-1]:
return False
return True
def rec_palindrome(string):
"""
input: string
output: True if p... | true |
5c30a3093ad4fca9ef738d7901f659eff9698700 | ase1590/python-spaghetti | /divide.py | 254 | 4.1875 | 4 | import time
print('divide two numbers')
# get the user to enter in some integers
x=int(input('enter first number: '))
y=int(input('enter number to divide by: '))
print('the answer is: ',int(x/y)),
time.sleep(3) #delay of a few seconds before closing
| true |
5cfd561fc32a028223208019bde4c60736e786a5 | ndvssankar/ClassOf2021 | /Operating Systems/WebServer/test_pipe.py | 1,316 | 4.3125 | 4 | # Python program to explain os.pipe() method
# importing os module
import os
import sys
# Create a pipe
pr, cw = os.pipe()
cr, pw = os.pipe()
stdin = sys.stdin.fileno() # usually 0
stdout = sys.stdout.fileno() # usually 1
# The returned file descriptor r and w
# can be used for reading and
# writing re... | true |
564be3d797b4993009205db721f2fb1c1513c820 | koussay-dellai/holbertonschool-higher_level_programming | /0x06-python-classes/3-square.py | 415 | 4.125 | 4 | #!/usr/bin/python3
class Square:
'''defining a sqaure'''
def __init__(self, size=0):
'''initialize an instance'''
self.__size = size
if type(size) is not int:
raise TypeError("size must be an integer")
elif (size < 0):
raise ValueError("size must be >= 0")... | true |
99f7f46430267a6ee17e0288b14511e3cbef57fc | koussay-dellai/holbertonschool-higher_level_programming | /0x0B-python-input_output/2-read_lines.py | 350 | 4.1875 | 4 | #!/usr/bin/python3
"""
module to print lines of a file
"""
def read_lines(filename="", nb_lines=0):
"""
function to print n lines of a file
"""
number = 0
with open(filename, encoding="UTF8") as f:
for i in f:
number += 1
print(i, end="")
if nb_lines == ... | true |
fce2be88790287f25b5d6cf863720bbf172f772c | katealex97/python-programming | /UNIT2/homework/hw-1.py/hw-3.py | 394 | 4.21875 | 4 | odd_strings = ['abba', '111', 'canal', 'level', 'abc', 'racecar',
'123451' , '0.0', 'papa', '-pq-']
count = 0
for string in odd_strings:
#find strings greater than 3 and have same
#first and last character
first = string[0]
last = string[len(string) - 1] #python allows neg. indexes last = string[-1]
... | true |
cde77dfa50a8a370bf1c589bc8d262488dc81e29 | thecipherrr/Assignments | /New Project/Number1.py | 488 | 4.25 | 4 | # Main Function
def convert_to_days():
hours = float(input("Enter number of hours:"))
minutes = float(input("Enter number of minutes:"))
seconds = float(input("Enter number of seconds:"))
print("The number of days is:", get_days(hours, minutes, seconds))
# Helper Function
def get_days(hours, mi... | true |
1414aef6db7b039b2f065d68376d903c79e7ba3f | seangrogan-archive/datastructures_class | /TP2/BoxClass.py | 1,691 | 4.28125 | 4 | class BoxClass:
"""class for easy box handling"""
def __init__(self, name, width, height):
"""init method"""
self._name = name
self._width = width
self._height = height
self._rotate = False
def __lt__(self, other):
"""for sorting"""
return ... | true |
a761dad436a049421f7e6fa8b0bf3c478df6b8aa | pavanjavvadi/leet_code_examples | /anagram.py | 1,681 | 4.3125 | 4 | """
Given an array of strings strs, group the anagrams together. You can return the answer in any order.
An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
Example 1:
Input: strs = ["eat","tea","tan","ate","nat","b... | true |
66d180a6bfbc522549ac68db6d3b04d940455159 | Rinatik79/PythonAlgoritms | /Lesson 1/lesson1-7.py | 609 | 4.21875 | 4 | sides = input("Enter length of every side of triangle, separated by ';' : ")
sides = sides.split(";")
sides[0] = float(sides[0])
current = sides[0]
sides[1] = float(sides[1])
if sides[1] > sides[0]:
sides[0] = sides[1]
sides[1] = current
current = sides[0]
sides[2] = float(sides[2])
if sides[2] > sides[0]:... | true |
4977a7a7e99f1f571ade665a927e97a059287ae4 | AtharvBagade/Python | /Question7.py | 304 | 4.28125 | 4 | string=input("Enter the string")
def Most_Duplicate_Character(str1):
count = 0
for i in str1:
count2 = str1.count(i)
if(count2 > count):
count = count2
num = i
print(num,"Count:",count)
Most_Duplicate_Character(string)
| true |
cf05f6410b6878b34067ecb3b89b38bef59f59b5 | Design-Computing/me | /set3/exercise2.py | 1,216 | 4.5 | 4 | """Set 3, Exercise 2.
An example of how a guessing game might be written.
Play it through a few times, but also stress test it. What if your lower bound
is 🍟, or your guess is "pencil", or "seven"
This will give you some intuition about how to make exercise 3 more robust.
"""
import random
def exampleGuessingGam... | true |
03f695385e9a5b6dd258029d10e11b9bb6ffa371 | ahmedzaabal/Beginner-Python | /Dictionary.py | 606 | 4.28125 | 4 | # Dictionary = a changeable, unorderd collecion of unique key:value pairs
# fast because they use hashing, allow us to access a value quickly
capitals = {'USA': 'Washington DC',
'India': 'New Delhi',
'China': 'Beijing',
'Russia': 'Moscow'}
capitals.update({'Germany': 'B... | true |
c5d91ba52a45b61a4442201fc22f7a20aa575c63 | malay1803/Python-For-Everybody-freecododecamp- | /files/findLine.py | 1,218 | 4.375 | 4 | # Exercise 2: Write a program to prompt for a file name, and then read through the file and look for lines of the form:
#X-DSPAM-Confidence: 0.8475
# When you encounter a line that starts with "X-DSPAM-Confidence:" pull apart the line to extract the floating-point number on the line. Count these lines and then comput... | true |
53c6e9853a06f737c8c43009c4ed2c154e11e107 | vmysechko/QAlight | /metiz/files_and_exceptions/file_writer.py | 720 | 4.21875 | 4 | filename = "programming.txt"
with open(filename, 'w') as file_object:
file_object.write("I love programming.\n")
# 'w' argument tells Python that we want to open a file in write mode.
# In the write mode Python will erase the content of the file.
# 'r' - read mode
# 'a' - append mode
# 'r+' - read/write mode
wi... | true |
7f26b982dd0543a277216ca671b882f9d1c1f3a1 | calder3/BCA_Project- | /hang_man2.py | 1,186 | 4.15625 | 4 | '''
This will play the game hangman. Need to have the random word modual installed.
'''
from random_word import RandomWords
r = RandomWords()
word = r.get_random_word(hasDictionaryDef = 'true')
word = word.lower()
space = list(word)
dash = []
dash.extend(word)
#print(word)
for i in range(len(dash))... | true |
028e73aab6a25145064048c00eb5d9f35d8037c1 | PriyaRcodes/Threading-Arduino-Tasks | /multi-threading-locks.py | 995 | 4.375 | 4 | '''
Multi Threading using Locks
This involves 3 threads excluding the main thread.
'''
import threading
import time
lock = threading.Lock()
def Fact(n):
lock.acquire()
print('Thread 1 started ')
f = 1
for i in range(n,0,-1):
f = f*i
print('Factorial of',n,'=',f)
lock.release()
de... | true |
6fe40fec45477da49060eb84fc699ce68e6075c7 | ant0nm/reinforcement_exercise_d23 | /exercise.py | 818 | 4.375 | 4 | def select_cards(possible_cards, hand):
for current_card in possible_cards:
print("Do you want to pick up {}?".format(current_card))
answer = input()
if answer.lower() == 'y':
if len(hand) >= 3:
print("Sorry, you can only pick up 3 cards.")
else:
... | true |
28789e85fe5a651088aed96262a4ba1c9bb97bed | ntuong196/AI-for-Puzzle-Solving | /Week7-Formula-puzzle/formula_puzzle.py | 1,095 | 4.34375 | 4 | #
# Instructions:
#
# Complete the fill_in(formula) function
#
# Hints:
# itertools.permutations
# and str.maketrans are handy functions
# Using the 're' module leads to more concise code.
import re
import itertools
def solve(formula):
"""Given a formula like 'ODD + ODD == EVEN', fill in digits to... | true |
1c44fed92ef5e6e7c986f79a0f2473de31325184 | hansweni/UBC_PHYS_Python-crash-course | /2. Arduino for Data Collection/RGB_LED.py | 1,311 | 4.28125 | 4 | '''
Program to demonstrate how to flash the three colors of a RGB diode
sequentially using the Arduino-Python serial library.
'''
# import libraries
from Arduino import Arduino
import time
board = Arduino() # find and connect microcontroller
print('Connected') # confirms the microcontroller has been found
# give pi... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.