0% found this document useful (0 votes)
13 views10 pages

Project Sripts

The document describes a Python health management system that allows logging diet and exercise details for different users. It also contains code for a Snake, Water, Gun game in Python. Additionally, it includes SQL queries to explore COVID data from two tables and create views.

Uploaded by

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

Project Sripts

The document describes a Python health management system that allows logging diet and exercise details for different users. It also contains code for a Snake, Water, Gun game in Python. Additionally, it includes SQL queries to explore COVID data from two tables and create views.

Uploaded by

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

PROJECT SRIPTS

Python: Health management System


# diet , exercise

def getdate():
import datetime
return datetime.datetime.now()

def log():
a = int(input("Enter 1 for harry, 2 for rohan, 3 for hammad \n"))
if a==1:
b= int(input("type 1 for diet and 2 for exercise \n"))
if b==1:
print(" what did he eat :")
c= input()
with open("harrydiet.txt" , "a") as f:
f.write(c)
print("successfully written")
if b==2:
print(" what did he exercise :")
ex = input()
with open("harryex.txt", "a") as f:
f.write(ex)
print("successfully written")
if a == 2:
b = int(input("type 1 for diet and 2 for exercise\n"))
if b == 1:
print(" what did he eat :")
c = input()
with open("rorhandiet.txt", "a") as f:
f.write(c)
print("successfully written")
if b == 2:
print(" what did he exercise :")
ex = input()
with open("rohanex.txt", "a") as f:
f.write(ex)
print("successfully written")
if a == 3:
b = int(input("type 1 for diet and 2 for exercise \n"))
if b == 1:
print(" what did he eat :")
c = input()
with open("hammaddiet.txt", "a") as f:
f.write(c)
print("successfully written")
if b == 2:
print(" what did he exercise :")
ex = input()
with open("hammadex.txt", "a") as f:
f.write(ex)
print("successfully written")
def retrieve():
a = int(input("Enter 1 for harry, 2 for rohan, 3 for hammad \n "))
if a==1 :
b=int(input("Enter 1 for diet , 2 for exercise\n"))
if b==1 :
with open("harrydiet.txt") as f:
print(getdate(), f.read())
if b==2 :
with open("harryex.txt") as f:
print(getdate(), f.read())
if a==2 :
b=int(input("Enter 1 for diet , 2 for exercise\n"))
if b==1 :
with open("rorhandiet.txt") as f:
print(getdate(), f.read())
if b==2 :
with open("rohanex.txt") as f:
print(getdate(), f.read())
if a==3 :
b=int(input("Enter 1 for diet , 2 for exercise\n"))
if b==1 :
with open("hammaddiet.txt") as f:
print(getdate(), f.read())
if b==2 :
with open("hammadex.txt") as f:
print(getdate(), f.read())
n = int(input("press 0 to log , 1 to retrieve\n"))
if n==0 :
log()
elif n==1 :
retrieve()

SQL : COVID DATA EXPLORATION


use projects
select * from projects..CovidDeaths
--select * from projects..CovidVaccine order by 3,4

select location, date, total_cases, new_cases, total_deaths, population


from projects..CovidDeaths
order by 1,2

--creating %total deaths


select location, date, total_cases, total_deaths, (total_deaths/total_cases)*100 as
Percentdeath
from projects..CovidDeaths
order by 1,2

--PercentDeaths for india


-- shows % chance of one dying when contracted by the virus in india
select location, date, total_cases, total_deaths, (total_deaths/total_cases)*100 as
Percentdeath
from projects..CovidDeaths
where location = 'india'
order by 1,2

--creating total cases vs population


select location, date, total_cases, population, (total_cases/population)*100 as PercentCases
from projects..CovidDeaths
where location = 'india'
order by 1,2

-- finding which country has highest infection rate


select location, Population , max(total_cases) as HighestCasesCount,
max((total_cases/population))*100 as PercentCases
from projects..CovidDeaths
group by location , population
order by PercentCases Desc

-- finding which country has highest deathPercent


select location, population, max((total_deaths/population))*100 as PercentDeaths
from projects..CovidDeaths
group by location , population
order by PercentDeaths Desc

--finding which country has highest TotalDeaths


