Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Practice9.py and Updated README.md #16

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Binary file added Images/9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

1) A username is accepted and the user is asked to guess a number. The user will get 10 guesses. With every guess the interpreter will tell whether the guess is higher than or lower than the expected value.
------------------------------------------------------
8) A string is accepted from the user as an input and the sorted string is given as the output.
------------------------------------------------------
9) A string, tuple and list is taken as input from the user and the first and last elements of string, tuple and list are given as the output.
------------------------------------------------------
27) A password will be generated with the following Program.
------------------------------------------------------
## Table of Contents:
Expand All @@ -14,6 +18,7 @@
| 27 | [Code](practice27.py) | [Output](Images/27.png)
| 5 | [Code](practice5.py) | [Output](Images/practice5.py.jpg)
| 8 | [Code](practice8.py) | [Output](Images/8.PNG)
| 9 | [Code](practice9.py) | [Output](Images/9.png)
------------------------------------------------------
## Requirements:

Expand Down
10 changes: 10 additions & 0 deletions practice9.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#Exercise 9 - First-last - (Print first and last elements of inputs like strings,tuples,lists)

def fl(seq):
return seq[:1] + seq[-1:]

#For string
print (fl(input("Enter a string :")))

#For tuple and list
print(fl(eval(input("Enter a tuple or list :"))))