hhalim commited on
Commit
ca9af8e
1 Parent(s): e04f9d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -66
app.py CHANGED
@@ -1,71 +1,19 @@
1
- import streamlit as st
2
- import pygame
3
- from pygame.locals import *
4
- import sys
5
-
6
- #Initialize Pygame
7
- pygame.init()
8
-
9
- #Set the window size
10
- window_width=640
11
- window_height=480
12
-
13
- screen=pygame.display.set_mode((window_width,window_height))
14
 
15
- #Set window title
16
- pygame.display.set_caption('Pacman')
17
-
18
- #Set the background color
19
- bgcolor = (0,0,0)
20
- screen.fill(bgcolor)
21
-
22
- #Pacman variables
23
- x_pos = 50
24
- y_pos = 50
25
- pacman_width = 20
26
-
27
- #Ghost variables
28
- ghost_xpos = 300
29
- ghost_ypos = 300
30
- ghost_width = 20
31
- ghost_height = 20
32
 
33
- #Draw Pacman
34
- def drawPacman(x,y):
35
- pygame.draw.circle(screen,(255,255,0),(x,y),pacman_width)
36
 
37
- #Draw Ghost
38
- def drawGhost(x,y):
39
- pygame.draw.rect(screen,(255,0,0),(x,y,ghost_width,ghost_height))
 
 
40
 
41
- #Game loop
42
- while True:
43
- for event in pygame.event.get():
44
- if event.type == QUIT:
45
- pygame.quit()
46
- sys.exit()
47
- #Move Pacman
48
- keys = pygame.key.get_pressed()
49
- if keys[K_LEFT]:
50
- x_pos -= 5
51
- if keys[K_RIGHT]:
52
- x_pos += 5
53
- if keys[K_UP]:
54
- y_pos -= 5
55
- if keys[K_DOWN]:
56
- y_pos += 5
57
- #Move Ghost
58
- if ghost_xpos < x_pos:
59
- ghost_xpos += 1
60
- if ghost_xpos > x_pos:
61
- ghost_xpos -= 1
62
- if ghost_ypos < y_pos:
63
- ghost_ypos += 1
64
- if ghost_ypos > y_pos:
65
- ghost_ypos -= 1
66
 
67
- #Draw elements
68
- screen.fill(bgcolor)
69
- drawPacman(x_pos,y_pos)
70
- drawGhost(ghost_xpos,ghost_ypos)
71
- pygame.display.update()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
+ import streamlit as st
3
+ import pandas as pd
4
+ import plotly.express as px
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ st.title('Random Population Dataset and Treemap')
 
 
7
 
8
+ # Generate random population dataset
9
+ data = pd.DataFrame({
10
+ 'Country': ['USA', 'China', 'India', 'Japan', 'Germany'],
11
+ 'Population': [331002651, 1403500365, 1377233523, 126476461, 82927922]
12
+ })
13
 
14
+ # Render table
15
+ st.table(data)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
+ # Render plotly treemap
18
+ fig = px.treemap(data, path=['Country'], values='Population', title='Global Population')
19
+ st.plotly_chart(fig)