This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# basic quiz app - one question | |
print("Welcome to the Quiz App!") | |
print("Please answer the following questions:") | |
print("1. What is the capital of India?") | |
answer = input("Your answer: ").strip().lower() | |
if answer == "new delhi": | |
print("Correct!") | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
number = 7 | |
print("Welcome to the Guessing Game!") | |
guess = int(input("Guess a number between 1 and 10: ")) | |
if guess == number: | |
print("Yay! You guessed it right!") | |
else: | |
print("Oops! Wrong guess") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a simple Rock, Paper, Scissors game in Python | |
# where the computer's choice is fixed to "rock" for demonstration purposes. | |
# | |
# print, if-elif-else, input, and string comparison | |
computer_choice = "rock" | |
print('--' * 17) | |
print("Welcome to Rock, Paper, Scissors!") | |
print('--' * 17) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the marks of a student and print the result based on the marks. | |
# getting input, print, functions, conditionals | |
def pass_or_fail(marks): | |
if marks >= 40: | |
return "Pass" | |
else: | |
return "Fail" | |
name = input("Enter the student's name: ") | |
marks = int(input(f"Enter marks for subject {i + 1}: ")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PySimpleGUI as sg | |
from utils import get_statistics | |
layout = [ | |
[sg.Text("Enter the URL: ", font=('Arial','16')), | |
sg.Input("", font=('Arial','16'), size=(40,1), key='url'), | |
sg.Button("Get Data", font=('Arial','16'), key='get')], | |
[sg.Multiline("", font=('Arial','16'), size=(70, 15), key='output')] | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
num = randint(1, 10) | |
guess = None | |
while guess != num: | |
guess = input("guess a number between 1 and 10: ") | |
guess = int(guess) | |
if guess == num: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
One enemy | |
''' | |
import pgzrun | |
from random import randint | |
WIDTH = 800 | |
HEIGHT = 600 | |
tank = Actor('tank_blue') | |
tank.bottom = HEIGHT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pgzrun | |
WIDTH = 800 | |
HEIGHT = 600 | |
tank = Actor('tank_blue') | |
tank.bottom = HEIGHT | |
tank.x = WIDTH / 2 | |
tank.angle = 90 | |
def draw(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pgzrun | |
WIDTH = 800 | |
HEIGHT = 600 | |
tank = Actor('tank_blue') | |
tank.bottom = HEIGHT | |
tank.x = WIDTH / 2 | |
tank.angle = 90 | |
def draw(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pgzrun | |
WIDTH = 800 | |
HEIGHT = 600 | |
tank = Actor('tank_blue') | |
tank.bottom = HEIGHT | |
tank.x = WIDTH / 2 | |
tank.angle = 90 | |
def draw(): |
NewerOlder