-- has to typecast total_deaths as datatype is nvarchar and max() func is showing inacuracies
therefore, typecast it to int
select location, max(cast(total_deaths as int)) as TotalDeathsCountry
from projects..CovidDeaths
where continent is not null
group by location
order by TotalDeathsCountry Desc

--finding which continents has highest TotalDeaths


select continent, max(cast(total_deaths as int)) as TotalDeathsContinent
from projects..CovidDeaths
where continent is not null
group by continent
order by TotalDeathsContinent Desc

-- worldwide data by date


select date , sum(new_cases) as NewCasesperDate ,sum(cast(new_deaths as int)) as
NewDeathsperDate ,sum((cast(new_deaths as int)))/sum(new_cases) as
DeathPercentPerDate
from projects..CovidDeaths
where continent is not null
group by date
order by 1,2

--now gathering data from vaccination table


select * from projects..CovidVaccine

--joining the two tables


select dea.continent , dea.location, dea.date, dea.population, vac.new_vaccinations
, sum(cast(vac.new_vaccinations as int)) over(partition by dea.location order by dea.date) as
RollingVaccinations
from projects..CovidDeaths as dea
join projects..CovidVaccine as vac
on dea.location = vac.location and dea.date = vac.date
where dea.continent is not null
order by 2,3

--using CTE
with PercentVaccByPop(Continent, location , date,
population,new_vaccinations,RollingVaccinations) as
(select dea.continent , dea.location, dea.date, dea.population, vac.new_vaccinations
, sum(cast(vac.new_vaccinations as int)) over(partition by dea.location order by dea.date) as
RollingVaccinations
from projects..CovidDeaths as dea
join projects..CovidVaccine as vac
on dea.location = vac.location and dea.date = vac.date
where dea.continent is not null
)
select *,(RollingVaccinations/population)*100 as PercentVaccinated from PercentVaccByPop

-- view
create view VaccinatedVsPopulation as
select dea.continent , dea.location, dea.date, dea.population, vac.new_vaccinations
, sum(cast(vac.new_vaccinations as int)) over(partition by dea.location order by dea.date) as
RollingVaccinations
from projects..CovidDeaths as dea
join projects..CovidVaccine as vac
on dea.location = vac.location and dea.date = vac.date
where dea.continent is not null

select*from VaccinatedVsPopulation
create view PercentVaccinated as
with PercentVaccByPop(Continent, location , date,
population,new_vaccinations,RollingVaccinations) as
(select dea.continent , dea.location, dea.date, dea.population, vac.new_vaccinations
, sum(cast(vac.new_vaccinations as int)) over(partition by dea.location order by dea.date) as
RollingVaccinations
from projects..CovidDeaths as dea
join projects..CovidVaccine as vac
on dea.location = vac.location and dea.date = vac.date
where dea.continent is not null
)
select *,(RollingVaccinations/population)*100 as PercentVaccinated from PercentVaccByPop

select * from PercentVaccinated

Python: Snake,Water,Gun
import random

lst = ["Snake","Water", "Gun"]


i=0
win=0
draw=0
lose=0
while(i<10):
x= input("select s for snake, w for water, g for gun\n")
a = random.choice(lst)
if x=="s":
if a=="Snake":
print(f"computer's choice was {a} : draw")
draw+=1
if a == "Water":
print(f"computer's choice was {a} : You win")
win+=1

if a == "Gun":
print(f"computer's choice was {a} : You lose")
lose+=1
i=i+1

if x == "w":
if a == "Snake":
print(f"computer's choice was {a} : You lose")
lose += 1

if a == "Water":
print(f"computer's choice was {a} : draw")
draw += 1

if a == "Gun":
print(f"computer's choice was {a} : You win")
win += 1
i=i+1
if x == "g":
if a == "Snake":
print(f"computer's choice was {a} : You win")
win+=1

if a == "Water":
print(f"computer's choice was {a} : You lose")
lose += 1

if a == "Gun":
print(f"computer's choice was {a} : draw")
draw += 1
i=i+1

else:
print("choose correct character")
print("game over")
print(f"your score: {win}")
print(f"computer score: {lose}")
print(f"times you drew: {draw}")
print(draw)
print(lose)

You might also like