Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit de87664

Browse files
committed
day7
1 parent 8dd6901 commit de87664

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

‎Day7/q27.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#Take a list and return first and last value
2+
3+
4+
def returnList(l):
5+
return l[0],l[-1]
6+
7+
a=[1,2,3,4,5,6,7,8,9]
8+
print(returnList(a))

‎Day7/q28.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def fibonacci(a):
2+
"""Recursive function to print fibbonacci series"""
3+
if (a<=1):
4+
return a
5+
else:
6+
return (fibonacci(a-1)+fibonacci(a-2))
7+
8+
9+
10+
11+
n=5
12+
for i in range(n):
13+
14+
print(fibonacci(i))
15+

‎Day7/q29.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Write a program (using functions!) that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order. For example, say I type the string:
2+
3+
# My name is Michele
4+
# Then I would see the string:
5+
6+
# Michele is name My
7+
# shown back to me.
8+
9+
10+
def reverse_word(x):
11+
y = x.split()
12+
result = []
13+
for word in y:
14+
result.insert(0,word)
15+
return " ".join(result)
16+
17+
18+
w = "My name is Michele"
19+
print(reverse_word(w))

‎Day7/q30.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# create a random password generator
3+
import random
4+
5+
s = "abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()?"
6+
passlen = 8
7+
p = "".join(random.sample(s,passlen ))
8+
print(p)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /