C.S Project-1
C.S Project-1
Sr.No TOPICS
1 INTRODUCTION
2 THEORY
3 USES OF PYTHON
4 ADVANTAGES & DISADVANTAGES
5 TOPIC
6 CODE
7 OUTPUT
8 FUTURE SCOPE OF PYTHON
9 CONCLUSION
10 BIBLIOGRAPHY
Introduction
In the gaming cafe scenario, customers are required to register
by creating an account using their name, mobile number, and a
4-digit password as authentication. A nominal fee of 60 rupees
grants access to one of the 30 computers for an hour of play. As
the hour elapses, the system automatically logs the user out from
the computer with intervals of warnings displayed at 5, 3, and 1
minute markers, ensuring a smooth transition. Furthermore, the
system efficiently clears all cache upon logging the user out to
maintain privacy and system performance integrity. This
structured process not only manages user access effectively but
also enhances the overall gaming experience at the cafe. Whether
it is facilitating secure access or optimizing system utilization, the
operational framework ensures seamless user interactions and
system maintenance in the dynamic gaming environment.
Python does not use any symbol for it rather it uses indentation.
Uses of Python
Web Development: Frameworks like Django and Flask make web
development a breeze.
Data Analysis: Libraries like Pandas and NumPy are perfect for
crunching numbers.
Machine Learning: TensorFlow and scikit-learn are popular for
building models.
Automation: Great for writing scripts to automate repetitive
tasks.
Game Development: Libraries like Pygame can help you build your
own games.
Desktop Applications: Tkinter and PyQt can be used for creating
GUI applications.
Network Programming: Useful for building networked applications
like servers and clients.
Scientific Computing: SciPy and other libraries make it a go-to for
research.
Advantages and Disadvantages of Python:
1)Advantage of Python:
*Easy to use/ user friendly *Interpreted Language
*Cross Platform Language *Free and Open Source
*Variety of Usage
2)Disadvantages of Python:
*Not the fastest Language *Lesser Libraries than Java et
*Not Strong on Type binding *Not Easily Convertible/slow
Topic
-ok write a code about a gaming cafe where you have to make
account with name and mobile number and 4 digit pas pay 60
rupees to play for one hour on any of the 30 computers once one
hour ends the system logs the person out of the computer they
logged in by issue warnings displayed at 5 3 1 min left when shut
down log the person out and clear all cache in system
CODE
import time
class GamingCafe:
def __init__(self):
self.user_accounts = {}
def signup(self):
while True:
phone = input("Enter your phone
number (10 digits): ")
if len(phone) != 10 or not
phone.isdigit():
print("Invalid phone number.
Please enter a 10-digit phone number.")
else:
break
if phone in self.user_accounts:
print("This phone number is already
registered. Please login.")
return
while True:
username = input("Enter your
username: ")
if any(account["username"] ==
username for account in
self.user_accounts.values()):
print("This username is already
taken. Please choose a different username.")
else:
break
while True:
password = input("Enter a 4-digit
passcode: ")
if len(password) != 4 or not
password.isdigit():
print("Passcode must be a
4-digit number.")
else:
break
self.user_accounts[phone] = {"username":
username, "password": password}
print(f"Account created successfully for
{username}!")
def login(self):
username = input("Enter your username:
")
password = input("Enter your passcode:
")
user_found = False
for phone, account in
self.user_accounts.items():
if account["username"] == username
and account["password"] == password:
user_found = True
break
if not user_found:
print("Incorrect username or
passcode.")
return
print(f"Welcome {username}! Starting
your session.")
self.start_session()
def start_session(self):
session_time = 60
warnings = [5, 3, 1]
for time_left in range(session_time, 0,
-1):
if time_left in warnings:
print(f"Warning: {time_left}
second(s) left!")
time.sleep(1)
print("Your session has ended. Please
login again if you'd like to play more.")
if __name__ == "__main__":
cafe = GamingCafe()
while True:
print("\n1. Login")
print("2. Signup")
print("3. Exit")
choice = input("Enter your choice: ")
if choice == "1":
cafe.login()
elif choice == "2":
cafe.signup()
elif choice == "3":
print("Thank you for visiting the
gaming cafe!")
break
else:
print("Invalid choice. Please try
again.")
-
-Here we also used a def organizer provided my
our sources which is placed in front of some
variables for easy understanding
OUTPUT
1. Login
2. Signup
3. Exit
Enter your choice: 2
Enter your phone number (10 digits): 1111111111
Enter your username: 3
Enter a 4-digit passcode: 1111
Account created successfully for !
1. Login
2. Signup
3. Exit
Enter your choice: 1
Enter your username: 3
Enter your passcode: 1111
Welcome 3 ! Starting your session.
Warning: 5 second(s) left!
Warning: 3 second(s) left!
Warning: 1 second(s) left!
Your session has ended. Please login again if you'd like to play
more.
1. Login
2. Signup
3. Exit
1. Login
2. Signup
3. Exit
Enter your choice: 1
Enter your username: 3
Enter your passcode: 4444
Incorrect username or passcode.
Future Scope of Python
Here are some areas where Python is expected to continue to
grow and thrive:
https://www.python.org
https://www.programiz.com/online-compiler/9CcsAR9sCphGA
2)BOOKS
https://www.codecademy.com/learn/learn-python-3
https://www.pygame.org/docs/
4) Coding
syntax sheet :
https://indico.global/event/6155/attachments/25456/43759/beginners_python_c
heat_sheet_pcc_all.pdf