Posts

Showing posts from November, 2022

File Handling using Python

Image
Basic File Open Syntax. Basic Syntax for 'with' and 'as' keyword while open a file: Basic Syntax to show for loop to go through each line from the file. Write Mode: File can open in Write mode which works as Over Write file content with String you Pass in syntax. Syntax: with open('demo.txt') as file:     file.write("String here") Another important feature of write mode is that if file does not exist then it will be added empty file at the Current folder in which you are working. Append Mode : Files can open in append mode which includes write method. Syntax : with open('demo.txt", mode='a') as file:     file.write("Appended String Here")

Turtle Crossing Project Using Turtle modules.

Introduction of Project: Here Turtle crossing road Game Project, F irst  Turtle starts with Bottom position. After that Car randomly generated from right which all are goes to the left hand side. Now Turtle takes place to move forward with UP key only. Down, Right ,Left keys \ directions are not allowed here.  Logic Behind Project. Above project is completely created in OOPS based concepts. Turtle is having 20 x 20 pixel space in Screen. Car height = 20, width = 40 pixels. Turtle starts with Bottom most position at center. Cars are randomly generated by right most side but not at align to SCORE and TURTLE. Car's colors are generated randomly by random module. When Turtle reach at the top of the Line, Score was increased at a time and turtle starts again at bottom most position. If Turtle collided with car then only GAME OVER message was display, before that time turtle scores up and along with that Level should increase every time.

Number Guessing Project Using Python 3.10

Image
Guessing_number.py 1)  2) 3) Output :

Quiz Performance

Image
 

Program to Perform Calculator Function.

Image
def add(n1, n2):     return n1 + n2 def subtract(n1, n2):     return n1 - n2 def multiply(n1, n2):     return n1 * n2 def divide(n1, n2):     return n1 / n2 def sqaure_root(num1):     n = num1 ** 0.5     print(f"Current Result : {round(n, 1)} \n End of calculation") def sqaure(num1):     n = num1 ** 2     print(f"Current Result : {round(n, 1)} \n End of calculation") def display():     print(" + \n - \n * \n / \n Square Root(sr) for one value \n Sqaure(s) for one value\n ") op_list = ['+', '-', '*', '/', 's', 'sr'] def calculation_operation():     num1 = int(input(" Enter a First number : "))     display()     def further(num1):         flag = True         while flag:             op = input(" Choose operator from above : ")             if op == 's':                 sqaure(num1)                 break             elif op == 'sr':                 sqaure_root(num1)