Posts

Showing posts from April, 2020

To find average number in python programming.

# Get three test score round1 = int(input("Enter score for round 1: ")) round2 = int(input("\nEnter score for round 2: ")) round3 = int(input("\nEnter score for round 3: "))     # Calculate the average average = (round1 + round2 + round3) / 3 # Print out the test score print("\nThe average score is: ", average) Output: 4 37 64 Enter score for round 1: Enter score for round 2: Enter score for round 3: The average score is: 35.0

To find area of triangle in python programming

# Find the area of triangle a = 5 b = 6 c = 7 # calculate the semi-perimeter s = (a + b + c) / 2 # calculate the area area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 print('The area of the triangle is %0.2f' %area) Output : The area of the triangle is 14.70

To find the sum of two numbers in python programming

# This program adds two numbers value1 = 14.0 value2 = 56.60 # Add two numbers result = float(value1) + float(value2) # Display the sum print('The sum of {0} and {1} is {2}'.format(value1, value2, result)) Output: The sum of 14.0 and 56.6 is 70.6

moving circle on canvas by tkinter

Image
#!/usr/bin/python from tkinter import * import time gui = Tk() var=IntVar() gui.geometry("800x800") c = Canvas(gui ,width=800 ,height=800) c.pack() oval = c.create_oval(5,5,60,60,fill='pink') a = 5 b = 5 for x in range(0 ,100):   c.move(oval,a,b)   gui.update()   time.sleep(.01) gui.title("First title") gui.mainloop()

oval in canvas

Image
from tkinter import * import time gui = Tk() gui.geometry("400x400") gui.title(" First title") canvas = Canvas(gui, width=1000,height=1200,bg='red') canvas.pack() ov1 = canvas.create_oval(25,25,60,60, fill='yellow') gui.mainloop()

analog clock

Image
# import winsound from turtle import Turtle, Screen, Terminator from datetime import datetime screen = Screen() screen.mode('logo') screen.setup(700, 700) screen.title('Alarm Clock') tag_list = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] monat = ['Jan.', 'Feb.', 'Mar.', 'Apr.', 'May', 'June', 'July', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.'] FONT_SIZE = 14 FONT = ('Courier', FONT_SIZE, 'bold') BUTTON_SIZE = 40 CURSOR_SIZE = 20 def jump(turtle, distance):     turtle.penup()     turtle.forward(distance)     turtle.pendown() def hand(turtle, laenge, spitze):     turtle.fd(laenge * 1.10)     turtle.rt(90)     turtle.fd(spitze / 20.0)     turtle.lt(120)     turtle.fd(spitze)     turtle.lt(120)     turtle.fd(spitze) ...