Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhayanithi committed Oct 11, 2019
1 parent e7db70b commit 81bebea
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 38 deletions.
2 changes: 2 additions & 0 deletions 01.print.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
print("hello world")
#this will be printed 20 times
print("_" * 20)


16 changes: 16 additions & 0 deletions 20.higherorderfunctions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#map

a=[1,2,3,4]
squared=list(map(lambda x:x*x,a))
print(squared)


from functools import reduce
#reduce
sum = reduce((lambda x, y: x + y), a)
print (sum)

#filter

filtered=list(filter(lambda x:x>2,a))
print(filtered)
17 changes: 17 additions & 0 deletions 21.systemprogramming.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
import platform
#waits for a keystroke without return statement
def getch():
os.system("bash -c \"read -n 1\"")
print('type any key')
getch()

#different code for different platforms

def plat():
if(platform.system()=='Windows'):
print('you are in windows')
elif(platform.system()=='Linux'):
print('you are in linux')

plat()
13 changes: 13 additions & 0 deletions 22.timer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from threading import Timer
def prin():
print('i will print after 4sec')

x=Timer(2.0,prin,args = None, kwargs = None)
Timer.start(x)
#to cancel a timer
#Timer.cancel(x)





1 change: 1 addition & 0 deletions projects/apirequests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
originaldata={}
choicearray=[]
userchoice=[]

def getUsers(url):
print('......loading')
response=requests.get(url=url)
Expand Down
Empty file added projects/encrypter.py
Empty file.
50 changes: 50 additions & 0 deletions projects/quiz.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Q:What number does the Roman numeral "D" stand for?

Answer:500


Q:Which anime heavily features music from the genre "Eurobeat"?

Answer:Initial D


Q:What is the name of the final boss in Turok: Dinosaur Hunter?

Answer:The Campaigner


Q:In "Shakugan no Shana" what was the Shana usually referred as?

Answer:Flame-Haired Burning-Eyed Hunter


Q:Which Italian automobile manufacturer gained majority control of U.S. automobile manufacturer Chrysler in 2011?

Answer:Fiat


Q:In the beta version of the 1986 game "The Legend of Zelda", players have the choice between a sword and what other item?

Answer:Boomerang


Q:What is the correct term for the metal object in between the CPU and the CPU fan within a computer system?

Answer:Heat Sink


Q:What breed of dog is "Scooby Doo"?

Answer:Great Dane


Q:In the game "Red Dead Redemption", what is the name of John Marston's dog?

Answer:Rufus


Q:What is the capital city of Slovenia?

Answer:Ljubljana


38 changes: 0 additions & 38 deletions projects/suduko.py

This file was deleted.

20 changes: 20 additions & 0 deletions projects/writingtofile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import requests

def getquiz():
reqresponse=requests.get('https://opentdb.com/api.php?amount=10&type=multiple')
reqdata=reqresponse.json()['results']
return reqdata

def write():
data=getquiz()
file=open('quiz.txt','w+')

for question in data:
q=question['question']
ans=question['correct_answer']
file.write('Q:{q} \n\n Answer:{ans}\n\n\n'.format(q=q,ans=ans))
file.close()
write()



0 comments on commit 81bebea

Please sign in to comment.