0% found this document useful (0 votes)
2 views3 pages

Internship Mini Project

The document contains a collection of ten simple Python programs, each demonstrating a different functionality such as a number guessing game, arithmetic calculator, even/odd checker, BMI calculator, palindrome checker, rock-paper-scissors game, prime number validator, factorial calculator, countdown timer, and word frequency counter. Each program includes user input and basic conditional logic to perform its task. The examples serve as practical exercises for beginners learning Python programming.

Uploaded by

ayanokogyi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Internship Mini Project

The document contains a collection of ten simple Python programs, each demonstrating a different functionality such as a number guessing game, arithmetic calculator, even/odd checker, BMI calculator, palindrome checker, rock-paper-scissors game, prime number validator, factorial calculator, countdown timer, and word frequency counter. Each program includes user input and basic conditional logic to perform its task. The examples serve as practical exercises for beginners learning Python programming.

Uploaded by

ayanokogyi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

#1.

Number Guessing Game

import random
number = random.randint(1, 100)
guess = None
while guess != number:
guess = int(input("Guess a number between 1 and 100: "))
if guess < number:
print("Too low!")
elif guess > number:
print("Too high!")
else:
print("Correct!")

#2. Simple Arithmetic Calculator

num1 = float(input("Enter first number: "))


op = input("Enter operator (+, -, *, /): ")
num2 = float(input("Enter second number: "))
if op == '+':
print(num1 + num2)
elif op == '-':
print(num1 - num2)
elif op == '*':
print(num1 * num2)
elif op == '/':
print(num1 / num2)
else:
print("Invalid operator")

#3. Even/Odd Number Checker

num = int(input("Enter a number: "))


print("Even" if num % 2 == 0 else "Odd")

#4. BMI Calculator

try:
weight = float(input("Enter your weight in kilograms (kg): "))
height = float(input("Enter your height in meters (m): "))

if height <= 0:
print("Height must be greater than zero.")
else:
bmi = weight / (height ** 2)
print(f"Your BMI is: {bmi:.2f}")

if bmi < 18.5:


print("You are underweight.")
elif 18.5 <= bmi < 24.9:
print("You have a normal weight.")
elif 25 <= bmi < 29.9:
print("You are overweight.")
else:
print("You are obese.")
except ValueError:
print("Invalid input. Please enter numeric values.")

#5. Palindrome Checker

text = input("Enter a string or number: ")


if str(text) == str(text)[::-1]:
print("Palindrome")
else:
print("Not a palindrome")

#6. Rock-Paper-Scissors Game

import random
choices = ['rock', 'paper', 'scissors']
user = input("Enter rock, paper, or scissors: ").lower()
computer = random.choice(choices)
print(f"Computer chose {computer}")
if user == computer:
print("It's a tie!")
elif (user == 'rock' and computer == 'scissors') or \
(user == 'scissors' and computer == 'paper') or \
(user == 'paper' and computer == 'rock'):
print("You win!")
else:
print("You lose!")

#7. Prime Number Validator

num = int(input("Enter a number: "))


if num > 1:
for i in range(2, int(num**0.5) + 1):
if num % i == 0:
print("Not Prime")
break
else:
print("Prime")
else:
print("Not Prime")

#8. Factorial Calculator

num = int(input("Enter a number: "))


factorial = 1
for i in range(2, num + 1):
factorial *= i
print(f"Factorial: {factorial}")

#9. Countdown Timer

import time
seconds = int(input("Enter countdown time in seconds: "))
while seconds:
print(f"Time left: {seconds} sec")
time.sleep(1)
seconds -= 1
print("Time's up!")

#10. Word Frequency Counter

text = input("Enter text: ")


words = text.split()
freq = {}
for word in words:
word = word.lower()
freq[word] = freq.get(word, 0) + 1
print(freq)

You might also like