PYTHON
DAY 1
WHEN OPENING THE PROGRAMME ITT SHOULD SHOW “HI RAKSHITA”
ANS : Open a text editor (like Notepad, VS Code, or IDLE).
name = rakshita
print(“hi Rakshita”)
paste the above code
Save the file with a .py extension, like [Link].
Run it using Python by opening a terminal or command prompt and
typing: python [Link]
FOR OPENING A TERMINAL AND COMMAND PROMPT
Press Windows + R, type cmd, then hit Enter OR
Go to python and type the code
OUTPUT =
DAY 2
PYTHON ASK QUESTIONS
Ans:
name = input("What is your name? ")
print(name)
name = input("What is your dad's name? ")
name= input ("how old are you ? ")
name = input ("where do you live ? ")
name = input ("wow!! ive always wanted to visit you are indeed lucky..")
name = input ("ok!bye..")
input("\nPress Enter to exit...")
OUTPUT:
DAY-3
PYTHON SHOULD ASK A NUMBER WE SHOULD GIVE A DIGIT THEN PYTHON
SHOULD TELL WHETHER THE DIGIT IS GREATER OR LESSER THAN 5
ANS: num = int(input("enter a number: "))
if num > 5:
print ("num bigger than 5")
elif num == 5:
print("num equals to 5")
else:
print("smaller than 5")
input("\nPress Enter to exit...")
OUTPUT:
DAY-4
PYTHONSHOULD ASK A NUMBER WHICH SHOULD BE LESS THAN 6
WE GIVE INPUT AND THEN IF THE NUMBER IS
*
1
*
2 **
*
3 **
***
*
4 **
**
****
*
5 **
***
****
*****
*
6 **
***
****
*****
******
def get_user_input():
while True:
try:
user_input = int(input("Enter a number less than 6: "))
if 0 <= user_input < 6:
return user_input
else:
print("Number must be less than 6. Try again.")
except ValueError:
print("Invalid input. Please enter a number.")
def print_pattern(num):
if num == 1:
print("*")
elif num == 2:
print("*")
print("**")
elif num == 3:
print("*")
print("**")
print("***")
elif num == 4:
print("*")
print("**")
print("***")
print("****")
elif num == 5:
print("*")
print("**")
print("***")
print("****")
print("*****")
elif num == 6:
print("*")
print("**")
print("***")
print("****")
print("*****")
print("******")
user_number = get_user_input()
print_pattern(user_number)
DAY-4
CREATE A PROGRAMME USING FORLOOP
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
print(fruit)
input ("\nPress Enter to exit...")
For loop is used in a place where instead of typing a code again and
again we type one single code. But the output is same
A for loop lets you do something multiple times, usually by going
through each item in a list.
SAMPLE FOR FOR LOOP
for i in range(5):
print("Hello")
input ("\nPress Enter to exit...")
instead of 200 we can change the
number to forloopit that much times
for loop = looping
GAME IN PYTHON
import random
secret_number = [Link](1, 100)
guess = 0
attempts = 0
while guess != secret_number:
attempts += 1
guess = int(input(f"Guess the number (between 1 and 100). Attempt {attempts}: "))
if guess == secret_number:
print(f"Congratulations! You guessed it in {attempts} attempts.")
elif guess < secret_number:
print("Too low!")
else:
print("Too high!")
9 Easy Games to Make in Python (Perfect for Beginners) - iD Tech
7 Feb 2025 — 9 Easy Games to Make in Python (Perfect for Beginners) * Number Guessing
Game. A simple game where the computer picks a...
iD Tech