text stringlengths 5 121k |
|---|
import pandas as pd
import sqlite3
import os
from shutil import copyfile
from pathlib import Path
def dbWrite(dbPath, dbTable, df, optional_path):
'''
Writes dataframe to summary database file.
Parameters:
dbPath:
Path of summary database
this database is saved to local ... |
print("------------Pattern 16---------")
txt = ""
i = 0
print(txt+"*")
txt = ""
j = 0
for i in range(3):
txt = txt+"*"
for k in range(i):
txt = txt+" "
txt = txt+"*"
print(txt)
j = 0
k = 0
txt = ""
for i in range(4):
txt = txt+"*"
for k in range(3-i):
txt = txt+" "
... |
print("------------Pattern 12---------")
txt = ""
i = 0
for j in range(5):
txt = txt+"*"
print(txt)
i = 0
for i in range(3):
j = 0
txt = ""
for l in range(i):
txt = txt+" "
txt = txt+"*"
for j in range(3-i):
txt = txt+" "
txt = txt+"*"
print(txt)
txt = ""
j = 0
txt = ... |
number_to_guess = 2
user_number = int(input("Adivina el numero: "))
if number_to_guess== user_number:
print("Menuda Potra")
else:
print("Ni de coña, ")
number_to_guess = 2
user_number = int(input("Sigue rascando: "))
if number_to_guess == user_number:
print("Menuda Potra")
else:
print("Ni de... |
time = int(input())
reference = 10.5
if (reference + time) < 0:
print("Monday")
elif (reference + time) > 24:
print("Wednesday")
else:
print("Tuesday")
|
class Ship:
def __init__(self, name, capacity, city):
self.name = name
self.capacity = capacity
self.cargo = 0
self.city = city
def sail(self):
return print("The {} has sailed for {}!".format(self.name, self.city))
black_pearl = Ship("Black Pearl", 800, input())
... |
class Queue(object):
"""An Queue is a list of objects"""
def __init__(self):
"""Create an empty list"""
self.objects = []
def insert(self, e):
"""Inserts e into self"""
self.objects.append(e)
def remove(self):
"""Removes first element from the list"""
... |
print("enter 1st number")
num1= int(input())
print("enter 2nd number")
num2= int(input())
print("so what u weant" ,"+,*,/,-,%")
num3= input()
if num1 == 45 and num2==3 and num3== "*":
print("555")
elif num1 ==56 and num2==9 and num3=="+":
print("77")
elif num1== 56 and num2==6 and num3=="/":
pr... |
import time
s=0
class Character(object):
def __init__(self,name,location):
self.name = name
self.location = location
myself = Character("me" , "A")
map = ["A", "B", "C"]
visited = ["A"]
def gps():
print("|", end=" ")
for x in map:
print(x, end=" | ")
print('\x1b[1;37;40m' + ... |
def to_sort(a, b, c):
s_list = []
if len(a) != 0 and len(b) != 0:
if a[-1] > b[-1]:
s_list.append(a.pop())
to_sort(a, b, c)
else:
s_list.append(b.pop())
to_sort(a, b, c)
elif len(a) == 0:
s_list.extend(b)
else:
s_list.extend... |
a = int(input())
count = 1
fib_num = 0
fib_num_2 = 0
fib_num_1 = 1
while fib_num < a:
count += 1
fib_num = fib_num_1 + fib_num_2
fib_num_2 = fib_num_1
fib_num_1 = fib_num
if fib_num_1 != a:
print(-1)
else:
print(count)
|
k = int(input())
m = (k % 10) + 10
if k < 10:
m = k
if m == 7 or m == 4 or m == 2 or m == 1:
print('NO')
else:
print('YES')
|
def max2 (a, b):
if a > b:
return a
return b
def max3 (a, b, c):
return max2(max2(a, b), c)
print(max3(2, 5, 3))
|
a = int(input())
b = int(input())
c = int(input())
d = 0
if a == b or b == c or a == c:
d = 2
if a == b == c:
d = 3
print(d)
|
n = int(input())
count = 1
fib_num = 0
fib_num_2 = 0
fib_num_1 = 1
while count < n:
count += 1
fib_num = fib_num_1 + fib_num_2
fib_num_2 = fib_num_1
fib_num_1 = fib_num
print(fib_num_1)
|
n = int(input())
n_prev = n
count = 1
count_plus = 1
count_minus = 1
check_plus = 0
while n != 0:
count_plus = 1 + check_plus
count_minus = 1
check_plus = 0
n_prev = n
n = int(input())
while n > n_prev and n != 0:
count_plus += 1
n_prev = n
n = int(input()... |
n = int(input())
count = 1
le = 0
for x in range(1, n + 1):
count *= x
le += count
print(le)
|
n = int(input())
my_flag = [('+___ '), ('|', ' / '), ('|__\ '), ('| ')]
for i in range(0, 4):
if i != 1:
for j in range(0, n):
print(*my_flag[i], sep='', end='')
else:
for j in range(0, n):
print(*my_flag[i][0], j + 1, my_flag[i][1], sep='', end='')
print()
... |
now = int(input())
sum_seq = now
while now != 0:
now = int(input())
sum_seq += now
print(sum_seq)
now = int(input())
while now != 0:
if now > 0:
print(now)
now = int(input())
|
import re
pattern = r"bread(eggs)*bread"
if re.match(pattern ,"breadeggsbread"):
print("macth found")
|
import re
pattern = r"eggs"
if re.findall(pattern,"baconeggseggseggsbacon"):
print("match found")
else:
print("match not found")
print(re.findall(pattern,"baconeggseggseggsbacon"))
|
month = int(input("Enter an month as an integer from 1-12: "))
if (month>12) or (0>=month):
print ("Invalid input. Months are numbered from 1 to 12")
else:
date = int(input("Enter a date from 1-31: "))
if (date>31) or (0>=date):
print ("Invalid input. No month has more than 31 days/less than 0... |
import struct
def convertFloat (number):
num = struct.unpack('I', struct.pack('f', number))[0]
signBit = (num & 0x80000000) >> 31
exponentBits = (num & 0x7f800000) >> 23
mantissaBits = (num & 0x007fffff)
return '(' + str(signBit) + "," + str(... |
from queue import PriorityQueue
class Graph:
def __init__(self, num_of_vertices):
self.v = num_of_vertices
self.edges = [[-1 for i in range(num_of_vertices)] for j in range(num_of_vertices)]
self.visited = []
def add_edge(self, u, v, weight):
self.edges[u][v] = weight
s... |
name=input("이름을 입력하세요.: ")
a=1
f=open('방명록.txt', 'r', encoding='UTF8')
visitor = f.readlines()
def insert_birth(a):
if a==1:
birth = input("생년월일을 입력하세요 (예:801212):")
print(name + "님 환영합니다. 아래 내용을 입력하셨습니다.\n" + name + " " + birth)
with open('방명록.txt', 'a', encoding='UTF8') as f:
... |
my_str="̽"
my_list=[1,2,3]
my_tuple=(1,2,3)
my_dic={"߹̾":"Ҿ ִ","ö":"ٸ ̷"}
my_num=100
print("1] ڿ(String) Ÿ True/False")
if my_str:
print("True")
else:
print("False")
print("\n2] Ʈ(List) Ÿ True/False")
print("my_list: ",end='')
print(my_list)
if my_list:
print("True")
else:
print("False")
print... |
def sum_many(*args):
sum=0
for i in args:
sum=sum+i
return sum
result = sum_many(1,2,3)
print(result)
result=sum_many(1,2,3,4,5,6,7,8,9,10)
print(result) |
VALID_MOVES = ["NORTH",
"SOUTH",
"EAST",
"WEST",
"PLACE",
"MOVE","LEFT","RIGHT","REPORT"]
PLACE=["PLACE"]
ROTATION_MOVE =["LEFT","RIGHT"]
ACTIONS = {'NORTH' : (lambda x, y: (x, y + 1), "WEST", "EAST"),
'EAST' : (lambda x, y: (x + 1, y), "NORTH", "SOUTH"),
... |
import sys
def append_to_file( name, text, encoding='utf-8' ):
version = sys.version_info[0]
if version == 2 and isinstance(text, str):
open( name, 'ab' ).write( text )
elif version == 2 and isinstance(text, unicode):
open( name, 'ab' ).write( text.encode(encoding) )
elif version != 2:
op... |
import pandas as pd
import excel
var1=pd.read_excel("C:\\Users\\DELL\\Desktop\\dataset.xlsx",0)
var2=pd.read_excel("C:\\Users\\DELL\\Desktop\\dataset.xlsx",0)
CE_ME=0
l1=var1.describe()
l2=var2.describe()
req=0
for i in range(l2.Name[0]):
if(var2["Year"][i]>=str("3rd")):
name=var2["Name"][i]
... |
from two import *
"""place everything in iterable sets,
check if already visted,
traversing call recursively, getting as far away from node before visting"""
def dfs_r(nodes, node, visited=None):
if visited == None:
visited = set()
visited.add(node)
for i in nodes.node_dict[node] - visited:... |
students = []
professor = ['Gary Kane']
course = ['CSC 131']
print("%s's %s is the best!" % (professor[0], course[0]))
print("Students: %s" % ', '.join(map(str, students)))
|
import uuid, hashlib
"""
you can get slightly more efficient storage in your database by storing the salt and hashed password as raw bytes
rather than hex strings. To do so, replace hex with bytes and hexdigest with digest.
how do you reverse it to get the password back?
You don't reverse it, you never reverse ... |
import math
import aerosandbox.numpy as np
import hashlib
def eng_string(x: float, format='%.3g', si=True):
'''
Taken from: https://stackoverflow.com/questions/17973278/python-decimal-engineering-notation-for-mili-10e-3-and-micro-10e-6/40691220
Returns float/int value <x> formatted in a simplified engine... |
from itertools import cycle
relevant_primes = [3, 7, 11, 13, 17, 19]
def is_prime(n):
for p in relevant_primes:
if n % p == 0:
return False
return True
p = 21
steps = cycle([2, 4, 2, 2])
soma = sum(relevant_primes) + 7
while p < 2_000_000:
if is_prime(p):
relevant_primes.ap... |
try:
age = int(input('Age: '))
if age > 1:
print(f"You are {age} years old")
elif age == 1 or age == 0:
print(f"You are {age} year old")
else:
print(f"You input {age}, age invalid")
except ValueError:
print('You put an invalid age')
print('Execution continues')
|
age = int(input('Age: '))
numbers = [*range(18, 40, 2)]
if age in numbers:
print(f"Your age is {age}, you're allowed here")
else:
print(f"Your age is {age}, you're not allowed here")
|
def noon_meal(
opening, dessert): return f"Food: {opening.title()} {dessert.title()}"
print(noon_meal('Ice cream', 'Chocolate'))
print(noon_meal)
def the_meal(
food, drink): return f"I have eat {food.title()} and {drink.title()}"
the_meal('Soup', 'Oxygen Water')
|
import re
TraceStudent = '''
Agung is 175cm and Adenta is 171cm
Aljevon is 172cm and Agra is 165cm
'''
tall = re.findall(r'\d{1,3}', TraceStudent)
names = re.findall(r'[A-Z][a-z]*', TraceStudent)
tallDict = {}
x = 0
for eachname in names:
tallDict[eachname] = tall[x]
x += 1
print(tallDict)
|
import world
import sys
import setup
import os
import colour
from tkinter import *
root = Tk()
Console = Text(root)
Console.pack()
def write(*message, end = "\n", sep = " "):
text = ""
for item in message:
text += "{}".format(item)
text += sep
text += end
Console.ins... |
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
data = pd.read_csv(r"C:\Users\Rising IT\PycharmProjects\Pos_Salaries.csv")
x = data.iloc[:,1:2].values
y = data.iloc[:,2].values
lin = LinearRe... |
def are_on_same_side(check_p_1, check_p_2, point_1, point_2):
'''
returns True, if check points are on the same side of a line
formed by connecting point_1 and point_2
arguments:
1. check_p_1 - tuple with x and y coordinates of check point 1
2. check_p_2 - tuple with x and y coor... |
"""
Starter code for exploring the Enron dataset (emails + finances);
loads up the dataset (pickled dict of dicts).
The dataset has the form:
enron_data["LASTNAME FIRSTNAME MIDDLEINITIAL"] = { features_dict }
{features_dict} is a dictionary of features associated with that person.
You should... |
'''
6. Complex types - mixed list
'''
from typing import List, Union
def sum_mixed_list(mxd_lst: List[Union[int, float]]) -> float:
'''
Function that sum mixed list
Arguments:
mxd_lst (List): A List with float and integer values
Return:
float: the result of ... |
'''
1. Async Comprehensions
'''
import asyncio
import random
from typing import List
async_generator = __import__("0-async_generator").async_generator
async def async_comprehension() -> List[float]:
'''
Coroutine that will collect 10 random numbers using an
async comprehensing over async_generator
... |
nome = input('Digite um nome: ')
print('A pessoa possui SILVA? {}'.format('Silva' in nome.upper()))
|
class animal:
def __init__(self, n, t, c):
self.name = n
self.type = t
self.color = c
def eat(self):
print(f'{self.type} {self.name} zjadł obiad')
def move(self):
print(f'{self.type} {self.name} zmienił położenie')
if __name__ == "__main__":
cat1 = animal("Pusia... |
def isValidChar(c):
return c.isalpha()
def isPalindrome(S):
start =0
end = len(S)-1
while start < end:
c1 = S[start].lower()
c2 = S[end].lower()
if isValidChar(c1) and isValidChar(c2):
if c1 != c2:
return False
start += 1
end ... |
while True:
for i in range(5):
print(i)
if i == 3:
exit(3) |
class Queue:
class Cell:
def __init__(self, data, link=None):
self.data = data
self.link = link
def __init__(self):
self.size = 0
self.front = None
self.rear = None
def enqueue(self, x):
if self.size == 0:
self.front = self.rear =... |
"""
Jhonatan da Silva
Last Updated version :
Tue Jan 31 22:35:52 2017
Number of code lines:
19
"""
class Functions():
def __init__(self):
self.numFunctions = 3
def firstFunction(self):
print("I'm in the first function")
def secondFunction(self):
print("I'm in the second function"... |
from typing import List
class Solution:
def moveZeroes(self, nums: List[int]) -> None:
"""
Do not return anything, modify nums in-place instead.
"""
k = 0
cnt = 0
length = len(nums)
for i in range(length):
if nums[i] != 0:
nums[k] =... |
from typing import List
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def levelOrder(self, root: TreeNode) -> List[List[int]]:
if not root:
return []
cur_layer = [root]
res = []
while cu... |
from typing import List
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def constructMaximumBinaryTree(self, nums: List[int]) -> TreeNode:
def dfs(left, right):
if left > right or left <0 or right>len(nums)-1:
... |
class Solution:
def connect(self, root: 'Node') -> 'Node':
if not root:
return root
leftmost = root
while leftmost.left:
head = leftmost
while head:
head.left.next = head.right
... |
from typing import List
class Solution:
def majorityElement(self, nums: List[int]) -> int:
count = 0
candidate = None
for num in nums:
if count == 0:
candidate = num
count += 1 if n... |
from typing import List
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
l1 = len(nums)
l2 = len(set(nums))
return not l1 == l2
input = [1,2,3]
print(Solution().containsDuplicate(input))
|
from typing import List
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
l = 0
r = len(numbers)-1
while(l < r):
sum_val = ... |
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def rotateRight(self, head: ListNode, k: int) -> ListNode:
if not (head and head.next and k) :
return head
fast = head
cnt = 1
while fast.next:
fast = fas... |
from typing import List
class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
if not intervals:
return []
sorted_intervals = sorted(intervals, key=lambda x: x[0])
res = [sorted_intervals[0]]
for i in range(1, len(sorted_intervals)):
l... |
from typing import List
import heapq
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def mergeKLists(self, lists: List[ListNode]) -> ListNode:
def merge2Lists(a, b):
if not a or not b:
return a or b
... |
a=int(input())
b=int(input())
c=int(input())
def greatest(a,b,c):
if a>=b and a>=c:
print(a)
elif b>=a and b>=c:
print(b)
else:
print(c)
greatest(a,b,c)
|
def main():
x = int(input("Enter a number"));
pattern(x);
def pattern(x):
if(x>0):
print("*",end = " ");
x= x-1
pattern(x);
if __name__ == '__main__':
main(); |
A = int(input("Masukan Nilai pertama = "))
B = int(input("Masukan Nilai kedua = "))
C = int(input("Masukan Nilai ketiga = "))
D = A + B + C
E = A - B - C
F = A * B * C
G = A //B // C
print(" %d + %d + %d = "%(A,B,C),D)
print(" %d - %d - %d = "%(A,B,C),E)
print(" %d x %d x %d = "%(A,B,C),F)
print(" %d / %d / %d = "%(A,... |
import random
import json
secret = random.randint(1, 30)
count = 0
low_score = 0
with open("score.json", "r") as score:
score_list = json.loads(score.read())
score_list.sort()
out_list = ""
for x in range(len(score_list)):
out_list = out_list + str(score_list[x])
if x != len(score_list... |
from __future__ import unicode_literals
import random
def random_word(length, chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ' \
'abcdefghijklmnopqrstuvwxyz' \
'0123456789'):
'''Returns a random string of some `length`.'''
return ''.join((random.choice(chars) ... |
def addition(a, b):
return a+b
print (addition(25, 10))
def subtraction (a, b):
return a-b
print (subtraction(25, 10))
def multiplication (a, b):
return a*b
print (multiplication(25, 10))
def division(a, b):
return a/b
print (division (25, 10))
|
dict = {"key1": "value1", "key2": "value2"}
print(dict.keys())
print(dict.values())
print(dict.items())
|
"""
A program to receive packets from a channel.
For a COSC264 assignment.
Author: Ollie Chick
Date modified: 29 August 2017
"""
import sys, socket, os, select
from packet import Packet, MAGIC_NO, PTYPE_DATA, PTYPE_ACK
from socket_generator import create_sending_socket, create_listening_socket
def main... |
class Pokemon:
def __init__(self, name, level, health, max_health, group, knocked_out = False):
self.name = name
self.level = level
self.health = health
self.max_health = max_health
self.group = group
self.knocked_out = knocked_out
def lose_health(self, decrease):
hp_decre... |
from itertools import permutations
import enchant
d = enchant.Dict("en_US")
list_a = list(input("please input a shuffled word:"))
a_length = len(list_a)
list_copy=[]
for permu in list(permutations(range(a_length), a_length)):
for i in permu:
list_copy.append(list_a[i])
maybe_word = "".join... |
vocales = ["a", "e", "i", "o", "u"]
def dividirEnLetras(texto):
return [char for char in texto]
def contarVocales(texto):
lista = dividirEnLetras(texto)
dic = {}
for vocal in vocales:
dic[vocal] = lista.count(vocal)
return dic
texto = input("ingrese el texto")
print(contarVocales(texto... |
import threading
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
class Button(threading.Thread):
"""A Thread that monitors a GPIO button"""
def __init__(self, channel):
threading.Thread.__init__(self)
self._pressed = False
self.channel = channel
GPIO.setup(self.channel,GPIO.IN)
self.daem... |
def cube(num):
return num * num * num
result = cube(4)
print(cube(3))
print(result)
|
def sort(arr):
for i in range(len(arr)):
for j in range(len(arr)-i-1):
if arr[j] > arr[j+1]:
arr[j], arr[j+1] = arr[j+1], arr[j]
return arr
def find_position(arr, key):
left = -1
right = len(arr)
while right > left + 1:
mid = (left + right) /... |
print("************Salary employees Check***************")
annual_salary = int(input("Please enter your annual salary:R "))
contract_type = input("what is your contract type: ")
if contract_type == "full-time":
print("***Full time Employee***")
income_tax = float(input("Please enter your income tax without per... |
'''
This file contains the functions that the joytick uses.
Last Modified: R. Nance 5/15/2018
#####################DO NOT EDIT BELOW INFORMATION##################################
Originating Branch: Joystick
Originally Created: R. Nance 12/2017
'''
import pygame
from helper import *
xAxisNum = 0
yAxisNum = 1
throt... |
print("Hello \n Marin")
print("Bye!")
txt = "hello world"
txt.islower()
print("\n")
print(txt)
txt2 = "UPPER"
y = txt2.isupper()
print("\n", y)
|
""" Dictionary is a special structure, which allows us to store information in what is called
key value pairs (KVP). You can create one KVP and when you want to access specific information
inside of the dictionary, you can just refer to it by its key """
monthConversions = {
"Jan": "January",
"Feb": "F... |
'''
Some observations:
A)B
B)C
C)D
number of indirect orbits for p+1 is
number of direct orbits of planet p + number of indirect orbits of planet p
number of direct orbits can be calculated when input is read.
'''
class Planet:
def __init__(self, name):
self.name = name
self.planets_orbiting = []
self.orbits ... |
"""Get a website from http://ddg.gg/ ."""
import requests
from bs4 import BeautifulSoup
from user_agent import generate_user_agent
def get_website(need_website=None):
"""Return a website."""
website = None
if need_website:
find_website_ddg = "website " + need_website
ua = generate... |
from cs50 import get_string
from cs50 import get_int
from sys import argv
if len(argv) != 2:
print("Usage: ./caesar key k")
exit(1)
elif not argv[1].isdigit():
print("Usage: ./caesar key k")
exit(1)
key = argv[1]
k = int(key)
word = get_string("plaintext: ")
print("ciphertext: ", end="")
for c... |
import datetime
import math
d1=datetime.date(2014, 7, 2)
d2=datetime.date(2014, 7, 11)
delta = d2-d1
print(delta.days)
print("%3.5f" %(math.pi*4/3*6**3))
def diff(n):
if n>17:
return 2*(n-17)
else:
return 17-n
print(diff(22))
print(diff(3))
|
import random
print('enter a number to see what it trully is')
base_number= len(input())
random_number = random.randint(1,15)
new_number= random_number + int(base_number)
print(new_number)
|
print("welcome to Space Dungeon")
print("Press Enter To Continue")
input()
print("Choose your Class")
print("Space Duck")
print("That One Human")
print("Sexy Alien")
classes = input()
print("Delegate Points. You have 100 to spend. ")
print("How Many points to magic")
magic = input()
print("How many points to attack")
a... |
n = int(input())
for i in range(n):
instrucoes = int(input())
movimentos = []
for i in range(instrucoes):
instrucao = input()
if instrucao == 'LEFT':
movimentos.append(-1)
elif instrucao == 'RIGHT':
movimentos.append(1)
else:
idx... |
a = int(input())
b = int(input())
if (a >= 65 or b >= 30 or (a >= 60 and b >= 25)):
print('Apto a aposentadoria')
else:
print('Inapto a aposentadoria')
|
a = float(input())*3
b = float(input())*5
c = float(input())*2
print("Media = {:.2f}".format((a+b+c)/10))
|
v1 = []
v2 = []
soma = 0
val = int(input())
while val >= 0:
v1.append(val)
val = int(input())
val = int(input())
while val >= 0:
v2.append(val)
val = int(input())
if len(v1) > len(v2):
for i in range(len(v1) - len(v2)):
v2.append(0)
else:
for i in range(len(v2) - l... |
'''
>>> f(3,4)
7
>>> f(4,3)
Traceback (most recent call last):
...
TypeError: Incorrect return type
>>> a_to_upper("alpha")
'ALPHA'
>>> a_to_upper("Andrew")
'ANDREW'
>>> a_to_upper("Bart")
Traceback (most recent call last):
...
TypeError: Incorrect return type
>>> a_to_upper("Zed")
Traceback (most recent call last)... |
'''
Your job in this lab is to implement a decorator called "memoize".
This decorator is already applied to the functions f, g, and h below.
You just need to write it.
HINT: The wrapper function only needs to accept non-keyword arguments
(i.e., *args). You don't need to accept keyword arguments in this lab.
(That is m... |
import math
import matplotlib.pyplot as plt
def T(n):
if n<1:
return 1
return T(n-1)+3*n+1
y1 = []
y2 = []
x = range(0,501)
for i in range (0,501):
y1.append(T(i))
y2.append(i**2)
plt.plot(y1,x)
plt.show()
|
import csv
from HashTable import HashMap
with open('WGUInputData.csv') as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
insert_into_hash_table = HashMap()
first_truck = []
second_truck = []
first_truck_second_trip = []
for row in readCSV:
package_ID_row_value =... |
"""
Four suspects; one of them is a thief. In interrogation
John said: I am not the thief.
Paul said: George is the thief.
George said: It must be Ringo.
Ringo said: George is lying.
Among them, three were telling the truth while one was lying.
Could you find out who is the thief?
"""
for thief in ['Jo... |
import math
def mysqrt(n):
a = float(n)
x = n / 2
i = 0
while i < 10:
y = (x + n/x) / 2
x = y
i += 1
return y
def libmath_method(n):
a = float(n)
return math.sqrt(n)
def test_square_root():
for i in range(1,10):
n = s... |
def check_if_word_is_in_wordlist(s):
document = open('words.txt')
d = {}
for line in document:
word = line.strip()
if word in d:
d[word] += 1
else:
d[word] = 1
retur... |
age = 33
text ="my name bodour i am {}"
print(text.format(age))
qunantity = 77
itemno = 123
price= 78
myorder = "i want {} pieces of item {} for {} dollars."
print(myorder.format(qunantity,itemno,price))
qunantity = 77
itemno = 123
price= 78
myorder = "i want {2} pieces of item {0} for {1} dollars."
print(m... |
thistuple = ("mohamed","ahmed","sarh")
if "mohamed" in thistuple:
print("yes,he is here")
thistuple = ("bodour amizing girl,")*4
print(thistuple)
x = (1,3,5,5)
q = (9,6,6)
v = x+q
print(v)
print (len(v))
i = (("hi","wlcome","sir"))
print(i)
thistuple =[2,4,4,"a","e"]
thistuple = tuple(thistuple)
p... |
thisset = {}
print(thisset)
thisset = {"a","h","y"}
print(thisset)
y = {"ahmed","bodour","asma","bodour",1,8,8}
print(y)
for x in y:
print(x)
print("bodour" in y)
y.add("soso")
print(y)
u = {"say","hi"}
u.update(["welcome"])
print(u) |
import itertools as it
from typing import Iterable
def munch(iterable: Iterable, n: int):
"""
Consume an iterable in sequential n-length chunks.
>>> [list(x) for x in munch([1, 2, 3, 4], 2)]
[[1, 2], [3, 4]]
:param iterable: sequence to iterate.
:param n: int - Chunk length.
:return: Ite... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.