embedded system,Arduino,Raspberry pi,ARM7,MM32,STM32,PIC and Python,Django,Datascience and web development
Wednesday, May 20, 2020
Python program to accept two strings and check if second string is prefix of first
str1 = input("enter the string")
str2 = input("enter the sub string")
flag =0
if len(str1) > len(str2):
for i in range(0,len(str2)):
#print(i)
if str1[i] == str2[i]:
pass
#i=i+1
flag=flag+1
print(str1,str2,end="\n")
print("matched at position{}".format(flag))
output:
enter the stringsubject
enter the sub stringsub
subject sub
matched at position3
openGL using cube in python
import pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *
verticies = (
(1, -1, -1),
(1, 1, -1),
(-1, 1, -1),
(-1, -1, -1),
(1, -1, 1),
(1, 1, 1),
(-1, -1, 1),
(-1, 1, 1),
)
edges = (
(0,1),
(0,3),
(0,4),
(2,1),
(2,3),
(2,7),
(6,3),
(6,4),
(6,7),
(5,1),
(5,4),
(5,7),
)
surfaces = (
(0,1,2,3),
(3,2,7,6),
(6,7,5,4),
(4,5,1,0),
(1,5,7,2),
(4,0,3,6)
)
def Draw_Cube():
glBegin(GL_QUADS)
for surface in surfaces:
for vertex in surface:
glColor3fv((0,1,1))
glVertex3fv(verticies[vertex])
glEnd()
glBegin(GL_LINES)
for edge in edges:
for vertex in edge:
glColor3fv(( 1, 1,1))
glVertex3fv(verticies[vertex])
glEnd()
def main():
pygame.init()
display = (800,600)
pygame.display.set_mode(display, DOUBLEBUF|OPENGL)
#
gluPerspective(90.0, (display[0]/display[1]), 0.1, 50)
# moving back.
glTranslatef(0.0,0.0,-5.0)
# where we might be
glRotatef(20, 2, 0, 0)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.MOUSEBUTTONDOWN:
print(event)
print(event.button)
if event.button == 4:
glTranslatef(0.0,0.0,1.0)
elif event.button == 5:
glTranslatef(0.0,0.0,-1.0)
glRotatef(1, 3, 1, 1)
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
Draw_Cube()
pygame.display.flip()
pygame.time.wait(10)
main()
Subscribe to:
Posts (Atom)
-
How to do the programming python in windows command prompt Step 1: please go through below link website f...
-
Serial.print() Description Prints data to the serial port as human-readable ASCII text. This command can take many forms. Numbers a...